@algolia/wizard 0.84.0-rc.202.644 → 0.84.0-rc.202.645

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 +61 -14
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -2315,7 +2315,7 @@ async function ensureApplication(resumeAppId) {
2315
2315
  // package.json
2316
2316
  var package_default = {
2317
2317
  name: "@algolia/wizard",
2318
- version: "0.84.0-rc.202.644",
2318
+ version: "0.84.0-rc.202.645",
2319
2319
  description: "Magically implement Algolia functionality in your codebase",
2320
2320
  type: "module",
2321
2321
  engines: {
@@ -6193,6 +6193,11 @@ var INGESTION_SOURCE = {
6193
6193
  var BUILD_CHECK_PROMPT = "Run type-check now? This can take several minutes on a large repository.";
6194
6194
  var MISSING_DEPENDENCIES_PROMPT = "Dependencies are not installed. Install them and run type-check now?";
6195
6195
  var UNRELATED_FAILURE_PROMPT = "These checks are still failing and appear unrelated to the changes. Continue the investigation?";
6196
+ var INGEST_RETRY_PROMPT = "Fix the cause (for example, start the database the script reads from), then retry.";
6197
+ var INGEST_RETRY = {
6198
+ retry: "Retry ingestion",
6199
+ skip: "Continue without records"
6200
+ };
6196
6201
  var FILE_UPLOAD_PATH_PROMPT = "Enter the path to your JSON, CSV, or TSV file (relative to the project root, or absolute):";
6197
6202
  var JS_LANGUAGES = ["javascript", "typescript", "jsx", "tsx", "node"];
6198
6203
  function lower(entries) {
@@ -6295,6 +6300,7 @@ function ingestionInstructions(input) {
6295
6300
  ] : [],
6296
6301
  `When the script is finished, decide the exact command and cwd you will use to run it. Make sure that the script path in the command resolves from that cwd to the filePath. Then call reviewScript with that filePath, command, cwd, the exact selected entityName, and usesGeneratedRecords set to ${input.ingestionSource === "generated"}. Wait for the developer to review it because running it writes records to a live index. Do not run it before that call returns. If you change the command or cwd after a failed run, call reviewScript again before runShell.`,
6297
6302
  'Then, without changing directories, run the script yourself via runShell using the exact same command and cwd. Report the command you ran as "ingestCommand" so the developer can re-run it. Its explanation must say that running it writes records to Algolia.',
6303
+ "When the script reads from a database or another service, find how the project connects to it locally (env files, README, socket or TCP settings). If that connection needs a local service, such as a database proxy (for example cloud-sql-proxy) or a tunnel, make the script check the connection before it reads, and exit with an error that names the service and the command from the project docs that starts it.",
6298
6304
  "If external data access fails, do not run authentication commands, change accounts or machine configuration, or start proxies, containers, or services.",
6299
6305
  "Do not troubleshoot unavailable external infrastructure. Preserve the script and command, report success, and let the developer prepare the data source.",
6300
6306
  "If the script cannot access an external data source because credentials or a service are unavailable, do not report status=fail. Report status=success with the completed script, ingestCommand, and a concise failure summary. The wizard handles this run failure and tells the developer how to retry.",
@@ -6596,6 +6602,18 @@ function ingestFailure(attempt, executions) {
6596
6602
  }
6597
6603
  return { reason: `it failed (exit ${attempt.exitCode ?? "unknown"})`, detail };
6598
6604
  }
6605
+ function ingestFailureMessages(headline, detail, command, cwd) {
6606
+ return [
6607
+ headline,
6608
+ // One message per line: Notices.tsx counts a message as one wrapped
6609
+ // line, so an embedded newline overflows the panel's height accounting.
6610
+ ...detail?.split("\n").filter((l) => l.trim()) ?? [],
6611
+ ...command ? [
6612
+ `Ingestion command: ${command}`,
6613
+ ...cwd !== "." ? [`Working directory: ${cwd}`] : []
6614
+ ] : []
6615
+ ];
6616
+ }
6599
6617
  function makeToolContext(root, appId, env = async () => ({}), secretEnv = async () => ({})) {
6600
6618
  return {
6601
6619
  ...createToolContext(
@@ -6903,11 +6921,45 @@ async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES) {
6903
6921
  ingestCommand = result.ingestCommand;
6904
6922
  const ingestionContext = ingestionTools;
6905
6923
  const executions = ingestionContext.shell.executions;
6924
+ let outcome = ingestOutcome(executions, repoRoot, ingestCommand);
6925
+ let failureAcknowledged = false;
6926
+ while (!outcome.run && outcome.attempt?.approved) {
6927
+ const attempt = outcome.attempt;
6928
+ const { reason, detail } = ingestFailure(attempt, executions);
6929
+ const choice = await ctx.requestUserInput({
6930
+ prompt: INGEST_RETRY_PROMPT,
6931
+ promptType: "multipleChoice",
6932
+ options: [INGEST_RETRY.retry, INGEST_RETRY.skip],
6933
+ messages: ingestFailureMessages(
6934
+ `\u26A0\uFE0F Records were not indexed \u2014 ${reason}.`,
6935
+ detail,
6936
+ attempt.command,
6937
+ relativeIngestCwd(attempt, repoRoot)
6938
+ )
6939
+ });
6940
+ if (choice !== INGEST_RETRY.retry) {
6941
+ failureAcknowledged = true;
6942
+ break;
6943
+ }
6944
+ const rerun = await runReviewedCommand(
6945
+ ingestionContext,
6946
+ attempt.command,
6947
+ attempt.cwd
6948
+ );
6949
+ if (rerun === void 0 || typeof rerun === "string") {
6950
+ logger.warn(
6951
+ { command: attempt.command, refusal: rerun },
6952
+ "implement: could not retry the ingestion command"
6953
+ );
6954
+ break;
6955
+ }
6956
+ outcome = ingestOutcome(executions, repoRoot, ingestCommand);
6957
+ }
6906
6958
  const {
6907
6959
  run: ingestRun,
6908
6960
  attempt: ingestAttempt,
6909
6961
  recordCount
6910
- } = ingestOutcome(executions, repoRoot, ingestCommand);
6962
+ } = outcome;
6911
6963
  let ingestCwd = ".";
6912
6964
  if (ingestAttempt) {
6913
6965
  ingestCommand = ingestAttempt.command;
@@ -6987,22 +7039,17 @@ ${detail}` : ""}`
6987
7039
  "When you're ready to continue, we'll move on to search implementation."
6988
7040
  ]
6989
7041
  });
6990
- } else {
6991
- const commandMessages = ingestCommand ? [
6992
- `Ingestion command: ${ingestCommand}`,
6993
- ...ingestCwd !== "." ? [`Working directory: ${ingestCwd}`] : []
6994
- ] : [];
7042
+ } else if (!failureAcknowledged) {
6995
7043
  await ctx.requestUserInput({
6996
7044
  prompt: "",
6997
7045
  promptType: "enterToContinue",
6998
7046
  options: [],
6999
- // One message per line: Notices.tsx counts a message as one wrapped
7000
- // line, so an embedded newline overflows the panel's height accounting.
7001
- messages: [
7047
+ messages: ingestFailureMessages(
7002
7048
  ingestOutcomeMessage,
7003
- ...ingestFailureDetail?.split("\n").filter((l) => l.trim()) ?? [],
7004
- ...commandMessages
7005
- ]
7049
+ ingestFailureDetail,
7050
+ ingestCommand,
7051
+ ingestCwd
7052
+ )
7006
7053
  });
7007
7054
  }
7008
7055
  }
@@ -9270,7 +9317,7 @@ async function resetProjectState() {
9270
9317
  // package.json with { type: 'json' }
9271
9318
  var package_default2 = {
9272
9319
  name: "@algolia/wizard",
9273
- version: "0.84.0-rc.202.644",
9320
+ version: "0.84.0-rc.202.645",
9274
9321
  description: "Magically implement Algolia functionality in your codebase",
9275
9322
  type: "module",
9276
9323
  engines: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algolia/wizard",
3
- "version": "0.84.0-rc.202.644",
3
+ "version": "0.84.0-rc.202.645",
4
4
  "description": "Magically implement Algolia functionality in your codebase",
5
5
  "type": "module",
6
6
  "engines": {