@algolia/wizard 0.26.0-rc.118.217 → 0.26.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 +28 -20
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1922,20 +1922,8 @@ function reconcileWorkflowState(state, workflow) {
1922
1922
  const definedIds = workflow.steps.map((s) => s.id).join("\n");
1923
1923
  if (persistedIds !== definedIds) return null;
1924
1924
  for (let i = 0; i < state.steps.length; i++) {
1925
- const record = state.steps[i];
1926
- const step = workflow.steps[i];
1927
- if (record.status === "done") {
1928
- const parsed = step.outputSchema.safeParse(record.output);
1929
- if (!parsed.success) {
1930
- logger.warn(
1931
- { stepId: step.id, issues: parsed.error.issues },
1932
- "reconcileWorkflowState: persisted output for a completed step no longer matches its schema; restarting the run from scratch"
1933
- );
1934
- return null;
1935
- }
1936
- }
1937
- record.title = step.title;
1938
- record.visible = step.visible;
1925
+ state.steps[i].title = workflow.steps[i].title;
1926
+ state.steps[i].visible = workflow.steps[i].visible;
1939
1927
  }
1940
1928
  return state;
1941
1929
  }
@@ -3272,9 +3260,28 @@ import { tool as tool9 } from "ai";
3272
3260
  import z16 from "zod";
3273
3261
  import { stat as stat2 } from "node:fs/promises";
3274
3262
  import { relative as relative5 } from "node:path";
3263
+
3264
+ // src/lib/editor.ts
3265
+ import { spawn as spawn3 } from "node:child_process";
3266
+ function openInEditor(filePath) {
3267
+ const { command, args } = process.platform === "darwin" ? (
3268
+ // -t forces the default *text* editor; plain `open` on an extension
3269
+ // with no handler (.mjs, .py) pops a "choose an application" dialog.
3270
+ { command: "open", args: ["-t", filePath] }
3271
+ ) : process.platform === "win32" ? { command: "cmd", args: ["/c", "start", "", filePath] } : { command: "xdg-open", args: [filePath] };
3272
+ try {
3273
+ const child = spawn3(command, args, { stdio: "ignore", detached: true });
3274
+ child.on("error", () => {
3275
+ });
3276
+ child.unref();
3277
+ } catch {
3278
+ }
3279
+ }
3280
+
3281
+ // src/lib/tools/reviewScript.ts
3275
3282
  function reviewScriptTool(ctx) {
3276
3283
  return tool9({
3277
- description: "Show a script you have written to the user and wait while they read it. Call this as soon as the script is finished and before you run it for the first time, so nothing with a side effect happens behind their back. It shows the file path and returns once they have confirmed reviewing it.",
3284
+ description: "Show a script you have written to the user and wait while they read it. Call this as soon as the script is finished and before you run it for the first time, so nothing with a side effect happens behind their back. It opens the file in their editor and returns once they have confirmed.",
3278
3285
  inputSchema: z16.object({
3279
3286
  filePath: z16.string().describe(
3280
3287
  "Path to the script to review, relative to the project root."
@@ -3292,6 +3299,7 @@ function reviewScriptTool(ctx) {
3292
3299
  return `Refused: ${filePath} is not a file. Write the script first, then review the path you wrote.`;
3293
3300
  }
3294
3301
  return serializePrompt(async () => {
3302
+ openInEditor(resolved2.target);
3295
3303
  await useWizard.getState().requestUserInput({
3296
3304
  prompt: "",
3297
3305
  promptType: "enterToContinue",
@@ -3739,7 +3747,7 @@ async function runAnalysis(mode, extraInstructions = []) {
3739
3747
  // package.json
3740
3748
  var package_default = {
3741
3749
  name: "@algolia/wizard",
3742
- version: "0.26.0-rc.118.217",
3750
+ version: "0.26.0",
3743
3751
  description: "Magically implement Algolia functionality in your codebase",
3744
3752
  type: "module",
3745
3753
  engines: {
@@ -4493,9 +4501,9 @@ function sourceSpecificInstructions(input) {
4493
4501
  "Never fabricate, hardcode, or substitute a different file."
4494
4502
  ],
4495
4503
  generated: [
4496
- "No real data source exists; use sample records for each confirmed entity.",
4497
- "Call the generateRecord tool once per entity (entityName, attributes, count 20-50); it invents the values and unique objectIDs and writes them to a JSON file in the worktree, returning the file path. Do not write records or objectIDs yourself.",
4498
- "In the script, read and parse each returned file path at runtime using your language's standard JSON support, instead of inlining the records as literals.",
4504
+ "No real data source exists; generate sample records for the entity.",
4505
+ "Call the generateRecord tool once with a count of 100. It invents the values and unique objectIDs and writes them to a JSON file, returning the file path. Do not write records or objectIDs yourself.",
4506
+ "In the script, read and parse the returned file path at runtime using your language's standard JSON support, instead of inlining the records as literals.",
4499
4507
  "Add a prominent TODO where the developer swaps the generated records (and the JSON file under `.algolia-wizard/data/`) for their real record source."
4500
4508
  ]
4501
4509
  };
@@ -4514,7 +4522,7 @@ function ingestionInstructions(input) {
4514
4522
  return [
4515
4523
  ...input.confirmed && input.confirmed.length ? [
4516
4524
  `Create an ingestion script under "${input.ingestDir}/" at the repo root.`,
4517
- `Ingest only these confirmed entities (name, source paths, attributes): ${JSON.stringify(input.confirmed)}.`,
4525
+ `Ingest only the confirmed entity (name, source paths, attributes): ${JSON.stringify(input.confirmed)}.`,
4518
4526
  `Ingesting writes to Algolia, so the script needs a write API key and App ID \u2014 read them from the ${API_KEY_VAR} and ${APP_ID_VAR} environment variables rather than hardcoding them. The wizard sets these when it runs the script.`,
4519
4527
  `Read the index name from the ${INDEX_NAME_VAR} environment variable, which the wizard sets to "${input.targetIndex}". Never hardcode an index name or derive one from the project, file, or entity name \u2014 the write key only works for that exact index. Exit with an error if ${INDEX_NAME_VAR} is unset.`,
4520
4528
  "Write the script in the project's primary language, using Algolia's official client for that language. Do not use the raw HTTP API.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algolia/wizard",
3
- "version": "0.26.0-rc.118.217",
3
+ "version": "0.26.0",
4
4
  "description": "Magically implement Algolia functionality in your codebase",
5
5
  "type": "module",
6
6
  "engines": {