@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 +82 -51
- package/SKILL.md +46 -132
- package/dist/analyzer/pattern-catalog.d.ts +5 -2
- package/dist/analyzer/pattern-catalog.d.ts.map +1 -1
- package/dist/analyzer/pattern-catalog.js +338 -234
- package/dist/analyzer/pattern-catalog.js.map +1 -1
- package/dist/analyzer/scanner.d.ts +4 -0
- package/dist/analyzer/scanner.d.ts.map +1 -1
- package/dist/analyzer/scanner.js +13 -1
- package/dist/analyzer/scanner.js.map +1 -1
- package/dist/analyzer/structure-analyzer.d.ts +40 -0
- package/dist/analyzer/structure-analyzer.d.ts.map +1 -0
- package/dist/analyzer/structure-analyzer.js +228 -0
- package/dist/analyzer/structure-analyzer.js.map +1 -0
- package/dist/auditor/ux-auditor.js +8 -8
- package/dist/auditor/ux-auditor.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -4
- package/dist/index.js.map +1 -1
- package/dist/schemas/output.schema.d.ts +18 -0
- package/dist/schemas/output.schema.d.ts.map +1 -1
- package/dist/schemas/output.schema.js +3 -0
- package/dist/schemas/output.schema.js.map +1 -1
- package/dist/verifier/context7.d.ts +24 -10
- package/dist/verifier/context7.d.ts.map +1 -1
- package/dist/verifier/context7.js +63 -34
- package/dist/verifier/context7.js.map +1 -1
- package/package.json +1 -1
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-
|
|
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
|
|
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
|
|
67
|
-
const recommender: Recommender = (detection) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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,
|
|
93
|
-
|
|
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
|
|
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
|
|
115
|
-
| **
|
|
116
|
-
| **
|
|
117
|
-
| **
|
|
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
|
|
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
|
|
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
|
|
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
|
-
//
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
import {
|
|
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 =
|
|
176
|
-
return <h1>{t
|
|
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
|
-
//
|
|
203
|
-
//
|
|
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
|
|
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)
|
|
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 | `
|
|
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`, `
|
|
283
|
-
| Backend / Platform | 8 | `database-orm-migrations`, `
|
|
284
|
-
| Security | 5 | `auth-security`, `
|
|
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 #
|
|
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
|
|
344
|
-
git push origin
|
|
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:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
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
|
-
**
|
|
35
|
-
- No hardcoded library recommendations —
|
|
36
|
-
- Two analysis modes: **replacement** (hand-rolled code
|
|
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.
|
|
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)
|
|
34
|
+
Run `scanCodebase(input)`. The scanner:
|
|
51
35
|
|
|
52
|
-
1.
|
|
53
|
-
2.
|
|
54
|
-
3.
|
|
55
|
-
4.
|
|
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
|
|
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
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
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
|
|
65
|
+
For each scanner detection, recommend a **solution**. Consider:
|
|
86
66
|
|
|
87
67
|
1. **Ecosystem composition** — recommend companion libraries that work together
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
134
|
-
- **Step 9**: Auto-update existing dependencies
|
|
135
|
-
- **Step 10**: PR auto-creation via GitHub/GitLab
|
|
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
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
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"}
|