@nebutra/next-unicorn-skill 1.0.2 → 1.0.4

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 CHANGED
@@ -5,20 +5,24 @@ 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.2] - 2026-02-09
8
+ ## [1.0.3] - 2026-02-09
9
9
 
10
10
  ### Added
11
11
 
12
- - **Ecosystem-level recommendations** — `LibraryRecommendation` now supports `rationale`, `ecosystem` (companion packages with roles), and `stackContext` fields, enabling AI agents to produce unicorn-grade solution stacks instead of single-library suggestions
13
- - New `EcosystemPackage` type for companion packages (library + version + role)
14
- - Output schema `RecommendedChange.recommendedLibrary` extended with `rationale`, `ecosystem`, and `stackContext` optional fields
15
- - SKILL.md Step 3 rewritten to guide AI agents toward ecosystem-level thinking: "not just 'a library that does this', but the specific combination of tools that the best engineering teams ship with"
12
+ - **Gap Analysis** — AI agent can now identify capabilities the project is MISSING entirely, not just hand-rolled code to replace. New `GapRecommendation` type with `domain`, `description`, `recommendedLibrary`, and `priority` (critical/recommended/nice-to-have).
13
+ - New `gaps` option in `AnalyzeOptions` AI agent provides gap recommendations alongside scanner-based detections.
14
+ - New `gapAnalysis` field in `OutputSchema` gap recommendations appear in the output alongside `recommendedChanges`.
15
+ - New `GapRecommendationSchema` Zod schema with full validation.
16
+ - SKILL.md Step 2.5: Gap Analysis guidance for AI agents.
17
+ - 3 new gap analysis tests (202 total).
16
18
 
17
19
  ### Changed
18
20
 
19
- - `LibraryRecommendation` interface extended (backward-compatible new fields are optional)
20
- - SKILL.md example now shows full ecosystem recommendation (@lingui/core + @lingui/macro + @lingui/cli + Crowdin TMS)
21
- - Version bumped to 1.0.2
21
+ - `LibraryRecommendation` enriched with optional `rationale`, `ecosystem`, `antiPatterns`, `alternatives` fields AI agent can express ecosystem-level solutions (e.g., Lingui + TMS + compile-time extraction).
22
+ - `RecommendedChange.recommendedLibrary` output schema widened to match enriched `LibraryRecommendation`.
23
+ - SKILL.md Step 3 renamed "Recommend Solutions" — guides AI agent to think at ecosystem level.
24
+ - Summary table template updated to render rationale, ecosystem, anti-patterns, and alternatives.
25
+ - README updated with gap analysis, ecosystem recommendations features and API docs.
22
26
 
23
27
  ## [1.0.1] - 2026-02-09
24
28
 
package/README.md CHANGED
@@ -63,20 +63,14 @@ npm install @nebutra/next-unicorn-skill
63
63
  import { analyze, scanCodebase } from '@nebutra/next-unicorn-skill';
64
64
  import type { Recommender } from '@nebutra/next-unicorn-skill';
65
65
 
66
- // The recommender function: AI agent decides the full ecosystem for each detection
66
+ // The recommender function: AI agent decides which library fits each detection
67
67
  const recommender: Recommender = (detection) => {
68
68
  // AI agent uses its knowledge + project context to recommend
69
69
  // Return null to skip a detection (false positive, intentional custom code)
70
70
  return {
71
- library: '@lingui/core', // primary library
72
- version: '^4.0.0', // verified via Context7
71
+ library: 'zustand', // dynamically chosen, not hardcoded
72
+ version: '^5.0.0', // verified via Context7
73
73
  license: 'MIT',
74
- rationale: 'Compile-time extraction with near-zero runtime overhead',
75
- ecosystem: [ // companion packages
76
- { library: '@lingui/macro', version: '^4.0.0', role: 'Zero-runtime tagged templates' },
77
- { library: '@lingui/cli', version: '^4.0.0', role: 'CI/CD message extraction' },
78
- ],
79
- stackContext: 'Integrate with Crowdin TMS for professional translation workflows',
80
74
  };
81
75
  };
82
76
 
@@ -118,6 +112,8 @@ Or use as an **MCP SKILL** — provide [`SKILL.md`](./SKILL.md) to your AI agent
118
112
  | Feature | Description |
119
113
  |---------|-------------|
120
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" |
121
117
  | **Context7 verification** | Every recommendation verified against real, version-correct documentation |
122
118
  | **7-dimension impact scoring** | Scalability, performance, security, maintainability, feature richness, UX, UI aesthetics |
123
119
  | **Phased migration plans** | Low / medium / high risk phases with adapter strategies |
@@ -245,6 +241,7 @@ const logger = pino({
245
241
  | `input` | `InputSchema` | Yes | Project metadata, goals, constraints, focus areas |
246
242
  | `context7Client` | `Context7Client` | Yes | Context7 MCP client for doc verification |
247
243
  | `recommender` | `Recommender` | Yes | Maps each detection → library recommendation (AI agent provides this) |
244
+ | `gaps` | `GapRecommendation[]` | No | Missing capabilities the project should have (AI agent identifies these) |
248
245
  | `vulnClient` | `VulnerabilityClient` | No | OSV client for vulnerability scanning |
249
246
  | `registryClient` | `RegistryClient` | No | Package registry client for auto-update |
250
247
  | `platformClient` | `PlatformClient` | No | GitHub/GitLab client for PR creation |
@@ -258,7 +255,8 @@ Standalone scanner — returns detections and workspace info without recommendat
258
255
 
259
256
  ```jsonc
260
257
  {
261
- "recommendedChanges": [...], // Recommendations with impact scores
258
+ "recommendedChanges": [...], // Replacement recommendations with impact scores
259
+ "gapAnalysis": [...], // (optional) Missing capabilities with prioritized recs
262
260
  "filesToDelete": [...], // Files to remove after migration
263
261
  "linesSavedEstimate": 1250, // Total lines saved
264
262
  "uxAudit": [...], // UX completeness (8 categories)
package/SKILL.md CHANGED
@@ -1,87 +1,78 @@
1
1
  ---
2
2
  name: analyze-and-recommend-third-party-optimizations
3
- description: Scans any codebase and identifies where hand-rolled implementations should be replaced by battle-tested third-party libraries, producing structured migration plans with Context7-verified recommendations
4
- version: 1.0.2
5
- author: TsekaLuk
6
- tags:
7
- - code-analysis
8
- - third-party-libraries
9
- - migration-planning
10
- - dependency-optimization
11
- - context7-verification
12
- - ux-audit
13
- - impact-scoring
14
- - vulnerability-scanning
15
- - auto-update
16
- - pr-automation
3
+ description: >-
4
+ Scan a codebase to identify hand-rolled implementations that should be replaced
5
+ by third-party libraries, and identify missing capabilities the project should
6
+ have. Produce structured migration plans with Context7-verified recommendations.
7
+ Use when analyzing technical debt, auditing dependency health, reviewing
8
+ hand-rolled code, planning library migrations, or assessing capability gaps.
17
9
  ---
18
10
 
19
11
  # Analyze and Recommend Third-Party Optimizations
20
12
 
21
- ## Purpose
22
-
23
- 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
-
25
13
  ## Architecture
26
14
 
27
15
  ```
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
16
+ Scanner (deterministic) → AI Agent (generative) → Pipeline (deterministic)
17
+ Regex patterns detect 1. Recommend replacements Score, plan, audit,
18
+ hand-rolled code 2. Identify capability gaps filter, serialize
19
+ using knowledge + Context7
31
20
  ```
32
21
 
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.
22
+ **Design constraints**:
23
+ - No hardcoded library recommendations — evaluate project context dynamically
24
+ - Two analysis modes: **replacement** (hand-rolled code found) and **gap** (capability missing entirely)
34
25
 
35
26
  ## Standard Operating Procedure
36
27
 
37
28
  ### Step 1: Validate Input
38
29
 
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
30
+ Parse and validate `InputSchema` JSON via Zod. Read `src/schemas/input.schema.ts` for the full schema.
44
31
 
45
32
  ### Step 2: Scan Codebase
46
33
 
47
- Run `scanCodebase(input)` to walk the file tree and match against regex patterns. The scanner:
34
+ Run `scanCodebase(input)`. The scanner:
35
+
36
+ 1. Detect workspace roots for monorepo support
37
+ 2. Match code against 20+ domain patterns (i18n, auth, state-management, etc.)
38
+ 3. Record each detection with: file path, line range, pattern category, confidence score, domain
39
+ 4. Return `ScanResult` with detections and workspace info
40
+
41
+ Detections contain no library suggestions — only what was detected and where.
42
+
43
+ ### Step 2.5: Gap Analysis (AI Agent)
44
+
45
+ Beyond scanner detections, analyze what the project is **missing entirely**. Inspect:
48
46
 
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
47
+ 1. **Installed dependencies** identify low-level tools that should be upgraded to platform-level solutions
48
+ 2. **Monorepo structure** identify missing architectural layers (e.g., shared token package, shared config preset)
49
+ 3. **Cross-cutting concerns** identify absent capabilities: structured logging, error monitoring, rate limiting, event-driven workflows, transactional email, type-safe API layer
50
+ 4. **Architecture patterns** identify opportunities for multi-package solutions (e.g., design-tokens → tailwind-config → ui three-layer architecture for design systems)
53
51
 
54
- Detections contain **no library suggestions** — only what was detected and where.
52
+ Analyze at three levels of depth:
53
+ - **Single library gap**: missing one tool (e.g., no form validation library)
54
+ - **Ecosystem gap**: missing a coordinated set of tools (e.g., no observability stack)
55
+ - **Architecture gap**: missing an entire structural layer (e.g., no design system, no shared config)
56
+
57
+ Provide each gap as a `GapRecommendation`. Read `src/index.ts` for the interface. Pass gaps via the `gaps` option in `analyze()`.
58
+
59
+ **Design system gaps** — Two paths depending on project maturity:
60
+ - **No existing frontend**: Scaffold from reference repos. Read `references/design-system-sources.md` for curated sources and sparse-checkout workflow.
61
+ - **Existing frontend without formal design system**: First extract the spec (audit → tokens → classify → document) via `references/design-system-extraction.md`, then implement the architecture via `references/design-system-sources.md`.
55
62
 
56
63
  ### Step 3: Recommend Solutions (AI Agent)
57
64
 
58
- For each detection, recommend a **unicorn-grade solution** — not just "a library that does this", but the specific combination of tools that the best engineering teams ship with, configured the way they configure it.
59
-
60
- **Recommendation approach:**
61
-
62
- 1. **Project context** — framework, runtime, existing deps determine the primary library (Next.js App Router → next-intl; Vite SPA → @lingui/core; Edge → jose, not jsonwebtoken)
63
- 2. **Full ecosystem** — include companion packages that complete the solution (e.g., @lingui/macro for zero-runtime tagged templates + @lingui/cli for CI extraction + Crowdin TMS for professional translation workflows)
64
- 3. **Stack integration** — explain how this fits the broader architecture (e.g., "combine react-hook-form + @hookform/resolvers + zod for schema-validated forms that share types with server validation")
65
- 4. **Context7 verification** — call `resolve-library-id` + `query-docs` to confirm the library exists and get latest version/docs
66
-
67
- Return a `LibraryRecommendation` per detection:
68
- ```typescript
69
- {
70
- library: '@lingui/core',
71
- version: '^4.0.0',
72
- license: 'MIT',
73
- rationale: 'Compile-time message extraction with near-zero runtime overhead',
74
- ecosystem: [
75
- { library: '@lingui/macro', version: '^4.0.0', role: 'Zero-runtime tagged template macros' },
76
- { library: '@lingui/cli', version: '^4.0.0', role: 'CI/CD message extraction pipeline' },
77
- ],
78
- stackContext: 'Integrate with Crowdin TMS for professional translation workflows; use @lingui/vite-plugin for Vite or @lingui/swc-plugin for Next.js SWC compiler',
79
- }
80
- ```
65
+ For each scanner detection, recommend a **solution**. Consider:
81
66
 
82
- Return `null` to skip a detection (intentional custom code, false positive, etc.).
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
83
72
 
84
- **False positive filtering** skip if:
73
+ Read `src/index.ts` for the `LibraryRecommendation` interface. Return `null` to skip a detection.
74
+
75
+ **Skip a detection if**:
85
76
  - Code has comments explaining why it is custom
86
77
  - Detection is in test/mock/fixture files
87
78
  - Library is already in project dependencies (suggest version update instead)
@@ -89,15 +80,15 @@ Return `null` to skip a detection (intentional custom code, false positive, etc.
89
80
 
90
81
  ### Step 4: Score Impact
91
82
 
92
- Compute 7-dimension impact scores (scalability, performance, security, maintainability, feature richness, UX, UI aesthetics) with composite score, migration risk, and estimated effort.
83
+ Call `computeImpactScore()` for each detection. Optionally provide `dimensionHints` and `baseEffortHours` for more accurate scoring. Read `src/scorer/impact-scorer.ts` for the interface.
93
84
 
94
85
  ### Step 5: Build Migration Plan
95
86
 
96
- Group recommendations into phases by risk (low medium high), ordered by domain priority (infrastructure first, presentation last). High-risk items include adapter strategies.
87
+ Call `buildMigrationPlan()` to group recommendations into phases by risk (low, medium, high). High-risk items include adapter strategies.
97
88
 
98
89
  ### Step 6: Audit UX Completeness
99
90
 
100
- Evaluate frontend codebase across 8 UX categories: accessibility, error/empty/loading states, form validation, performance feel, copy consistency, design system alignment.
91
+ Call `auditUxCompleteness()` to evaluate 8 UX categories. The auditor determines status (present/partial/missing). Fill in `recommendedLibrary` on partial/missing items based on project context.
101
92
 
102
93
  ### Step 7: Apply Constraints and Serialize
103
94
 
@@ -105,64 +96,21 @@ Filter by license allowlist, detect dependency conflicts, serialize to JSON.
105
96
 
106
97
  ### Optional Steps
107
98
 
108
- - **Step 8**: Vulnerability scanning via OSV database
109
- - **Step 9**: Auto-update existing dependencies via registry queries
110
- - **Step 10**: PR auto-creation via GitHub/GitLab API
111
-
112
- ## Programmatic API
113
-
114
- ```typescript
115
- import { analyze, scanCodebase } from './src/index.js';
116
- import type { Recommender } from './src/index.js';
117
-
118
- // Step 1: Scan standalone (for AI agent inspection)
119
- const scanResult = await scanCodebase(validatedInput);
120
-
121
- // Step 2: Full pipeline with ecosystem-level recommender
122
- const recommender: Recommender = (detection) => ({
123
- library: '@lingui/core',
124
- version: '^4.0.0',
125
- license: 'MIT',
126
- rationale: 'Compile-time extraction with near-zero runtime overhead',
127
- ecosystem: [
128
- { library: '@lingui/macro', version: '^4.0.0', role: 'Zero-runtime tagged templates' },
129
- { library: '@lingui/cli', version: '^4.0.0', role: 'CI message extraction' },
130
- ],
131
- stackContext: 'Integrate with Crowdin TMS; use @lingui/swc-plugin for Next.js',
132
- });
133
-
134
- const result = await analyze({
135
- input: inputJson,
136
- context7Client: myContext7Client,
137
- recommender, // AI agent provides ecosystem-level recommendations
138
- });
139
- ```
99
+ - **Step 8**: Vulnerability scan via OSV database (`vulnClient`)
100
+ - **Step 9**: Auto-update existing dependencies (`registryClient`)
101
+ - **Step 10**: PR auto-creation via GitHub/GitLab (`platformClient` + `gitOps`)
140
102
 
141
- ## Output Artifacts
103
+ ## Output
142
104
 
143
105
  Single `OutputSchema` JSON containing:
144
- - `recommendedChanges` — recommendations with scores, verification status, adapter strategies
106
+ - `recommendedChanges` — replacement recommendations with scores, verification, adapter strategies
107
+ - `gapAnalysis` (optional) — missing capabilities with prioritized recommendations
145
108
  - `filesToDelete` — file paths to remove after migration
146
109
  - `linesSavedEstimate` — total lines saved
147
- - `uxAudit` — UX completeness checklist
110
+ - `uxAudit` — UX completeness checklist (8 categories)
148
111
  - `migrationPlan` — phased plan with deletion checklist
149
112
  - `vulnerabilityReport` (optional)
150
113
  - `updatePlan` (optional)
151
114
  - `pullRequests` (optional)
152
115
 
153
- ## Vibe Coding Domain Coverage (20+ detection patterns)
154
-
155
- | Category | Domains |
156
- |----------|---------|
157
- | UX / Design | ux-completeness, a11y-accessibility, forms-ux, state-management |
158
- | SEO / i18n / Content | seo, i18n, content-marketing |
159
- | Growth / Data | growth-hacking |
160
- | App Architecture | agent-architecture, data-fetching-caching, error-handling-resilience |
161
- | Backend / Platform | database-orm-migrations, auth-security |
162
- | Observability | observability, logging-tracing-metrics |
163
- | Testing | testing-strategy |
164
- | AI Engineering | ai-model-serving |
165
- | Business | cross-border-ecommerce |
166
- | File / Media | file-upload-media |
167
-
168
- > **Extensibility:** Use `customDomains?: string[]` in input for project-specific domains.
116
+ Read `src/schemas/output.schema.ts` for the full schema.
@@ -25,10 +25,13 @@ export interface PatternDefinition {
25
25
  }
26
26
  /**
27
27
  * Returns the full pattern catalog covering Vibe Coding domains.
28
- * Each covered domain has 2–3 patterns for hand-rolled code detection.
28
+ *
29
+ * Domain assignment rules:
30
+ * - Each pattern goes in its MOST SPECIFIC domain (e.g., A/B test → ab-testing-experimentation, not growth-hacking)
31
+ * - Parent domains (growth-hacking, observability, ux-completeness) are used only when no specific child domain fits
32
+ * - Domains with no regex-detectable patterns are left for Gap Analysis (AI Agent)
29
33
  *
30
34
  * The catalog defines WHAT to detect, not WHAT to recommend.
31
- * Library recommendations are generated dynamically by the AI agent.
32
35
  */
33
36
  export declare function getPatternCatalog(): PatternDefinition[];
34
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"pattern-catalog.d.ts","sourceRoot":"","sources":["../../src/analyzer/pattern-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,MAAM,EAAE,gBAAgB,CAAC;IACzB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,EAAE,CAuiBvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAExE"}
1
+ {"version":3,"file":"pattern-catalog.d.ts","sourceRoot":"","sources":["../../src/analyzer/pattern-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,MAAM,EAAE,gBAAgB,CAAC;IACzB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,EAAE,CAkqBvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAExE"}