@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.
Files changed (59) hide show
  1. package/README.md +82 -51
  2. package/SKILL.md +13 -19
  3. package/dist/index.d.ts +22 -86
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +159 -157
  6. package/dist/index.js.map +1 -1
  7. package/dist/pr-creator/pr-executor.d.ts +2 -0
  8. package/dist/pr-creator/pr-executor.d.ts.map +1 -1
  9. package/dist/pr-creator/pr-executor.js +26 -1
  10. package/dist/pr-creator/pr-executor.js.map +1 -1
  11. package/dist/verifier/context7.d.ts +24 -10
  12. package/dist/verifier/context7.d.ts.map +1 -1
  13. package/dist/verifier/context7.js +63 -34
  14. package/dist/verifier/context7.js.map +1 -1
  15. package/package.json +1 -1
  16. package/dist/auditor/ux-auditor.d.ts +0 -29
  17. package/dist/auditor/ux-auditor.d.ts.map +0 -1
  18. package/dist/auditor/ux-auditor.js +0 -250
  19. package/dist/auditor/ux-auditor.js.map +0 -1
  20. package/dist/planner/migration-planner.d.ts +0 -52
  21. package/dist/planner/migration-planner.d.ts.map +0 -1
  22. package/dist/planner/migration-planner.js +0 -156
  23. package/dist/planner/migration-planner.js.map +0 -1
  24. package/dist/pr-creator/pr-description-builder.d.ts +0 -23
  25. package/dist/pr-creator/pr-description-builder.d.ts.map +0 -1
  26. package/dist/pr-creator/pr-description-builder.js +0 -187
  27. package/dist/pr-creator/pr-description-builder.js.map +0 -1
  28. package/dist/scorer/impact-scorer.d.ts +0 -71
  29. package/dist/scorer/impact-scorer.d.ts.map +0 -1
  30. package/dist/scorer/impact-scorer.js +0 -178
  31. package/dist/scorer/impact-scorer.js.map +0 -1
  32. package/dist/security/vuln-report-builder.d.ts +0 -18
  33. package/dist/security/vuln-report-builder.d.ts.map +0 -1
  34. package/dist/security/vuln-report-builder.js +0 -141
  35. package/dist/security/vuln-report-builder.js.map +0 -1
  36. package/dist/updater/changelog-verifier.d.ts +0 -29
  37. package/dist/updater/changelog-verifier.d.ts.map +0 -1
  38. package/dist/updater/changelog-verifier.js +0 -80
  39. package/dist/updater/changelog-verifier.js.map +0 -1
  40. package/dist/updater/update-plan-builder.d.ts +0 -23
  41. package/dist/updater/update-plan-builder.d.ts.map +0 -1
  42. package/dist/updater/update-plan-builder.js +0 -93
  43. package/dist/updater/update-plan-builder.js.map +0 -1
  44. package/dist/updater/update-scorer.d.ts +0 -51
  45. package/dist/updater/update-scorer.d.ts.map +0 -1
  46. package/dist/updater/update-scorer.js +0 -166
  47. package/dist/updater/update-scorer.js.map +0 -1
  48. package/dist/utils/constraint-filter.d.ts +0 -44
  49. package/dist/utils/constraint-filter.d.ts.map +0 -1
  50. package/dist/utils/constraint-filter.js +0 -69
  51. package/dist/utils/constraint-filter.js.map +0 -1
  52. package/dist/utils/serializer.d.ts +0 -17
  53. package/dist/utils/serializer.d.ts.map +0 -1
  54. package/dist/utils/serializer.js +0 -24
  55. package/dist/utils/serializer.js.map +0 -1
  56. package/dist/utils/skill-parser.d.ts +0 -29
  57. package/dist/utils/skill-parser.d.ts.map +0 -1
  58. package/dist/utils/skill-parser.js +0 -175
  59. 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-198%20passed-brightgreen.svg" alt="Tests" /></a>
14
+ <a href="./tests/"><img src="https://img.shields.io/badge/tests-210%20passed-brightgreen.svg" alt="Tests" /></a>
15
15
  <a href="./tests/"><img src="https://img.shields.io/badge/properties-29%20verified-purple.svg" alt="Property Tests" /></a>
16
16
  </p>
17
17
 
@@ -31,9 +31,9 @@
31
31
 
32
32
  Every codebase accumulates hand-rolled implementations that should be mature libraries. Custom date formatters, DIY loggers, bespoke state machines, ad-hoc i18n — **Vibe Coding debt**.
33
33
 
34
- Snyk, Dependabot, and Renovate manage your *existing* dependencies. They can't find code you wrote that *should become* a dependency.
34
+ Snyk, Dependabot, and Renovate manage your *existing* dependencies. They can't find code you wrote that *should become* a dependency — or capabilities your project is *missing entirely*.
35
35
 
36
- **Next-Unicorn does both** — and verifies every recommendation against real documentation via [Context7 MCP](https://context7.com).
36
+ **Next-Unicorn does all three** — replacement, gap analysis, and dependency management verified against real documentation via [Context7 MCP](https://context7.com).
37
37
 
38
38
  ## Quick Start
39
39
 
@@ -61,18 +61,36 @@ npm install @nebutra/next-unicorn-skill
61
61
 
62
62
  ```typescript
63
63
  import { analyze, scanCodebase } from '@nebutra/next-unicorn-skill';
64
- import type { Recommender } from '@nebutra/next-unicorn-skill';
65
-
66
- // The recommender function: AI agent decides which library fits each detection
67
- const recommender: Recommender = (detection) => {
68
- // AI agent uses its knowledge + project context to recommend
69
- // Return null to skip a detection (false positive, intentional custom code)
70
- return {
71
- library: 'zustand', // dynamically chosen, not hardcoded
72
- version: '^5.0.0', // verified via Context7
73
- license: 'MIT',
74
- };
75
- };
64
+ import type { Recommender, GapRecommendation } from '@nebutra/next-unicorn-skill';
65
+
66
+ // The recommender: AI agent decides which library fits each detection
67
+ const recommender: Recommender = (detection) => ({
68
+ library: '@lingui/core',
69
+ version: '^4.0.0',
70
+ license: 'MIT',
71
+ rationale: 'Compile-time i18n with near-zero runtime overhead',
72
+ ecosystem: [
73
+ { library: '@lingui/macro', version: '^4.0.0', role: 'Tagged templates' },
74
+ { library: '@lingui/cli', version: '^4.0.0', role: 'CI message extraction' },
75
+ ],
76
+ antiPatterns: ['Avoid i18next if bundle size matters — Lingui compiles away'],
77
+ alternatives: [
78
+ { library: 'next-intl', when: 'Next.js App Router with server components' },
79
+ ],
80
+ });
81
+
82
+ // Gap analysis: capabilities the project should have but doesn't
83
+ const gaps: GapRecommendation[] = [
84
+ {
85
+ domain: 'observability',
86
+ description: 'No structured logging detected',
87
+ recommendedLibrary: {
88
+ name: 'pino', version: '^9.0.0', license: 'MIT',
89
+ rationale: 'Fastest Node.js JSON logger with redaction and child loggers',
90
+ },
91
+ priority: 'critical',
92
+ },
93
+ ];
76
94
 
77
95
  const result = await analyze({
78
96
  input: {
@@ -83,27 +101,22 @@ const result = await analyze({
83
101
  currentLibraries: { react: '18.2.0', next: '14.1.0' },
84
102
  },
85
103
  optimizationGoals: ['reduce custom code', 'improve maintainability'],
86
- constraints: {
87
- licenseAllowlist: ['MIT', 'Apache-2.0', 'ISC'],
88
- },
104
+ constraints: { licenseAllowlist: ['MIT', 'Apache-2.0', 'ISC'] },
89
105
  priorityFocusAreas: ['i18n', 'observability', 'auth-security'],
90
106
  },
91
107
  context7Client: myContext7Client,
92
- recommender, // AI agent provides library recommendations
93
- // Optional Phase 2 clients:
94
- vulnClient: myOsvClient, // vulnerability scanning
95
- registryClient: myRegistryClient, // auto-update
96
- platformClient: myGitHubClient, // PR creation
97
- gitOps: myGitOperations, // PR creation
108
+ recommender,
109
+ gaps,
98
110
  });
99
111
 
100
112
  if (result.success) {
101
113
  console.log(result.prettyJson);
102
- // result.scanResult contains raw detections for further AI analysis
114
+ // result.scanResult raw detections + structural findings for AI analysis
115
+ // result.output.gapAnalysis — Context7-verified gap recommendations
103
116
  }
104
117
  ```
105
118
 
106
- Or use as an **MCP SKILL** — provide [`SKILL.md`](./SKILL.md) to your AI agent (Claude Code, Kiro, etc.).
119
+ Or use as an **MCP SKILL** — provide [`SKILL.md`](./SKILL.md) to your AI agent (Claude Code, Kiro, Cursor, etc.).
107
120
 
108
121
  ## Features
109
122
 
@@ -111,17 +124,19 @@ Or use as an **MCP SKILL** — provide [`SKILL.md`](./SKILL.md) to your AI agent
111
124
 
112
125
  | Feature | Description |
113
126
  |---------|-------------|
114
- | **Pattern-based scanning** | Detects hand-rolled code across 68 Vibe Coding Domains (ISO 25010-aligned) |
115
- | **Gap analysis** | AI agent identifies missing capabilities — not just hand-rolled code, but things you should have but don't (e.g., no error monitoring, no rate limiting, no event-driven workflows) |
116
- | **Ecosystem-level recommendations** | Solutions include rationale, companion packages, anti-patterns, and alternatives not just "use library X" |
117
- | **Context7 verification** | Every recommendation verified against real, version-correct documentation |
127
+ | **Pattern-based scanning** | Detects hand-rolled code across 30 domains with 40+ regex patterns (design-system, auth, state-management, etc.) |
128
+ | **Structural analysis** | Detects monorepo architecture gaps: missing token layers, dependency flow violations, hardcoded config values |
129
+ | **Gap analysis** | AI agent identifies missing capabilities — not just hand-rolled code, but things you should have but don't |
130
+ | **Ecosystem-level recommendations** | Solutions include rationale, companion packages, anti-patterns, and alternatives |
131
+ | **Context7 verification** | Every recommendation (replacements AND gaps) verified with exponential backoff retry |
118
132
  | **7-dimension impact scoring** | Scalability, performance, security, maintainability, feature richness, UX, UI aesthetics |
119
133
  | **Phased migration plans** | Low / medium / high risk phases with adapter strategies |
120
134
  | **Deletion checklists** | Every file and line range to remove, with estimated lines saved |
121
135
  | **UX completeness audit** | A11y, error/empty/loading states, form validation, design system alignment |
136
+ | **Design system support** | Two paths: scaffold from reference repos (Primer, Polaris, Supabase, Dub) or extract from existing code |
122
137
  | **Monorepo support** | Detects npm, pip, cargo, go workspaces independently |
123
138
 
124
- ### Dependency Management (v2.0)
139
+ ### Dependency Management
125
140
 
126
141
  | Feature | Description |
127
142
  |---------|-------------|
@@ -133,13 +148,14 @@ Or use as an **MCP SKILL** — provide [`SKILL.md`](./SKILL.md) to your AI agent
133
148
  ## How It Works
134
149
 
135
150
  ```
136
- Input ─> Validator ─> Scanner ─> Recommender (AI Agent) ─> Context7 Verifier
151
+ Input ─> Validator ─> Scanner + Structure Analyzer
152
+ ─> Gap Analysis (AI Agent) ─> Recommender (AI Agent) ─> Context7 Verifier
137
153
  ─> Impact Scorer ─> Conflict Detection ─> Vuln Scanner ─> License Filter
138
154
  ─> Migration Planner ─> UX Auditor ─> Auto-Updater
139
155
  ─> Serializer ─> PR Creator ─> Output
140
156
  ```
141
157
 
142
- **Key architecture**: The scanner detects WHAT is hand-rolled; the **Recommender** (AI agent or caller) decides WHAT library to use. No library recommendations are hardcoded — they are provided dynamically based on project context, ecosystem knowledge, and Context7 verification.
158
+ **Key architecture**: The scanner detects WHAT is hand-rolled; the structure analyzer detects architectural gaps; the **Recommender** (AI agent or caller) decides WHAT to use. No library recommendations are hardcoded — they are provided dynamically based on project context, ecosystem knowledge, and Context7 verification.
143
159
 
144
160
  Each stage is a pure function with structured I/O. All external dependencies (Context7, OSV, npm registry, GitHub API) are **injected via interfaces** for testability.
145
161
 
@@ -166,14 +182,14 @@ function t(key, locale) {
166
182
  <td>
167
183
 
168
184
  ```tsx
169
- // next-intl — Context7 verified, MIT
170
- // Impact: 9.2/10 composite
171
- // Migration risk: low | Effort: 8h
172
- import { useTranslations } from 'next-intl';
185
+ // @lingui/core — Context7 verified, MIT
186
+ // Ecosystem: @lingui/macro + @lingui/cli
187
+ // Impact: 9.2/10 | Risk: low | Effort: 8h
188
+ import { useLingui } from '@lingui/react';
173
189
 
174
190
  export default function Page() {
175
- const t = useTranslations('common');
176
- return <h1>{t('greeting')}</h1>;
191
+ const { t } = useLingui();
192
+ return <h1>{t`greeting`}</h1>;
177
193
  }
178
194
  ```
179
195
 
@@ -199,8 +215,8 @@ function logRequest(req) {
199
215
 
200
216
  ```typescript
201
217
  // pino — Context7 verified, MIT
202
- // Impact: 9.0/10 composite
203
- // Migration risk: low | Effort: 4h
218
+ // Gap analysis: "No structured logging detected"
219
+ // Priority: critical
204
220
  import pino from 'pino';
205
221
  const logger = pino({
206
222
  level: 'info',
@@ -217,11 +233,15 @@ const logger = pino({
217
233
  | Feature | Next-Unicorn | Snyk | Dependabot | Renovate |
218
234
  |---------|:---:|:---:|:---:|:---:|
219
235
  | Finds hand-rolled code to replace | **Yes** | | | |
236
+ | Identifies missing capabilities (gaps) | **Yes** | | | |
237
+ | Structural architecture analysis | **Yes** | | | |
220
238
  | Recommends new libraries | **Yes** | | | |
239
+ | Ecosystem-level solutions | **Yes** | | | |
221
240
  | 7-dimension impact scoring | **Yes** | | | |
222
241
  | Context7 doc verification | **Yes** | | | |
223
242
  | Phased migration plans | **Yes** | | | |
224
243
  | UX completeness audit | **Yes** | | | |
244
+ | Design system scaffold/extraction | **Yes** | | | |
225
245
  | Deletion checklists | **Yes** | | | |
226
246
  | Vulnerability scanning | **Yes** | Yes | Yes | |
227
247
  | Scans *recommended* libs for vulns | **Yes** | | | |
@@ -249,14 +269,18 @@ const logger = pino({
249
269
 
250
270
  ### `scanCodebase(input): Promise<ScanResult>`
251
271
 
252
- Standalone scanner — returns detections and workspace info without recommendations. AI agents can call this first, then provide recommendations via the `Recommender` callback.
272
+ Standalone scanner — returns detections, workspace info, and structural findings (design system layer analysis, dependency flow violations). AI agents can call this first, then provide recommendations via the `Recommender` callback.
273
+
274
+ ### `analyzeStructure(repoPath, workspaces): StructuralAnalysis`
275
+
276
+ Standalone structure analyzer — detects missing design system layers, dependency flow violations, hardcoded config values, and missing shared presets in monorepos.
253
277
 
254
278
  ### Output Structure
255
279
 
256
280
  ```jsonc
257
281
  {
258
282
  "recommendedChanges": [...], // Replacement recommendations with impact scores
259
- "gapAnalysis": [...], // (optional) Missing capabilities with prioritized recs
283
+ "gapAnalysis": [...], // (optional) Context7-verified gap recommendations
260
284
  "filesToDelete": [...], // Files to remove after migration
261
285
  "linesSavedEstimate": 1250, // Total lines saved
262
286
  "uxAudit": [...], // UX completeness (8 categories)
@@ -272,16 +296,16 @@ Standalone scanner — returns detections and workspace info without recommendat
272
296
 
273
297
  ## Vibe Coding Domains
274
298
 
275
- 68 domains across 11 categories, aligned with ISO/IEC 25010:
299
+ 68 domains across 11 categories, aligned with ISO/IEC 25010. 30 domains have scanner patterns; the rest are covered by AI agent gap analysis.
276
300
 
277
301
  | Category | Count | Examples |
278
302
  |----------|:-----:|---------|
279
- | UX / Design | 14 | `ux-completeness`, `a11y-accessibility`, `forms-ux`, `design-system` |
303
+ | UX / Design | 14 | `design-system`, `a11y-accessibility`, `forms-ux`, `empty-loading-error-states` |
280
304
  | SEO / i18n | 5 | `seo`, `i18n`, `content-marketing` |
281
305
  | Growth / Data | 7 | `analytics-tracking`, `ab-testing-experimentation` |
282
- | Frontend Arch | 8 | `state-management`, `data-fetching-caching`, `agent-architecture` |
283
- | Backend / Platform | 8 | `database-orm-migrations`, `jobs-queue-scheduler`, `feature-flags-config` |
284
- | Security | 5 | `auth-security`, `permissions-rbac-ux`, `fraud-abuse-prevention` |
306
+ | Frontend Arch | 8 | `state-management`, `data-fetching-caching`, `realtime-collaboration` |
307
+ | Backend / Platform | 8 | `database-orm-migrations`, `caching-rate-limit`, `feature-flags-config` |
308
+ | Security | 5 | `auth-security`, `security-hardening`, `fraud-abuse-prevention` |
285
309
  | Observability | 4 | `logging-tracing-metrics`, `error-monitoring` |
286
310
  | Delivery / DevEx | 6 | `testing-strategy`, `ci-cd-release`, `dependency-management` |
287
311
  | Performance | 3 | `performance-web-vitals`, `cost-optimization` |
@@ -293,7 +317,7 @@ Standalone scanner — returns detections and workspace info without recommendat
293
317
  ## Testing
294
318
 
295
319
  ```bash
296
- pnpm test # 198 tests (vitest + fast-check)
320
+ pnpm test # 210 tests (vitest + fast-check)
297
321
  pnpm typecheck # TypeScript strict mode
298
322
  pnpm build # Compile to dist/
299
323
  ```
@@ -330,6 +354,13 @@ pnpm build # Compile to dist/
330
354
  | [`update-plan.md`](./templates/update-plan.md) | Dependency update plan |
331
355
  | [`prd-template.md`](./templates/prd-template.md) | PRD for stakeholder presentation |
332
356
 
357
+ ## References
358
+
359
+ | Reference | Purpose |
360
+ |-----------|---------|
361
+ | [`design-system-sources.md`](./references/design-system-sources.md) | 25+ curated design system repos for scaffolding (Primer, Polaris, Dub, Supabase, etc.) |
362
+ | [`design-system-extraction.md`](./references/design-system-extraction.md) | Workflow for extracting a design system from existing code (6 principles, 5 phases) |
363
+
333
364
  ## Contributing
334
365
 
335
366
  See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup, architecture overview, and contribution guidelines.
@@ -340,8 +371,8 @@ Releases are automated via GitHub Actions:
340
371
 
341
372
  ```bash
342
373
  # Tag a new version
343
- git tag v2.0.0
344
- git push origin v2.0.0
374
+ git tag v1.0.5
375
+ git push origin v1.0.5
345
376
  # → CI runs tests → creates GitHub Release → publishes to npmjs + GitHub Packages
346
377
  ```
347
378
 
package/SKILL.md CHANGED
@@ -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. **Ecosystem composition** — recommend companion libraries that work together
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
70
- 4. **Alternatives** — different solutions for different architectural contexts
71
- 5. **Context7 verification** — call `resolve-library-id` + `query-docs` to confirm the library exists and get latest version/docs
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 Impact
83
+ ### Step 4–7: Score, Plan, Audit, Serialize
82
84
 
83
- Call `computeImpactScore()` for each detection. Optionally provide `dimensionHints` and `baseEffortHours` for more accurate scoring. Read `src/scorer/impact-scorer.ts` for the interface.
84
-
85
- ### Step 5: Build Migration Plan
86
-
87
- Call `buildMigrationPlan()` to group recommendations into phases by risk (low, medium, high). High-risk items include adapter strategies.
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
- * This is the orchestrator that wires the full pipeline:
9
- * validate inputscan recommend (caller) → verify → score → plan →
10
- * audit filter vuln scan → auto-update serialize → PR creation
8
+ * Redundant modules removed (Occam's Razor):
9
+ * - impact-scorerinlined (trivial math)
10
+ * - migration-plannerinlined (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.4";
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 identified by the AI agent something the project
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 — if provided, enables vulnerability scanning */
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EACL,YAAY,EAIb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAgB,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,8BAA8B,CAAC;AAEtC,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;AAOnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAMpE,eAAO,MAAM,OAAO,UAAU,CAAC;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