specialist-agent 2.12.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +33 -207
- package/dist/catalog.json +15529 -0
- package/dist/hw-worker.mjs +254 -0
- package/dist/icones/icone.ico +0 -0
- package/dist/icones/icone.png +0 -0
- package/dist/interface/assets/figtree-latin-400-normal-g7Dtegnw.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-500-normal-BWnGEVsr.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-600-normal-Cv_xCTDl.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-700-normal-th6qEP7c.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-400-normal-CXAzuTZb.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-500-normal-Du0rIuHj.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-600-normal-DJlfifZj.woff2 +0 -0
- package/dist/interface/assets/figtree-latin-ext-700-normal-CS4sQkGV.woff2 +0 -0
- package/dist/interface/assets/index-BIyqZkro.css +1 -0
- package/dist/interface/assets/index-zAegy908.js +13 -0
- package/dist/interface/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
- package/dist/interface/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-500-normal-4slEIF53.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-700-normal-CaoNriVp.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-ext-500-normal-BTIpesyw.woff2 +0 -0
- package/dist/interface/assets/unbounded-latin-ext-700-normal-BLzWLLjG.woff2 +0 -0
- package/dist/interface/icones/apple-touch-icon.png +0 -0
- package/dist/interface/icones/favicon-32.png +0 -0
- package/dist/interface/icones/icone-192.png +0 -0
- package/dist/interface/icones/icone-512.png +0 -0
- package/dist/interface/icones/icone-mascara-512.png +0 -0
- package/dist/interface/index.html +19 -0
- package/dist/interface/manifest.webmanifest +19 -0
- package/dist/interface/sw.js +63 -0
- package/dist/specialist-agent.mjs +6919 -0
- package/dist/usage-worker.mjs +174 -0
- package/package.json +32 -57
- package/.claude-plugin/marketplace.json +0 -52
- package/.claude-plugin/plugin.json +0 -37
- package/.codex/INSTALL.md +0 -145
- package/.cursor-plugin/marketplace.json +0 -52
- package/.cursor-plugin/plugin.json +0 -37
- package/.opencode/INSTALL.md +0 -127
- package/.opencode/opencode.json +0 -186
- package/agents/analyst-lite.md +0 -48
- package/agents/analyst.md +0 -396
- package/agents/api-lite.md +0 -43
- package/agents/api.md +0 -427
- package/agents/architect-lite.md +0 -104
- package/agents/architect.md +0 -571
- package/agents/autopilot-lite.md +0 -46
- package/agents/autopilot.md +0 -196
- package/agents/cloud-lite.md +0 -75
- package/agents/cloud.md +0 -213
- package/agents/data-lite.md +0 -67
- package/agents/data.md +0 -306
- package/agents/debugger-lite.md +0 -46
- package/agents/debugger.md +0 -410
- package/agents/deps-lite.md +0 -41
- package/agents/deps.md +0 -363
- package/agents/designer-lite.md +0 -67
- package/agents/designer.md +0 -195
- package/agents/devops-lite.md +0 -67
- package/agents/devops.md +0 -205
- package/agents/docs-lite.md +0 -42
- package/agents/docs.md +0 -454
- package/agents/executor-lite.md +0 -61
- package/agents/executor.md +0 -695
- package/agents/explorer-lite.md +0 -55
- package/agents/explorer.md +0 -152
- package/agents/finance-lite.md +0 -66
- package/agents/finance.md +0 -255
- package/agents/i18n-lite.md +0 -44
- package/agents/i18n.md +0 -594
- package/agents/legal-lite.md +0 -113
- package/agents/legal.md +0 -302
- package/agents/marketing-lite.md +0 -25
- package/agents/marketing.md +0 -188
- package/agents/memory.md +0 -166
- package/agents/orchestrator-lite.md +0 -40
- package/agents/orchestrator.md +0 -512
- package/agents/pair-lite.md +0 -38
- package/agents/pair.md +0 -310
- package/agents/perf-lite.md +0 -42
- package/agents/perf.md +0 -320
- package/agents/planner-lite.md +0 -59
- package/agents/planner.md +0 -272
- package/agents/product-lite.md +0 -25
- package/agents/product.md +0 -195
- package/agents/refactor-lite.md +0 -42
- package/agents/refactor.md +0 -467
- package/agents/ripple-lite.md +0 -106
- package/agents/ripple.md +0 -166
- package/agents/scout-lite.md +0 -37
- package/agents/scout.md +0 -224
- package/agents/security-lite.md +0 -66
- package/agents/security.md +0 -252
- package/agents/sentry-triage-lite.md +0 -54
- package/agents/sentry-triage.md +0 -217
- package/agents/starter-lite.md +0 -80
- package/agents/starter.md +0 -300
- package/agents/support-lite.md +0 -24
- package/agents/support.md +0 -191
- package/agents/tdd-lite.md +0 -43
- package/agents/tdd.md +0 -329
- package/agents/tester-lite.md +0 -71
- package/agents/tester.md +0 -237
- package/cli/architectures.mjs +0 -713
- package/cli/detect-architecture.mjs +0 -752
- package/cli/generate-architecture.mjs +0 -1096
- package/cli/index.mjs +0 -1217
- package/cli/recommend-architecture.mjs +0 -870
- package/hooks/after-review.mjs +0 -130
- package/hooks/after-task.mjs +0 -117
- package/hooks/before-plan.mjs +0 -155
- package/hooks/before-review.mjs +0 -139
- package/hooks/hooks.json +0 -66
- package/hooks/lifecycle.json +0 -91
- package/hooks/native/auto-dispatch.mjs +0 -207
- package/hooks/native/auto-format.mjs +0 -176
- package/hooks/native/mcp-discovery.mjs +0 -168
- package/hooks/native/security-config.json +0 -38
- package/hooks/native/security-guard.mjs +0 -323
- package/hooks/native/session-context.mjs +0 -179
- package/hooks/native/session-end.mjs +0 -42
- package/hooks/native/utils.mjs +0 -62
- package/hooks/on-error.mjs +0 -129
- package/hooks/session-end.mjs +0 -185
- package/hooks/session-start.mjs +0 -154
- package/packs/angular/ARCHITECTURE.md +0 -814
- package/packs/angular/CLAUDE.md +0 -105
- package/packs/angular/agents/builder.md +0 -113
- package/packs/angular/agents/doctor.md +0 -187
- package/packs/angular/agents/migrator.md +0 -101
- package/packs/angular/agents/reviewer.md +0 -252
- package/packs/angular/agents-lite/builder.md +0 -65
- package/packs/angular/agents-lite/doctor.md +0 -64
- package/packs/angular/agents-lite/migrator.md +0 -75
- package/packs/angular/agents-lite/reviewer.md +0 -69
- package/packs/angular/skills/dev-create-component/SKILL.md +0 -56
- package/packs/angular/skills/dev-create-injectable/SKILL.md +0 -60
- package/packs/angular/skills/dev-create-module/SKILL.md +0 -49
- package/packs/angular/skills/dev-create-service/SKILL.md +0 -34
- package/packs/angular/skills/dev-create-test/SKILL.md +0 -78
- package/packs/angular/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/angular/skills/docs-onboard/SKILL.md +0 -42
- package/packs/angular/skills/migration-migrate-component/SKILL.md +0 -42
- package/packs/angular/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/angular/skills/review-check-architecture/SKILL.md +0 -67
- package/packs/angular/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/angular/skills/review-review/SKILL.md +0 -43
- package/packs/astro/ARCHITECTURE.md +0 -718
- package/packs/astro/CLAUDE.md +0 -106
- package/packs/astro/agents/builder.md +0 -123
- package/packs/astro/agents/doctor.md +0 -200
- package/packs/astro/agents/migrator.md +0 -105
- package/packs/astro/agents/reviewer.md +0 -253
- package/packs/astro/agents-lite/builder.md +0 -71
- package/packs/astro/agents-lite/doctor.md +0 -66
- package/packs/astro/agents-lite/migrator.md +0 -71
- package/packs/astro/agents-lite/reviewer.md +0 -70
- package/packs/astro/skills/dev-create-component/SKILL.md +0 -50
- package/packs/astro/skills/dev-create-island/SKILL.md +0 -63
- package/packs/astro/skills/dev-create-module/SKILL.md +0 -49
- package/packs/astro/skills/dev-create-service/SKILL.md +0 -34
- package/packs/astro/skills/dev-create-test/SKILL.md +0 -76
- package/packs/astro/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/astro/skills/docs-onboard/SKILL.md +0 -51
- package/packs/astro/skills/migration-migrate-component/SKILL.md +0 -48
- package/packs/astro/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/astro/skills/review-check-architecture/SKILL.md +0 -72
- package/packs/astro/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/astro/skills/review-review/SKILL.md +0 -45
- package/packs/nextjs/ARCHITECTURE.md +0 -1033
- package/packs/nextjs/CLAUDE.md +0 -106
- package/packs/nextjs/agents/builder.md +0 -132
- package/packs/nextjs/agents/doctor.md +0 -226
- package/packs/nextjs/agents/migrator.md +0 -101
- package/packs/nextjs/agents/reviewer.md +0 -243
- package/packs/nextjs/agents-lite/builder.md +0 -74
- package/packs/nextjs/agents-lite/doctor.md +0 -74
- package/packs/nextjs/agents-lite/migrator.md +0 -75
- package/packs/nextjs/agents-lite/reviewer.md +0 -73
- package/packs/nextjs/skills/dev-create-component/SKILL.md +0 -82
- package/packs/nextjs/skills/dev-create-hook/SKILL.md +0 -90
- package/packs/nextjs/skills/dev-create-module/SKILL.md +0 -63
- package/packs/nextjs/skills/dev-create-service/SKILL.md +0 -35
- package/packs/nextjs/skills/dev-create-test/SKILL.md +0 -106
- package/packs/nextjs/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/nextjs/skills/docs-onboard/SKILL.md +0 -55
- package/packs/nextjs/skills/migration-migrate-component/SKILL.md +0 -58
- package/packs/nextjs/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/nextjs/skills/review-check-architecture/SKILL.md +0 -101
- package/packs/nextjs/skills/review-fix-violations/SKILL.md +0 -48
- package/packs/nextjs/skills/review-review/SKILL.md +0 -47
- package/packs/nuxt/ARCHITECTURE.md +0 -831
- package/packs/nuxt/CLAUDE.md +0 -111
- package/packs/nuxt/agents/builder.md +0 -120
- package/packs/nuxt/agents/doctor.md +0 -198
- package/packs/nuxt/agents/migrator.md +0 -101
- package/packs/nuxt/agents/reviewer.md +0 -255
- package/packs/nuxt/agents-lite/builder.md +0 -67
- package/packs/nuxt/agents-lite/doctor.md +0 -67
- package/packs/nuxt/agents-lite/migrator.md +0 -80
- package/packs/nuxt/agents-lite/reviewer.md +0 -71
- package/packs/nuxt/skills/dev-create-component/SKILL.md +0 -60
- package/packs/nuxt/skills/dev-create-composable/SKILL.md +0 -33
- package/packs/nuxt/skills/dev-create-module/SKILL.md +0 -49
- package/packs/nuxt/skills/dev-create-service/SKILL.md +0 -34
- package/packs/nuxt/skills/dev-create-test/SKILL.md +0 -61
- package/packs/nuxt/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/nuxt/skills/docs-onboard/SKILL.md +0 -49
- package/packs/nuxt/skills/migration-migrate-component/SKILL.md +0 -48
- package/packs/nuxt/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/nuxt/skills/review-check-architecture/SKILL.md +0 -71
- package/packs/nuxt/skills/review-fix-violations/SKILL.md +0 -43
- package/packs/nuxt/skills/review-review/SKILL.md +0 -45
- package/packs/react/ARCHITECTURE.md +0 -991
- package/packs/react/CLAUDE.md +0 -102
- package/packs/react/agents/builder.md +0 -113
- package/packs/react/agents/doctor.md +0 -203
- package/packs/react/agents/migrator.md +0 -101
- package/packs/react/agents/reviewer.md +0 -252
- package/packs/react/agents-lite/builder.md +0 -65
- package/packs/react/agents-lite/doctor.md +0 -64
- package/packs/react/agents-lite/migrator.md +0 -74
- package/packs/react/agents-lite/reviewer.md +0 -69
- package/packs/react/skills/dev-create-component/SKILL.md +0 -53
- package/packs/react/skills/dev-create-hook/SKILL.md +0 -78
- package/packs/react/skills/dev-create-module/SKILL.md +0 -51
- package/packs/react/skills/dev-create-service/SKILL.md +0 -34
- package/packs/react/skills/dev-create-test/SKILL.md +0 -92
- package/packs/react/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/react/skills/docs-onboard/SKILL.md +0 -42
- package/packs/react/skills/migration-migrate-component/SKILL.md +0 -44
- package/packs/react/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/react/skills/review-check-architecture/SKILL.md +0 -73
- package/packs/react/skills/review-fix-violations/SKILL.md +0 -45
- package/packs/react/skills/review-review/SKILL.md +0 -44
- package/packs/svelte/ARCHITECTURE.md +0 -975
- package/packs/svelte/CLAUDE.md +0 -102
- package/packs/svelte/agents/builder.md +0 -114
- package/packs/svelte/agents/doctor.md +0 -174
- package/packs/svelte/agents/migrator.md +0 -101
- package/packs/svelte/agents/reviewer.md +0 -238
- package/packs/svelte/agents-lite/builder.md +0 -66
- package/packs/svelte/agents-lite/doctor.md +0 -67
- package/packs/svelte/agents-lite/migrator.md +0 -82
- package/packs/svelte/agents-lite/reviewer.md +0 -70
- package/packs/svelte/skills/dev-create-component/SKILL.md +0 -77
- package/packs/svelte/skills/dev-create-module/SKILL.md +0 -59
- package/packs/svelte/skills/dev-create-service/SKILL.md +0 -35
- package/packs/svelte/skills/dev-create-store/SKILL.md +0 -94
- package/packs/svelte/skills/dev-create-test/SKILL.md +0 -98
- package/packs/svelte/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/svelte/skills/docs-onboard/SKILL.md +0 -47
- package/packs/svelte/skills/migration-migrate-component/SKILL.md +0 -51
- package/packs/svelte/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/svelte/skills/review-check-architecture/SKILL.md +0 -79
- package/packs/svelte/skills/review-fix-violations/SKILL.md +0 -47
- package/packs/svelte/skills/review-review/SKILL.md +0 -45
- package/packs/vue/ARCHITECTURE.md +0 -798
- package/packs/vue/CLAUDE.md +0 -102
- package/packs/vue/agents/builder.md +0 -112
- package/packs/vue/agents/doctor.md +0 -185
- package/packs/vue/agents/migrator.md +0 -101
- package/packs/vue/agents/reviewer.md +0 -249
- package/packs/vue/agents-lite/builder.md +0 -65
- package/packs/vue/agents-lite/doctor.md +0 -63
- package/packs/vue/agents-lite/migrator.md +0 -73
- package/packs/vue/agents-lite/reviewer.md +0 -68
- package/packs/vue/skills/dev-create-component/SKILL.md +0 -58
- package/packs/vue/skills/dev-create-composable/SKILL.md +0 -31
- package/packs/vue/skills/dev-create-module/SKILL.md +0 -50
- package/packs/vue/skills/dev-create-service/SKILL.md +0 -34
- package/packs/vue/skills/dev-create-test/SKILL.md +0 -62
- package/packs/vue/skills/dev-generate-types/SKILL.md +0 -37
- package/packs/vue/skills/docs-onboard/SKILL.md +0 -42
- package/packs/vue/skills/migration-migrate-component/SKILL.md +0 -41
- package/packs/vue/skills/migration-migrate-module/SKILL.md +0 -25
- package/packs/vue/skills/review-check-architecture/SKILL.md +0 -73
- package/packs/vue/skills/review-fix-violations/SKILL.md +0 -42
- package/packs/vue/skills/review-review/SKILL.md +0 -43
- package/skills/audit/SKILL.md +0 -231
- package/skills/autofix/SKILL.md +0 -166
- package/skills/autopilot/SKILL.md +0 -286
- package/skills/brainstorm/SKILL.md +0 -298
- package/skills/checkpoint/SKILL.md +0 -217
- package/skills/codereview/SKILL.md +0 -268
- package/skills/commit/SKILL.md +0 -150
- package/skills/copywriting/SKILL.md +0 -218
- package/skills/cro/SKILL.md +0 -234
- package/skills/debug/SKILL.md +0 -210
- package/skills/design-review/SKILL.md +0 -217
- package/skills/discovery/SKILL.md +0 -218
- package/skills/estimate/SKILL.md +0 -154
- package/skills/finish/SKILL.md +0 -220
- package/skills/grill/SKILL.md +0 -270
- package/skills/health/SKILL.md +0 -251
- package/skills/improve-architecture/SKILL.md +0 -205
- package/skills/learn/SKILL.md +0 -260
- package/skills/lint/SKILL.md +0 -126
- package/skills/migrate-architecture/SKILL.md +0 -242
- package/skills/migrate-framework/SKILL.md +0 -172
- package/skills/onboard/SKILL.md +0 -168
- package/skills/plan/SKILL.md +0 -141
- package/skills/prd/SKILL.md +0 -241
- package/skills/recall/SKILL.md +0 -112
- package/skills/remember/SKILL.md +0 -108
- package/skills/seo-audit/SKILL.md +0 -240
- package/skills/tdd/SKILL.md +0 -201
- package/skills/tutorial/SKILL.md +0 -346
- package/skills/verify/SKILL.md +0 -168
- package/skills/worktree/SKILL.md +0 -168
- package/skills/write-skill/SKILL.md +0 -225
- package/templates/autopilot/PROMPT.md +0 -39
- package/templates/autopilot/README.md +0 -122
- package/templates/autopilot/devcontainer.json +0 -21
- package/templates/industry/ecommerce.md +0 -127
- package/templates/industry/fintech.md +0 -161
- package/templates/industry/saas.md +0 -134
- package/templates/session-memory.json +0 -48
- package/templates/skill-template/SKILL.md +0 -90
|
@@ -1,752 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Architecture Detection Engine
|
|
3
|
-
*
|
|
4
|
-
* Scans a project directory to detect:
|
|
5
|
-
* 1. Monorepo pattern (Turborepo, Nx, Lerna, pnpm, npm/yarn workspaces)
|
|
6
|
-
* 2. Framework (Next.js, React, Vue, Nuxt, Svelte, Angular, Astro)
|
|
7
|
-
* 3. Architecture pattern with confidence score
|
|
8
|
-
* 4. Sub-project architectures (for monorepos)
|
|
9
|
-
*
|
|
10
|
-
* Returns structured detection result with migration suggestions.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { existsSync, readdirSync, readFileSync, statSync } from 'fs'
|
|
14
|
-
import { join, relative } from 'path'
|
|
15
|
-
import { ARCHITECTURE_PATTERNS, MONOREPO_PATTERNS, getSuggestedArchitectures } from './architectures.mjs'
|
|
16
|
-
|
|
17
|
-
// ── Main Detection Function ───────────────────────────
|
|
18
|
-
|
|
19
|
-
export function detectProjectArchitecture(cwd, options = {}) {
|
|
20
|
-
const { framework = null, verbose = false } = options
|
|
21
|
-
|
|
22
|
-
const result = {
|
|
23
|
-
monorepo: detectMonorepo(cwd),
|
|
24
|
-
framework: framework,
|
|
25
|
-
architecture: null,
|
|
26
|
-
confidence: 0,
|
|
27
|
-
scores: {},
|
|
28
|
-
subProjects: [],
|
|
29
|
-
nextjsRouter: null,
|
|
30
|
-
projectInfo: {
|
|
31
|
-
hasTypeScript: false,
|
|
32
|
-
hasSrc: false,
|
|
33
|
-
totalDirs: 0,
|
|
34
|
-
totalFiles: 0,
|
|
35
|
-
srcRoot: '',
|
|
36
|
-
},
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Gather project info
|
|
40
|
-
result.projectInfo = gatherProjectInfo(cwd)
|
|
41
|
-
|
|
42
|
-
// Detect Next.js router type if applicable
|
|
43
|
-
if (framework === 'nextjs') {
|
|
44
|
-
result.nextjsRouter = detectNextjsRouterType(cwd)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Detect architecture
|
|
48
|
-
const srcRoot = result.projectInfo.srcRoot
|
|
49
|
-
const detectionResult = scoreAllPatterns(cwd, srcRoot)
|
|
50
|
-
result.scores = detectionResult.scores
|
|
51
|
-
result.architecture = detectionResult.bestMatch
|
|
52
|
-
result.confidence = detectionResult.bestScore
|
|
53
|
-
|
|
54
|
-
// For monorepos, also detect sub-project architectures
|
|
55
|
-
if (result.monorepo) {
|
|
56
|
-
result.subProjects = detectSubProjectArchitectures(cwd, result.monorepo)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return result
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// ── Monorepo Detection ────────────────────────────────
|
|
63
|
-
|
|
64
|
-
export function detectMonorepo(cwd) {
|
|
65
|
-
// Check in priority order
|
|
66
|
-
for (const [id, pattern] of Object.entries(MONOREPO_PATTERNS)) {
|
|
67
|
-
// Check detect files
|
|
68
|
-
if (pattern.detectFiles?.length > 0) {
|
|
69
|
-
const hasFile = pattern.detectFiles.some(f => existsSync(join(cwd, f)))
|
|
70
|
-
if (hasFile) {
|
|
71
|
-
return {
|
|
72
|
-
type: id,
|
|
73
|
-
name: pattern.name,
|
|
74
|
-
workspaceConfig: pattern.workspaceConfig,
|
|
75
|
-
apps: findMonorepoApps(cwd, id),
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Check detect deps
|
|
81
|
-
if (pattern.detectDeps?.length > 0) {
|
|
82
|
-
const pkgPath = join(cwd, 'package.json')
|
|
83
|
-
if (existsSync(pkgPath)) {
|
|
84
|
-
try {
|
|
85
|
-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
|
86
|
-
const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) }
|
|
87
|
-
const hasDep = pattern.detectDeps.some(d => deps[d])
|
|
88
|
-
if (hasDep) {
|
|
89
|
-
return {
|
|
90
|
-
type: id,
|
|
91
|
-
name: pattern.name,
|
|
92
|
-
workspaceConfig: pattern.workspaceConfig,
|
|
93
|
-
apps: findMonorepoApps(cwd, id),
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
} catch {}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Check custom rules
|
|
101
|
-
if (pattern.customRule === 'package-json-workspaces') {
|
|
102
|
-
const pkgPath = join(cwd, 'package.json')
|
|
103
|
-
if (existsSync(pkgPath)) {
|
|
104
|
-
try {
|
|
105
|
-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
|
106
|
-
if (pkg.workspaces) {
|
|
107
|
-
// Make sure it's not already detected as turborepo/nx/lerna
|
|
108
|
-
const alreadyDetected = ['turbo.json', 'nx.json', 'lerna.json', 'pnpm-workspace.yaml']
|
|
109
|
-
.some(f => existsSync(join(cwd, f)))
|
|
110
|
-
if (!alreadyDetected) {
|
|
111
|
-
return {
|
|
112
|
-
type: id,
|
|
113
|
-
name: pattern.name,
|
|
114
|
-
workspaceConfig: 'package.json',
|
|
115
|
-
apps: findMonorepoApps(cwd, id),
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
} catch {}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return null
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function findMonorepoApps(cwd, type) {
|
|
128
|
-
const apps = []
|
|
129
|
-
const searchDirs = []
|
|
130
|
-
|
|
131
|
-
switch (type) {
|
|
132
|
-
case 'turborepo':
|
|
133
|
-
case 'workspaces':
|
|
134
|
-
searchDirs.push('apps', 'packages')
|
|
135
|
-
break
|
|
136
|
-
case 'nx':
|
|
137
|
-
searchDirs.push('apps', 'libs')
|
|
138
|
-
break
|
|
139
|
-
case 'lerna':
|
|
140
|
-
searchDirs.push('packages')
|
|
141
|
-
break
|
|
142
|
-
case 'pnpm':
|
|
143
|
-
// Read pnpm-workspace.yaml for workspace patterns
|
|
144
|
-
try {
|
|
145
|
-
const content = readFileSync(join(cwd, 'pnpm-workspace.yaml'), 'utf-8')
|
|
146
|
-
const match = content.match(/packages:\s*\n((?:\s+-\s+.*\n?)*)/m)
|
|
147
|
-
if (match) {
|
|
148
|
-
const patterns = match[1].match(/'([^']+)'|"([^"]+)"|(\S+)/g)
|
|
149
|
-
if (patterns) {
|
|
150
|
-
for (const p of patterns) {
|
|
151
|
-
const clean = p.replace(/['"]/g, '').replace(/\/\*$/, '').replace(/^\s*-\s*/, '')
|
|
152
|
-
if (clean && !clean.startsWith('#')) searchDirs.push(clean)
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
} catch {}
|
|
157
|
-
if (searchDirs.length === 0) searchDirs.push('apps', 'packages')
|
|
158
|
-
break
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
for (const dir of searchDirs) {
|
|
162
|
-
const fullPath = join(cwd, dir)
|
|
163
|
-
if (!existsSync(fullPath)) continue
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
const entries = readdirSync(fullPath, { withFileTypes: true })
|
|
167
|
-
for (const entry of entries) {
|
|
168
|
-
if (!entry.isDirectory()) continue
|
|
169
|
-
const appPath = join(fullPath, entry.name)
|
|
170
|
-
const appPkgPath = join(appPath, 'package.json')
|
|
171
|
-
if (existsSync(appPkgPath)) {
|
|
172
|
-
try {
|
|
173
|
-
const pkg = JSON.parse(readFileSync(appPkgPath, 'utf-8'))
|
|
174
|
-
apps.push({
|
|
175
|
-
name: pkg.name || entry.name,
|
|
176
|
-
path: relative(cwd, appPath),
|
|
177
|
-
hasPackageJson: true,
|
|
178
|
-
})
|
|
179
|
-
} catch {
|
|
180
|
-
apps.push({ name: entry.name, path: relative(cwd, appPath), hasPackageJson: true })
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
} catch {}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return apps
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// ── Project Info Gathering ────────────────────────────
|
|
191
|
-
|
|
192
|
-
function gatherProjectInfo(cwd) {
|
|
193
|
-
const info = {
|
|
194
|
-
hasTypeScript: false,
|
|
195
|
-
hasSrc: false,
|
|
196
|
-
totalDirs: 0,
|
|
197
|
-
totalFiles: 0,
|
|
198
|
-
srcRoot: '',
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// Check for TypeScript
|
|
202
|
-
info.hasTypeScript = existsSync(join(cwd, 'tsconfig.json')) ||
|
|
203
|
-
existsSync(join(cwd, 'tsconfig.app.json'))
|
|
204
|
-
|
|
205
|
-
// Check for src directory
|
|
206
|
-
info.hasSrc = existsSync(join(cwd, 'src'))
|
|
207
|
-
info.srcRoot = info.hasSrc ? join(cwd, 'src') : cwd
|
|
208
|
-
|
|
209
|
-
// Count dirs/files (shallow, for project size estimation)
|
|
210
|
-
try {
|
|
211
|
-
const entries = readdirSync(info.srcRoot, { withFileTypes: true })
|
|
212
|
-
for (const entry of entries) {
|
|
213
|
-
if (entry.name.startsWith('.') || entry.name === 'node_modules') continue
|
|
214
|
-
if (entry.isDirectory()) info.totalDirs++
|
|
215
|
-
else info.totalFiles++
|
|
216
|
-
}
|
|
217
|
-
} catch {}
|
|
218
|
-
|
|
219
|
-
return info
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// ── Next.js Router Detection ──────────────────────────
|
|
223
|
-
|
|
224
|
-
function detectNextjsRouterType(cwd) {
|
|
225
|
-
const appRouterPaths = [
|
|
226
|
-
join(cwd, 'src', 'app', 'layout.tsx'),
|
|
227
|
-
join(cwd, 'src', 'app', 'layout.ts'),
|
|
228
|
-
join(cwd, 'src', 'app', 'layout.jsx'),
|
|
229
|
-
join(cwd, 'app', 'layout.tsx'),
|
|
230
|
-
join(cwd, 'app', 'layout.ts'),
|
|
231
|
-
]
|
|
232
|
-
|
|
233
|
-
const pagesRouterPaths = [
|
|
234
|
-
join(cwd, 'src', 'pages', '_app.tsx'),
|
|
235
|
-
join(cwd, 'src', 'pages', '_app.ts'),
|
|
236
|
-
join(cwd, 'src', 'pages', '_app.jsx'),
|
|
237
|
-
join(cwd, 'pages', '_app.tsx'),
|
|
238
|
-
join(cwd, 'pages', '_app.ts'),
|
|
239
|
-
]
|
|
240
|
-
|
|
241
|
-
const hasAppRouter = appRouterPaths.some(p => existsSync(p))
|
|
242
|
-
const hasPagesRouter = pagesRouterPaths.some(p => existsSync(p))
|
|
243
|
-
|
|
244
|
-
if (hasAppRouter && hasPagesRouter) return 'hybrid'
|
|
245
|
-
if (hasAppRouter) return 'app-router'
|
|
246
|
-
if (hasPagesRouter) return 'pages-router'
|
|
247
|
-
return 'unknown'
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// ── Architecture Scoring Engine ───────────────────────
|
|
251
|
-
|
|
252
|
-
function scoreAllPatterns(cwd, srcRoot) {
|
|
253
|
-
const scores = {}
|
|
254
|
-
let bestMatch = 'unstructured'
|
|
255
|
-
let bestScore = 0
|
|
256
|
-
|
|
257
|
-
// Get directories at srcRoot level
|
|
258
|
-
const srcDirs = listDirs(srcRoot)
|
|
259
|
-
const rootDirs = srcRoot !== cwd ? listDirs(cwd) : srcDirs
|
|
260
|
-
const allDirs = new Set([...srcDirs, ...rootDirs])
|
|
261
|
-
|
|
262
|
-
for (const [patternId, pattern] of Object.entries(ARCHITECTURE_PATTERNS)) {
|
|
263
|
-
if (patternId === 'unstructured') continue
|
|
264
|
-
|
|
265
|
-
let score = 0
|
|
266
|
-
const details = { matched: [], missed: [] }
|
|
267
|
-
|
|
268
|
-
const detection = pattern.detection
|
|
269
|
-
|
|
270
|
-
// Score required dirs (+3 each, all must be present for valid match)
|
|
271
|
-
let allRequiredFound = true
|
|
272
|
-
for (const dir of detection.requiredDirs) {
|
|
273
|
-
if (dirExists(srcRoot, dir) || dirExists(cwd, dir)) {
|
|
274
|
-
score += 3
|
|
275
|
-
details.matched.push(`required dir: ${dir}`)
|
|
276
|
-
} else {
|
|
277
|
-
allRequiredFound = false
|
|
278
|
-
details.missed.push(`required dir: ${dir}`)
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// If required dirs not all found and there are required dirs, heavily penalize
|
|
283
|
-
if (detection.requiredDirs.length > 0 && !allRequiredFound) {
|
|
284
|
-
score -= 10
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// Score optional dirs (+1.5 each)
|
|
288
|
-
for (const dir of detection.optionalDirs) {
|
|
289
|
-
if (dirExists(srcRoot, dir) || dirExists(cwd, dir)) {
|
|
290
|
-
score += 1.5
|
|
291
|
-
details.matched.push(`optional dir: ${dir}`)
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// Score module sub-dirs (check inside modules/* or features/*)
|
|
296
|
-
const moduleDirNames = ['modules', 'features', 'domains', 'bounded-contexts']
|
|
297
|
-
let foundModuleDir = null
|
|
298
|
-
for (const mDir of moduleDirNames) {
|
|
299
|
-
if (dirExists(srcRoot, mDir)) { foundModuleDir = join(srcRoot, mDir); break }
|
|
300
|
-
if (dirExists(cwd, mDir)) { foundModuleDir = join(cwd, mDir); break }
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
if (foundModuleDir && detection.moduleSubDirs.length > 0) {
|
|
304
|
-
const moduleExamples = listDirs(foundModuleDir).slice(0, 3)
|
|
305
|
-
for (const example of moduleExamples) {
|
|
306
|
-
const examplePath = join(foundModuleDir, example)
|
|
307
|
-
for (const subDir of detection.moduleSubDirs) {
|
|
308
|
-
if (dirExists(examplePath, subDir)) {
|
|
309
|
-
score += 2
|
|
310
|
-
details.matched.push(`module subdir: ${example}/${subDir}`)
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
for (const subDir of detection.optionalModuleSubDirs) {
|
|
314
|
-
if (dirExists(examplePath, subDir)) {
|
|
315
|
-
score += 1
|
|
316
|
-
details.matched.push(`optional module subdir: ${example}/${subDir}`)
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// Score file patterns (+1 each)
|
|
323
|
-
for (const filePattern of detection.filePatterns) {
|
|
324
|
-
if (hasFileMatchingPattern(cwd, filePattern)) {
|
|
325
|
-
score += 1
|
|
326
|
-
details.matched.push(`file pattern: ${filePattern}`)
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// Anti-patterns (-2 each)
|
|
331
|
-
for (const antiDir of detection.antiPatterns) {
|
|
332
|
-
if (dirExists(srcRoot, antiDir) || dirExists(cwd, antiDir)) {
|
|
333
|
-
score -= 2
|
|
334
|
-
details.missed.push(`anti-pattern: ${antiDir}`)
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// Custom rules
|
|
339
|
-
if (detection.customRule) {
|
|
340
|
-
const customScore = evaluateCustomRule(detection.customRule, cwd, srcRoot, allDirs)
|
|
341
|
-
score += customScore.score
|
|
342
|
-
details.matched.push(...customScore.matched)
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// Only consider if score meets minimum
|
|
346
|
-
if (score >= detection.minScore) {
|
|
347
|
-
scores[patternId] = { score, details, name: pattern.name }
|
|
348
|
-
if (score > bestScore) {
|
|
349
|
-
bestScore = score
|
|
350
|
-
bestMatch = patternId
|
|
351
|
-
}
|
|
352
|
-
} else {
|
|
353
|
-
scores[patternId] = { score, details, name: pattern.name, belowThreshold: true }
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
return { scores, bestMatch, bestScore }
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function evaluateCustomRule(rule, cwd, srcRoot, allDirs) {
|
|
361
|
-
const result = { score: 0, matched: [] }
|
|
362
|
-
|
|
363
|
-
switch (rule) {
|
|
364
|
-
case 'fsd-layers': {
|
|
365
|
-
const fsdLayers = ['app', 'processes', 'pages', 'widgets', 'features', 'entities', 'shared']
|
|
366
|
-
let count = 0
|
|
367
|
-
for (const layer of fsdLayers) {
|
|
368
|
-
if (dirExists(srcRoot, layer) || dirExists(cwd, layer)) count++
|
|
369
|
-
}
|
|
370
|
-
if (count >= 3) {
|
|
371
|
-
result.score = count * 2
|
|
372
|
-
result.matched.push(`FSD: ${count}/7 layers found`)
|
|
373
|
-
} else {
|
|
374
|
-
result.score = -5
|
|
375
|
-
}
|
|
376
|
-
break
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
case 'atomic-layers': {
|
|
380
|
-
const atomicLayers = ['atoms', 'molecules', 'organisms', 'templates']
|
|
381
|
-
let count = 0
|
|
382
|
-
for (const layer of atomicLayers) {
|
|
383
|
-
if (findDirRecursive(srcRoot, layer, 2) || findDirRecursive(cwd, layer, 2)) count++
|
|
384
|
-
}
|
|
385
|
-
if (count >= 2) {
|
|
386
|
-
result.score = count * 2
|
|
387
|
-
result.matched.push(`Atomic: ${count}/4 layers found`)
|
|
388
|
-
} else {
|
|
389
|
-
result.score = -5
|
|
390
|
-
}
|
|
391
|
-
break
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
case 'flat-components': {
|
|
395
|
-
const componentsDir = join(srcRoot, 'components')
|
|
396
|
-
if (existsSync(componentsDir)) {
|
|
397
|
-
try {
|
|
398
|
-
const files = readdirSync(componentsDir).filter(f => !f.startsWith('.'))
|
|
399
|
-
const componentFiles = files.filter(f =>
|
|
400
|
-
f.endsWith('.tsx') || f.endsWith('.jsx') || f.endsWith('.vue') || f.endsWith('.svelte') || f.endsWith('.astro')
|
|
401
|
-
)
|
|
402
|
-
if (componentFiles.length > 5) {
|
|
403
|
-
result.score = 3
|
|
404
|
-
result.matched.push(`Flat: ${componentFiles.length} component files in src/components/`)
|
|
405
|
-
}
|
|
406
|
-
} catch {}
|
|
407
|
-
}
|
|
408
|
-
break
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
case 'screaming-domains': {
|
|
412
|
-
// Check if top-level dirs in src are business nouns (not technical names)
|
|
413
|
-
const technicalDirs = new Set([
|
|
414
|
-
'components', 'utils', 'helpers', 'hooks', 'services', 'types', 'config',
|
|
415
|
-
'constants', 'assets', 'styles', 'lib', 'shared', 'common', 'core',
|
|
416
|
-
'app', 'pages', 'routes', 'api', '__tests__', 'test', 'tests',
|
|
417
|
-
'public', 'static', 'vendor', 'plugins', 'middleware', 'store',
|
|
418
|
-
'stores', 'adapters', 'providers', 'layouts', 'modules', 'features',
|
|
419
|
-
'domain', 'infrastructure', 'presentation', 'application',
|
|
420
|
-
])
|
|
421
|
-
const srcEntries = listDirs(srcRoot)
|
|
422
|
-
let domainCount = 0
|
|
423
|
-
let technicalCount = 0
|
|
424
|
-
for (const dir of srcEntries) {
|
|
425
|
-
if (technicalDirs.has(dir.toLowerCase())) technicalCount++
|
|
426
|
-
else domainCount++
|
|
427
|
-
}
|
|
428
|
-
if (domainCount >= 3 && domainCount > technicalCount) {
|
|
429
|
-
result.score = domainCount * 1.5
|
|
430
|
-
result.matched.push(`Screaming: ${domainCount} domain dirs vs ${technicalCount} technical dirs`)
|
|
431
|
-
} else {
|
|
432
|
-
result.score = -3
|
|
433
|
-
}
|
|
434
|
-
break
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
case 'microservices-check': {
|
|
438
|
-
// Multiple package.json files in subdirectories
|
|
439
|
-
let serviceCount = 0
|
|
440
|
-
for (const dir of ['services', 'apps', 'packages']) {
|
|
441
|
-
const fullPath = join(cwd, dir)
|
|
442
|
-
if (existsSync(fullPath)) {
|
|
443
|
-
try {
|
|
444
|
-
const entries = readdirSync(fullPath, { withFileTypes: true })
|
|
445
|
-
for (const entry of entries) {
|
|
446
|
-
if (entry.isDirectory()) {
|
|
447
|
-
if (existsSync(join(fullPath, entry.name, 'package.json'))) {
|
|
448
|
-
serviceCount++
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
} catch {}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
// Also check for multiple Dockerfiles
|
|
456
|
-
let dockerfileCount = 0
|
|
457
|
-
for (const dir of ['services', 'apps', '.']) {
|
|
458
|
-
const fullPath = dir === '.' ? cwd : join(cwd, dir)
|
|
459
|
-
if (existsSync(fullPath)) {
|
|
460
|
-
try {
|
|
461
|
-
const entries = readdirSync(fullPath, { withFileTypes: true })
|
|
462
|
-
for (const entry of entries) {
|
|
463
|
-
if (entry.isDirectory() && existsSync(join(fullPath, entry.name, 'Dockerfile'))) {
|
|
464
|
-
dockerfileCount++
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
} catch {}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
if (serviceCount >= 2 || dockerfileCount >= 2) {
|
|
471
|
-
result.score = serviceCount + dockerfileCount
|
|
472
|
-
result.matched.push(`Microservices: ${serviceCount} services, ${dockerfileCount} Dockerfiles`)
|
|
473
|
-
}
|
|
474
|
-
break
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
case 'modular-monolith-check': {
|
|
478
|
-
// Single package.json but modules with internal layering
|
|
479
|
-
const singlePkg = existsSync(join(cwd, 'package.json'))
|
|
480
|
-
const moduleDirNames = ['modules', 'bounded-contexts']
|
|
481
|
-
let foundModuleDir = null
|
|
482
|
-
for (const mDir of moduleDirNames) {
|
|
483
|
-
if (dirExists(srcRoot, mDir)) { foundModuleDir = join(srcRoot, mDir); break }
|
|
484
|
-
if (dirExists(cwd, mDir)) { foundModuleDir = join(cwd, mDir); break }
|
|
485
|
-
}
|
|
486
|
-
if (singlePkg && foundModuleDir) {
|
|
487
|
-
const moduleExamples = listDirs(foundModuleDir).slice(0, 3)
|
|
488
|
-
let hasInternalLayers = 0
|
|
489
|
-
for (const example of moduleExamples) {
|
|
490
|
-
const examplePath = join(foundModuleDir, example)
|
|
491
|
-
if (dirExists(examplePath, 'domain') || dirExists(examplePath, 'application') || dirExists(examplePath, 'infrastructure')) {
|
|
492
|
-
hasInternalLayers++
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
if (hasInternalLayers >= 1) {
|
|
496
|
-
result.score = 4 + hasInternalLayers
|
|
497
|
-
result.matched.push(`Modular Monolith: ${hasInternalLayers} modules with internal layering`)
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
break
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
case 'unstructured-fallback': {
|
|
504
|
-
result.score = 1
|
|
505
|
-
result.matched.push('Fallback: no clear pattern detected')
|
|
506
|
-
break
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
return result
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
// ── Sub-Project Detection (Monorepos) ─────────────────
|
|
514
|
-
|
|
515
|
-
function detectSubProjectArchitectures(cwd, monorepo) {
|
|
516
|
-
const subProjects = []
|
|
517
|
-
|
|
518
|
-
for (const app of monorepo.apps) {
|
|
519
|
-
const appPath = join(cwd, app.path)
|
|
520
|
-
const appInfo = gatherProjectInfo(appPath)
|
|
521
|
-
const detection = scoreAllPatterns(appPath, appInfo.srcRoot)
|
|
522
|
-
|
|
523
|
-
// Detect framework for this sub-project
|
|
524
|
-
let framework = null
|
|
525
|
-
const pkgPath = join(appPath, 'package.json')
|
|
526
|
-
if (existsSync(pkgPath)) {
|
|
527
|
-
try {
|
|
528
|
-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
|
529
|
-
const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) }
|
|
530
|
-
if (deps['nuxt']) framework = 'nuxt'
|
|
531
|
-
else if (deps['next']) framework = 'nextjs'
|
|
532
|
-
else if (deps['@sveltejs/kit'] || deps['svelte']) framework = 'svelte'
|
|
533
|
-
else if (deps['@angular/core']) framework = 'angular'
|
|
534
|
-
else if (deps['astro']) framework = 'astro'
|
|
535
|
-
else if (deps['vue']) framework = 'vue'
|
|
536
|
-
else if (deps['react']) framework = 'react'
|
|
537
|
-
} catch {}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
subProjects.push({
|
|
541
|
-
...app,
|
|
542
|
-
framework,
|
|
543
|
-
architecture: detection.bestMatch,
|
|
544
|
-
confidence: detection.bestScore,
|
|
545
|
-
})
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
return subProjects
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
// ── Utility Functions ─────────────────────────────────
|
|
552
|
-
|
|
553
|
-
function listDirs(dirPath) {
|
|
554
|
-
if (!existsSync(dirPath)) return []
|
|
555
|
-
try {
|
|
556
|
-
return readdirSync(dirPath, { withFileTypes: true })
|
|
557
|
-
.filter(d => d.isDirectory() && !d.name.startsWith('.') && d.name !== 'node_modules')
|
|
558
|
-
.map(d => d.name)
|
|
559
|
-
} catch {
|
|
560
|
-
return []
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
function dirExists(base, name) {
|
|
565
|
-
return existsSync(join(base, name)) && isDir(join(base, name))
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
function isDir(path) {
|
|
569
|
-
try {
|
|
570
|
-
return statSync(path).isDirectory()
|
|
571
|
-
} catch {
|
|
572
|
-
return false
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
function findDirRecursive(base, name, maxDepth) {
|
|
577
|
-
if (maxDepth <= 0 || !existsSync(base)) return false
|
|
578
|
-
try {
|
|
579
|
-
const entries = readdirSync(base, { withFileTypes: true })
|
|
580
|
-
for (const entry of entries) {
|
|
581
|
-
if (entry.name.startsWith('.') || entry.name === 'node_modules') continue
|
|
582
|
-
if (entry.isDirectory()) {
|
|
583
|
-
if (entry.name === name) return true
|
|
584
|
-
if (maxDepth > 1 && findDirRecursive(join(base, entry.name), name, maxDepth - 1)) return true
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
} catch {}
|
|
588
|
-
return false
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
function hasFileMatchingPattern(cwd, pattern) {
|
|
592
|
-
// Simple glob matching: check if any file matches the pattern
|
|
593
|
-
// Handles: **/dir/file, dir/*/file, specific files
|
|
594
|
-
const parts = pattern.split('/')
|
|
595
|
-
|
|
596
|
-
if (pattern.startsWith('**/')) {
|
|
597
|
-
const rest = pattern.slice(3)
|
|
598
|
-
return findFileRecursive(cwd, rest, 3)
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
// Check as direct path (with glob expansion for * in directory names)
|
|
602
|
-
if (parts.includes('*')) {
|
|
603
|
-
// e.g., services/*/package.json
|
|
604
|
-
return expandGlobPath(cwd, parts)
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
// Direct file check
|
|
608
|
-
return existsSync(join(cwd, pattern))
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
function findFileRecursive(base, pattern, maxDepth) {
|
|
612
|
-
if (maxDepth <= 0 || !existsSync(base)) return false
|
|
613
|
-
|
|
614
|
-
const parts = pattern.split('/')
|
|
615
|
-
const fileName = parts[parts.length - 1]
|
|
616
|
-
const dirName = parts.length > 1 ? parts[0] : null
|
|
617
|
-
|
|
618
|
-
try {
|
|
619
|
-
const entries = readdirSync(base, { withFileTypes: true })
|
|
620
|
-
for (const entry of entries) {
|
|
621
|
-
if (entry.name.startsWith('.') || entry.name === 'node_modules') continue
|
|
622
|
-
|
|
623
|
-
if (entry.isDirectory()) {
|
|
624
|
-
if (dirName && entry.name === dirName) {
|
|
625
|
-
// Found the directory, check deeper
|
|
626
|
-
const restPattern = parts.slice(1).join('/')
|
|
627
|
-
if (findFileRecursive(join(base, entry.name), restPattern, maxDepth - 1)) return true
|
|
628
|
-
}
|
|
629
|
-
// Also check recursively
|
|
630
|
-
if (findFileRecursive(join(base, entry.name), pattern, maxDepth - 1)) return true
|
|
631
|
-
} else if (!dirName) {
|
|
632
|
-
// Check file name matching
|
|
633
|
-
if (matchFileName(entry.name, fileName)) return true
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
} catch {}
|
|
637
|
-
return false
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
function expandGlobPath(base, parts) {
|
|
641
|
-
if (parts.length === 0) return true
|
|
642
|
-
if (!existsSync(base)) return false
|
|
643
|
-
|
|
644
|
-
const [current, ...rest] = parts
|
|
645
|
-
|
|
646
|
-
if (current === '*') {
|
|
647
|
-
try {
|
|
648
|
-
const entries = readdirSync(base, { withFileTypes: true })
|
|
649
|
-
for (const entry of entries) {
|
|
650
|
-
if (entry.name.startsWith('.') || entry.name === 'node_modules') continue
|
|
651
|
-
if (entry.isDirectory() && rest.length > 0) {
|
|
652
|
-
if (expandGlobPath(join(base, entry.name), rest)) return true
|
|
653
|
-
} else if (!entry.isDirectory() && rest.length === 0) {
|
|
654
|
-
return true
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
} catch {}
|
|
658
|
-
return false
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
if (rest.length === 0) {
|
|
662
|
-
// Last part - check if file exists
|
|
663
|
-
return existsSync(join(base, current))
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
return expandGlobPath(join(base, current), rest)
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
function matchFileName(actual, pattern) {
|
|
670
|
-
if (!pattern.includes('*')) return actual === pattern
|
|
671
|
-
const regex = new RegExp('^' + pattern.replace(/\*/g, '.*').replace(/\?/g, '.') + '$')
|
|
672
|
-
return regex.test(actual)
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
// ── Report Generation ─────────────────────────────────
|
|
676
|
-
|
|
677
|
-
export function generateDetectionReport(result) {
|
|
678
|
-
const lines = []
|
|
679
|
-
|
|
680
|
-
lines.push('Architecture Detection Report')
|
|
681
|
-
lines.push('─'.repeat(40))
|
|
682
|
-
lines.push('')
|
|
683
|
-
|
|
684
|
-
// Monorepo
|
|
685
|
-
if (result.monorepo) {
|
|
686
|
-
lines.push(`Monorepo: ${result.monorepo.name}`)
|
|
687
|
-
lines.push(` Config: ${result.monorepo.workspaceConfig}`)
|
|
688
|
-
if (result.monorepo.apps.length > 0) {
|
|
689
|
-
lines.push(` Apps/Packages: ${result.monorepo.apps.length}`)
|
|
690
|
-
for (const app of result.monorepo.apps) {
|
|
691
|
-
lines.push(` - ${app.name} (${app.path})`)
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
lines.push('')
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
// Framework
|
|
698
|
-
if (result.framework) {
|
|
699
|
-
const labels = { vue: 'Vue 3', react: 'React', nextjs: 'Next.js', svelte: 'SvelteKit', angular: 'Angular', astro: 'Astro', nuxt: 'Nuxt' }
|
|
700
|
-
lines.push(`Framework: ${labels[result.framework] || result.framework}`)
|
|
701
|
-
if (result.nextjsRouter) {
|
|
702
|
-
lines.push(` Router: ${result.nextjsRouter}`)
|
|
703
|
-
}
|
|
704
|
-
lines.push('')
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
// Architecture
|
|
708
|
-
const pattern = ARCHITECTURE_PATTERNS[result.architecture]
|
|
709
|
-
if (pattern) {
|
|
710
|
-
const confidenceLabel = result.confidence >= 8 ? 'high' : result.confidence >= 5 ? 'medium' : 'low'
|
|
711
|
-
lines.push(`Architecture: ${pattern.name}`)
|
|
712
|
-
lines.push(` Confidence: ${confidenceLabel} (score: ${result.confidence.toFixed(1)})`)
|
|
713
|
-
lines.push(` Category: ${pattern.category}`)
|
|
714
|
-
lines.push(` ${pattern.description}`)
|
|
715
|
-
lines.push('')
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
// Top scored patterns
|
|
719
|
-
const sortedScores = Object.entries(result.scores)
|
|
720
|
-
.filter(([, s]) => !s.belowThreshold)
|
|
721
|
-
.sort(([, a], [, b]) => b.score - a.score)
|
|
722
|
-
.slice(0, 5)
|
|
723
|
-
|
|
724
|
-
if (sortedScores.length > 1) {
|
|
725
|
-
lines.push('Pattern Scores:')
|
|
726
|
-
for (const [id, info] of sortedScores) {
|
|
727
|
-
const marker = id === result.architecture ? ' <-- detected' : ''
|
|
728
|
-
lines.push(` ${info.name}: ${info.score.toFixed(1)}${marker}`)
|
|
729
|
-
}
|
|
730
|
-
lines.push('')
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
// Sub-projects
|
|
734
|
-
if (result.subProjects.length > 0) {
|
|
735
|
-
lines.push('Sub-Project Architectures:')
|
|
736
|
-
for (const sub of result.subProjects) {
|
|
737
|
-
const subPattern = ARCHITECTURE_PATTERNS[sub.architecture]
|
|
738
|
-
const labels = { vue: 'Vue', react: 'React', nextjs: 'Next.js', svelte: 'Svelte', angular: 'Angular', astro: 'Astro', nuxt: 'Nuxt' }
|
|
739
|
-
const fw = sub.framework ? ` [${labels[sub.framework] || sub.framework}]` : ''
|
|
740
|
-
lines.push(` ${sub.name} (${sub.path})${fw}: ${subPattern?.name || 'Unknown'}`)
|
|
741
|
-
}
|
|
742
|
-
lines.push('')
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// Project info
|
|
746
|
-
lines.push('Project Info:')
|
|
747
|
-
lines.push(` TypeScript: ${result.projectInfo.hasTypeScript ? 'Yes' : 'No'}`)
|
|
748
|
-
lines.push(` src/ directory: ${result.projectInfo.hasSrc ? 'Yes' : 'No'}`)
|
|
749
|
-
lines.push('')
|
|
750
|
-
|
|
751
|
-
return lines.join('\n')
|
|
752
|
-
}
|