@algolia/wizard 0.26.0-rc.118.217 → 0.27.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 +51 -22
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -5,6 +5,7 @@ import { render } from "ink";
5
5
 
6
6
  // src/ui/App.tsx
7
7
  import { Box as Box17, Text as Text17, useApp, useInput as useInput7, useWindowSize as useWindowSize8 } from "ink";
8
+ import Spinner2 from "ink-spinner";
8
9
 
9
10
  // src/core/store.ts
10
11
  import { create } from "zustand";
@@ -1779,7 +1780,7 @@ function track(event, payload) {
1779
1780
  // src/ui/App.tsx
1780
1781
  import { jsx as jsx15, jsxs as jsxs16 } from "react/jsx-runtime";
1781
1782
  function App() {
1782
- const { phase, error, homeScreen, currentStepIndex, steps, inputReq } = useWizard();
1783
+ const { phase, error, homeScreen, currentStepIndex, steps, inputReq, user } = useWizard();
1783
1784
  const { exit } = useApp();
1784
1785
  const { columns, rows } = useWindowSize8();
1785
1786
  const [showLogs, setShowLogs] = useState7(false);
@@ -1850,8 +1851,19 @@ function App() {
1850
1851
  width: showSidebar ? 70 : "100%",
1851
1852
  flexGrow: 1,
1852
1853
  children: [
1854
+ phase === "preflight" && !user && /* @__PURE__ */ jsx15(Box17, { flexDirection: "column", marginBottom: 1, children: /* @__PURE__ */ jsxs16(Text17, { color: COLORS.strong, bold: true, children: [
1855
+ /* @__PURE__ */ jsx15(Spinner2, { type: "dots" }),
1856
+ " Signing in to Algolia"
1857
+ ] }) }),
1858
+ phase === "preflight" && user && /* @__PURE__ */ jsx15(Box17, { flexDirection: "column", marginBottom: 1, children: /* @__PURE__ */ jsxs16(Text17, { color: COLORS.strong, bold: true, children: [
1859
+ /* @__PURE__ */ jsx15(Spinner2, { type: "dots" }),
1860
+ " Getting things ready"
1861
+ ] }) }),
1853
1862
  phase === "authenticating" && /* @__PURE__ */ jsxs16(Box17, { flexDirection: "column", marginBottom: 1, children: [
1854
- /* @__PURE__ */ jsx15(Text17, { color: COLORS.strong, bold: true, children: "Signing in to Algolia" }),
1863
+ /* @__PURE__ */ jsxs16(Text17, { color: COLORS.strong, bold: true, children: [
1864
+ /* @__PURE__ */ jsx15(Spinner2, { type: "dots" }),
1865
+ " Signing in to Algolia"
1866
+ ] }),
1855
1867
  /* @__PURE__ */ jsx15(Text17, { color: COLORS.muted, children: "A browser window will open \u2014 complete sign-in there." })
1856
1868
  ] }),
1857
1869
  /* @__PURE__ */ jsx15(CliOutput, {}),
@@ -1922,20 +1934,8 @@ function reconcileWorkflowState(state, workflow) {
1922
1934
  const definedIds = workflow.steps.map((s) => s.id).join("\n");
1923
1935
  if (persistedIds !== definedIds) return null;
1924
1936
  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;
1937
+ state.steps[i].title = workflow.steps[i].title;
1938
+ state.steps[i].visible = workflow.steps[i].visible;
1939
1939
  }
1940
1940
  return state;
1941
1941
  }
@@ -3272,9 +3272,28 @@ import { tool as tool9 } from "ai";
3272
3272
  import z16 from "zod";
3273
3273
  import { stat as stat2 } from "node:fs/promises";
3274
3274
  import { relative as relative5 } from "node:path";
3275
+
3276
+ // src/lib/editor.ts
3277
+ import { spawn as spawn3 } from "node:child_process";
3278
+ function openInEditor(filePath) {
3279
+ const { command, args } = process.platform === "darwin" ? (
3280
+ // -t forces the default *text* editor; plain `open` on an extension
3281
+ // with no handler (.mjs, .py) pops a "choose an application" dialog.
3282
+ { command: "open", args: ["-t", filePath] }
3283
+ ) : process.platform === "win32" ? { command: "cmd", args: ["/c", "start", "", filePath] } : { command: "xdg-open", args: [filePath] };
3284
+ try {
3285
+ const child = spawn3(command, args, { stdio: "ignore", detached: true });
3286
+ child.on("error", () => {
3287
+ });
3288
+ child.unref();
3289
+ } catch {
3290
+ }
3291
+ }
3292
+
3293
+ // src/lib/tools/reviewScript.ts
3275
3294
  function reviewScriptTool(ctx) {
3276
3295
  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.",
3296
+ 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
3297
  inputSchema: z16.object({
3279
3298
  filePath: z16.string().describe(
3280
3299
  "Path to the script to review, relative to the project root."
@@ -3292,6 +3311,7 @@ function reviewScriptTool(ctx) {
3292
3311
  return `Refused: ${filePath} is not a file. Write the script first, then review the path you wrote.`;
3293
3312
  }
3294
3313
  return serializePrompt(async () => {
3314
+ openInEditor(resolved2.target);
3295
3315
  await useWizard.getState().requestUserInput({
3296
3316
  prompt: "",
3297
3317
  promptType: "enterToContinue",
@@ -3739,7 +3759,7 @@ async function runAnalysis(mode, extraInstructions = []) {
3739
3759
  // package.json
3740
3760
  var package_default = {
3741
3761
  name: "@algolia/wizard",
3742
- version: "0.26.0-rc.118.217",
3762
+ version: "0.27.0",
3743
3763
  description: "Magically implement Algolia functionality in your codebase",
3744
3764
  type: "module",
3745
3765
  engines: {
@@ -4493,9 +4513,9 @@ function sourceSpecificInstructions(input) {
4493
4513
  "Never fabricate, hardcode, or substitute a different file."
4494
4514
  ],
4495
4515
  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.",
4516
+ "No real data source exists; generate sample records for the entity.",
4517
+ "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.",
4518
+ "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
4519
  "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
4520
  ]
4501
4521
  };
@@ -4514,7 +4534,7 @@ function ingestionInstructions(input) {
4514
4534
  return [
4515
4535
  ...input.confirmed && input.confirmed.length ? [
4516
4536
  `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)}.`,
4537
+ `Ingest only the confirmed entity (name, source paths, attributes): ${JSON.stringify(input.confirmed)}.`,
4518
4538
  `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
4539
  `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
4540
  "Write the script in the project's primary language, using Algolia's official client for that language. Do not use the raw HTTP API.",
@@ -5521,6 +5541,15 @@ async function run(workflow) {
5521
5541
  const store = useWizard.getState();
5522
5542
  const instance = render(/* @__PURE__ */ jsx16(App, {}), { incrementalRendering: true });
5523
5543
  await store.waitForStart();
5544
+ store.syncSteps(
5545
+ workflow.steps.map((s) => ({
5546
+ id: s.id,
5547
+ title: s.title,
5548
+ visible: s.visible,
5549
+ status: "pending"
5550
+ })),
5551
+ 0
5552
+ );
5524
5553
  let user = await getUser();
5525
5554
  if (!user) {
5526
5555
  store.beginAuth();
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.27.0",
4
4
  "description": "Magically implement Algolia functionality in your codebase",
5
5
  "type": "module",
6
6
  "engines": {