@algolia/wizard 0.44.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +62 -22
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -3368,22 +3368,59 @@ var detectLanguageSchema = z21.object({
3368
3368
  `The prefix a bundler/framework requires for an env var to reach client-side code (e.g. "NEXT_PUBLIC_", "VITE_", "NUXT_PUBLIC_"), uppercase with a trailing underscore when non-empty. Prefer the project's own existing convention over a framework default. Empty string when the project has no client-side env var exposure (e.g. a backend-only project).`
3369
3369
  )
3370
3370
  });
3371
- var detectLanguage = () => runAgent({
3372
- instructions: [
3373
- "Analyze the codebase and determine the programming languages and frameworks used",
3374
- "If a superset language is found, exclude the subset language (e.g. TypeScript over JavaScript).",
3375
- "If a meta-framework is used, exclude the framework it builds on (e.g. Next.js over React, Rails over Rack).",
3376
- "Return the exact version",
3377
- "Exclude things like CSS frameworks, build tools, or testing frameworks",
3378
- `Determine publicEnvVarPrefix: check the project's own env var usage first (e.g. names already referenced in code, .env/.env.example); if none exists, fall back to the detected framework's known convention for exposing env vars to client-side code; use "" when the project has no such convention (e.g. a backend-only project).`,
3379
- "A brand-new project has no existing env var usage to find \u2014 one or two targeted checks (e.g. .env/.env.example, or a grep for the bundler's public-prefix convention) are enough to confirm that. Do not keep searching once those turn up nothing; fall back to the framework convention immediately.",
3380
- 'Use as few tools as possible, but do not guess. If you cant find the answer, say "unknown"',
3381
- "When done, call reportStatus"
3382
- ],
3383
- tools: ["listFiles", "changeDirectory", "readFile", "searchFiles"],
3384
- outputSchema: detectLanguageSchema,
3385
- modelSize: "small"
3386
- });
3371
+ var FRONTEND_FRAMEWORKS = /* @__PURE__ */ new Set([
3372
+ "angular",
3373
+ "astro",
3374
+ "ember",
3375
+ "javascript",
3376
+ "next",
3377
+ "nextjs",
3378
+ "nuxt",
3379
+ "preact",
3380
+ "qwik",
3381
+ "react",
3382
+ "remix",
3383
+ "solid",
3384
+ "solidjs",
3385
+ "svelte",
3386
+ "sveltekit",
3387
+ "vanilla",
3388
+ "vanillajs",
3389
+ "vue",
3390
+ "vuejs"
3391
+ ]);
3392
+ var normalizeFramework = (name) => name.toLowerCase().replace(/[^a-z0-9]/g, "");
3393
+ function prioritizeFrontendFrameworks(result) {
3394
+ const frontend = result.frameworks.filter(
3395
+ (framework) => FRONTEND_FRAMEWORKS.has(normalizeFramework(framework.name))
3396
+ );
3397
+ if (frontend.length === 0) return result;
3398
+ const remaining = result.frameworks.filter(
3399
+ (framework) => !FRONTEND_FRAMEWORKS.has(normalizeFramework(framework.name))
3400
+ );
3401
+ return { ...result, frameworks: [...frontend, ...remaining] };
3402
+ }
3403
+ var detectLanguage = async () => {
3404
+ const result = await runAgent({
3405
+ instructions: [
3406
+ "Analyze the codebase and determine the programming languages and frameworks used",
3407
+ "If a superset language is found, exclude the subset language (e.g. TypeScript over JavaScript).",
3408
+ "For frameworks, inspect the code that implements the UI and prioritize the frontend framework used by the primary UI.",
3409
+ "When a separate frontend framework exists, omit backend frameworks (e.g. report React, not Rails, when Rails serves a React UI). If no separate frontend framework exists, report the server framework that renders the UI.",
3410
+ "If a frontend meta-framework is used, exclude the framework it builds on (e.g. Next.js over React).",
3411
+ "Return the exact version",
3412
+ "Exclude things like CSS frameworks, build tools, or testing frameworks",
3413
+ `Determine publicEnvVarPrefix: check the project's own env var usage first (e.g. names already referenced in code, .env/.env.example); if none exists, fall back to the detected framework's known convention for exposing env vars to client-side code; use "" when the project has no such convention (e.g. a backend-only project).`,
3414
+ "A brand-new project has no existing env var usage to find \u2014 one or two targeted checks (e.g. .env/.env.example, or a grep for the bundler's public-prefix convention) are enough to confirm that. Do not keep searching once those turn up nothing; fall back to the framework convention immediately.",
3415
+ 'Use as few tools as possible, but do not guess. If you cant find the answer, say "unknown"',
3416
+ "When done, call reportStatus"
3417
+ ],
3418
+ tools: ["listFiles", "changeDirectory", "readFile", "searchFiles"],
3419
+ outputSchema: detectLanguageSchema,
3420
+ modelSize: "small"
3421
+ });
3422
+ return prioritizeFrontendFrameworks(result);
3423
+ };
3387
3424
 
3388
3425
  // src/actions/analyzeCodebase.ts
3389
3426
  import z22 from "zod";
@@ -3472,7 +3509,7 @@ async function runAnalysis(mode, extraInstructions = []) {
3472
3509
  // package.json
3473
3510
  var package_default = {
3474
3511
  name: "@algolia/wizard",
3475
- version: "0.44.0",
3512
+ version: "0.45.0",
3476
3513
  description: "Magically implement Algolia functionality in your codebase",
3477
3514
  type: "module",
3478
3515
  engines: {
@@ -3661,7 +3698,7 @@ function confirmed(name, version) {
3661
3698
  return { frameworks };
3662
3699
  }
3663
3700
  async function askOtherFramework(ctx) {
3664
- let prompt = "enter your framework";
3701
+ let prompt = "enter the framework used for your frontend";
3665
3702
  for (; ; ) {
3666
3703
  const answer = await ctx.requestUserInput({
3667
3704
  prompt,
@@ -3673,7 +3710,7 @@ async function askOtherFramework(ctx) {
3673
3710
  }
3674
3711
  const name = parseEntries(answer)[0]?.name;
3675
3712
  if (name) return name;
3676
- prompt = "please enter a framework name:";
3713
+ prompt = "please enter the framework used for your frontend:";
3677
3714
  }
3678
3715
  }
3679
3716
  async function confirmFramework(ctx) {
@@ -3688,9 +3725,12 @@ async function confirmFramework(ctx) {
3688
3725
  const primary = detectedFrameworks[0];
3689
3726
  if (primary) {
3690
3727
  const accepted = await ctx.requestUserInput({
3691
- prompt: `Use ${primary.name}?`,
3728
+ prompt: `Use ${primary.name} for your frontend?`,
3692
3729
  promptType: "acceptReject",
3693
- options: [`Confirm ${primary.name}`, "Use a different framework"],
3730
+ options: [
3731
+ `Confirm ${primary.name}`,
3732
+ "Use a different framework for your frontend"
3733
+ ],
3694
3734
  secondary: [{ kind: "badge", value: "[DETECTED]" }, void 0]
3695
3735
  });
3696
3736
  if (accepted === true) return confirmed(primary.name, primary.version);
@@ -3703,7 +3743,7 @@ async function confirmFramework(ctx) {
3703
3743
  0
3704
3744
  );
3705
3745
  const selection = await ctx.requestUserInput({
3706
- prompt: "select a framework",
3746
+ prompt: "select a framework for your frontend",
3707
3747
  promptType: "multipleChoice",
3708
3748
  options,
3709
3749
  secondary,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algolia/wizard",
3
- "version": "0.44.0",
3
+ "version": "0.45.0",
4
4
  "description": "Magically implement Algolia functionality in your codebase",
5
5
  "type": "module",
6
6
  "engines": {