@algolia/wizard 0.87.0 → 0.89.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.
- package/dist/main.js +92 -13
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2358,7 +2358,7 @@ async function ensureApplication(resumeAppId) {
|
|
|
2358
2358
|
// package.json
|
|
2359
2359
|
var package_default = {
|
|
2360
2360
|
name: "@algolia/wizard",
|
|
2361
|
-
version: "0.
|
|
2361
|
+
version: "0.89.0",
|
|
2362
2362
|
description: "Magically implement Algolia functionality in your codebase",
|
|
2363
2363
|
type: "module",
|
|
2364
2364
|
engines: {
|
|
@@ -6272,6 +6272,7 @@ var INGEST_RETRY = {
|
|
|
6272
6272
|
retry: "Retry ingestion",
|
|
6273
6273
|
skip: "Continue without records"
|
|
6274
6274
|
};
|
|
6275
|
+
var INGEST_AGENT_RETRY_PROMPT = "Retry to let the wizard write and run the ingestion script again.";
|
|
6275
6276
|
var FILE_UPLOAD_PATH_PROMPT = "Enter the path to your JSON, CSV, or TSV file (relative to the project root, or absolute):";
|
|
6276
6277
|
var JS_LANGUAGES = ["javascript", "typescript", "jsx", "tsx", "node"];
|
|
6277
6278
|
function lower(entries) {
|
|
@@ -6681,12 +6682,25 @@ function recordSchema(sample, attributes) {
|
|
|
6681
6682
|
}
|
|
6682
6683
|
return Object.fromEntries(attributes.map((key) => [key, "unknown"]));
|
|
6683
6684
|
}
|
|
6684
|
-
function
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6685
|
+
function noRunReason({
|
|
6686
|
+
agentFailure,
|
|
6687
|
+
executions,
|
|
6688
|
+
ingestCommand,
|
|
6689
|
+
scriptPath
|
|
6690
|
+
}) {
|
|
6691
|
+
if (agentFailure !== void 0) {
|
|
6692
|
+
return `the wizard stopped before it finished the ingestion script (${agentFailure || "no reason given"})`;
|
|
6693
|
+
}
|
|
6694
|
+
if (executions.some((e) => !e.approved)) {
|
|
6695
|
+
return "a command it needed was declined";
|
|
6696
|
+
}
|
|
6697
|
+
if (!ingestCommand) {
|
|
6698
|
+
return scriptPath ? `the ingestion script ${scriptPath} was written but not run` : "no ingestion script was written";
|
|
6689
6699
|
}
|
|
6700
|
+
return "no successful run was recorded";
|
|
6701
|
+
}
|
|
6702
|
+
function ingestFailure(attempt, missingRunReason = "no successful run was recorded") {
|
|
6703
|
+
if (!attempt) return { reason: missingRunReason };
|
|
6690
6704
|
if (!attempt.approved) return { reason: "you declined to run it" };
|
|
6691
6705
|
const detail = errorLine(attempt.output);
|
|
6692
6706
|
if (attempt.timedOut) {
|
|
@@ -6728,6 +6742,9 @@ function briefSummary(summary) {
|
|
|
6728
6742
|
if (!firstLine) return "no summary given";
|
|
6729
6743
|
return firstLine.length > ERROR_SUMMARY_MAX_CHARS ? `${firstLine.slice(0, ERROR_SUMMARY_MAX_CHARS - 1)}\u2026` : firstLine;
|
|
6730
6744
|
}
|
|
6745
|
+
function ingestionRetryInstruction(reason) {
|
|
6746
|
+
return `The previous ingestion attempt ended with no successful run: ${reason}. Look in "${INGEST_DIR}/" for a script from that attempt and finish or fix it instead of starting over. Then call reviewScript and run the script as described above.`;
|
|
6747
|
+
}
|
|
6731
6748
|
function validationRetryInstructions(validation) {
|
|
6732
6749
|
return [
|
|
6733
6750
|
`Implementation insufficient. Address these findings before reporting completion: ${validation.additionalInstructions ?? validation.summary}`
|
|
@@ -7014,16 +7031,70 @@ async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES) {
|
|
|
7014
7031
|
}
|
|
7015
7032
|
if (useCases.includes("ingestion")) {
|
|
7016
7033
|
let ingestFailureDetail;
|
|
7017
|
-
const result = await runImplementationUseCase("ingestion");
|
|
7018
|
-
summaries.push(formatSummary("ingestion", result.summary));
|
|
7019
|
-
ingestCommand = result.ingestCommand;
|
|
7020
7034
|
const ingestionContext = ingestionTools;
|
|
7021
7035
|
const executions = ingestionContext.shell.executions;
|
|
7036
|
+
let agentFailure;
|
|
7037
|
+
const runIngestionAgent = async (extraInstructions = []) => {
|
|
7038
|
+
const isRetry = extraInstructions.length > 0;
|
|
7039
|
+
if (isRetry) {
|
|
7040
|
+
resetToolCounts(ingestionContext);
|
|
7041
|
+
ingestionContext.cwd = ingestionContext.root;
|
|
7042
|
+
}
|
|
7043
|
+
try {
|
|
7044
|
+
const result = await runImplementationUseCase(
|
|
7045
|
+
"ingestion",
|
|
7046
|
+
extraInstructions,
|
|
7047
|
+
isRetry
|
|
7048
|
+
);
|
|
7049
|
+
summaries.push(formatSummary("ingestion", result.summary));
|
|
7050
|
+
ingestCommand = result.ingestCommand ?? ingestCommand;
|
|
7051
|
+
agentFailure = void 0;
|
|
7052
|
+
} catch (err) {
|
|
7053
|
+
if (!(err instanceof AgentReportedFailureError)) throw err;
|
|
7054
|
+
agentFailure = err.reason ?? "";
|
|
7055
|
+
summaries.push(
|
|
7056
|
+
formatSummary(
|
|
7057
|
+
"ingestion",
|
|
7058
|
+
`Stopped before the script was finished: ${err.reason ?? "no reason given"}`
|
|
7059
|
+
)
|
|
7060
|
+
);
|
|
7061
|
+
logger.warn(
|
|
7062
|
+
{ reason: err.reason, counts: ingestionContext.counts },
|
|
7063
|
+
"implement: ingestion agent reported fail"
|
|
7064
|
+
);
|
|
7065
|
+
}
|
|
7066
|
+
};
|
|
7067
|
+
const currentNoRunReason = async () => noRunReason({
|
|
7068
|
+
agentFailure,
|
|
7069
|
+
executions,
|
|
7070
|
+
ingestCommand,
|
|
7071
|
+
scriptPath: await findIngestionScript(
|
|
7072
|
+
repoRoot,
|
|
7073
|
+
INGEST_DIR,
|
|
7074
|
+
ingestCommand
|
|
7075
|
+
)
|
|
7076
|
+
});
|
|
7077
|
+
await runIngestionAgent();
|
|
7022
7078
|
let outcome = ingestOutcome(executions, repoRoot, ingestCommand);
|
|
7023
7079
|
let failureAcknowledged = false;
|
|
7024
|
-
while (!outcome.run && outcome.attempt
|
|
7080
|
+
while (!outcome.run && !outcome.attempt) {
|
|
7081
|
+
const reason = await currentNoRunReason();
|
|
7082
|
+
const choice = await ctx.requestUserInput({
|
|
7083
|
+
prompt: INGEST_AGENT_RETRY_PROMPT,
|
|
7084
|
+
promptType: "multipleChoice",
|
|
7085
|
+
options: [INGEST_RETRY.retry, INGEST_RETRY.skip],
|
|
7086
|
+
messages: [`\u26A0\uFE0F Records were not indexed \u2014 ${reason}.`]
|
|
7087
|
+
});
|
|
7088
|
+
if (choice !== INGEST_RETRY.retry) {
|
|
7089
|
+
failureAcknowledged = true;
|
|
7090
|
+
break;
|
|
7091
|
+
}
|
|
7092
|
+
await runIngestionAgent([ingestionRetryInstruction(reason)]);
|
|
7093
|
+
outcome = ingestOutcome(executions, repoRoot, ingestCommand);
|
|
7094
|
+
}
|
|
7095
|
+
while (!failureAcknowledged && !outcome.run && outcome.attempt?.approved) {
|
|
7025
7096
|
const attempt = outcome.attempt;
|
|
7026
|
-
const { reason, detail } = ingestFailure(attempt
|
|
7097
|
+
const { reason, detail } = ingestFailure(attempt);
|
|
7027
7098
|
const choice = await ctx.requestUserInput({
|
|
7028
7099
|
prompt: INGEST_RETRY_PROMPT,
|
|
7029
7100
|
promptType: "multipleChoice",
|
|
@@ -7099,7 +7170,10 @@ async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES) {
|
|
|
7099
7170
|
);
|
|
7100
7171
|
}
|
|
7101
7172
|
} else {
|
|
7102
|
-
const { reason, detail } = ingestFailure(
|
|
7173
|
+
const { reason, detail } = ingestFailure(
|
|
7174
|
+
ingestAttempt,
|
|
7175
|
+
await currentNoRunReason()
|
|
7176
|
+
);
|
|
7103
7177
|
ingestOutcomeMessage = `\u26A0\uFE0F Records were not indexed \u2014 ${reason}.${ingestCommand ? " Run the command below when you are ready." : ""}`;
|
|
7104
7178
|
ingestFailureDetail = detail;
|
|
7105
7179
|
summaries.push(
|
|
@@ -9294,6 +9368,11 @@ function App() {
|
|
|
9294
9368
|
useRepaintOnResize();
|
|
9295
9369
|
const compactRun = isCompactTerminal(columns, rows);
|
|
9296
9370
|
const [showLogs, setShowLogs] = useState14(false);
|
|
9371
|
+
const [seenInputReq, setSeenInputReq] = useState14(inputReq);
|
|
9372
|
+
if (inputReq !== seenInputReq) {
|
|
9373
|
+
setSeenInputReq(inputReq);
|
|
9374
|
+
if (inputReq) setShowLogs(false);
|
|
9375
|
+
}
|
|
9297
9376
|
const [tipState, setTipState] = useState14("idle");
|
|
9298
9377
|
const [tipsComplete, setTipsComplete] = useState14(false);
|
|
9299
9378
|
const finished = phase === "done" || phase === "error";
|
|
@@ -9662,7 +9741,7 @@ async function resetProjectState() {
|
|
|
9662
9741
|
// package.json with { type: 'json' }
|
|
9663
9742
|
var package_default2 = {
|
|
9664
9743
|
name: "@algolia/wizard",
|
|
9665
|
-
version: "0.
|
|
9744
|
+
version: "0.89.0",
|
|
9666
9745
|
description: "Magically implement Algolia functionality in your codebase",
|
|
9667
9746
|
type: "module",
|
|
9668
9747
|
engines: {
|