@nebutra/next-unicorn-skill 1.0.3 → 1.0.5

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/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  <a href="https://www.npmjs.com/package/@nebutra/next-unicorn-skill"><img src="https://img.shields.io/npm/v/@nebutra/next-unicorn-skill.svg?color=blue" alt="npm version" /></a>
12
12
  <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License" /></a>
13
13
  <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-strict-blue.svg" alt="TypeScript" /></a>
14
- <a href="./tests/"><img src="https://img.shields.io/badge/tests-198%20passed-brightgreen.svg" alt="Tests" /></a>
14
+ <a href="./tests/"><img src="https://img.shields.io/badge/tests-210%20passed-brightgreen.svg" alt="Tests" /></a>
15
15
  <a href="./tests/"><img src="https://img.shields.io/badge/properties-29%20verified-purple.svg" alt="Property Tests" /></a>
16
16
  </p>
17
17
 
@@ -31,9 +31,9 @@
31
31
 
32
32
  Every codebase accumulates hand-rolled implementations that should be mature libraries. Custom date formatters, DIY loggers, bespoke state machines, ad-hoc i18n — **Vibe Coding debt**.
33
33
 
34
- Snyk, Dependabot, and Renovate manage your *existing* dependencies. They can't find code you wrote that *should become* a dependency.
34
+ Snyk, Dependabot, and Renovate manage your *existing* dependencies. They can't find code you wrote that *should become* a dependency — or capabilities your project is *missing entirely*.
35
35
 
36
- **Next-Unicorn does both** — and verifies every recommendation against real documentation via [Context7 MCP](https://context7.com).
36
+ **Next-Unicorn does all three** — replacement, gap analysis, and dependency management verified against real documentation via [Context7 MCP](https://context7.com).
37
37
 
38
38
  ## Quick Start
39
39
 
@@ -61,18 +61,36 @@ npm install @nebutra/next-unicorn-skill
61
61
 
62
62
  ```typescript
63
63
  import { analyze, scanCodebase } from '@nebutra/next-unicorn-skill';
64
- import type { Recommender } from '@nebutra/next-unicorn-skill';
65
-
66
- // The recommender function: AI agent decides which library fits each detection
67
- const recommender: Recommender = (detection) => {
68
- // AI agent uses its knowledge + project context to recommend
69
- // Return null to skip a detection (false positive, intentional custom code)
70
- return {
71
- library: 'zustand', // dynamically chosen, not hardcoded
72
- version: '^5.0.0', // verified via Context7
73
- license: 'MIT',
74
- };
75
- };
64
+ import type { Recommender, GapRecommendation } from '@nebutra/next-unicorn-skill';
65
+
66
+ // The recommender: AI agent decides which library fits each detection
67
+ const recommender: Recommender = (detection) => ({
68
+ library: '@lingui/core',
69
+ version: '^4.0.0',
70
+ license: 'MIT',
71
+ rationale: 'Compile-time i18n with near-zero runtime overhead',
72
+ ecosystem: [
73
+ { library: '@lingui/macro', version: '^4.0.0', role: 'Tagged templates' },
74
+ { library: '@lingui/cli', version: '^4.0.0', role: 'CI message extraction' },
75
+ ],
76
+ antiPatterns: ['Avoid i18next if bundle size matters — Lingui compiles away'],
77
+ alternatives: [
78
+ { library: 'next-intl', when: 'Next.js App Router with server components' },
79
+ ],
80
+ });
81
+
82
+ // Gap analysis: capabilities the project should have but doesn't
83
+ const gaps: GapRecommendation[] = [
84
+ {
85
+ domain: 'observability',
86
+ description: 'No structured logging detected',
87
+ recommendedLibrary: {
88
+ name: 'pino', version: '^9.0.0', license: 'MIT',
89
+ rationale: 'Fastest Node.js JSON logger with redaction and child loggers',
90
+ },
91
+ priority: 'critical',
92
+ },
93
+ ];
76
94
 
77
95
  const result = await analyze({
78
96
  input: {
@@ -83,27 +101,22 @@ const result = await analyze({
83
101
  currentLibraries: { react: '18.2.0', next: '14.1.0' },
84
102
  },
85
103
  optimizationGoals: ['reduce custom code', 'improve maintainability'],
86
- constraints: {
87
- licenseAllowlist: ['MIT', 'Apache-2.0', 'ISC'],
88
- },
104
+ constraints: { licenseAllowlist: ['MIT', 'Apache-2.0', 'ISC'] },
89
105
  priorityFocusAreas: ['i18n', 'observability', 'auth-security'],
90
106
  },
91
107
  context7Client: myContext7Client,
92
- recommender, // AI agent provides library recommendations
93
- // Optional Phase 2 clients:
94
- vulnClient: myOsvClient, // vulnerability scanning
95
- registryClient: myRegistryClient, // auto-update
96
- platformClient: myGitHubClient, // PR creation
97
- gitOps: myGitOperations, // PR creation
108
+ recommender,
109
+ gaps,
98
110
  });
99
111
 
100
112
  if (result.success) {
101
113
  console.log(result.prettyJson);
102
- // result.scanResult contains raw detections for further AI analysis
114
+ // result.scanResult raw detections + structural findings for AI analysis
115
+ // result.output.gapAnalysis — Context7-verified gap recommendations
103
116
  }
104
117
  ```
105
118
 
106
- Or use as an **MCP SKILL** — provide [`SKILL.md`](./SKILL.md) to your AI agent (Claude Code, Kiro, etc.).
119
+ Or use as an **MCP SKILL** — provide [`SKILL.md`](./SKILL.md) to your AI agent (Claude Code, Kiro, Cursor, etc.).
107
120
 
108
121
  ## Features
109
122
 
@@ -111,17 +124,19 @@ Or use as an **MCP SKILL** — provide [`SKILL.md`](./SKILL.md) to your AI agent
111
124
 
112
125
  | Feature | Description |
113
126
  |---------|-------------|
114
- | **Pattern-based scanning** | Detects hand-rolled code across 68 Vibe Coding Domains (ISO 25010-aligned) |
115
- | **Gap analysis** | AI agent identifies missing capabilities — not just hand-rolled code, but things you should have but don't (e.g., no error monitoring, no rate limiting, no event-driven workflows) |
116
- | **Ecosystem-level recommendations** | Solutions include rationale, companion packages, anti-patterns, and alternatives not just "use library X" |
117
- | **Context7 verification** | Every recommendation verified against real, version-correct documentation |
127
+ | **Pattern-based scanning** | Detects hand-rolled code across 30 domains with 40+ regex patterns (design-system, auth, state-management, etc.) |
128
+ | **Structural analysis** | Detects monorepo architecture gaps: missing token layers, dependency flow violations, hardcoded config values |
129
+ | **Gap analysis** | AI agent identifies missing capabilities — not just hand-rolled code, but things you should have but don't |
130
+ | **Ecosystem-level recommendations** | Solutions include rationale, companion packages, anti-patterns, and alternatives |
131
+ | **Context7 verification** | Every recommendation (replacements AND gaps) verified with exponential backoff retry |
118
132
  | **7-dimension impact scoring** | Scalability, performance, security, maintainability, feature richness, UX, UI aesthetics |
119
133
  | **Phased migration plans** | Low / medium / high risk phases with adapter strategies |
120
134
  | **Deletion checklists** | Every file and line range to remove, with estimated lines saved |
121
135
  | **UX completeness audit** | A11y, error/empty/loading states, form validation, design system alignment |
136
+ | **Design system support** | Two paths: scaffold from reference repos (Primer, Polaris, Supabase, Dub) or extract from existing code |
122
137
  | **Monorepo support** | Detects npm, pip, cargo, go workspaces independently |
123
138
 
124
- ### Dependency Management (v2.0)
139
+ ### Dependency Management
125
140
 
126
141
  | Feature | Description |
127
142
  |---------|-------------|
@@ -133,13 +148,14 @@ Or use as an **MCP SKILL** — provide [`SKILL.md`](./SKILL.md) to your AI agent
133
148
  ## How It Works
134
149
 
135
150
  ```
136
- Input ─> Validator ─> Scanner ─> Recommender (AI Agent) ─> Context7 Verifier
151
+ Input ─> Validator ─> Scanner + Structure Analyzer
152
+ ─> Gap Analysis (AI Agent) ─> Recommender (AI Agent) ─> Context7 Verifier
137
153
  ─> Impact Scorer ─> Conflict Detection ─> Vuln Scanner ─> License Filter
138
154
  ─> Migration Planner ─> UX Auditor ─> Auto-Updater
139
155
  ─> Serializer ─> PR Creator ─> Output
140
156
  ```
141
157
 
142
- **Key architecture**: The scanner detects WHAT is hand-rolled; the **Recommender** (AI agent or caller) decides WHAT library to use. No library recommendations are hardcoded — they are provided dynamically based on project context, ecosystem knowledge, and Context7 verification.
158
+ **Key architecture**: The scanner detects WHAT is hand-rolled; the structure analyzer detects architectural gaps; the **Recommender** (AI agent or caller) decides WHAT to use. No library recommendations are hardcoded — they are provided dynamically based on project context, ecosystem knowledge, and Context7 verification.
143
159
 
144
160
  Each stage is a pure function with structured I/O. All external dependencies (Context7, OSV, npm registry, GitHub API) are **injected via interfaces** for testability.
145
161
 
@@ -166,14 +182,14 @@ function t(key, locale) {
166
182
  <td>
167
183
 
168
184
  ```tsx
169
- // next-intl — Context7 verified, MIT
170
- // Impact: 9.2/10 composite
171
- // Migration risk: low | Effort: 8h
172
- import { useTranslations } from 'next-intl';
185
+ // @lingui/core — Context7 verified, MIT
186
+ // Ecosystem: @lingui/macro + @lingui/cli
187
+ // Impact: 9.2/10 | Risk: low | Effort: 8h
188
+ import { useLingui } from '@lingui/react';
173
189
 
174
190
  export default function Page() {
175
- const t = useTranslations('common');
176
- return <h1>{t('greeting')}</h1>;
191
+ const { t } = useLingui();
192
+ return <h1>{t`greeting`}</h1>;
177
193
  }
178
194
  ```
179
195
 
@@ -199,8 +215,8 @@ function logRequest(req) {
199
215
 
200
216
  ```typescript
201
217
  // pino — Context7 verified, MIT
202
- // Impact: 9.0/10 composite
203
- // Migration risk: low | Effort: 4h
218
+ // Gap analysis: "No structured logging detected"
219
+ // Priority: critical
204
220
  import pino from 'pino';
205
221
  const logger = pino({
206
222
  level: 'info',
@@ -217,11 +233,15 @@ const logger = pino({
217
233
  | Feature | Next-Unicorn | Snyk | Dependabot | Renovate |
218
234
  |---------|:---:|:---:|:---:|:---:|
219
235
  | Finds hand-rolled code to replace | **Yes** | | | |
236
+ | Identifies missing capabilities (gaps) | **Yes** | | | |
237
+ | Structural architecture analysis | **Yes** | | | |
220
238
  | Recommends new libraries | **Yes** | | | |
239
+ | Ecosystem-level solutions | **Yes** | | | |
221
240
  | 7-dimension impact scoring | **Yes** | | | |
222
241
  | Context7 doc verification | **Yes** | | | |
223
242
  | Phased migration plans | **Yes** | | | |
224
243
  | UX completeness audit | **Yes** | | | |
244
+ | Design system scaffold/extraction | **Yes** | | | |
225
245
  | Deletion checklists | **Yes** | | | |
226
246
  | Vulnerability scanning | **Yes** | Yes | Yes | |
227
247
  | Scans *recommended* libs for vulns | **Yes** | | | |
@@ -249,14 +269,18 @@ const logger = pino({
249
269
 
250
270
  ### `scanCodebase(input): Promise<ScanResult>`
251
271
 
252
- Standalone scanner — returns detections and workspace info without recommendations. AI agents can call this first, then provide recommendations via the `Recommender` callback.
272
+ Standalone scanner — returns detections, workspace info, and structural findings (design system layer analysis, dependency flow violations). AI agents can call this first, then provide recommendations via the `Recommender` callback.
273
+
274
+ ### `analyzeStructure(repoPath, workspaces): StructuralAnalysis`
275
+
276
+ Standalone structure analyzer — detects missing design system layers, dependency flow violations, hardcoded config values, and missing shared presets in monorepos.
253
277
 
254
278
  ### Output Structure
255
279
 
256
280
  ```jsonc
257
281
  {
258
282
  "recommendedChanges": [...], // Replacement recommendations with impact scores
259
- "gapAnalysis": [...], // (optional) Missing capabilities with prioritized recs
283
+ "gapAnalysis": [...], // (optional) Context7-verified gap recommendations
260
284
  "filesToDelete": [...], // Files to remove after migration
261
285
  "linesSavedEstimate": 1250, // Total lines saved
262
286
  "uxAudit": [...], // UX completeness (8 categories)
@@ -272,16 +296,16 @@ Standalone scanner — returns detections and workspace info without recommendat
272
296
 
273
297
  ## Vibe Coding Domains
274
298
 
275
- 68 domains across 11 categories, aligned with ISO/IEC 25010:
299
+ 68 domains across 11 categories, aligned with ISO/IEC 25010. 30 domains have scanner patterns; the rest are covered by AI agent gap analysis.
276
300
 
277
301
  | Category | Count | Examples |
278
302
  |----------|:-----:|---------|
279
- | UX / Design | 14 | `ux-completeness`, `a11y-accessibility`, `forms-ux`, `design-system` |
303
+ | UX / Design | 14 | `design-system`, `a11y-accessibility`, `forms-ux`, `empty-loading-error-states` |
280
304
  | SEO / i18n | 5 | `seo`, `i18n`, `content-marketing` |
281
305
  | Growth / Data | 7 | `analytics-tracking`, `ab-testing-experimentation` |
282
- | Frontend Arch | 8 | `state-management`, `data-fetching-caching`, `agent-architecture` |
283
- | Backend / Platform | 8 | `database-orm-migrations`, `jobs-queue-scheduler`, `feature-flags-config` |
284
- | Security | 5 | `auth-security`, `permissions-rbac-ux`, `fraud-abuse-prevention` |
306
+ | Frontend Arch | 8 | `state-management`, `data-fetching-caching`, `realtime-collaboration` |
307
+ | Backend / Platform | 8 | `database-orm-migrations`, `caching-rate-limit`, `feature-flags-config` |
308
+ | Security | 5 | `auth-security`, `security-hardening`, `fraud-abuse-prevention` |
285
309
  | Observability | 4 | `logging-tracing-metrics`, `error-monitoring` |
286
310
  | Delivery / DevEx | 6 | `testing-strategy`, `ci-cd-release`, `dependency-management` |
287
311
  | Performance | 3 | `performance-web-vitals`, `cost-optimization` |
@@ -293,7 +317,7 @@ Standalone scanner — returns detections and workspace info without recommendat
293
317
  ## Testing
294
318
 
295
319
  ```bash
296
- pnpm test # 198 tests (vitest + fast-check)
320
+ pnpm test # 210 tests (vitest + fast-check)
297
321
  pnpm typecheck # TypeScript strict mode
298
322
  pnpm build # Compile to dist/
299
323
  ```
@@ -330,6 +354,13 @@ pnpm build # Compile to dist/
330
354
  | [`update-plan.md`](./templates/update-plan.md) | Dependency update plan |
331
355
  | [`prd-template.md`](./templates/prd-template.md) | PRD for stakeholder presentation |
332
356
 
357
+ ## References
358
+
359
+ | Reference | Purpose |
360
+ |-----------|---------|
361
+ | [`design-system-sources.md`](./references/design-system-sources.md) | 25+ curated design system repos for scaffolding (Primer, Polaris, Dub, Supabase, etc.) |
362
+ | [`design-system-extraction.md`](./references/design-system-extraction.md) | Workflow for extracting a design system from existing code (6 principles, 5 phases) |
363
+
333
364
  ## Contributing
334
365
 
335
366
  See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup, architecture overview, and contribution guidelines.
@@ -340,8 +371,8 @@ Releases are automated via GitHub Actions:
340
371
 
341
372
  ```bash
342
373
  # Tag a new version
343
- git tag v2.0.0
344
- git push origin v2.0.0
374
+ git tag v1.0.5
375
+ git push origin v1.0.5
345
376
  # → CI runs tests → creates GitHub Release → publishes to npmjs + GitHub Packages
346
377
  ```
347
378
 
package/SKILL.md CHANGED
@@ -1,27 +1,15 @@
1
1
  ---
2
2
  name: analyze-and-recommend-third-party-optimizations
3
- description: Scans any codebase and identifies where hand-rolled implementations should be replaced by battle-tested third-party libraries, producing structured migration plans with Context7-verified recommendations
4
- version: 1.0.3
5
- author: TsekaLuk
6
- tags:
7
- - code-analysis
8
- - third-party-libraries
9
- - migration-planning
10
- - dependency-optimization
11
- - context7-verification
12
- - ux-audit
13
- - impact-scoring
14
- - vulnerability-scanning
15
- - auto-update
16
- - pr-automation
3
+ description: >-
4
+ Scan a codebase to identify hand-rolled implementations that should be replaced
5
+ by third-party libraries, and identify missing capabilities the project should
6
+ have. Produce structured migration plans with Context7-verified recommendations.
7
+ Use when analyzing technical debt, auditing dependency health, reviewing
8
+ hand-rolled code, planning library migrations, or assessing capability gaps.
17
9
  ---
18
10
 
19
11
  # Analyze and Recommend Third-Party Optimizations
20
12
 
21
- ## Purpose
22
-
23
- Two-pronged analysis: (1) detect hand-rolled code that should be replaced by libraries, and (2) identify missing capabilities the project should have. The scanner pre-filters; the AI agent provides unicorn-grade recommendations — ecosystem-level solutions with rationale, anti-patterns, and alternatives, verified via Context7 MCP.
24
-
25
13
  ## Architecture
26
14
 
27
15
  ```
@@ -31,82 +19,60 @@ hand-rolled code 2. Identify capability gaps filter, seria
31
19
  using knowledge + Context7
32
20
  ```
33
21
 
34
- **Key principles**:
35
- - No hardcoded library recommendations — the AI agent evaluates project context dynamically
36
- - Two analysis modes: **replacement** (hand-rolled code → library) and **gap** (missing capability library)
22
+ **Design constraints**:
23
+ - No hardcoded library recommendations — evaluate project context dynamically
24
+ - Two analysis modes: **replacement** (hand-rolled code found) and **gap** (capability missing entirely)
37
25
 
38
26
  ## Standard Operating Procedure
39
27
 
40
28
  ### Step 1: Validate Input
41
29
 
42
- Parse and validate `InputSchema` JSON via Zod. Required fields:
43
- - **Project metadata**: repo path, languages, package managers, current libraries
44
- - **Optimization goals**: what the project wants to improve
45
- - **Constraints**: license allowlist, excluded libraries
46
- - **Priority focus areas**: Vibe Coding Domains to prioritize
30
+ Parse and validate `InputSchema` JSON via Zod. Read `src/schemas/input.schema.ts` for the full schema.
47
31
 
48
32
  ### Step 2: Scan Codebase
49
33
 
50
- Run `scanCodebase(input)` to walk the file tree and match against regex patterns. The scanner:
34
+ Run `scanCodebase(input)`. The scanner:
51
35
 
52
- 1. Detects workspace roots for monorepo support
53
- 2. Matches code against 20+ domain patterns (i18n, auth, state-management, etc.)
54
- 3. Records each detection with: file path, line range, pattern category, confidence score, domain
55
- 4. Returns `ScanResult` with detections and workspace info
36
+ 1. Detect workspace roots for monorepo support
37
+ 2. Match code against 20+ domain patterns (i18n, auth, state-management, etc.)
38
+ 3. Record each detection with: file path, line range, pattern category, confidence score, domain
39
+ 4. Return `ScanResult` with detections and workspace info
56
40
 
57
- Detections contain **no library suggestions** — only what was detected and where.
41
+ Detections contain no library suggestions — only what was detected and where.
58
42
 
59
43
  ### Step 2.5: Gap Analysis (AI Agent)
60
44
 
61
- Beyond what the scanner detects (hand-rolled code), analyze what the project is **missing entirely**. Review `currentLibraries`, `languages`, `optimizationGoals`, and `priorityFocusAreas` to identify capability gaps.
62
-
63
- Think at the level of unicorn-grade products:
64
- - "No structured logging" recommend pino + OpenTelemetry ecosystem
65
- - "No error monitoring" recommend Sentry with source maps + release health
66
- - "No event-driven workflows"recommend Inngest for reliable async tasks
67
- - "Using nodemailer" → recommend Resend for modern transactional email
68
- - "No rate limiting or bot protection" → recommend Arcjet as unified security layer
69
- - "REST API without type safety" recommend tRPC for end-to-end types
70
-
71
- Provide each gap as a `GapRecommendation`:
72
- ```typescript
73
- {
74
- domain: string; // e.g., "observability"
75
- description: string; // e.g., "No structured logging detected"
76
- recommendedLibrary: { name, version, license, rationale?, ecosystem?, antiPatterns?, alternatives? };
77
- priority: 'critical' | 'recommended' | 'nice-to-have';
78
- }
79
- ```
45
+ Beyond scanner detections, analyze what the project is **missing entirely**. Inspect:
46
+
47
+ 1. **Installed dependencies** — identify low-level tools that should be upgraded to platform-level solutions
48
+ 2. **Monorepo structure** identify missing architectural layers (e.g., shared token package, shared config preset)
49
+ 3. **Cross-cutting concerns** — identify absent capabilities: structured logging, error monitoring, rate limiting, event-driven workflows, transactional email, type-safe API layer
50
+ 4. **Architecture patterns** — identify opportunities for multi-package solutions (e.g., design-tokens tailwind-config ui three-layer architecture for design systems)
51
+
52
+ Analyze at three levels of depth:
53
+ - **Single library gap**: missing one tool (e.g., no form validation library)
54
+ - **Ecosystem gap**: missing a coordinated set of tools (e.g., no observability stack)
55
+ - **Architecture gap**: missing an entire structural layer (e.g., no design system, no shared config)
80
56
 
81
- Pass gaps to `analyze()` via the `gaps` option. They appear in the output as `gapAnalysis`.
57
+ Provide each gap as a `GapRecommendation`. Read `src/index.ts` for the interface. Pass gaps via the `gaps` option in `analyze()`.
58
+
59
+ **Design system gaps** — Two paths depending on project maturity:
60
+ - **No existing frontend**: Scaffold from reference repos. Read `references/design-system-sources.md` for curated sources and sparse-checkout workflow.
61
+ - **Existing frontend without formal design system**: First extract the spec (audit → tokens → classify → document) via `references/design-system-extraction.md`, then implement the architecture via `references/design-system-sources.md`.
82
62
 
83
63
  ### Step 3: Recommend Solutions (AI Agent)
84
64
 
85
- For each detection, recommend a **solution** — not just a library, but an ecosystem-level answer. Consider:
65
+ For each scanner detection, recommend a **solution**. Consider:
86
66
 
87
67
  1. **Ecosystem composition** — recommend companion libraries that work together
88
- (e.g., `@lingui/core` + `@lingui/macro` + `@lingui/cli` for compile-time i18n with TMS integration)
89
- 2. **Rationale** — explain WHY this specific choice fits this project's framework, runtime, and scale
90
- 3. **Anti-patterns** — what NOT to use and why (e.g., "Never use jsonwebtoken — no edge runtime support; use jose")
68
+ 2. **Rationale** explain WHY this choice fits this project's framework, runtime, and scale
69
+ 3. **Anti-patterns** — what NOT to use and why
91
70
  4. **Alternatives** — different solutions for different architectural contexts
92
71
  5. **Context7 verification** — call `resolve-library-id` + `query-docs` to confirm the library exists and get latest version/docs
93
72
 
94
- Return a `LibraryRecommendation` per detection:
95
- ```typescript
96
- {
97
- library: string; // required — primary package
98
- version: string; // required
99
- license: string; // required
100
- rationale?: string; // recommended — WHY this choice
101
- ecosystem?: Array<{...}>; // when solution involves multiple packages
102
- antiPatterns?: string[]; // when common mistakes exist
103
- alternatives?: Array<{...}>; // when architecture affects the choice
104
- }
105
- ```
106
-
107
- Return `null` to skip a detection (intentional custom code, false positive, etc.).
73
+ Read `src/index.ts` for the `LibraryRecommendation` interface. Return `null` to skip a detection.
108
74
 
109
- **False positive filtering** — skip if:
75
+ **Skip a detection if**:
110
76
  - Code has comments explaining why it is custom
111
77
  - Detection is in test/mock/fixture files
112
78
  - Library is already in project dependencies (suggest version update instead)
@@ -114,15 +80,15 @@ Return `null` to skip a detection (intentional custom code, false positive, etc.
114
80
 
115
81
  ### Step 4: Score Impact
116
82
 
117
- Compute 7-dimension impact scores (scalability, performance, security, maintainability, feature richness, UX, UI aesthetics) with composite score, migration risk, and estimated effort.
83
+ Call `computeImpactScore()` for each detection. Optionally provide `dimensionHints` and `baseEffortHours` for more accurate scoring. Read `src/scorer/impact-scorer.ts` for the interface.
118
84
 
119
85
  ### Step 5: Build Migration Plan
120
86
 
121
- Group recommendations into phases by risk (low medium high), ordered by domain priority (infrastructure first, presentation last). High-risk items include adapter strategies.
87
+ Call `buildMigrationPlan()` to group recommendations into phases by risk (low, medium, high). High-risk items include adapter strategies.
122
88
 
123
89
  ### Step 6: Audit UX Completeness
124
90
 
125
- Evaluate frontend codebase across 8 UX categories: accessibility, error/empty/loading states, form validation, performance feel, copy consistency, design system alignment.
91
+ Call `auditUxCompleteness()` to evaluate 8 UX categories. The auditor determines status (present/partial/missing). Fill in `recommendedLibrary` on partial/missing items based on project context.
126
92
 
127
93
  ### Step 7: Apply Constraints and Serialize
128
94
 
@@ -130,73 +96,21 @@ Filter by license allowlist, detect dependency conflicts, serialize to JSON.
130
96
 
131
97
  ### Optional Steps
132
98
 
133
- - **Step 8**: Vulnerability scanning via OSV database
134
- - **Step 9**: Auto-update existing dependencies via registry queries
135
- - **Step 10**: PR auto-creation via GitHub/GitLab API
136
-
137
- ## Programmatic API
138
-
139
- ```typescript
140
- import { analyze, scanCodebase } from './src/index.js';
141
- import type { Recommender, GapRecommendation } from './src/index.js';
142
-
143
- // Step 1: Scan standalone (for AI agent inspection)
144
- const scanResult = await scanCodebase(validatedInput);
145
-
146
- // Step 2: Full pipeline with recommender + gap analysis
147
- const recommender: Recommender = (detection) => ({
148
- library: 'zustand',
149
- version: '^5.0.0',
150
- license: 'MIT',
151
- rationale: 'Minimal state library — no providers, 1KB gzipped',
152
- });
153
-
154
- const gaps: GapRecommendation[] = [
155
- {
156
- domain: 'observability',
157
- description: 'No structured logging detected',
158
- recommendedLibrary: {
159
- name: 'pino', version: '^9.0.0', license: 'MIT',
160
- rationale: 'Fastest Node.js JSON logger with redaction and child loggers',
161
- },
162
- priority: 'critical',
163
- },
164
- ];
165
-
166
- const result = await analyze({
167
- input: inputJson,
168
- context7Client: myContext7Client,
169
- recommender,
170
- gaps, // AI agent identifies missing capabilities
171
- });
172
- ```
99
+ - **Step 8**: Vulnerability scan via OSV database (`vulnClient`)
100
+ - **Step 9**: Auto-update existing dependencies (`registryClient`)
101
+ - **Step 10**: PR auto-creation via GitHub/GitLab (`platformClient` + `gitOps`)
173
102
 
174
- ## Output Artifacts
103
+ ## Output
175
104
 
176
105
  Single `OutputSchema` JSON containing:
177
106
  - `recommendedChanges` — replacement recommendations with scores, verification, adapter strategies
178
107
  - `gapAnalysis` (optional) — missing capabilities with prioritized recommendations
179
108
  - `filesToDelete` — file paths to remove after migration
180
109
  - `linesSavedEstimate` — total lines saved
181
- - `uxAudit` — UX completeness checklist
110
+ - `uxAudit` — UX completeness checklist (8 categories)
182
111
  - `migrationPlan` — phased plan with deletion checklist
183
112
  - `vulnerabilityReport` (optional)
184
113
  - `updatePlan` (optional)
185
114
  - `pullRequests` (optional)
186
115
 
187
- ## Vibe Coding Domain Coverage (20+ detection patterns)
188
-
189
- | Category | Domains |
190
- |----------|---------|
191
- | UX / Design | ux-completeness, a11y-accessibility, forms-ux, state-management |
192
- | SEO / i18n / Content | seo, i18n, content-marketing |
193
- | Growth / Data | growth-hacking |
194
- | App Architecture | agent-architecture, data-fetching-caching, error-handling-resilience |
195
- | Backend / Platform | database-orm-migrations, auth-security |
196
- | Observability | observability, logging-tracing-metrics |
197
- | Testing | testing-strategy |
198
- | AI Engineering | ai-model-serving |
199
- | Business | cross-border-ecommerce |
200
- | File / Media | file-upload-media |
201
-
202
- > **Extensibility:** Use `customDomains?: string[]` in input for project-specific domains.
116
+ Read `src/schemas/output.schema.ts` for the full schema.
@@ -25,10 +25,13 @@ export interface PatternDefinition {
25
25
  }
26
26
  /**
27
27
  * Returns the full pattern catalog covering Vibe Coding domains.
28
- * Each covered domain has 2–3 patterns for hand-rolled code detection.
28
+ *
29
+ * Domain assignment rules:
30
+ * - Each pattern goes in its MOST SPECIFIC domain (e.g., A/B test → ab-testing-experimentation, not growth-hacking)
31
+ * - Parent domains (growth-hacking, observability, ux-completeness) are used only when no specific child domain fits
32
+ * - Domains with no regex-detectable patterns are left for Gap Analysis (AI Agent)
29
33
  *
30
34
  * The catalog defines WHAT to detect, not WHAT to recommend.
31
- * Library recommendations are generated dynamically by the AI agent.
32
35
  */
33
36
  export declare function getPatternCatalog(): PatternDefinition[];
34
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"pattern-catalog.d.ts","sourceRoot":"","sources":["../../src/analyzer/pattern-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,MAAM,EAAE,gBAAgB,CAAC;IACzB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,EAAE,CAuiBvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAExE"}
1
+ {"version":3,"file":"pattern-catalog.d.ts","sourceRoot":"","sources":["../../src/analyzer/pattern-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,MAAM,EAAE,gBAAgB,CAAC;IACzB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,EAAE,CAkqBvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAExE"}