@nebutra/next-unicorn-skill 1.0.0 → 1.0.1
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/CHANGELOG.md +25 -0
- package/README.md +48 -12
- package/SKILL.md +87 -256
- package/dist/analyzer/pattern-catalog.d.ts +11 -8
- package/dist/analyzer/pattern-catalog.d.ts.map +1 -1
- package/dist/analyzer/pattern-catalog.js +273 -67
- package/dist/analyzer/pattern-catalog.js.map +1 -1
- package/dist/analyzer/scanner.d.ts +0 -1
- package/dist/analyzer/scanner.d.ts.map +1 -1
- package/dist/analyzer/scanner.js +70 -61
- package/dist/analyzer/scanner.js.map +1 -1
- package/dist/auditor/ux-auditor.d.ts +4 -1
- package/dist/auditor/ux-auditor.d.ts.map +1 -1
- package/dist/auditor/ux-auditor.js +25 -47
- package/dist/auditor/ux-auditor.js.map +1 -1
- package/dist/index.d.ts +40 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -24
- package/dist/index.js.map +1 -1
- package/dist/planner/migration-planner.d.ts +7 -2
- package/dist/planner/migration-planner.d.ts.map +1 -1
- package/dist/planner/migration-planner.js +16 -4
- package/dist/planner/migration-planner.js.map +1 -1
- package/dist/pr-creator/pr-description-builder.js +1 -1
- package/dist/pr-creator/pr-description-builder.js.map +1 -1
- package/dist/scorer/impact-scorer.d.ts +28 -2
- package/dist/scorer/impact-scorer.d.ts.map +1 -1
- package/dist/scorer/impact-scorer.js +46 -111
- package/dist/scorer/impact-scorer.js.map +1 -1
- package/dist/verifier/context7.d.ts +15 -4
- package/dist/verifier/context7.d.ts.map +1 -1
- package/dist/verifier/context7.js +12 -9
- package/dist/verifier/context7.js.map +1 -1
- package/package.json +12 -14
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.1] - 2026-02-09
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **Architecture: Decouple detection from recommendation** — The pattern catalog no longer contains hardcoded library names, versions, licenses, best practices, or alternatives. Library recommendations are now provided dynamically by the caller via the `Recommender` callback, enabling AI agents to leverage their generalization ability and Context7 MCP for real-time, context-aware recommendations.
|
|
13
|
+
- **New `Recommender` type** — `analyze()` now requires a `recommender: (detection) => LibraryRecommendation | null` callback. Return `null` to skip false positives.
|
|
14
|
+
- **New `scanCodebase()` export** — Standalone scanner for AI agents to inspect detections before providing recommendations.
|
|
15
|
+
- **UX Auditor decoupled** — `recommendedLibrary` is no longer hardcoded per category; the auditor reports status (present/partial/missing) with factual rationale, leaving library choice to the AI agent.
|
|
16
|
+
- **Impact Scorer decoupled** — Removed 200+ line `DOMAIN_DIMENSION_AFFINITY` mapping and `DOMAIN_BASE_EFFORT` table. Scoring uses confidence-based defaults with optional `dimensionHints` and `baseEffortHours` overrides from the AI agent.
|
|
17
|
+
- **Migration Planner decoupled** — Removed `DOMAIN_MIGRATION_PRIORITY` mapping. Sorting within each risk phase uses file co-location + composite score. AI agents can influence ordering via scoring.
|
|
18
|
+
- **`Detection` type simplified** — Removed `suggestedLibrary` field. Detections now contain only what was detected (file, line range, pattern, confidence, domain).
|
|
19
|
+
- **`VerificationItem` type added** — `verifyAllRecommendations()` now accepts `Array<VerificationItem | null>` instead of `Detection[]`, decoupling verification from scanner output.
|
|
20
|
+
- **`AnalyzeResult` includes `scanResult`** — Success results now include raw `ScanResult` for AI agent further analysis.
|
|
21
|
+
- Pattern catalog reduced from 880 to 370 lines (detection-only, no recommendation data)
|
|
22
|
+
- SKILL.md rewritten to 150 lines following Anthropic SKILL spec principles (concise, high freedom for recommendations)
|
|
23
|
+
- Test count increased from 191 to 198
|
|
24
|
+
|
|
25
|
+
### Removed
|
|
26
|
+
|
|
27
|
+
- All hardcoded library recommendations from `PatternDefinition` (`suggestedLibrary`, `suggestedVersion`, `license`, `bestPractice`, `alternatives`)
|
|
28
|
+
- All hardcoded UX audit library recommendations and rationale strings
|
|
29
|
+
- `DOMAIN_DIMENSION_AFFINITY` (68-domain × 7-dimension static mapping)
|
|
30
|
+
- `DOMAIN_BASE_EFFORT` (25-domain effort estimate table)
|
|
31
|
+
- `DOMAIN_MIGRATION_PRIORITY` (domain tier ordering)
|
|
32
|
+
|
|
8
33
|
## [2.0.0] - 2026-02-08
|
|
9
34
|
|
|
10
35
|
### Added
|
package/README.md
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
<a href="https://github.com/
|
|
10
|
+
<a href="https://github.com/Nebutra/Next-Unicorn-Skill/actions/workflows/ci.yml"><img src="https://github.com/Nebutra/Next-Unicorn-Skill/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
|
|
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-198%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
|
|
|
@@ -37,19 +37,42 @@ Snyk, Dependabot, and Renovate manage your *existing* dependencies. They can't f
|
|
|
37
37
|
|
|
38
38
|
## Quick Start
|
|
39
39
|
|
|
40
|
+
### From npmjs.org (recommended)
|
|
41
|
+
|
|
40
42
|
```bash
|
|
41
|
-
# npm
|
|
42
43
|
npm install @nebutra/next-unicorn-skill
|
|
43
|
-
|
|
44
|
-
# pnpm
|
|
44
|
+
# or
|
|
45
45
|
pnpm add @nebutra/next-unicorn-skill
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### From GitHub Packages
|
|
49
|
+
|
|
50
|
+
Configure your `.npmrc` first:
|
|
51
|
+
|
|
52
|
+
```shell
|
|
53
|
+
echo "@nebutra:registry=https://npm.pkg.github.com" >> .npmrc
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Then install:
|
|
46
57
|
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
```bash
|
|
59
|
+
npm install @nebutra/next-unicorn-skill
|
|
49
60
|
```
|
|
50
61
|
|
|
51
62
|
```typescript
|
|
52
|
-
import { analyze } from '@nebutra/next-unicorn-skill';
|
|
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
|
+
};
|
|
53
76
|
|
|
54
77
|
const result = await analyze({
|
|
55
78
|
input: {
|
|
@@ -66,6 +89,7 @@ const result = await analyze({
|
|
|
66
89
|
priorityFocusAreas: ['i18n', 'observability', 'auth-security'],
|
|
67
90
|
},
|
|
68
91
|
context7Client: myContext7Client,
|
|
92
|
+
recommender, // AI agent provides library recommendations
|
|
69
93
|
// Optional Phase 2 clients:
|
|
70
94
|
vulnClient: myOsvClient, // vulnerability scanning
|
|
71
95
|
registryClient: myRegistryClient, // auto-update
|
|
@@ -75,6 +99,7 @@ const result = await analyze({
|
|
|
75
99
|
|
|
76
100
|
if (result.success) {
|
|
77
101
|
console.log(result.prettyJson);
|
|
102
|
+
// result.scanResult contains raw detections for further AI analysis
|
|
78
103
|
}
|
|
79
104
|
```
|
|
80
105
|
|
|
@@ -106,12 +131,14 @@ Or use as an **MCP SKILL** — provide [`SKILL.md`](./SKILL.md) to your AI agent
|
|
|
106
131
|
## How It Works
|
|
107
132
|
|
|
108
133
|
```
|
|
109
|
-
Input ─> Validator ─> Scanner ─>
|
|
110
|
-
─> Conflict Detection ─> Vuln Scanner ─> License Filter
|
|
134
|
+
Input ─> Validator ─> Scanner ─> Recommender (AI Agent) ─> Context7 Verifier
|
|
135
|
+
─> Impact Scorer ─> Conflict Detection ─> Vuln Scanner ─> License Filter
|
|
111
136
|
─> Migration Planner ─> UX Auditor ─> Auto-Updater
|
|
112
137
|
─> Serializer ─> PR Creator ─> Output
|
|
113
138
|
```
|
|
114
139
|
|
|
140
|
+
**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.
|
|
141
|
+
|
|
115
142
|
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.
|
|
116
143
|
|
|
117
144
|
### Before / After
|
|
@@ -211,11 +238,16 @@ const logger = pino({
|
|
|
211
238
|
|--------|------|:--------:|-------------|
|
|
212
239
|
| `input` | `InputSchema` | Yes | Project metadata, goals, constraints, focus areas |
|
|
213
240
|
| `context7Client` | `Context7Client` | Yes | Context7 MCP client for doc verification |
|
|
241
|
+
| `recommender` | `Recommender` | Yes | Maps each detection → library recommendation (AI agent provides this) |
|
|
214
242
|
| `vulnClient` | `VulnerabilityClient` | No | OSV client for vulnerability scanning |
|
|
215
243
|
| `registryClient` | `RegistryClient` | No | Package registry client for auto-update |
|
|
216
244
|
| `platformClient` | `PlatformClient` | No | GitHub/GitLab client for PR creation |
|
|
217
245
|
| `gitOps` | `GitOperations` | No | Git CLI operations for PR creation |
|
|
218
246
|
|
|
247
|
+
### `scanCodebase(input): Promise<ScanResult>`
|
|
248
|
+
|
|
249
|
+
Standalone scanner — returns detections and workspace info without recommendations. AI agents can call this first, then provide recommendations via the `Recommender` callback.
|
|
250
|
+
|
|
219
251
|
### Output Structure
|
|
220
252
|
|
|
221
253
|
```jsonc
|
|
@@ -257,7 +289,7 @@ const logger = pino({
|
|
|
257
289
|
## Testing
|
|
258
290
|
|
|
259
291
|
```bash
|
|
260
|
-
pnpm test #
|
|
292
|
+
pnpm test # 198 tests (vitest + fast-check)
|
|
261
293
|
pnpm typecheck # TypeScript strict mode
|
|
262
294
|
pnpm build # Compile to dist/
|
|
263
295
|
```
|
|
@@ -306,9 +338,13 @@ Releases are automated via GitHub Actions:
|
|
|
306
338
|
# Tag a new version
|
|
307
339
|
git tag v2.0.0
|
|
308
340
|
git push origin v2.0.0
|
|
309
|
-
# → CI runs tests → creates GitHub Release → publishes to
|
|
341
|
+
# → CI runs tests → creates GitHub Release → publishes to npmjs + GitHub Packages
|
|
310
342
|
```
|
|
311
343
|
|
|
344
|
+
Packages are also published automatically on every push to `main` via the CI workflow.
|
|
345
|
+
|
|
346
|
+
> **Required Secrets**: `NPM_TOKEN` (npmjs.org publish token). `GITHUB_TOKEN` is provided automatically.
|
|
347
|
+
|
|
312
348
|
See [CHANGELOG.md](./CHANGELOG.md) for version history.
|
|
313
349
|
|
|
314
350
|
## License
|
package/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: analyze-and-recommend-third-party-optimizations
|
|
3
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:
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
author: TsekaLuk
|
|
6
6
|
tags:
|
|
7
7
|
- code-analysis
|
|
@@ -20,299 +20,130 @@ tags:
|
|
|
20
20
|
|
|
21
21
|
## Purpose
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Scan a codebase to identify hand-rolled implementations that should be replaced by third-party libraries. The scanner detects WHAT is hand-rolled; the AI agent decides WHAT to recommend based on project context, current ecosystem knowledge, and Context7 MCP verification.
|
|
24
24
|
|
|
25
|
-
##
|
|
25
|
+
## Architecture
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
```
|
|
28
|
+
Scanner (deterministic) → AI Agent (generative) → Pipeline (deterministic)
|
|
29
|
+
Regex patterns detect Agent recommends library Score, plan, audit,
|
|
30
|
+
hand-rolled code using knowledge + Context7 filter, serialize
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Key principle**: The pattern catalog contains NO hardcoded library recommendations. Library choices depend on project framework, runtime, existing dependencies, and current ecosystem state — all of which the AI agent evaluates dynamically.
|
|
30
34
|
|
|
31
35
|
## Standard Operating Procedure
|
|
32
36
|
|
|
33
37
|
### Step 1: Validate Input
|
|
34
38
|
|
|
35
|
-
Parse and validate
|
|
36
|
-
|
|
37
|
-
- **
|
|
38
|
-
- **
|
|
39
|
-
- **
|
|
40
|
-
- **Priority focus areas**: Vibe Coding Domains to prioritize (i18n, seo, growth-hacking, ai-model-serving, agent-architecture, content-marketing, cross-border-ecommerce, observability, auth-security, ux-completeness)
|
|
41
|
-
- **Impact weights** (optional): custom weights for the 7 scoring dimensions
|
|
42
|
-
|
|
43
|
-
If validation fails, return a structured error response with field-level messages. Do not proceed.
|
|
39
|
+
Parse and validate `InputSchema` JSON via Zod. Required fields:
|
|
40
|
+
- **Project metadata**: repo path, languages, package managers, current libraries
|
|
41
|
+
- **Optimization goals**: what the project wants to improve
|
|
42
|
+
- **Constraints**: license allowlist, excluded libraries
|
|
43
|
+
- **Priority focus areas**: Vibe Coding Domains to prioritize
|
|
44
44
|
|
|
45
45
|
### Step 2: Scan Codebase
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
Run `scanCodebase(input)` to walk the file tree and match against regex patterns. The scanner:
|
|
48
48
|
|
|
49
|
-
1. Detects workspace roots for monorepo support
|
|
50
|
-
2.
|
|
51
|
-
3.
|
|
52
|
-
4.
|
|
53
|
-
5. Skips unreadable files (binary, permissions) gracefully
|
|
49
|
+
1. Detects workspace roots for monorepo support
|
|
50
|
+
2. Matches code against 20+ domain patterns (i18n, auth, state-management, etc.)
|
|
51
|
+
3. Records each detection with: file path, line range, pattern category, confidence score, domain
|
|
52
|
+
4. Returns `ScanResult` with detections and workspace info
|
|
54
53
|
|
|
55
|
-
|
|
54
|
+
Detections contain **no library suggestions** — only what was detected and where.
|
|
56
55
|
|
|
57
|
-
|
|
56
|
+
### Step 3: Recommend Libraries (AI Agent)
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
2. Call `get-library-docs` to retrieve version-specific documentation and confirm the use case
|
|
61
|
-
3. Set verification status:
|
|
62
|
-
- **verified** — Context7 confirmed the library and use case
|
|
63
|
-
- **unverified** — Context7 could not resolve the library identifier
|
|
64
|
-
- **unavailable** — Context7 service was unreachable (after one retry)
|
|
58
|
+
For each detection, recommend the best library based on:
|
|
65
59
|
|
|
66
|
-
|
|
60
|
+
1. **Project context** — framework (Next.js → next-intl, Vite → @lingui/core), runtime (Edge → jose, not jsonwebtoken), existing deps
|
|
61
|
+
2. **Ecosystem knowledge** — use your training knowledge of current best practices
|
|
62
|
+
3. **Context7 verification** — call `resolve-library-id` + `query-docs` to confirm the library exists and get latest version/docs
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
Return a `LibraryRecommendation` per detection:
|
|
65
|
+
```typescript
|
|
66
|
+
{ library: string; version: string; license: string }
|
|
67
|
+
```
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|-----------|-------|
|
|
72
|
-
| Scalability | 1–10 |
|
|
73
|
-
| Performance | 1–10 |
|
|
74
|
-
| Security | 1–10 |
|
|
75
|
-
| Maintainability | 1–10 |
|
|
76
|
-
| Feature Richness | 1–10 |
|
|
77
|
-
| UX | 1–10 |
|
|
78
|
-
| UI Aesthetics | 1–10 |
|
|
69
|
+
Return `null` to skip a detection (intentional custom code, false positive, etc.).
|
|
79
70
|
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
71
|
+
**False positive filtering** — skip if:
|
|
72
|
+
- Code has comments explaining why it is custom
|
|
73
|
+
- Detection is in test/mock/fixture files
|
|
74
|
+
- Library is already in project dependencies (suggest version update instead)
|
|
75
|
+
- Hand-rolled code is simpler than the library (3-line utility vs 50KB dep)
|
|
83
76
|
|
|
84
|
-
### Step
|
|
85
|
-
|
|
86
|
-
Group recommendations into ordered phases based on risk:
|
|
77
|
+
### Step 4: Score Impact
|
|
87
78
|
|
|
88
|
-
|
|
89
|
-
2. **Phase 2** — Medium-risk changes (moderate refactoring)
|
|
90
|
-
3. **Phase 3** — High-risk changes (require adapter strategies)
|
|
79
|
+
Compute 7-dimension impact scores (scalability, performance, security, maintainability, feature richness, UX, UI aesthetics) with composite score, migration risk, and estimated effort.
|
|
91
80
|
|
|
92
|
-
|
|
93
|
-
- Wrapper interface
|
|
94
|
-
- Legacy code being wrapped
|
|
95
|
-
- Target library to transition to
|
|
81
|
+
### Step 5: Build Migration Plan
|
|
96
82
|
|
|
97
|
-
|
|
83
|
+
Group recommendations into phases by risk (low → medium → high), ordered by domain priority (infrastructure first, presentation last). High-risk items include adapter strategies.
|
|
98
84
|
|
|
99
85
|
### Step 6: Audit UX Completeness
|
|
100
86
|
|
|
101
|
-
Evaluate
|
|
102
|
-
|
|
103
|
-
1. **Accessibility (A11y)** — ARIA attributes, semantic HTML, keyboard navigation
|
|
104
|
-
2. **Error states** — Error boundaries, error messages, fallback UI
|
|
105
|
-
3. **Empty states** — Empty data placeholders, zero-state illustrations
|
|
106
|
-
4. **Loading states** — Skeletons, spinners, suspense boundaries
|
|
107
|
-
5. **Form validation** — Client-side validation, error messages, field states
|
|
108
|
-
6. **Performance feel** — Optimistic updates, transitions, lazy loading
|
|
109
|
-
7. **Copy consistency** — i18n usage, consistent terminology
|
|
110
|
-
8. **Design system alignment** — Component library usage, token adherence
|
|
111
|
-
|
|
112
|
-
For each gap found, map it to a recommended library with a rationale.
|
|
87
|
+
Evaluate frontend codebase across 8 UX categories: accessibility, error/empty/loading states, form validation, performance feel, copy consistency, design system alignment.
|
|
113
88
|
|
|
114
89
|
### Step 7: Apply Constraints and Serialize
|
|
115
90
|
|
|
116
|
-
|
|
117
|
-
2. **License filtering** — Exclude recommendations whose library license is not in the allowlist
|
|
118
|
-
3. **Serialize** the final `OutputSchema` to pretty-printed JSON (2-space indent) with round-trip guarantee
|
|
119
|
-
|
|
120
|
-
### Step 8: Vulnerability Scanning (Optional)
|
|
121
|
-
|
|
122
|
-
Scan both current and recommended dependencies for known security vulnerabilities:
|
|
91
|
+
Filter by license allowlist, detect dependency conflicts, serialize to JSON.
|
|
123
92
|
|
|
124
|
-
|
|
125
|
-
2. Scan **current dependencies** for known CVEs and advisories
|
|
126
|
-
3. Scan **recommended replacement libraries** to prevent "upgrade into a vulnerability" scenarios
|
|
127
|
-
4. Filter findings by `minimumSeverity` threshold (critical > high > medium > low)
|
|
128
|
-
5. Compute summary: total scanned, count by severity, fixable vs unfixable
|
|
129
|
-
6. Generate SARIF output for CI/CD integration (GitHub Code Scanning)
|
|
93
|
+
### Optional Steps
|
|
130
94
|
|
|
131
|
-
|
|
95
|
+
- **Step 8**: Vulnerability scanning via OSV database
|
|
96
|
+
- **Step 9**: Auto-update existing dependencies via registry queries
|
|
97
|
+
- **Step 10**: PR auto-creation via GitHub/GitLab API
|
|
132
98
|
|
|
133
|
-
|
|
99
|
+
## Programmatic API
|
|
134
100
|
|
|
135
|
-
|
|
101
|
+
```typescript
|
|
102
|
+
import { analyze, scanCodebase } from './src/index.js';
|
|
103
|
+
import type { Recommender } from './src/index.js';
|
|
136
104
|
|
|
137
|
-
1
|
|
138
|
-
|
|
139
|
-
3. Verify changelogs via **Context7 MCP** to detect breaking changes, new features, deprecations
|
|
140
|
-
4. Score each update using the same **7-dimension impact model**
|
|
141
|
-
5. Classify urgency: critical (fixes CVE), urgent (deprecated), recommended (new features), routine
|
|
142
|
-
6. Group related packages (e.g. all `@babel/*` together)
|
|
143
|
-
7. Build structured update plan with summary statistics
|
|
105
|
+
// Step 1: Scan standalone (for AI agent inspection)
|
|
106
|
+
const scanResult = await scanCodebase(validatedInput);
|
|
144
107
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
1. **Plan PRs** — Security fixes as separate PRs, grouped updates, migration PRs by phase
|
|
152
|
-
2. **Generate code changes** — Update version in manifest files, scaffold adapter code for migrations
|
|
153
|
-
3. **Build PR descriptions** — Rich markdown with impact tables, vulnerability details, reviewer checklist
|
|
154
|
-
4. **Create branches and PRs** — Via injected `PlatformClient` and `GitOperations`
|
|
155
|
-
5. **Deduplicate** — Update existing PRs instead of creating duplicates
|
|
156
|
-
6. **Enforce limits** — Respect `maxOpenPRs`, prioritize security fixes first
|
|
157
|
-
|
|
158
|
-
PR titles follow conventional commit format: `fix(deps):`, `chore(deps):`, `refactor(domain):`.
|
|
159
|
-
|
|
160
|
-
## Output Artifacts
|
|
161
|
-
|
|
162
|
-
The SKILL produces a single `OutputSchema` JSON containing:
|
|
163
|
-
|
|
164
|
-
- `recommendedChanges` — Array of recommendations with impact scores, verification status, and adapter strategies
|
|
165
|
-
- `filesToDelete` — Array of file paths to remove after migration
|
|
166
|
-
- `linesSavedEstimate` — Total lines of code saved
|
|
167
|
-
- `uxAudit` — Structured UX completeness checklist
|
|
168
|
-
- `migrationPlan` — Phased plan with deletion checklist
|
|
169
|
-
- `vulnerabilityReport` (optional) — Vulnerability findings, summary, SARIF output
|
|
170
|
-
- `updatePlan` (optional) — Scored dependency updates with groups and summary
|
|
171
|
-
- `pullRequests` (optional) — Created/updated PR results with status summary
|
|
172
|
-
|
|
173
|
-
## Usage
|
|
174
|
-
|
|
175
|
-
```bash
|
|
176
|
-
# Run the analysis
|
|
177
|
-
npx tsx src/index.ts < input.json > output.json
|
|
178
|
-
|
|
179
|
-
# Or import programmatically
|
|
180
|
-
import { analyze } from './src/index.js';
|
|
108
|
+
// Step 2: Full pipeline with recommender
|
|
109
|
+
const recommender: Recommender = (detection) => ({
|
|
110
|
+
library: 'zustand',
|
|
111
|
+
version: '^5.0.0',
|
|
112
|
+
license: 'MIT',
|
|
113
|
+
});
|
|
181
114
|
|
|
182
115
|
const result = await analyze({
|
|
183
116
|
input: inputJson,
|
|
184
117
|
context7Client: myContext7Client,
|
|
185
|
-
//
|
|
186
|
-
vulnClient: myOsvClient, // enables vulnerability scanning
|
|
187
|
-
registryClient: myRegistryClient, // enables auto-update
|
|
188
|
-
platformClient: myGitHubClient, // enables PR creation
|
|
189
|
-
gitOps: myGitOperations, // enables PR creation
|
|
118
|
+
recommender, // AI agent provides this
|
|
190
119
|
});
|
|
191
120
|
```
|
|
192
121
|
|
|
193
|
-
##
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
|
208
|
-
|
|
209
|
-
|
|
|
210
|
-
|
|
|
211
|
-
|
|
|
212
|
-
|
|
|
213
|
-
|
|
|
214
|
-
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
| i18n | next-intl, react-i18next, FormatJS |
|
|
222
|
-
| localization-ux | @formatjs/intl, date-fns/locale |
|
|
223
|
-
| content-marketing | contentlayer, next-mdx-remote, sanity |
|
|
224
|
-
| landing-page-conversion | next-seo, posthog, ab-testing libs |
|
|
225
|
-
|
|
226
|
-
### C. Growth & Data (Experimentation / Analytics)
|
|
227
|
-
|
|
228
|
-
| Domain | Examples |
|
|
229
|
-
|--------|----------|
|
|
230
|
-
| growth-hacking | posthog, launchdarkly, mixpanel |
|
|
231
|
-
| analytics-tracking | posthog-js, segment, plausible |
|
|
232
|
-
| attribution-measurement | segment, mixpanel |
|
|
233
|
-
| ab-testing-experimentation | posthog, growthbook, statsig |
|
|
234
|
-
| product-led-growth | posthog, canny, intercom |
|
|
235
|
-
| retention-lifecycle-crm | customer.io, braze |
|
|
236
|
-
| referrals-virality | referral-saasquatch |
|
|
237
|
-
|
|
238
|
-
### D. App / Frontend Architecture (Maintainability / Modularity)
|
|
239
|
-
|
|
240
|
-
| Domain | Examples |
|
|
241
|
-
|--------|----------|
|
|
242
|
-
| agent-architecture | @modelcontextprotocol/sdk, ai (Vercel AI SDK) |
|
|
243
|
-
| frontend-architecture | next.js, remix, vite |
|
|
244
|
-
| state-management | zustand, jotai, @tanstack/react-query |
|
|
245
|
-
| data-fetching-caching | @tanstack/react-query, swr, apollo-client |
|
|
246
|
-
| error-handling-resilience | react-error-boundary, neverthrow |
|
|
247
|
-
| realtime-collaboration | yjs, liveblocks, socket.io |
|
|
248
|
-
| file-upload-media | uploadthing, tus-js-client |
|
|
249
|
-
| search-discovery | meilisearch, typesense, algolia |
|
|
250
|
-
|
|
251
|
-
### E. Backend / Platform (Scalability / Reliability / Compatibility)
|
|
252
|
-
|
|
253
|
-
| Domain | Examples |
|
|
254
|
-
|--------|----------|
|
|
255
|
-
| api-design-contracts | openapi, trpc, graphql-codegen |
|
|
256
|
-
| backend-architecture | fastify, hono, nestjs |
|
|
257
|
-
| database-orm-migrations | prisma, drizzle, knex |
|
|
258
|
-
| caching-rate-limit | rate-limiter-flexible, ioredis |
|
|
259
|
-
| jobs-queue-scheduler | bullmq, temporal, inngest |
|
|
260
|
-
| webhooks-integrations | svix, hookdeck |
|
|
261
|
-
| feature-flags-config | unleash, launchdarkly, growthbook |
|
|
262
|
-
| multi-tenancy-saas | @clerk/nextjs, auth0 |
|
|
263
|
-
|
|
264
|
-
### F. Security / Compliance (Security)
|
|
265
|
-
|
|
266
|
-
| Domain | Examples |
|
|
267
|
-
|--------|----------|
|
|
268
|
-
| auth-security | next-auth, passport, jose |
|
|
269
|
-
| permissions-rbac-ux | casl, casbin |
|
|
270
|
-
| security-hardening | helmet, csp-header |
|
|
271
|
-
| privacy-compliance | consent-manager, cookie-consent |
|
|
272
|
-
| fraud-abuse-prevention | arcjet, cloudflare turnstile |
|
|
273
|
-
|
|
274
|
-
### G. Observability / Ops (Reliability / Operability)
|
|
275
|
-
|
|
276
|
-
| Domain | Examples |
|
|
277
|
-
|--------|----------|
|
|
278
|
-
| observability | pino, opentelemetry, sentry |
|
|
279
|
-
| logging-tracing-metrics | pino, @opentelemetry/sdk-node |
|
|
280
|
-
| error-monitoring | @sentry/node, bugsnag |
|
|
281
|
-
| alerting-incident-response | pagerduty, opsgenie |
|
|
282
|
-
|
|
283
|
-
### H. Delivery / Quality / DevEx (Maintainability / DevEx)
|
|
284
|
-
|
|
285
|
-
| Domain | Examples |
|
|
286
|
-
|--------|----------|
|
|
287
|
-
| testing-strategy | vitest, playwright, fast-check |
|
|
288
|
-
| ci-cd-release | changesets, semantic-release |
|
|
289
|
-
| devex-tooling | turborepo, nx, biome |
|
|
290
|
-
| documentation-sop | typedoc, storybook, mintlify |
|
|
291
|
-
| code-quality-linting | eslint, biome, prettier |
|
|
292
|
-
| dependency-management | renovate, depcheck |
|
|
293
|
-
|
|
294
|
-
### I. Performance / Cost (Performance efficiency)
|
|
295
|
-
|
|
296
|
-
| Domain | Examples |
|
|
297
|
-
|--------|----------|
|
|
298
|
-
| performance-web-vitals | @next/bundle-analyzer, lighthouse |
|
|
299
|
-
| backend-performance | autocannon, clinic.js |
|
|
300
|
-
| cost-optimization | aws-cost-explorer, infracost |
|
|
301
|
-
|
|
302
|
-
### J. AI Engineering
|
|
303
|
-
|
|
304
|
-
| Domain | Examples |
|
|
305
|
-
|--------|----------|
|
|
306
|
-
| ai-model-serving | transformers.js, onnxruntime, langchain |
|
|
307
|
-
| ai-evaluation-observability | langfuse, promptfoo |
|
|
308
|
-
| rag-vector-search | @pinecone-database/pinecone, chromadb |
|
|
309
|
-
|
|
310
|
-
### K. Business Domains (optional)
|
|
311
|
-
|
|
312
|
-
| Domain | Examples |
|
|
313
|
-
|--------|----------|
|
|
314
|
-
| cross-border-ecommerce | stripe, shopify-api, taxjar |
|
|
315
|
-
| payments-billing | stripe, lemon-squeezy |
|
|
316
|
-
| marketplace-platform | medusa, saleor |
|
|
317
|
-
|
|
318
|
-
> **Extensibility:** The enum covers official domains. Use `customDomains?: string[]` in the input schema for community/project-specific domains without breaking the type system.
|
|
122
|
+
## Output Artifacts
|
|
123
|
+
|
|
124
|
+
Single `OutputSchema` JSON containing:
|
|
125
|
+
- `recommendedChanges` — recommendations with scores, verification status, adapter strategies
|
|
126
|
+
- `filesToDelete` — file paths to remove after migration
|
|
127
|
+
- `linesSavedEstimate` — total lines saved
|
|
128
|
+
- `uxAudit` — UX completeness checklist
|
|
129
|
+
- `migrationPlan` — phased plan with deletion checklist
|
|
130
|
+
- `vulnerabilityReport` (optional)
|
|
131
|
+
- `updatePlan` (optional)
|
|
132
|
+
- `pullRequests` (optional)
|
|
133
|
+
|
|
134
|
+
## Vibe Coding Domain Coverage (20+ detection patterns)
|
|
135
|
+
|
|
136
|
+
| Category | Domains |
|
|
137
|
+
|----------|---------|
|
|
138
|
+
| UX / Design | ux-completeness, a11y-accessibility, forms-ux, state-management |
|
|
139
|
+
| SEO / i18n / Content | seo, i18n, content-marketing |
|
|
140
|
+
| Growth / Data | growth-hacking |
|
|
141
|
+
| App Architecture | agent-architecture, data-fetching-caching, error-handling-resilience |
|
|
142
|
+
| Backend / Platform | database-orm-migrations, auth-security |
|
|
143
|
+
| Observability | observability, logging-tracing-metrics |
|
|
144
|
+
| Testing | testing-strategy |
|
|
145
|
+
| AI Engineering | ai-model-serving |
|
|
146
|
+
| Business | cross-border-ecommerce |
|
|
147
|
+
| File / Media | file-upload-media |
|
|
148
|
+
|
|
149
|
+
> **Extensibility:** Use `customDomains?: string[]` in input for project-specific domains.
|
|
@@ -2,6 +2,12 @@ import type { VibeCodingDomain } from '../schemas/input.schema.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Defines a pattern that identifies hand-rolled code which could be
|
|
4
4
|
* replaced by a battle-tested third-party library.
|
|
5
|
+
*
|
|
6
|
+
* NOTE: This interface intentionally contains NO library recommendation data.
|
|
7
|
+
* Library recommendations are the AI agent's responsibility — the agent uses
|
|
8
|
+
* its own knowledge + Context7 MCP to determine the best library for each
|
|
9
|
+
* detection at runtime, considering the project's framework, existing deps,
|
|
10
|
+
* and architectural context.
|
|
5
11
|
*/
|
|
6
12
|
export interface PatternDefinition {
|
|
7
13
|
/** Unique identifier for this pattern (e.g., "i18n-manual-pluralization") */
|
|
@@ -14,18 +20,15 @@ export interface PatternDefinition {
|
|
|
14
20
|
filePatterns: string[];
|
|
15
21
|
/** Regex patterns to match hand-rolled code */
|
|
16
22
|
codePatterns: RegExp[];
|
|
17
|
-
/** The library recommended to replace the hand-rolled code */
|
|
18
|
-
suggestedLibrary: string;
|
|
19
|
-
/** Recommended version of the suggested library */
|
|
20
|
-
suggestedVersion: string;
|
|
21
|
-
/** SPDX license identifier of the suggested library */
|
|
22
|
-
license: string;
|
|
23
23
|
/** Base confidence score for this pattern (0–1) */
|
|
24
24
|
confidenceBase: number;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Returns the full pattern catalog covering
|
|
28
|
-
* Each domain has
|
|
27
|
+
* Returns the full pattern catalog covering Vibe Coding domains.
|
|
28
|
+
* Each covered domain has 2–3 patterns for hand-rolled code detection.
|
|
29
|
+
*
|
|
30
|
+
* The catalog defines WHAT to detect, not WHAT to recommend.
|
|
31
|
+
* Library recommendations are generated dynamically by the AI agent.
|
|
29
32
|
*/
|
|
30
33
|
export declare function getPatternCatalog(): PatternDefinition[];
|
|
31
34
|
/**
|
|
@@ -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
|
|
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"}
|