@nebutra/next-unicorn-skill 1.0.4 → 1.0.6
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 +13 -19
- package/dist/index.d.ts +22 -86
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +159 -157
- package/dist/index.js.map +1 -1
- package/dist/pr-creator/pr-executor.d.ts +2 -0
- package/dist/pr-creator/pr-executor.d.ts.map +1 -1
- package/dist/pr-creator/pr-executor.js +26 -1
- package/dist/pr-creator/pr-executor.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/dist/auditor/ux-auditor.d.ts +0 -29
- package/dist/auditor/ux-auditor.d.ts.map +0 -1
- package/dist/auditor/ux-auditor.js +0 -250
- package/dist/auditor/ux-auditor.js.map +0 -1
- package/dist/planner/migration-planner.d.ts +0 -52
- package/dist/planner/migration-planner.d.ts.map +0 -1
- package/dist/planner/migration-planner.js +0 -156
- package/dist/planner/migration-planner.js.map +0 -1
- package/dist/pr-creator/pr-description-builder.d.ts +0 -23
- package/dist/pr-creator/pr-description-builder.d.ts.map +0 -1
- package/dist/pr-creator/pr-description-builder.js +0 -187
- package/dist/pr-creator/pr-description-builder.js.map +0 -1
- package/dist/scorer/impact-scorer.d.ts +0 -71
- package/dist/scorer/impact-scorer.d.ts.map +0 -1
- package/dist/scorer/impact-scorer.js +0 -178
- package/dist/scorer/impact-scorer.js.map +0 -1
- package/dist/security/vuln-report-builder.d.ts +0 -18
- package/dist/security/vuln-report-builder.d.ts.map +0 -1
- package/dist/security/vuln-report-builder.js +0 -141
- package/dist/security/vuln-report-builder.js.map +0 -1
- package/dist/updater/changelog-verifier.d.ts +0 -29
- package/dist/updater/changelog-verifier.d.ts.map +0 -1
- package/dist/updater/changelog-verifier.js +0 -80
- package/dist/updater/changelog-verifier.js.map +0 -1
- package/dist/updater/update-plan-builder.d.ts +0 -23
- package/dist/updater/update-plan-builder.d.ts.map +0 -1
- package/dist/updater/update-plan-builder.js +0 -93
- package/dist/updater/update-plan-builder.js.map +0 -1
- package/dist/updater/update-scorer.d.ts +0 -51
- package/dist/updater/update-scorer.d.ts.map +0 -1
- package/dist/updater/update-scorer.js +0 -166
- package/dist/updater/update-scorer.js.map +0 -1
- package/dist/utils/constraint-filter.d.ts +0 -44
- package/dist/utils/constraint-filter.d.ts.map +0 -1
- package/dist/utils/constraint-filter.js +0 -69
- package/dist/utils/constraint-filter.js.map +0 -1
- package/dist/utils/serializer.d.ts +0 -17
- package/dist/utils/serializer.d.ts.map +0 -1
- package/dist/utils/serializer.js +0 -24
- package/dist/utils/serializer.js.map +0 -1
- package/dist/utils/skill-parser.d.ts +0 -29
- package/dist/utils/skill-parser.d.ts.map +0 -1
- package/dist/utils/skill-parser.js +0 -175
- package/dist/utils/skill-parser.js.map +0 -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
|
@@ -64,11 +64,13 @@ Provide each gap as a `GapRecommendation`. Read `src/index.ts` for the interface
|
|
|
64
64
|
|
|
65
65
|
For each scanner detection, recommend a **solution**. Consider:
|
|
66
66
|
|
|
67
|
-
1. **
|
|
68
|
-
2. **
|
|
69
|
-
3. **
|
|
70
|
-
4. **
|
|
71
|
-
5. **
|
|
67
|
+
1. **Stack coherence** — don't recommend libraries in isolation; consider how they fit the project's overall stack (e.g., recommending Stripe should trigger consideration of Resend for transactional email and PostHog for payment funnel analytics)
|
|
68
|
+
2. **Ecosystem composition** — recommend companion libraries that work together
|
|
69
|
+
3. **Rationale** — explain WHY this choice fits this project's framework, runtime, and scale
|
|
70
|
+
4. **Anti-patterns** — what NOT to use and why
|
|
71
|
+
5. **Alternatives** — different solutions for different architectural contexts
|
|
72
|
+
6. **Migration snippet** — for each recommendation, read the detected code (file path + line range from scanner) and generate a concrete before/after code example showing the migration
|
|
73
|
+
7. **Context7 verification** — call `resolve-library-id` + `query-docs` to confirm the library exists and get latest version/docs
|
|
72
74
|
|
|
73
75
|
Read `src/index.ts` for the `LibraryRecommendation` interface. Return `null` to skip a detection.
|
|
74
76
|
|
|
@@ -78,21 +80,13 @@ Read `src/index.ts` for the `LibraryRecommendation` interface. Return `null` to
|
|
|
78
80
|
- Library is already in project dependencies (suggest version update instead)
|
|
79
81
|
- Hand-rolled code is simpler than the library (3-line utility vs 50KB dep)
|
|
80
82
|
|
|
81
|
-
### Step 4: Score
|
|
83
|
+
### Step 4–7: Score, Plan, Audit, Serialize
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
### Step 6: Audit UX Completeness
|
|
90
|
-
|
|
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.
|
|
92
|
-
|
|
93
|
-
### Step 7: Apply Constraints and Serialize
|
|
94
|
-
|
|
95
|
-
Filter by license allowlist, detect dependency conflicts, serialize to JSON.
|
|
85
|
+
The pipeline handles these automatically:
|
|
86
|
+
- **Scoring**: confidence-based dimension scores (overridable by AI agent via `dimensionHints`)
|
|
87
|
+
- **Migration plan**: auto-grouped by risk (low/medium/high), sorted by file co-location
|
|
88
|
+
- **UX audit**: provide via `uxAudit` option in `analyze()`. Evaluate 8 categories: accessibility, error/empty/loading states, form validation, performance feel, copy consistency, design system alignment. For each, assess status (present/partial/missing) based on project code and `currentLibraries`.
|
|
89
|
+
- **Constraints**: license allowlist filtering, dependency conflict detection, JSON serialization
|
|
96
90
|
|
|
97
91
|
### Optional Steps
|
|
98
92
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,81 +5,51 @@
|
|
|
5
5
|
* replaced by third-party libraries. Library recommendations are provided
|
|
6
6
|
* by the caller (AI agent or programmatic client) — NOT hardcoded.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Redundant modules removed (Occam's Razor):
|
|
9
|
+
* - impact-scorer → inlined (trivial math)
|
|
10
|
+
* - migration-planner → inlined (group-by-risk + sort)
|
|
11
|
+
* - ux-auditor → AI-agent-driven (Claude reads package.json better)
|
|
12
|
+
* - constraint-filter → inlined (Set.has)
|
|
13
|
+
* - serializer → inlined (JSON.stringify)
|
|
14
|
+
* - update-scorer, update-plan-builder, changelog-verifier → simplified
|
|
15
|
+
* - pr-description-builder → AI agent writes better PR descriptions
|
|
16
|
+
* - skill-parser, vuln-report-builder → dead code deleted
|
|
11
17
|
*/
|
|
12
|
-
import { OutputSchema } from './schemas/output.schema.js';
|
|
18
|
+
import { OutputSchema, type UxAuditItem } from './schemas/output.schema.js';
|
|
13
19
|
import { type Detection, type ScanResult } from './analyzer/scanner.js';
|
|
14
20
|
import { type Context7Client } from './verifier/context7.js';
|
|
15
|
-
import { type ExclusionRecord } from './utils/constraint-filter.js';
|
|
16
21
|
import { type PeerDependencyResolver } from './checker/peer-dependency-checker.js';
|
|
17
22
|
import type { VulnerabilityClient } from './security/osv-client.js';
|
|
18
23
|
import type { RegistryClient } from './updater/registry-client.js';
|
|
19
24
|
import type { PlatformClient } from './pr-creator/platform-client.js';
|
|
20
25
|
import type { GitOperations } from './pr-creator/git-operations.js';
|
|
21
|
-
export declare const VERSION = "1.0.
|
|
26
|
+
export declare const VERSION = "1.0.6";
|
|
22
27
|
/**
|
|
23
28
|
* A library recommendation provided by the AI agent (or caller).
|
|
24
|
-
* The scanner detects WHAT is hand-rolled; the recommender decides WHAT to use.
|
|
25
|
-
*
|
|
26
|
-
* Required fields give the pipeline what it needs for scoring/filtering.
|
|
27
|
-
* Optional fields let the AI agent express ecosystem-level solutions —
|
|
28
|
-
* rationale, companion packages, anti-patterns, and alternatives.
|
|
29
29
|
*/
|
|
30
30
|
export interface LibraryRecommendation {
|
|
31
|
-
/** Primary library name (e.g., "@lingui/core", "zustand") */
|
|
32
31
|
library: string;
|
|
33
|
-
/** Version constraint (e.g., "^4.0.0") */
|
|
34
32
|
version: string;
|
|
35
|
-
/** SPDX license identifier (e.g., "MIT") */
|
|
36
33
|
license: string;
|
|
37
|
-
/** WHY this library — the AI agent's reasoning for this specific choice */
|
|
38
34
|
rationale?: string;
|
|
39
|
-
/** Companion libraries that form a cohesive solution */
|
|
40
35
|
ecosystem?: Array<{
|
|
41
|
-
/** Package name */
|
|
42
36
|
library: string;
|
|
43
|
-
/** Version constraint */
|
|
44
37
|
version: string;
|
|
45
|
-
/** Role in the solution (e.g., "CI/CD message extraction") */
|
|
46
38
|
role: string;
|
|
47
39
|
}>;
|
|
48
|
-
/** What NOT to use, and why */
|
|
49
40
|
antiPatterns?: string[];
|
|
50
|
-
/** Alternative solutions for different architectural contexts */
|
|
51
41
|
alternatives?: Array<{
|
|
52
|
-
/** Package name */
|
|
53
42
|
library: string;
|
|
54
|
-
/** When to prefer this alternative (e.g., "Next.js App Router with server components") */
|
|
55
43
|
when: string;
|
|
56
44
|
}>;
|
|
57
45
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Function that provides library recommendations for detections.
|
|
60
|
-
* Called once per detection. Return null to skip a detection (no recommendation).
|
|
61
|
-
*
|
|
62
|
-
* In AI agent mode: the agent fills this based on its knowledge + Context7.
|
|
63
|
-
* In programmatic/test mode: the caller provides a deterministic function.
|
|
64
|
-
*/
|
|
65
46
|
export type Recommender = (detection: Detection) => LibraryRecommendation | null;
|
|
66
47
|
/**
|
|
67
|
-
* A capability gap
|
|
68
|
-
* SHOULD have but DOESN'T. Unlike scanner detections (which find hand-rolled
|
|
69
|
-
* code to replace), gaps identify missing capabilities entirely.
|
|
70
|
-
*
|
|
71
|
-
* Examples:
|
|
72
|
-
* - "No structured logging" → recommend pino
|
|
73
|
-
* - "No error monitoring" → recommend Sentry
|
|
74
|
-
* - "No rate limiting" → recommend Arcjet
|
|
75
|
-
* - "No event-driven workflows" → recommend Inngest
|
|
48
|
+
* A capability gap — something the project SHOULD have but DOESN'T.
|
|
76
49
|
*/
|
|
77
50
|
export interface GapRecommendation {
|
|
78
|
-
/** The Vibe Coding domain this gap belongs to */
|
|
79
51
|
domain: string;
|
|
80
|
-
/** What capability is missing (e.g., "No structured logging detected") */
|
|
81
52
|
description: string;
|
|
82
|
-
/** The recommended solution */
|
|
83
53
|
recommendedLibrary: {
|
|
84
54
|
name: string;
|
|
85
55
|
version: string;
|
|
@@ -97,44 +67,26 @@ export interface GapRecommendation {
|
|
|
97
67
|
when: string;
|
|
98
68
|
}>;
|
|
99
69
|
};
|
|
100
|
-
/** How important is filling this gap */
|
|
101
70
|
priority: 'critical' | 'recommended' | 'nice-to-have';
|
|
102
|
-
/** Context7 verification status — filled by the pipeline, not the AI agent */
|
|
103
71
|
verificationStatus?: 'verified' | 'unverified' | 'unavailable';
|
|
104
72
|
verificationNote?: string;
|
|
105
73
|
}
|
|
106
74
|
export interface AnalyzeOptions {
|
|
107
|
-
/** Raw input to be validated against InputSchema */
|
|
108
75
|
input: unknown;
|
|
109
|
-
/** Injected Context7 client for testability — no real HTTP calls in tests */
|
|
110
76
|
context7Client: Context7Client;
|
|
111
|
-
/**
|
|
112
|
-
* Recommender function: maps each detection to a library recommendation.
|
|
113
|
-
* This is the key integration point for AI agents — the agent decides
|
|
114
|
-
* which library best fits each detected pattern based on project context.
|
|
115
|
-
*/
|
|
116
77
|
recommender: Recommender;
|
|
117
|
-
/**
|
|
118
|
-
* Gap recommendations from the AI agent — capabilities the project should
|
|
119
|
-
* have but doesn't. The scanner finds "you hand-rolled X"; gaps find
|
|
120
|
-
* "you're missing Y entirely" (e.g., no error monitoring, no rate limiting).
|
|
121
|
-
*/
|
|
122
78
|
gaps?: GapRecommendation[];
|
|
123
|
-
/** Optional —
|
|
79
|
+
/** Optional UX audit items — AI agent provides these based on project analysis */
|
|
80
|
+
uxAudit?: UxAuditItem[];
|
|
124
81
|
vulnClient?: VulnerabilityClient;
|
|
125
|
-
/** Optional — if provided, enables auto-update recommendations */
|
|
126
82
|
registryClient?: RegistryClient;
|
|
127
|
-
/** Required only if prPolicy.enabled is true */
|
|
128
83
|
platformClient?: PlatformClient;
|
|
129
|
-
/** Required only if prPolicy.enabled is true */
|
|
130
84
|
gitOps?: GitOperations;
|
|
131
|
-
/** Optional — if provided, resolves peer dependency metadata for recommended libraries */
|
|
132
85
|
peerDependencyResolver?: PeerDependencyResolver;
|
|
133
86
|
}
|
|
134
87
|
export type AnalyzeResult = {
|
|
135
88
|
success: true;
|
|
136
89
|
output: OutputSchema;
|
|
137
|
-
/** Raw scan result (detections + workspaces) for AI agent further analysis */
|
|
138
90
|
scanResult: ScanResult;
|
|
139
91
|
json: string;
|
|
140
92
|
prettyJson: string;
|
|
@@ -144,39 +96,23 @@ export type AnalyzeResult = {
|
|
|
144
96
|
error: string;
|
|
145
97
|
issues?: unknown;
|
|
146
98
|
};
|
|
99
|
+
export interface ExclusionRecord {
|
|
100
|
+
libraryName: string;
|
|
101
|
+
license: string;
|
|
102
|
+
reason: string;
|
|
103
|
+
}
|
|
147
104
|
export type { Context7Client, VerificationResult } from './verifier/context7.js';
|
|
148
|
-
export type { ExclusionRecord } from './utils/constraint-filter.js';
|
|
149
105
|
export type { InputSchema } from './schemas/input.schema.js';
|
|
150
|
-
export type { OutputSchema } from './schemas/output.schema.js';
|
|
106
|
+
export type { OutputSchema, UxAuditItem } from './schemas/output.schema.js';
|
|
151
107
|
export type { Detection, ScanResult } from './analyzer/scanner.js';
|
|
152
108
|
export type { StructuralFinding, StructuralAnalysis } from './analyzer/structure-analyzer.js';
|
|
109
|
+
export { scanCodebase } from './analyzer/scanner.js';
|
|
153
110
|
export { analyzeStructure } from './analyzer/structure-analyzer.js';
|
|
111
|
+
export { getPatternCatalog } from './analyzer/pattern-catalog.js';
|
|
154
112
|
export type { VulnerabilityClient } from './security/osv-client.js';
|
|
155
113
|
export type { RegistryClient } from './updater/registry-client.js';
|
|
156
114
|
export type { PlatformClient } from './pr-creator/platform-client.js';
|
|
157
115
|
export type { GitOperations } from './pr-creator/git-operations.js';
|
|
158
116
|
export type { PeerDependencyResolver } from './checker/peer-dependency-checker.js';
|
|
159
|
-
export { scanCodebase } from './analyzer/scanner.js';
|
|
160
|
-
export { getPatternCatalog } from './analyzer/pattern-catalog.js';
|
|
161
|
-
/**
|
|
162
|
-
* Run the full Next-Unicorn analysis pipeline.
|
|
163
|
-
*
|
|
164
|
-
* Pipeline steps:
|
|
165
|
-
* 1. Validate input with InputSchema Zod schema
|
|
166
|
-
* 2. Scan codebase with scanCodebase
|
|
167
|
-
* 2.5 Get library recommendations from the recommender (AI agent / caller)
|
|
168
|
-
* 3. Verify recommendations with Context7
|
|
169
|
-
* 4. Score each detection
|
|
170
|
-
* 5. Build RecommendedChange objects
|
|
171
|
-
* 6. Apply dependency conflict detection
|
|
172
|
-
* 6.5 Vulnerability scanning (optional — Phase 2)
|
|
173
|
-
* 7. Apply license filtering
|
|
174
|
-
* 8. Build migration plan
|
|
175
|
-
* 9. Audit UX completeness
|
|
176
|
-
* 10. Auto-update existing dependencies (optional — Phase 2)
|
|
177
|
-
* 11. Assemble OutputSchema, serialize
|
|
178
|
-
* 12. PR auto-creation (optional — Phase 2)
|
|
179
|
-
* 13. Return result
|
|
180
|
-
*/
|
|
181
117
|
export declare function analyze(options: AnalyzeOptions): Promise<AnalyzeResult>;
|
|
182
118
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EACL,YAAY,EAIZ,KAAK,WAAW,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAgB,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,KAAK,sBAAsB,EAE5B,MAAM,sCAAsC,CAAC;AAG9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAMpE,eAAO,MAAM,OAAO,UAAU,CAAC;AAM/B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CA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