@nebutra/next-unicorn-skill 1.0.3 → 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/SKILL.md +46 -132
- package/dist/analyzer/pattern-catalog.d.ts +5 -2
- package/dist/analyzer/pattern-catalog.d.ts.map +1 -1
- package/dist/analyzer/pattern-catalog.js +338 -234
- package/dist/analyzer/pattern-catalog.js.map +1 -1
- package/dist/analyzer/scanner.d.ts +4 -0
- package/dist/analyzer/scanner.d.ts.map +1 -1
- package/dist/analyzer/scanner.js +13 -1
- package/dist/analyzer/scanner.js.map +1 -1
- package/dist/analyzer/structure-analyzer.d.ts +40 -0
- package/dist/analyzer/structure-analyzer.d.ts.map +1 -0
- package/dist/analyzer/structure-analyzer.js +228 -0
- package/dist/analyzer/structure-analyzer.js.map +1 -0
- package/dist/auditor/ux-auditor.js +8 -8
- package/dist/auditor/ux-auditor.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -4
- package/dist/index.js.map +1 -1
- package/dist/schemas/output.schema.d.ts +18 -0
- package/dist/schemas/output.schema.d.ts.map +1 -1
- package/dist/schemas/output.schema.js +3 -0
- package/dist/schemas/output.schema.js.map +1 -1
- package/package.json +1 -1
package/SKILL.md
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: analyze-and-recommend-third-party-optimizations
|
|
3
|
-
description:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
- migration-planning
|
|
10
|
-
- dependency-optimization
|
|
11
|
-
- context7-verification
|
|
12
|
-
- ux-audit
|
|
13
|
-
- impact-scoring
|
|
14
|
-
- vulnerability-scanning
|
|
15
|
-
- auto-update
|
|
16
|
-
- pr-automation
|
|
3
|
+
description: >-
|
|
4
|
+
Scan a codebase to identify hand-rolled implementations that should be replaced
|
|
5
|
+
by third-party libraries, and identify missing capabilities the project should
|
|
6
|
+
have. Produce structured migration plans with Context7-verified recommendations.
|
|
7
|
+
Use when analyzing technical debt, auditing dependency health, reviewing
|
|
8
|
+
hand-rolled code, planning library migrations, or assessing capability gaps.
|
|
17
9
|
---
|
|
18
10
|
|
|
19
11
|
# Analyze and Recommend Third-Party Optimizations
|
|
20
12
|
|
|
21
|
-
## Purpose
|
|
22
|
-
|
|
23
|
-
Two-pronged analysis: (1) detect hand-rolled code that should be replaced by libraries, and (2) identify missing capabilities the project should have. The scanner pre-filters; the AI agent provides unicorn-grade recommendations — ecosystem-level solutions with rationale, anti-patterns, and alternatives, verified via Context7 MCP.
|
|
24
|
-
|
|
25
13
|
## Architecture
|
|
26
14
|
|
|
27
15
|
```
|
|
@@ -31,82 +19,60 @@ hand-rolled code 2. Identify capability gaps filter, seria
|
|
|
31
19
|
using knowledge + Context7
|
|
32
20
|
```
|
|
33
21
|
|
|
34
|
-
**
|
|
35
|
-
- No hardcoded library recommendations —
|
|
36
|
-
- Two analysis modes: **replacement** (hand-rolled code
|
|
22
|
+
**Design constraints**:
|
|
23
|
+
- No hardcoded library recommendations — evaluate project context dynamically
|
|
24
|
+
- Two analysis modes: **replacement** (hand-rolled code found) and **gap** (capability missing entirely)
|
|
37
25
|
|
|
38
26
|
## Standard Operating Procedure
|
|
39
27
|
|
|
40
28
|
### Step 1: Validate Input
|
|
41
29
|
|
|
42
|
-
Parse and validate `InputSchema` JSON via Zod.
|
|
43
|
-
- **Project metadata**: repo path, languages, package managers, current libraries
|
|
44
|
-
- **Optimization goals**: what the project wants to improve
|
|
45
|
-
- **Constraints**: license allowlist, excluded libraries
|
|
46
|
-
- **Priority focus areas**: Vibe Coding Domains to prioritize
|
|
30
|
+
Parse and validate `InputSchema` JSON via Zod. Read `src/schemas/input.schema.ts` for the full schema.
|
|
47
31
|
|
|
48
32
|
### Step 2: Scan Codebase
|
|
49
33
|
|
|
50
|
-
Run `scanCodebase(input)
|
|
34
|
+
Run `scanCodebase(input)`. The scanner:
|
|
51
35
|
|
|
52
|
-
1.
|
|
53
|
-
2.
|
|
54
|
-
3.
|
|
55
|
-
4.
|
|
36
|
+
1. Detect workspace roots for monorepo support
|
|
37
|
+
2. Match code against 20+ domain patterns (i18n, auth, state-management, etc.)
|
|
38
|
+
3. Record each detection with: file path, line range, pattern category, confidence score, domain
|
|
39
|
+
4. Return `ScanResult` with detections and workspace info
|
|
56
40
|
|
|
57
|
-
Detections contain
|
|
41
|
+
Detections contain no library suggestions — only what was detected and where.
|
|
58
42
|
|
|
59
43
|
### Step 2.5: Gap Analysis (AI Agent)
|
|
60
44
|
|
|
61
|
-
Beyond
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
{
|
|
74
|
-
domain: string; // e.g., "observability"
|
|
75
|
-
description: string; // e.g., "No structured logging detected"
|
|
76
|
-
recommendedLibrary: { name, version, license, rationale?, ecosystem?, antiPatterns?, alternatives? };
|
|
77
|
-
priority: 'critical' | 'recommended' | 'nice-to-have';
|
|
78
|
-
}
|
|
79
|
-
```
|
|
45
|
+
Beyond scanner detections, analyze what the project is **missing entirely**. Inspect:
|
|
46
|
+
|
|
47
|
+
1. **Installed dependencies** — identify low-level tools that should be upgraded to platform-level solutions
|
|
48
|
+
2. **Monorepo structure** — identify missing architectural layers (e.g., shared token package, shared config preset)
|
|
49
|
+
3. **Cross-cutting concerns** — identify absent capabilities: structured logging, error monitoring, rate limiting, event-driven workflows, transactional email, type-safe API layer
|
|
50
|
+
4. **Architecture patterns** — identify opportunities for multi-package solutions (e.g., design-tokens → tailwind-config → ui three-layer architecture for design systems)
|
|
51
|
+
|
|
52
|
+
Analyze at three levels of depth:
|
|
53
|
+
- **Single library gap**: missing one tool (e.g., no form validation library)
|
|
54
|
+
- **Ecosystem gap**: missing a coordinated set of tools (e.g., no observability stack)
|
|
55
|
+
- **Architecture gap**: missing an entire structural layer (e.g., no design system, no shared config)
|
|
80
56
|
|
|
81
|
-
|
|
57
|
+
Provide each gap as a `GapRecommendation`. Read `src/index.ts` for the interface. Pass gaps via the `gaps` option in `analyze()`.
|
|
58
|
+
|
|
59
|
+
**Design system gaps** — Two paths depending on project maturity:
|
|
60
|
+
- **No existing frontend**: Scaffold from reference repos. Read `references/design-system-sources.md` for curated sources and sparse-checkout workflow.
|
|
61
|
+
- **Existing frontend without formal design system**: First extract the spec (audit → tokens → classify → document) via `references/design-system-extraction.md`, then implement the architecture via `references/design-system-sources.md`.
|
|
82
62
|
|
|
83
63
|
### Step 3: Recommend Solutions (AI Agent)
|
|
84
64
|
|
|
85
|
-
For each detection, recommend a **solution
|
|
65
|
+
For each scanner detection, recommend a **solution**. Consider:
|
|
86
66
|
|
|
87
67
|
1. **Ecosystem composition** — recommend companion libraries that work together
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
3. **Anti-patterns** — what NOT to use and why (e.g., "Never use jsonwebtoken — no edge runtime support; use jose")
|
|
68
|
+
2. **Rationale** — explain WHY this choice fits this project's framework, runtime, and scale
|
|
69
|
+
3. **Anti-patterns** — what NOT to use and why
|
|
91
70
|
4. **Alternatives** — different solutions for different architectural contexts
|
|
92
71
|
5. **Context7 verification** — call `resolve-library-id` + `query-docs` to confirm the library exists and get latest version/docs
|
|
93
72
|
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
{
|
|
97
|
-
library: string; // required — primary package
|
|
98
|
-
version: string; // required
|
|
99
|
-
license: string; // required
|
|
100
|
-
rationale?: string; // recommended — WHY this choice
|
|
101
|
-
ecosystem?: Array<{...}>; // when solution involves multiple packages
|
|
102
|
-
antiPatterns?: string[]; // when common mistakes exist
|
|
103
|
-
alternatives?: Array<{...}>; // when architecture affects the choice
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Return `null` to skip a detection (intentional custom code, false positive, etc.).
|
|
73
|
+
Read `src/index.ts` for the `LibraryRecommendation` interface. Return `null` to skip a detection.
|
|
108
74
|
|
|
109
|
-
**
|
|
75
|
+
**Skip a detection if**:
|
|
110
76
|
- Code has comments explaining why it is custom
|
|
111
77
|
- Detection is in test/mock/fixture files
|
|
112
78
|
- Library is already in project dependencies (suggest version update instead)
|
|
@@ -114,15 +80,15 @@ Return `null` to skip a detection (intentional custom code, false positive, etc.
|
|
|
114
80
|
|
|
115
81
|
### Step 4: Score Impact
|
|
116
82
|
|
|
117
|
-
|
|
83
|
+
Call `computeImpactScore()` for each detection. Optionally provide `dimensionHints` and `baseEffortHours` for more accurate scoring. Read `src/scorer/impact-scorer.ts` for the interface.
|
|
118
84
|
|
|
119
85
|
### Step 5: Build Migration Plan
|
|
120
86
|
|
|
121
|
-
|
|
87
|
+
Call `buildMigrationPlan()` to group recommendations into phases by risk (low, medium, high). High-risk items include adapter strategies.
|
|
122
88
|
|
|
123
89
|
### Step 6: Audit UX Completeness
|
|
124
90
|
|
|
125
|
-
|
|
91
|
+
Call `auditUxCompleteness()` to evaluate 8 UX categories. The auditor determines status (present/partial/missing). Fill in `recommendedLibrary` on partial/missing items based on project context.
|
|
126
92
|
|
|
127
93
|
### Step 7: Apply Constraints and Serialize
|
|
128
94
|
|
|
@@ -130,73 +96,21 @@ Filter by license allowlist, detect dependency conflicts, serialize to JSON.
|
|
|
130
96
|
|
|
131
97
|
### Optional Steps
|
|
132
98
|
|
|
133
|
-
- **Step 8**: Vulnerability
|
|
134
|
-
- **Step 9**: Auto-update existing dependencies
|
|
135
|
-
- **Step 10**: PR auto-creation via GitHub/GitLab
|
|
136
|
-
|
|
137
|
-
## Programmatic API
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
import { analyze, scanCodebase } from './src/index.js';
|
|
141
|
-
import type { Recommender, GapRecommendation } from './src/index.js';
|
|
142
|
-
|
|
143
|
-
// Step 1: Scan standalone (for AI agent inspection)
|
|
144
|
-
const scanResult = await scanCodebase(validatedInput);
|
|
145
|
-
|
|
146
|
-
// Step 2: Full pipeline with recommender + gap analysis
|
|
147
|
-
const recommender: Recommender = (detection) => ({
|
|
148
|
-
library: 'zustand',
|
|
149
|
-
version: '^5.0.0',
|
|
150
|
-
license: 'MIT',
|
|
151
|
-
rationale: 'Minimal state library — no providers, 1KB gzipped',
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const gaps: GapRecommendation[] = [
|
|
155
|
-
{
|
|
156
|
-
domain: 'observability',
|
|
157
|
-
description: 'No structured logging detected',
|
|
158
|
-
recommendedLibrary: {
|
|
159
|
-
name: 'pino', version: '^9.0.0', license: 'MIT',
|
|
160
|
-
rationale: 'Fastest Node.js JSON logger with redaction and child loggers',
|
|
161
|
-
},
|
|
162
|
-
priority: 'critical',
|
|
163
|
-
},
|
|
164
|
-
];
|
|
165
|
-
|
|
166
|
-
const result = await analyze({
|
|
167
|
-
input: inputJson,
|
|
168
|
-
context7Client: myContext7Client,
|
|
169
|
-
recommender,
|
|
170
|
-
gaps, // AI agent identifies missing capabilities
|
|
171
|
-
});
|
|
172
|
-
```
|
|
99
|
+
- **Step 8**: Vulnerability scan via OSV database (`vulnClient`)
|
|
100
|
+
- **Step 9**: Auto-update existing dependencies (`registryClient`)
|
|
101
|
+
- **Step 10**: PR auto-creation via GitHub/GitLab (`platformClient` + `gitOps`)
|
|
173
102
|
|
|
174
|
-
## Output
|
|
103
|
+
## Output
|
|
175
104
|
|
|
176
105
|
Single `OutputSchema` JSON containing:
|
|
177
106
|
- `recommendedChanges` — replacement recommendations with scores, verification, adapter strategies
|
|
178
107
|
- `gapAnalysis` (optional) — missing capabilities with prioritized recommendations
|
|
179
108
|
- `filesToDelete` — file paths to remove after migration
|
|
180
109
|
- `linesSavedEstimate` — total lines saved
|
|
181
|
-
- `uxAudit` — UX completeness checklist
|
|
110
|
+
- `uxAudit` — UX completeness checklist (8 categories)
|
|
182
111
|
- `migrationPlan` — phased plan with deletion checklist
|
|
183
112
|
- `vulnerabilityReport` (optional)
|
|
184
113
|
- `updatePlan` (optional)
|
|
185
114
|
- `pullRequests` (optional)
|
|
186
115
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
| Category | Domains |
|
|
190
|
-
|----------|---------|
|
|
191
|
-
| UX / Design | ux-completeness, a11y-accessibility, forms-ux, state-management |
|
|
192
|
-
| SEO / i18n / Content | seo, i18n, content-marketing |
|
|
193
|
-
| Growth / Data | growth-hacking |
|
|
194
|
-
| App Architecture | agent-architecture, data-fetching-caching, error-handling-resilience |
|
|
195
|
-
| Backend / Platform | database-orm-migrations, auth-security |
|
|
196
|
-
| Observability | observability, logging-tracing-metrics |
|
|
197
|
-
| Testing | testing-strategy |
|
|
198
|
-
| AI Engineering | ai-model-serving |
|
|
199
|
-
| Business | cross-border-ecommerce |
|
|
200
|
-
| File / Media | file-upload-media |
|
|
201
|
-
|
|
202
|
-
> **Extensibility:** Use `customDomains?: string[]` in input for project-specific domains.
|
|
116
|
+
Read `src/schemas/output.schema.ts` for the full schema.
|
|
@@ -25,10 +25,13 @@ export interface PatternDefinition {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Returns the full pattern catalog covering Vibe Coding domains.
|
|
28
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* Domain assignment rules:
|
|
30
|
+
* - Each pattern goes in its MOST SPECIFIC domain (e.g., A/B test → ab-testing-experimentation, not growth-hacking)
|
|
31
|
+
* - Parent domains (growth-hacking, observability, ux-completeness) are used only when no specific child domain fits
|
|
32
|
+
* - Domains with no regex-detectable patterns are left for Gap Analysis (AI Agent)
|
|
29
33
|
*
|
|
30
34
|
* The catalog defines WHAT to detect, not WHAT to recommend.
|
|
31
|
-
* Library recommendations are generated dynamically by the AI agent.
|
|
32
35
|
*/
|
|
33
36
|
export declare function getPatternCatalog(): PatternDefinition[];
|
|
34
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pattern-catalog.d.ts","sourceRoot":"","sources":["../../src/analyzer/pattern-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,MAAM,EAAE,gBAAgB,CAAC;IACzB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED
|
|
1
|
+
{"version":3,"file":"pattern-catalog.d.ts","sourceRoot":"","sources":["../../src/analyzer/pattern-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,MAAM,EAAE,gBAAgB,CAAC;IACzB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,EAAE,CAkqBvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAExE"}
|