opencode-skills-collection 3.0.35 → 3.0.37
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/bundled-skills/.antigravity-install-manifest.json +15 -1
- package/bundled-skills/accesslint-audit/SKILL.md +115 -0
- package/bundled-skills/accesslint-diff/SKILL.md +81 -0
- package/bundled-skills/accesslint-scan/SKILL.md +47 -0
- package/bundled-skills/composition-patterns/SKILL.md +87 -0
- package/bundled-skills/composition-patterns/rules/_sections.md +29 -0
- package/bundled-skills/composition-patterns/rules/_template.md +24 -0
- package/bundled-skills/composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
- package/bundled-skills/composition-patterns/rules/architecture-compound-components.md +112 -0
- package/bundled-skills/composition-patterns/rules/patterns-children-over-render-props.md +87 -0
- package/bundled-skills/composition-patterns/rules/patterns-explicit-variants.md +100 -0
- package/bundled-skills/composition-patterns/rules/react19-no-forwardref.md +42 -0
- package/bundled-skills/composition-patterns/rules/state-context-interface.md +191 -0
- package/bundled-skills/composition-patterns/rules/state-decouple-implementation.md +113 -0
- package/bundled-skills/composition-patterns/rules/state-lift-state.md +125 -0
- package/bundled-skills/debugging-toolkit/SKILL.md +35 -0
- package/bundled-skills/deploy-to-vercel/SKILL.md +304 -0
- package/bundled-skills/deploy-to-vercel/resources/deploy-codex.sh +301 -0
- package/bundled-skills/deploy-to-vercel/resources/deploy.sh +301 -0
- package/bundled-skills/docs/integrations/jetski-cortex.md +3 -3
- package/bundled-skills/docs/integrations/jetski-gemini-loader/README.md +1 -1
- package/bundled-skills/docs/maintainers/backups/README-2026-06-02.md +687 -0
- package/bundled-skills/docs/maintainers/repo-growth-seo.md +4 -4
- package/bundled-skills/docs/maintainers/skills-update-guide.md +1 -1
- package/bundled-skills/docs/users/bundles.md +245 -1
- package/bundled-skills/docs/users/claude-code-skills.md +1 -1
- package/bundled-skills/docs/users/gemini-cli-skills.md +1 -1
- package/bundled-skills/docs/users/getting-started.md +1 -1
- package/bundled-skills/docs/users/kiro-integration.md +1 -1
- package/bundled-skills/docs/users/plugins.md +21 -13
- package/bundled-skills/docs/users/specialized-plugin-roadmap.md +95 -0
- package/bundled-skills/docs/users/usage.md +4 -4
- package/bundled-skills/docs/users/visual-guide.md +4 -4
- package/bundled-skills/polis-protocol/SKILL.md +93 -0
- package/bundled-skills/python-development/SKILL.md +35 -0
- package/bundled-skills/radix-ui-design-system/SKILL.md +2 -2
- package/bundled-skills/react-native-skills/SKILL.md +120 -0
- package/bundled-skills/react-native-skills/rules/_sections.md +86 -0
- package/bundled-skills/react-native-skills/rules/_template.md +28 -0
- package/bundled-skills/react-native-skills/rules/animation-derived-value.md +53 -0
- package/bundled-skills/react-native-skills/rules/animation-gesture-detector-press.md +95 -0
- package/bundled-skills/react-native-skills/rules/animation-gpu-properties.md +65 -0
- package/bundled-skills/react-native-skills/rules/design-system-compound-components.md +66 -0
- package/bundled-skills/react-native-skills/rules/fonts-config-plugin.md +71 -0
- package/bundled-skills/react-native-skills/rules/imports-design-system-folder.md +68 -0
- package/bundled-skills/react-native-skills/rules/js-hoist-intl.md +61 -0
- package/bundled-skills/react-native-skills/rules/list-performance-callbacks.md +44 -0
- package/bundled-skills/react-native-skills/rules/list-performance-function-references.md +132 -0
- package/bundled-skills/react-native-skills/rules/list-performance-images.md +53 -0
- package/bundled-skills/react-native-skills/rules/list-performance-inline-objects.md +97 -0
- package/bundled-skills/react-native-skills/rules/list-performance-item-expensive.md +94 -0
- package/bundled-skills/react-native-skills/rules/list-performance-item-memo.md +82 -0
- package/bundled-skills/react-native-skills/rules/list-performance-item-types.md +104 -0
- package/bundled-skills/react-native-skills/rules/list-performance-virtualize.md +67 -0
- package/bundled-skills/react-native-skills/rules/monorepo-native-deps-in-app.md +46 -0
- package/bundled-skills/react-native-skills/rules/monorepo-single-dependency-versions.md +63 -0
- package/bundled-skills/react-native-skills/rules/navigation-native-navigators.md +188 -0
- package/bundled-skills/react-native-skills/rules/react-compiler-destructure-functions.md +50 -0
- package/bundled-skills/react-native-skills/rules/react-compiler-reanimated-shared-values.md +48 -0
- package/bundled-skills/react-native-skills/rules/react-state-dispatcher.md +91 -0
- package/bundled-skills/react-native-skills/rules/react-state-fallback.md +56 -0
- package/bundled-skills/react-native-skills/rules/react-state-minimize.md +65 -0
- package/bundled-skills/react-native-skills/rules/rendering-no-falsy-and.md +74 -0
- package/bundled-skills/react-native-skills/rules/rendering-text-in-text-component.md +36 -0
- package/bundled-skills/react-native-skills/rules/scroll-position-no-state.md +82 -0
- package/bundled-skills/react-native-skills/rules/state-ground-truth.md +80 -0
- package/bundled-skills/react-native-skills/rules/ui-expo-image.md +66 -0
- package/bundled-skills/react-native-skills/rules/ui-image-gallery.md +104 -0
- package/bundled-skills/react-native-skills/rules/ui-measure-views.md +78 -0
- package/bundled-skills/react-native-skills/rules/ui-menus.md +174 -0
- package/bundled-skills/react-native-skills/rules/ui-native-modals.md +77 -0
- package/bundled-skills/react-native-skills/rules/ui-pressable.md +61 -0
- package/bundled-skills/react-native-skills/rules/ui-safe-area-scroll.md +65 -0
- package/bundled-skills/react-native-skills/rules/ui-scrollview-content-inset.md +45 -0
- package/bundled-skills/react-native-skills/rules/ui-styling.md +87 -0
- package/bundled-skills/skill-issue/SKILL.md +73 -0
- package/bundled-skills/tdd-workflows/SKILL.md +35 -0
- package/bundled-skills/vercel-cli-with-tokens/SKILL.md +361 -0
- package/bundled-skills/vercel-optimize/CONTRIBUTING.md +41 -0
- package/bundled-skills/vercel-optimize/SKILL.md +331 -0
- package/bundled-skills/vercel-optimize/lib/auth-route.mjs +23 -0
- package/bundled-skills/vercel-optimize/lib/budget-summary.mjs +182 -0
- package/bundled-skills/vercel-optimize/lib/citations.mjs +139 -0
- package/bundled-skills/vercel-optimize/lib/cost-coverage.mjs +143 -0
- package/bundled-skills/vercel-optimize/lib/dedup-recs.mjs +325 -0
- package/bundled-skills/vercel-optimize/lib/deep-dive.mjs +350 -0
- package/bundled-skills/vercel-optimize/lib/display-labels.mjs +185 -0
- package/bundled-skills/vercel-optimize/lib/extract-claims.mjs +550 -0
- package/bundled-skills/vercel-optimize/lib/framework-support.mjs +67 -0
- package/bundled-skills/vercel-optimize/lib/gates/build-minutes-fanout.mjs +69 -0
- package/bundled-skills/vercel-optimize/lib/gates/cold-start.mjs +66 -0
- package/bundled-skills/vercel-optimize/lib/gates/contract.mjs +79 -0
- package/bundled-skills/vercel-optimize/lib/gates/cwv-poor.mjs +87 -0
- package/bundled-skills/vercel-optimize/lib/gates/external-api-slow.mjs +55 -0
- package/bundled-skills/vercel-optimize/lib/gates/hard-gates.mjs +73 -0
- package/bundled-skills/vercel-optimize/lib/gates/index.mjs +45 -0
- package/bundled-skills/vercel-optimize/lib/gates/isr-overrevalidation.mjs +62 -0
- package/bundled-skills/vercel-optimize/lib/gates/middleware-heavy.mjs +51 -0
- package/bundled-skills/vercel-optimize/lib/gates/observability-events-attribution.mjs +56 -0
- package/bundled-skills/vercel-optimize/lib/gates/platform-bot-protection.mjs +115 -0
- package/bundled-skills/vercel-optimize/lib/gates/platform-fluid-compute.mjs +83 -0
- package/bundled-skills/vercel-optimize/lib/gates/region-misconfig.mjs +64 -0
- package/bundled-skills/vercel-optimize/lib/gates/route-errors.mjs +80 -0
- package/bundled-skills/vercel-optimize/lib/gates/scanner-driven.mjs +122 -0
- package/bundled-skills/vercel-optimize/lib/gates/select-candidates.mjs +134 -0
- package/bundled-skills/vercel-optimize/lib/gates/slow-route.mjs +88 -0
- package/bundled-skills/vercel-optimize/lib/gates/types.d.ts +38 -0
- package/bundled-skills/vercel-optimize/lib/gates/uncached-route.mjs +93 -0
- package/bundled-skills/vercel-optimize/lib/gates/usage-spike-triage.mjs +121 -0
- package/bundled-skills/vercel-optimize/lib/grade-recommendation.mjs +155 -0
- package/bundled-skills/vercel-optimize/lib/impact-label.mjs +126 -0
- package/bundled-skills/vercel-optimize/lib/impact-magnitude.mjs +60 -0
- package/bundled-skills/vercel-optimize/lib/investigation-brief.mjs +610 -0
- package/bundled-skills/vercel-optimize/lib/observation-safety.mjs +174 -0
- package/bundled-skills/vercel-optimize/lib/project-facts.mjs +99 -0
- package/bundled-skills/vercel-optimize/lib/queries.mjs +315 -0
- package/bundled-skills/vercel-optimize/lib/reconcile-candidates.mjs +372 -0
- package/bundled-skills/vercel-optimize/lib/render-report.mjs +955 -0
- package/bundled-skills/vercel-optimize/lib/repo-root.mjs +86 -0
- package/bundled-skills/vercel-optimize/lib/route-normalize.mjs +220 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/bot-protection-certainty.mjs +38 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/cache-tag-invalidation-certainty.mjs +30 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/count-correct.mjs +52 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/function-duration-invocations.mjs +38 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/index.mjs +79 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/middleware-conflict.mjs +36 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/missing-citation.mjs +16 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/pre-release.mjs +74 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/rate-limit.mjs +67 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/rendering-mode-mislabel.mjs +38 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/undeclared-dep.mjs +78 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/vercel-directive-strip.mjs +37 -0
- package/bundled-skills/vercel-optimize/lib/sanitizers/window-units.mjs +32 -0
- package/bundled-skills/vercel-optimize/lib/scanners/cache-components-suspense-dedupe.mjs +109 -0
- package/bundled-skills/vercel-optimize/lib/scanners/edge-heavy-import.mjs +94 -0
- package/bundled-skills/vercel-optimize/lib/scanners/force-dynamic.mjs +42 -0
- package/bundled-skills/vercel-optimize/lib/scanners/headers-in-page.mjs +44 -0
- package/bundled-skills/vercel-optimize/lib/scanners/index.mjs +35 -0
- package/bundled-skills/vercel-optimize/lib/scanners/large-static-asset.mjs +92 -0
- package/bundled-skills/vercel-optimize/lib/scanners/max-age-without-s-maxage.mjs +42 -0
- package/bundled-skills/vercel-optimize/lib/scanners/middleware-broad-matcher.mjs +55 -0
- package/bundled-skills/vercel-optimize/lib/scanners/missing-cache-headers.mjs +90 -0
- package/bundled-skills/vercel-optimize/lib/scanners/prisma-include-tree.mjs +42 -0
- package/bundled-skills/vercel-optimize/lib/scanners/region-pin-in-config.mjs +88 -0
- package/bundled-skills/vercel-optimize/lib/scanners/source-maps-production.mjs +36 -0
- package/bundled-skills/vercel-optimize/lib/scanners/sveltekit-prerender-missing.mjs +43 -0
- package/bundled-skills/vercel-optimize/lib/scanners/turbo-force-bypass.mjs +129 -0
- package/bundled-skills/vercel-optimize/lib/scanners/unoptimized-image.mjs +113 -0
- package/bundled-skills/vercel-optimize/lib/scanners/use-cache-date-stamp.mjs +106 -0
- package/bundled-skills/vercel-optimize/lib/support-topics.mjs +355 -0
- package/bundled-skills/vercel-optimize/lib/throttle.mjs +273 -0
- package/bundled-skills/vercel-optimize/lib/util.mjs +17 -0
- package/bundled-skills/vercel-optimize/lib/vercel.mjs +784 -0
- package/bundled-skills/vercel-optimize/lib/verify-claim.mjs +1296 -0
- package/bundled-skills/vercel-optimize/lib/workspace-resolver.mjs +521 -0
- package/bundled-skills/vercel-optimize/references/candidates.md +176 -0
- package/bundled-skills/vercel-optimize/references/data-collection.md +218 -0
- package/bundled-skills/vercel-optimize/references/docs-library.json +683 -0
- package/bundled-skills/vercel-optimize/references/doctrine.md +105 -0
- package/bundled-skills/vercel-optimize/references/observability-plus.md +108 -0
- package/bundled-skills/vercel-optimize/references/playbooks/README.md +53 -0
- package/bundled-skills/vercel-optimize/references/playbooks/ai-application.md +32 -0
- package/bundled-skills/vercel-optimize/references/playbooks/api-service.md +30 -0
- package/bundled-skills/vercel-optimize/references/playbooks/content-site.md +30 -0
- package/bundled-skills/vercel-optimize/references/playbooks/ecommerce.md +30 -0
- package/bundled-skills/vercel-optimize/references/playbooks/marketing.md +30 -0
- package/bundled-skills/vercel-optimize/references/playbooks/saas.md +31 -0
- package/bundled-skills/vercel-optimize/references/playbooks/sveltekit.md +75 -0
- package/bundled-skills/vercel-optimize/references/recommendations.md +203 -0
- package/bundled-skills/vercel-optimize/references/scanner-patterns.md +251 -0
- package/bundled-skills/vercel-optimize/references/scoring.md +205 -0
- package/bundled-skills/vercel-optimize/references/support-topics/README.md +46 -0
- package/bundled-skills/vercel-optimize/references/support-topics/astro-edge-middleware-scope.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/astro-output-mode-and-isr.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/auth-preserving-parallelization.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/bot-protection-product-guardrails.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/build-minutes-monorepo-fanout.md +23 -0
- package/bundled-skills/vercel-optimize/references/support-topics/cache-components-static-shell-boundaries.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/cache-components-suspense-dedupe-pitfall.md +23 -0
- package/bundled-skills/vercel-optimize/references/support-topics/cdn-cache-auth-safety.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/cold-start-initialization-bundle.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/core-web-vitals-client-bottlenecks.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/database-egress-pooling-region.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/dynamic-rendering-traps.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/external-api-critical-path-platform.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/external-api-critical-path.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/fast-data-transfer-payloads.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/fluid-compute-caveats.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/function-duration-io-and-after.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/function-invocation-reduction.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/function-region-misconfiguration-ttfb.md +23 -0
- package/bundled-skills/vercel-optimize/references/support-topics/image-optimization-cost-control.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/isr-revalidation-static-generation.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/middleware-proxy-edge-cost.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/next-fetch-revalidate-floor.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/next-font-cls-self-hosting.md +23 -0
- package/bundled-skills/vercel-optimize/references/support-topics/next-heavy-ui-lazy-load-boundaries.md +23 -0
- package/bundled-skills/vercel-optimize/references/support-topics/next-image-lcp-preload-sizes.md +23 -0
- package/bundled-skills/vercel-optimize/references/support-topics/next-route-handler-get-cache-defaults.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/next-script-third-party-strategy.md +23 -0
- package/bundled-skills/vercel-optimize/references/support-topics/nextjs-version-cache-semantics.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/not-found-catchall-request-waste.md +23 -0
- package/bundled-skills/vercel-optimize/references/support-topics/nuxt-route-rules-cache-isr.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/observability-events-cost-attribution.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/post-response-work-waituntil.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/route-error-durable-offload.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/route-error-runtime-limits.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/runtime-cache-reusable-data.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/sveltekit-isr-prerender-safety.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/sveltekit-split-cold-start-tradeoff.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/usage-spike-triage.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/use-cache-date-stamp-isr-write-amplifier.md +23 -0
- package/bundled-skills/vercel-optimize/references/support-topics/use-cache-remote-shared-origin-data.md +22 -0
- package/bundled-skills/vercel-optimize/references/support-topics/workflow-resumable-stream-routes.md +23 -0
- package/bundled-skills/vercel-optimize/references/verification.md +102 -0
- package/bundled-skills/vercel-optimize/references/voice.md +76 -0
- package/bundled-skills/vercel-optimize/scripts/budget-summary.mjs +56 -0
- package/bundled-skills/vercel-optimize/scripts/build-docs.mjs +74 -0
- package/bundled-skills/vercel-optimize/scripts/check-citations.mjs +81 -0
- package/bundled-skills/vercel-optimize/scripts/check-docs-fresh.mjs +93 -0
- package/bundled-skills/vercel-optimize/scripts/collect-signals.mjs +576 -0
- package/bundled-skills/vercel-optimize/scripts/collect-sub-agent-outputs.mjs +296 -0
- package/bundled-skills/vercel-optimize/scripts/deep-dive.mjs +319 -0
- package/bundled-skills/vercel-optimize/scripts/gate-investigations.mjs +166 -0
- package/bundled-skills/vercel-optimize/scripts/merge-signals.mjs +192 -0
- package/bundled-skills/vercel-optimize/scripts/prepare-investigation-brief.mjs +231 -0
- package/bundled-skills/vercel-optimize/scripts/reconcile-candidates.mjs +62 -0
- package/bundled-skills/vercel-optimize/scripts/render-report.mjs +437 -0
- package/bundled-skills/vercel-optimize/scripts/scan-codebase.mjs +313 -0
- package/bundled-skills/vercel-optimize/scripts/verify-and-regen.mjs +346 -0
- package/bundled-skills/vercel-optimize/scripts/verify-finding.mjs +19 -0
- package/bundled-skills/vercel-react-view-transitions/SKILL.md +327 -0
- package/bundled-skills/vercel-react-view-transitions/references/css-recipes.md +242 -0
- package/bundled-skills/vercel-react-view-transitions/references/implementation.md +182 -0
- package/bundled-skills/vercel-react-view-transitions/references/nextjs.md +176 -0
- package/bundled-skills/vercel-react-view-transitions/references/patterns.md +262 -0
- package/package.json +2 -2
- package/skills_index.json +312 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vercel-optimize
|
|
3
|
+
description: "Audit deployed Vercel apps for cost and performance issues using metrics, project config, code scans, and version-aware recommendations."
|
|
4
|
+
risk: safe
|
|
5
|
+
source: "https://github.com/vercel-labs/agent-skills"
|
|
6
|
+
date_added: "2026-06-02"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Vercel Optimize
|
|
10
|
+
|
|
11
|
+
Run an observability-first Vercel optimization audit. Do not inspect source files until `signals.json` exists and a deterministic gate points to a route, file, or project setting.
|
|
12
|
+
|
|
13
|
+
Core doctrine: read [references/doctrine.md](references/doctrine.md) if any rule is unclear.
|
|
14
|
+
|
|
15
|
+
- Metrics first. Recommendations start from Vercel production signals, not repo-wide grep.
|
|
16
|
+
- Deterministic gates. `scripts/gate-investigations.mjs` decides what deserves investigation.
|
|
17
|
+
- Candidate-bound scope. Read only files named by a candidate or a route-local import chain.
|
|
18
|
+
- Version-aware citations. Use only `references/docs-library.json`; invalid or version-mismatched citations are stripped.
|
|
19
|
+
- Customer copy. Read [references/voice.md](references/voice.md) before writing report text or chat output.
|
|
20
|
+
|
|
21
|
+
## When to Use
|
|
22
|
+
- Use this skill when the task matches this description: Audit deployed Vercel apps for cost and performance issues using metrics, project config, code scans, and version-aware recommendations.
|
|
23
|
+
|
|
24
|
+
## Prerequisites
|
|
25
|
+
|
|
26
|
+
- Vercel CLI v53+ with `vercel metrics`, `vercel usage`, `vercel contract`, and `vercel api`.
|
|
27
|
+
- Authenticated CLI session: `vercel login`.
|
|
28
|
+
- Linked app directory: `vercel link`. `VERCEL_PROJECT_ID` can help resolve project config, but `vercel metrics` still requires directory linkage. The link or environment must include the intended project org/team/user scope so the collector can resolve a CLI-safe `--scope` and keep `vercel metrics`, `vercel usage`, and `vercel contract` on the same account.
|
|
29
|
+
- Node.js 20+.
|
|
30
|
+
- Observability Plus for route-level metric-backed recommendations.
|
|
31
|
+
|
|
32
|
+
Never put auth tokens in shell commands. Do not type `VERCEL_TOKEN=...`, `--token ...`, or `Authorization: Bearer ...` into commands that may be echoed in chat.
|
|
33
|
+
|
|
34
|
+
## Framework Support
|
|
35
|
+
|
|
36
|
+
The preflight reads `package.json` and sets expectations before metric fan-out.
|
|
37
|
+
|
|
38
|
+
| Framework | Status | Notes |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| Next.js App Router | supported | strongest route mapping, scanners, playbooks, citations |
|
|
41
|
+
| Next.js Pages Router | supported | scoped to Pages Router idioms when detected |
|
|
42
|
+
| SvelteKit | supported | route mapping for `src/routes` files and SvelteKit scanner |
|
|
43
|
+
| Nuxt | supported | route mapping plus generic/platform checks; fewer framework-specific recs |
|
|
44
|
+
| Astro | limited | route mapping plus generic checks; fewer framework-specific recs |
|
|
45
|
+
| Hono / Remix / unknown | blocked by default | continue only if the user accepts a limited platform/code-only audit |
|
|
46
|
+
|
|
47
|
+
If unsupported, stop and ask before scanning or gating:
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
This project uses <framework>. Vercel Optimize supports metric-backed code recommendations for Next.js, SvelteKit, and Nuxt. Astro support is limited. For <framework>, I can still run a limited platform/scanner audit, but route-level Vercel metrics may not map back to source files.
|
|
51
|
+
|
|
52
|
+
Do you want me to continue with the limited audit, or stop here?
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
If the user continues, rerun collection with `--continue-unsupported-framework`.
|
|
56
|
+
|
|
57
|
+
## Run Directory
|
|
58
|
+
|
|
59
|
+
Use a fresh run directory for every audit. Do not reuse briefs, sub-agent outputs, or reports across runs.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
RUN_DIR="$(mktemp -d -t vercel-optimize-XXXXXX)"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Pipeline
|
|
66
|
+
|
|
67
|
+
### 1. Collect, scan, and merge signals
|
|
68
|
+
|
|
69
|
+
Run from the linked app directory or pass `--cwd` where a script supports it. Keep stdout JSON separate from stderr logs. Do not combine streams.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
node scripts/collect-signals.mjs [projectId] > "$RUN_DIR/vercel-signals.json" 2> "$RUN_DIR/collect.stderr"
|
|
73
|
+
node -e 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))' "$RUN_DIR/vercel-signals.json"
|
|
74
|
+
|
|
75
|
+
node scripts/scan-codebase.mjs <repo-root> > "$RUN_DIR/codebase.json"
|
|
76
|
+
node scripts/merge-signals.mjs "$RUN_DIR/vercel-signals.json" "$RUN_DIR/codebase.json" --out "$RUN_DIR/signals.json"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Collection details, schemas, metric IDs, and degradation behavior live in [references/data-collection.md](references/data-collection.md). The metric registry is [lib/queries.mjs](lib/queries.mjs); keep all queries on the shared 14-day window.
|
|
80
|
+
|
|
81
|
+
`collect-signals.mjs` resolves the linked project owner to `commandScope.cliScope` and verifies that the resolved account can read the resolved project before it checks Observability Plus. Downstream scripts reuse that scope for every Vercel CLI command that accepts `--scope`. Do not run `vercel usage`, `vercel metrics`, or `vercel contract` manually without the same scope; unscoped usage can report the user's personal organization while route metrics come from the team project.
|
|
82
|
+
|
|
83
|
+
If project or scope resolution is ambiguous, stop and ask the user which Vercel project and team/personal scope they want audited. Do not infer the intended scope from the current `vercel whoami` team, and do not proceed with metrics, usage, or contract collection until the link, an exact project match in `.vercel/repo.json`, or `VERCEL_PROJECT_ID` + `VERCEL_ORG_ID` identifies the intended account.
|
|
84
|
+
|
|
85
|
+
Use this prompt for `PROJECT_SCOPE_UNRESOLVED`, `SCOPE_UNRESOLVED`, or `PROJECT_SCOPE_MISMATCH`:
|
|
86
|
+
|
|
87
|
+
```text
|
|
88
|
+
I can't safely identify the Vercel project and account for this audit yet.
|
|
89
|
+
|
|
90
|
+
Please confirm the Vercel project name or ID and the team slug/name, or tell me it's under your personal account. Once confirmed, I'll relink or rerun collection against that exact scope before checking metrics.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 1.1 Stop on blockers
|
|
94
|
+
|
|
95
|
+
Check blockers before gating:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
jq '{frameworkSupportBlocker, observabilityPlus, observabilityPlusUsable, observabilityPlusBlocker, observabilityPlusBlockerDetail}' "$RUN_DIR/signals.json"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Required actions:
|
|
102
|
+
|
|
103
|
+
- `frameworkSupportBlocker === "unsupported_framework"`: use the unsupported-framework prompt above.
|
|
104
|
+
- `PROJECT_SCOPE_UNRESOLVED`, `SCOPE_UNRESOLVED`, or `PROJECT_SCOPE_MISMATCH`: stop and ask which Vercel project and team/personal scope the user wants audited. For team projects, rerun after `vercel link --yes --project <project-name-or-id> --team <team-slug>`; for personal projects, rerun after linking under the intended user account or after setting both `VERCEL_PROJECT_ID` and `VERCEL_ORG_ID`.
|
|
105
|
+
- `observabilityPlusBlocker === null`: continue.
|
|
106
|
+
- `no_traffic`: tell the user route metrics are sparse; continue only if they accept limited output.
|
|
107
|
+
- `payment_required` or `no_oplus_probe`: render [references/observability-plus.md](references/observability-plus.md) verbatim and ask.
|
|
108
|
+
- `project_disabled`: tell the user to enable Observability Plus for the project or accept a limited audit.
|
|
109
|
+
- `daily_quota_exceeded`: stop and tell the user the Observability query quota is exhausted; retry after the next UTC midnight reset, or ask whether to continue with a limited code-only audit.
|
|
110
|
+
- `not_linked`: link the app directory, then rerun Step 1. If app path and project are known:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
vercel link --yes --project <project-name-or-id> --cwd <app-dir>
|
|
114
|
+
# add --team <team-id-or-slug> when known
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- `forbidden` or `project_not_found`: fix auth/team scope. Do not pitch Observability Plus.
|
|
118
|
+
- `all_failed_other`: show the raw error code and ask whether to continue in limited code-only mode.
|
|
119
|
+
|
|
120
|
+
Do not silently fall back to code-only mode. If the user accepts a limited audit, rerun collection with:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
node scripts/collect-signals.mjs [projectId] --continue-without-observability > "$RUN_DIR/vercel-signals.json" 2> "$RUN_DIR/collect.stderr"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Then scan and merge again.
|
|
127
|
+
|
|
128
|
+
### 2. Gate candidates
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
node scripts/gate-investigations.mjs "$RUN_DIR/signals.json" > "$RUN_DIR/gate.json"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Output shape:
|
|
135
|
+
|
|
136
|
+
- `toLaunch`: code-scope candidates to investigate.
|
|
137
|
+
- `platform`: project/account-scope recommendations.
|
|
138
|
+
- `gated`: skipped, covered, or disqualified candidates that must still appear in the report.
|
|
139
|
+
- `budget`: candidate budget and selection mode.
|
|
140
|
+
|
|
141
|
+
Default budget is 6 code-scope candidates with a diversity guardrail. To expand:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
node scripts/gate-investigations.mjs "$RUN_DIR/signals.json" --max-candidates 12 > "$RUN_DIR/gate.json"
|
|
145
|
+
node scripts/gate-investigations.mjs "$RUN_DIR/signals.json" --max-candidates all > "$RUN_DIR/gate.json"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Generated candidate docs: [references/candidates.md](references/candidates.md).
|
|
149
|
+
|
|
150
|
+
### 2.1 Ask about audit scope when needed
|
|
151
|
+
|
|
152
|
+
Before deep-dive, run:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
node scripts/budget-summary.mjs "$RUN_DIR/gate.json" --format json > "$RUN_DIR/budget-summary.json"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
If `shouldAsk` is false, continue.
|
|
159
|
+
|
|
160
|
+
If `shouldAsk` is true:
|
|
161
|
+
|
|
162
|
+
1. Print `exactChatMessage.body` exactly as returned. Do not summarize, truncate, reorder, or rewrite it.
|
|
163
|
+
2. Then ask `questionText` using `questionPayload` when the host supports structured questions.
|
|
164
|
+
3. If the user chooses a different number, rerun the gate with `--max-candidates <choice>`.
|
|
165
|
+
|
|
166
|
+
Never put the long preview inside the question field. The preview and the question are separate surfaces.
|
|
167
|
+
|
|
168
|
+
### 2.2 Deep-dive and reconcile
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
node scripts/deep-dive.mjs "$RUN_DIR/signals.json" "$RUN_DIR/gate.json" --cwd <project-dir> > "$RUN_DIR/investigation-evidence.json"
|
|
172
|
+
|
|
173
|
+
node scripts/reconcile-candidates.mjs "$RUN_DIR/investigation-evidence.json" \
|
|
174
|
+
--gate "$RUN_DIR/gate.json" \
|
|
175
|
+
--out "$RUN_DIR/reconciled-investigation.json"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
`--cwd` must be the linked project directory so `deep-dive.mjs` can verify the same project link and reuse `signals.json.commandScope.cliScope` for any follow-up `vercel metrics` calls.
|
|
179
|
+
|
|
180
|
+
Reconciliation deterministically converts disproven candidates into observations before any source investigation:
|
|
181
|
+
|
|
182
|
+
- `metric_mismatch`
|
|
183
|
+
- `error_storm`
|
|
184
|
+
- `deployment_regression`
|
|
185
|
+
- `scanner_only_no_metric`
|
|
186
|
+
|
|
187
|
+
### 2.3 Generate briefs and investigate
|
|
188
|
+
|
|
189
|
+
List the work:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
node scripts/prepare-investigation-brief.mjs "$RUN_DIR/signals.json" "$RUN_DIR/reconciled-investigation.json" --list > "$RUN_DIR/briefs-manifest.json"
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Generate one brief for every entry in `briefs-manifest.json.briefs`. The `group` can be `toLaunch` or `platform`; do not generate only `toLaunch` briefs.
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
mkdir -p "$RUN_DIR/briefs" "$RUN_DIR/sub-agent-outputs"
|
|
199
|
+
node scripts/prepare-investigation-brief.mjs "$RUN_DIR/signals.json" "$RUN_DIR/reconciled-investigation.json" \
|
|
200
|
+
--group <brief.group> --index <brief.index> --out "$RUN_DIR/briefs/<brief.group>-<brief.index>.md"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Use `briefs-manifest.json.briefs[].label` for visible worker names, for example `Low cache-hit route on /docs/llm-digest/[...slug]`, not `toLaunch-7`.
|
|
204
|
+
|
|
205
|
+
Fan-out rule:
|
|
206
|
+
|
|
207
|
+
- 1-2 briefs: investigate inline.
|
|
208
|
+
- 3+ briefs: spawn one sub-agent per brief when the host supports it.
|
|
209
|
+
- Hosts without sub-agents: run inline serially.
|
|
210
|
+
|
|
211
|
+
Sub-agent contract:
|
|
212
|
+
|
|
213
|
+
- The brief is the whole prompt.
|
|
214
|
+
- Read only files listed in the brief, plus route-local imports when needed.
|
|
215
|
+
- Emit one JSON recommendation or one JSON no-change finding using [references/recommendations.md](references/recommendations.md).
|
|
216
|
+
- Do not cite URLs outside the provided citation subset.
|
|
217
|
+
- Do not recommend framework features unavailable in the detected version.
|
|
218
|
+
|
|
219
|
+
If a sub-agent reaches for repo-wide grep, the candidate is malformed; drop or abstain rather than widening scope.
|
|
220
|
+
|
|
221
|
+
### 2.4 Collect outputs
|
|
222
|
+
|
|
223
|
+
Save each raw investigation result in `$RUN_DIR/sub-agent-outputs/`, then collect:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
node scripts/collect-sub-agent-outputs.mjs \
|
|
227
|
+
--manifest "$RUN_DIR/briefs-manifest.json" \
|
|
228
|
+
--out "$RUN_DIR/recommendations.json" \
|
|
229
|
+
"$RUN_DIR/sub-agent-outputs/"
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The collector extracts JSON, prepends pre-resolved records, enforces manifest order, and fails on missing, duplicate, unknown, or mismatched `candidateRef` values.
|
|
233
|
+
|
|
234
|
+
### 3. Verify recommendations
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
node scripts/verify-and-regen.mjs "$RUN_DIR/recommendations.json" \
|
|
238
|
+
--signals "$RUN_DIR/signals.json" \
|
|
239
|
+
--repo-root <project-dir> \
|
|
240
|
+
--out "$RUN_DIR/verify.json"
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
This script extracts claims, verifies files/citations/version fit, grades quality, applies sanitizers, emits `verifiedRecommendations`, `withheldRecommendations`, `renderableRecommendations`, and creates `regenPlan` for failed or unsafe recommendations.
|
|
244
|
+
|
|
245
|
+
Recommendation schema, writing rules, sanitizer order, and grading rules: [references/recommendations.md](references/recommendations.md). Verification rules: [references/verification.md](references/verification.md).
|
|
246
|
+
|
|
247
|
+
For each `regenPlan` entry, rerun the same brief with a `Previous attempt failed these checks` section listing `topFailures`. Keep the regenerated output only if verification improves without gutting citations.
|
|
248
|
+
|
|
249
|
+
### 4. Render report and final message
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
node scripts/render-report.mjs "$RUN_DIR/verify.json" "$RUN_DIR/gate.json" "$RUN_DIR/signals.json" \
|
|
253
|
+
--project <name> \
|
|
254
|
+
--out "$RUN_DIR/report.md" \
|
|
255
|
+
--message-out "$RUN_DIR/final-message.json"
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Use `--debug-out "$RUN_DIR/debug.json"` only when developing the skill. Customer Markdown and chat output must not expose `passRate`, `quality`, sanitizer trails, raw sub-agent names, or other implementation fields.
|
|
259
|
+
|
|
260
|
+
After rendering, print `final-message.json.body` verbatim and stop. Do not add highlights, debug notes, raw counts, sub-agent summaries, or extra explanation. Render-time dedupe, platform caps, and hard-safety drops can change the customer-visible count, so never summarize from raw `verify.json`.
|
|
261
|
+
|
|
262
|
+
Report structure and impact framing: [references/scoring.md](references/scoring.md).
|
|
263
|
+
|
|
264
|
+
## Recommendation Rules
|
|
265
|
+
|
|
266
|
+
Every recommendation must:
|
|
267
|
+
|
|
268
|
+
- Trace to a launched candidate, platform candidate, pre-resolved observation, or verified traffic-independent scanner finding.
|
|
269
|
+
- Include observed metric evidence from `signals.json` or `evidence.deepDive`.
|
|
270
|
+
- Cite verified files with line numbers when code is involved.
|
|
271
|
+
- Include at least one allowed citation that applies to the detected framework/version.
|
|
272
|
+
- Use precise observed performance numbers.
|
|
273
|
+
- Use cost magnitude phrases only; never customer-facing `$N` savings.
|
|
274
|
+
- Do not recommend duration reductions for Vercel Workflow runtime endpoints (`/.well-known/workflow/v1/*`). These are generated orchestration routes for durable step/flow execution and should be hard-gated before investigation.
|
|
275
|
+
- Workflow recommendations must name the boundary being changed. Valid examples: enqueue durable work and return a run ID instead of awaiting completion, fix stream replay/closure/locks, or reduce verified excess Workflow Steps/Storage. Do not infer cost savings from Workflow endpoint wall-clock duration.
|
|
276
|
+
- For streaming, SSE, resumable chat, or other intentionally long-lived routes, do not frame wall-clock function duration as a problem by itself. Require evidence of avoidable pre-first-byte work, high active CPU, duplicate invocations, or post-response work that can move out of the user-visible path.
|
|
277
|
+
- Name a specific cache policy when recommending caching.
|
|
278
|
+
- Keep unsafe responses dynamic unless evidence proves they are safe to cache: auth-sensitive paths, errors, fallback responses, missing content, invalid requests, geolocation/device-varying output, and unversioned dynamic URLs.
|
|
279
|
+
|
|
280
|
+
Never recommend "verify X is on" for facts already present in `signals.project`, including Fluid compute status, memory tier, regions, in-function concurrency, and timeout.
|
|
281
|
+
|
|
282
|
+
## Scanner Rules
|
|
283
|
+
|
|
284
|
+
Scanner findings are supplementary. Drop findings annotated `COLD-PATH` or `NO-ROUTE-MAPPING` unless the scanner declares `metadata.trafficIndependent === true`.
|
|
285
|
+
|
|
286
|
+
Traffic-independent examples: middleware matcher, source maps, React Compiler config, build settings. Route-local cache or data-fetch patterns need route-level traffic evidence.
|
|
287
|
+
|
|
288
|
+
Scanner docs: [references/scanner-patterns.md](references/scanner-patterns.md).
|
|
289
|
+
|
|
290
|
+
## Final Customer Terms
|
|
291
|
+
|
|
292
|
+
Use:
|
|
293
|
+
|
|
294
|
+
- `recommendations ready`
|
|
295
|
+
- `observations from investigation`
|
|
296
|
+
- `investigated, no change recommended`
|
|
297
|
+
- `not investigated in this run`
|
|
298
|
+
|
|
299
|
+
Avoid:
|
|
300
|
+
|
|
301
|
+
- `sub-agent`
|
|
302
|
+
- `abstention`
|
|
303
|
+
- `passRate`
|
|
304
|
+
- `quality score`
|
|
305
|
+
- `gate`
|
|
306
|
+
- `LLM`
|
|
307
|
+
|
|
308
|
+
## Failure Copy
|
|
309
|
+
|
|
310
|
+
Use these messages without adding sales copy or process detail.
|
|
311
|
+
|
|
312
|
+
**No traffic in the last 14 days:**
|
|
313
|
+
|
|
314
|
+
> This project has no meaningful traffic in the last 14 days, so route-level metrics are sparse. I can still check traffic-independent scanner findings and project settings, but I cannot rank route fixes until traffic accumulates.
|
|
315
|
+
|
|
316
|
+
**Route-level metrics unavailable:**
|
|
317
|
+
|
|
318
|
+
> Use the verbatim choice template in [references/observability-plus.md](references/observability-plus.md). Do not silently fall back to code-only mode; present the two-path choice: enable Observability Plus and rerun the metric-backed audit, or accept a limited code-only run.
|
|
319
|
+
|
|
320
|
+
**Project is not linked:**
|
|
321
|
+
|
|
322
|
+
> This worktree is not linked to a Vercel project. Run `vercel link --yes --project <project-name-or-id> --cwd <app-dir>` and rerun the audit. If the team is known, add `--team <team-id-or-slug>`.
|
|
323
|
+
|
|
324
|
+
**Most route-to-file mappings failed:**
|
|
325
|
+
|
|
326
|
+
> The route inventory matched fewer than half of the routes we saw in observability. This is common in monorepos with custom routing. I've surfaced what I can match; the rest appear in the "Not investigated in this run" section.
|
|
327
|
+
|
|
328
|
+
## Limitations
|
|
329
|
+
- Use this skill only when the task clearly matches the scope described above.
|
|
330
|
+
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
|
|
331
|
+
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Auth routes carry user state and must not be cached at CDN edge.
|
|
2
|
+
|
|
3
|
+
export const AUTH_ROUTE_REGEX =
|
|
4
|
+
/(login|logout|auth|account|dashboard|checkout|cart|profile|session|me)(?:\/|$)/i;
|
|
5
|
+
|
|
6
|
+
export function isAuthRoute(route) {
|
|
7
|
+
return AUTH_ROUTE_REGEX.test(String(route ?? ''));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Non-cache candidates pass through — errors/slowness on auth routes still warrant investigation.
|
|
11
|
+
export function applyAuthDisqualifier(candidate) {
|
|
12
|
+
const cacheKinds = new Set(['uncached_route', 'cache_header_gap']);
|
|
13
|
+
if (!cacheKinds.has(candidate.kind)) return candidate;
|
|
14
|
+
if (!candidate.route) return candidate;
|
|
15
|
+
if (isAuthRoute(candidate.route)) {
|
|
16
|
+
return {
|
|
17
|
+
...candidate,
|
|
18
|
+
disqualified: true,
|
|
19
|
+
disqualifyReason: 'auth-like route — should not be cached at edge',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return candidate;
|
|
23
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// Checkpoint between gate and deep-dive. Asks only when budget was default AND >=1 candidate got skipped — every question is a tax on the user.
|
|
2
|
+
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { formatCandidateLine } from './display-labels.mjs';
|
|
5
|
+
|
|
6
|
+
const TOP_INVESTIGATING_PREVIEW = 5;
|
|
7
|
+
const MAX_FULL_INVESTIGATING_PREVIEW = 10;
|
|
8
|
+
export function buildBudgetSummary(gate) {
|
|
9
|
+
const toLaunch = Array.isArray(gate?.toLaunch) ? gate.toLaunch : [];
|
|
10
|
+
const gated = Array.isArray(gate?.gated) ? gate.gated : [];
|
|
11
|
+
const budgetSource = gate?.budget?.source ?? 'default';
|
|
12
|
+
const currentBudget =
|
|
13
|
+
typeof gate?.budget?.maxCandidates === 'number'
|
|
14
|
+
? gate.budget.maxCandidates
|
|
15
|
+
: (gate?.budget?.maxCandidates === 'all' ? Infinity : 6);
|
|
16
|
+
|
|
17
|
+
// Only budget skips can be reached by raising the budget; disqualified/coveredBy can't.
|
|
18
|
+
const skippedByBudget = gated.filter((g) =>
|
|
19
|
+
typeof g.gatedReason === 'string' && g.gatedReason.startsWith('skippedByBudget')
|
|
20
|
+
);
|
|
21
|
+
const skipped = skippedByBudget.length;
|
|
22
|
+
const totalPassed = toLaunch.length + skipped;
|
|
23
|
+
|
|
24
|
+
const reasonParts = [];
|
|
25
|
+
if (budgetSource !== 'default') reasonParts.push(`user pre-set budget via ${budgetSource}`);
|
|
26
|
+
if (skipped === 0) reasonParts.push('no candidates skipped by budget');
|
|
27
|
+
const shouldAsk = budgetSource === 'default' && skipped > 0;
|
|
28
|
+
const reason = shouldAsk
|
|
29
|
+
? `default budget skipped ${skipped} candidate(s); ask user whether to expand`
|
|
30
|
+
: reasonParts.join('; ') || 'no expansion possible';
|
|
31
|
+
|
|
32
|
+
const summarize = (c) => ({
|
|
33
|
+
kind: c.kind,
|
|
34
|
+
route: c.route ?? c.hostname ?? null,
|
|
35
|
+
displayRoute: c.displayRoute ?? null,
|
|
36
|
+
o11ySignal: c.o11ySignal ?? null,
|
|
37
|
+
priority: c.priority ?? null,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const investigatingPreviewCount = typeof currentBudget === 'number' && currentBudget <= MAX_FULL_INVESTIGATING_PREVIEW
|
|
41
|
+
? currentBudget
|
|
42
|
+
: TOP_INVESTIGATING_PREVIEW;
|
|
43
|
+
const topInvestigating = toLaunch.slice(0, investigatingPreviewCount).map(summarize);
|
|
44
|
+
const topSkipped = skippedByBudget.map(summarize);
|
|
45
|
+
const options = buildOptions(toLaunch.length, skipped);
|
|
46
|
+
const questionText = buildQuestionText({ shouldAsk, totalPassed, currentBudget });
|
|
47
|
+
const printContract = shouldAsk
|
|
48
|
+
? 'Print chatPreview verbatim by copying exactChatMessage.body as a chat message before asking questionText. Do not summarize, truncate, reorder, shorten, or rewrite options.'
|
|
49
|
+
: null;
|
|
50
|
+
const questionPayload = shouldAsk ? buildQuestionPayload(questionText, options) : null;
|
|
51
|
+
const chatPreview = buildChatPreview({ shouldAsk, totalPassed, currentBudget, skipped, topInvestigating, topSkipped, reason });
|
|
52
|
+
const exactChatMessage = buildExactChatMessage(chatPreview);
|
|
53
|
+
return {
|
|
54
|
+
shouldAsk,
|
|
55
|
+
reason,
|
|
56
|
+
totalPassed,
|
|
57
|
+
currentBudget: currentBudget === Infinity ? 'all' : currentBudget,
|
|
58
|
+
budgetSource,
|
|
59
|
+
skipped,
|
|
60
|
+
topInvestigating,
|
|
61
|
+
topSkipped,
|
|
62
|
+
options,
|
|
63
|
+
printContract,
|
|
64
|
+
chatPreview,
|
|
65
|
+
exactChatMessage,
|
|
66
|
+
printCheck: shouldAsk ? buildPrintCheck({ exactChatMessage, skipped }) : null,
|
|
67
|
+
questionText,
|
|
68
|
+
questionPayload,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function buildChatPreview({ shouldAsk, totalPassed, currentBudget, skipped, topInvestigating, topSkipped, reason }) {
|
|
73
|
+
if (!shouldAsk) return `Audit scope: no question needed — ${reason}.`;
|
|
74
|
+
const lines = [];
|
|
75
|
+
lines.push(`Found ${totalPassed} potential issue${totalPassed === 1 ? '' : 's'} worth checking. By default I'll inspect the ${currentBudget} strongest now; ${skipped} will stay in the report for a larger run.`);
|
|
76
|
+
lines.push(`Choose a larger scope if you want broader coverage. More checks take longer.`);
|
|
77
|
+
if (topInvestigating.length > 0) {
|
|
78
|
+
lines.push('');
|
|
79
|
+
lines.push(`Checking now${topInvestigating.length < currentBudget ? ` (${topInvestigating.length} shown)` : ''}:`);
|
|
80
|
+
topInvestigating.forEach((c, i) => lines.push(` ${i + 1}. ${formatCandidateLine(c)}`));
|
|
81
|
+
}
|
|
82
|
+
if (topSkipped.length > 0) {
|
|
83
|
+
lines.push('');
|
|
84
|
+
lines.push(`Only checked if you expand this run (${topSkipped.length}):`);
|
|
85
|
+
topSkipped.forEach((c, i) => lines.push(` ${i + 1}. ${formatCandidateLine(c)}`));
|
|
86
|
+
}
|
|
87
|
+
return lines.join('\n');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function buildExactChatMessage(body) {
|
|
91
|
+
return {
|
|
92
|
+
body,
|
|
93
|
+
lineCount: body.split('\n').length,
|
|
94
|
+
sha256: createHash('sha256').update(body).digest('hex'),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function buildPrintCheck({ exactChatMessage, skipped }) {
|
|
99
|
+
return {
|
|
100
|
+
bodyField: 'exactChatMessage.body',
|
|
101
|
+
sameAs: 'chatPreview',
|
|
102
|
+
requiredLineCount: exactChatMessage.lineCount,
|
|
103
|
+
requiredSha256: exactChatMessage.sha256,
|
|
104
|
+
requiredSkippedRows: skipped,
|
|
105
|
+
requiredSkippedHeading: `Only checked if you expand this run (${skipped}):`,
|
|
106
|
+
forbiddenSummaryPatterns: [
|
|
107
|
+
'\\btop skipped\\b',
|
|
108
|
+
'\\bmore (?:candidate|candidates|routes|entries|items|in gated list)\\b',
|
|
109
|
+
'\\b\\d+\\s*[-–—]\\s*\\d+\\.\\s+\\d+\\s+more\\b',
|
|
110
|
+
'\\betc\\.\\b',
|
|
111
|
+
],
|
|
112
|
+
instruction: 'The budget message is valid only when every line from exactChatMessage.body is preserved exactly. If you cannot verify that, print exactChatMessage.body again before asking the question.',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function buildQuestionText({ shouldAsk, totalPassed, currentBudget }) {
|
|
117
|
+
if (!shouldAsk) return '';
|
|
118
|
+
return `How many potential issues should I check in this run?`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function buildOptions(currentCount, skippedCount) {
|
|
122
|
+
if (skippedCount === 0) return [];
|
|
123
|
+
const total = currentCount + skippedCount;
|
|
124
|
+
return [
|
|
125
|
+
{
|
|
126
|
+
label: `Check ${currentCount} (default)`,
|
|
127
|
+
value: currentCount,
|
|
128
|
+
recommended: true,
|
|
129
|
+
description: 'Fastest first pass; checks the strongest cost and performance signals.',
|
|
130
|
+
rationale: 'fastest first pass; checks the strongest cost and performance signals',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
label: `Check all ${total}`,
|
|
134
|
+
value: 'all',
|
|
135
|
+
recommended: false,
|
|
136
|
+
description: 'Most complete; takes longer because every flagged route is investigated.',
|
|
137
|
+
rationale: 'most complete; takes longer because every flagged route is investigated',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
label: 'Pick a number',
|
|
141
|
+
value: 'custom',
|
|
142
|
+
recommended: false,
|
|
143
|
+
description: `Check more than ${currentCount} without running the full ${total}.`,
|
|
144
|
+
rationale: `checks more than ${currentCount} without running the full ${total}`,
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function buildQuestionPayload(questionText, options) {
|
|
150
|
+
return {
|
|
151
|
+
questions: [{
|
|
152
|
+
question: questionText,
|
|
153
|
+
header: 'Audit scope',
|
|
154
|
+
multiSelect: false,
|
|
155
|
+
options: options.map((o) => ({
|
|
156
|
+
label: o.label,
|
|
157
|
+
description: o.description ?? o.rationale,
|
|
158
|
+
})),
|
|
159
|
+
}],
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function renderBudgetSummaryMarkdown(s) {
|
|
164
|
+
const lines = [];
|
|
165
|
+
lines.push(`## Audit scope`);
|
|
166
|
+
lines.push('');
|
|
167
|
+
if (!s.shouldAsk) {
|
|
168
|
+
lines.push(`_No question needed — ${s.reason}._`);
|
|
169
|
+
return lines.join('\n');
|
|
170
|
+
}
|
|
171
|
+
for (const ln of s.chatPreview.split('\n')) lines.push(ln);
|
|
172
|
+
lines.push('');
|
|
173
|
+
lines.push('### Options');
|
|
174
|
+
lines.push('');
|
|
175
|
+
for (const o of s.options) {
|
|
176
|
+
const tag = o.recommended ? ' (recommended)' : '';
|
|
177
|
+
lines.push(`- **${o.label}${tag}** — ${o.rationale}`);
|
|
178
|
+
}
|
|
179
|
+
lines.push('');
|
|
180
|
+
lines.push(`**Question:** ${s.questionText}`);
|
|
181
|
+
return lines.join('\n');
|
|
182
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Curated doc library — the allow-list for recommender citations.
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
|
|
7
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const LIBRARY_PATH = join(HERE, '..', 'references', 'docs-library.json');
|
|
9
|
+
|
|
10
|
+
let cached;
|
|
11
|
+
|
|
12
|
+
export async function loadLibrary() {
|
|
13
|
+
if (cached) return cached;
|
|
14
|
+
const raw = await readFile(LIBRARY_PATH, 'utf-8');
|
|
15
|
+
cached = JSON.parse(raw);
|
|
16
|
+
return cached;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function isKnownUrl(url) {
|
|
20
|
+
const lib = await loadLibrary();
|
|
21
|
+
return lib.urls.some(e => e.url === url);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function lookupUrl(url) {
|
|
25
|
+
const lib = await loadLibrary();
|
|
26
|
+
return lib.urls.find(e => e.url === url);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function lookupSkillRule(ref) {
|
|
30
|
+
const lib = await loadLibrary();
|
|
31
|
+
const m = ref.match(/^([\w-]+):([\w-]+)$/);
|
|
32
|
+
if (!m) return undefined;
|
|
33
|
+
return lib.ruleSkillRefs.find(r => r.skill === m[1] && r.rule === m[2]);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Narrow semver subset: "*", "fw@*", "fw@14", "fw@>=15.0.0", "fw@<X", "fw@X.Y", "fw@X.Y.Z", "a || b".
|
|
37
|
+
export function matchesFrameworkVersion(pattern, framework, version) {
|
|
38
|
+
if (pattern === '*') return true;
|
|
39
|
+
|
|
40
|
+
if (pattern.includes('||')) {
|
|
41
|
+
return pattern.split('||').map(p => p.trim()).some(p =>
|
|
42
|
+
matchesFrameworkVersion(p, framework, version)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const m = pattern.match(/^([\w-]+)@(.+)$/);
|
|
47
|
+
if (!m) return false;
|
|
48
|
+
const [, fw, range] = m;
|
|
49
|
+
|
|
50
|
+
if (fw !== framework) return false;
|
|
51
|
+
if (range === '*') return true;
|
|
52
|
+
|
|
53
|
+
const verParts = parseVersion(version);
|
|
54
|
+
if (!verParts) return false;
|
|
55
|
+
|
|
56
|
+
let m2 = range.match(/^>=\s*(.+)$/);
|
|
57
|
+
if (m2) {
|
|
58
|
+
const min = parseVersion(m2[1]);
|
|
59
|
+
return min ? compareVersion(verParts, min) >= 0 : false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
m2 = range.match(/^<\s*(.+)$/);
|
|
63
|
+
if (m2) {
|
|
64
|
+
const max = parseVersion(m2[1]);
|
|
65
|
+
return max ? compareVersion(verParts, max) < 0 : false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (/^\d+$/.test(range)) {
|
|
69
|
+
return verParts[0] === Number(range);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
m2 = range.match(/^(\d+)\.(\d+)$/);
|
|
73
|
+
if (m2) {
|
|
74
|
+
return verParts[0] === Number(m2[1]) && verParts[1] === Number(m2[2]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const exact = parseVersion(range);
|
|
78
|
+
if (exact) return compareVersion(verParts, exact) === 0;
|
|
79
|
+
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function parseVersion(v) {
|
|
84
|
+
const m = String(v).replace(/^[v^~]+/, '').match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?/);
|
|
85
|
+
if (!m) return null;
|
|
86
|
+
return [Number(m[1]) || 0, Number(m[2]) || 0, Number(m[3]) || 0];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function compareVersion(a, b) {
|
|
90
|
+
for (let i = 0; i < 3; i++) {
|
|
91
|
+
if (a[i] !== b[i]) return a[i] - b[i];
|
|
92
|
+
}
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Filtered subset embedded in recommender prompt — LLM never sees URLs for features not in user's stack.
|
|
97
|
+
export async function libraryForStack(framework, version) {
|
|
98
|
+
const lib = await loadLibrary();
|
|
99
|
+
const matches = (frameworks) =>
|
|
100
|
+
frameworks.some(p => matchesFrameworkVersion(p, framework, version) || p === '*');
|
|
101
|
+
return {
|
|
102
|
+
urls: lib.urls.filter(e => matches(e.applicableFrameworks)),
|
|
103
|
+
ruleSkillRefs: lib.ruleSkillRefs.filter(r => matches(r.applicableFrameworks)),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export async function sanitizeCitations(rec, framework, version) {
|
|
108
|
+
const lib = await loadLibrary();
|
|
109
|
+
const strippedUnknown = [];
|
|
110
|
+
const strippedVersion = [];
|
|
111
|
+
const kept = [];
|
|
112
|
+
|
|
113
|
+
for (const cite of rec.citations ?? []) {
|
|
114
|
+
const ruleRef = await lookupSkillRule(cite);
|
|
115
|
+
if (ruleRef) {
|
|
116
|
+
if (matchesFrameworkVersion(ruleRef.applicableFrameworks.join(' || '), framework, version) || ruleRef.applicableFrameworks.includes('*')) {
|
|
117
|
+
kept.push(cite);
|
|
118
|
+
} else {
|
|
119
|
+
strippedVersion.push(cite);
|
|
120
|
+
}
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const entry = lib.urls.find(e => e.url === cite);
|
|
125
|
+
if (!entry) {
|
|
126
|
+
strippedUnknown.push(cite);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (entry.applicableFrameworks.includes('*') ||
|
|
130
|
+
entry.applicableFrameworks.some(p => matchesFrameworkVersion(p, framework, version))) {
|
|
131
|
+
kept.push(cite);
|
|
132
|
+
} else {
|
|
133
|
+
strippedVersion.push(cite);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
rec.citations = kept;
|
|
138
|
+
return { rec, strippedUnknown, strippedVersion };
|
|
139
|
+
}
|