@algolia/wizard 0.51.0 → 0.52.0-rc.136.364
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 +220 -84
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -239,6 +239,9 @@ function describeInputValue(value) {
|
|
|
239
239
|
}
|
|
240
240
|
var NOTICE_INTERVAL_MS = 2e3;
|
|
241
241
|
var CLI_OUTPUT_LIMIT = 200;
|
|
242
|
+
function commandApprovalKey(command, cwd) {
|
|
243
|
+
return `${cwd}\0${command}`;
|
|
244
|
+
}
|
|
242
245
|
var useWizard = create((set, get) => ({
|
|
243
246
|
phase: "idle",
|
|
244
247
|
homeScreen: "home",
|
|
@@ -356,10 +359,17 @@ var useWizard = create((set, get) => ({
|
|
|
356
359
|
setTargetIndex: (index) => set({ targetIndex: index }),
|
|
357
360
|
recordWrittenFile: (path) => set((s) => ({ writtenFiles: [...s.writtenFiles, path] })),
|
|
358
361
|
clearWrittenFiles: () => set({ writtenFiles: [] }),
|
|
359
|
-
isCommandApproved: (command, cwd) => get().approvedCommands.has(
|
|
362
|
+
isCommandApproved: (command, cwd) => get().approvedCommands.has(commandApprovalKey(command, cwd)),
|
|
360
363
|
approveCommand: (command, cwd) => set((s) => ({
|
|
361
|
-
approvedCommands: new Set(s.approvedCommands).add(
|
|
364
|
+
approvedCommands: new Set(s.approvedCommands).add(
|
|
365
|
+
commandApprovalKey(command, cwd)
|
|
366
|
+
)
|
|
362
367
|
})),
|
|
368
|
+
revokeCommand: (command, cwd) => set((s) => {
|
|
369
|
+
const approvedCommands = new Set(s.approvedCommands);
|
|
370
|
+
approvedCommands.delete(commandApprovalKey(command, cwd));
|
|
371
|
+
return { approvedCommands };
|
|
372
|
+
}),
|
|
363
373
|
logStart: (kind, name, input) => {
|
|
364
374
|
const id = nanoid();
|
|
365
375
|
set((s) => ({
|
|
@@ -738,9 +748,11 @@ function DecisionSelect({
|
|
|
738
748
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
739
749
|
function CommandApproval({
|
|
740
750
|
command,
|
|
751
|
+
messages,
|
|
741
752
|
onDecide
|
|
742
753
|
}) {
|
|
743
754
|
return /* @__PURE__ */ jsxs5(Box6, { flexDirection: "column", gap: 1, children: [
|
|
755
|
+
messages?.map((message, index) => /* @__PURE__ */ jsx5(Text6, { color: COLORS.muted, children: message }, `msg-${index}`)),
|
|
744
756
|
/* @__PURE__ */ jsx5(Text6, { color: COLORS.primary, bold: true, children: "Run this command?" }),
|
|
745
757
|
/* @__PURE__ */ jsxs5(
|
|
746
758
|
Box6,
|
|
@@ -1157,7 +1169,6 @@ function PromptInput() {
|
|
|
1157
1169
|
return /* @__PURE__ */ jsx8(Box9, { flexGrow: 1, children: /* @__PURE__ */ jsx8(
|
|
1158
1170
|
SelectPrompt,
|
|
1159
1171
|
{
|
|
1160
|
-
question: inputReq.prompt,
|
|
1161
1172
|
messages: inputReq.messages,
|
|
1162
1173
|
options: ["Continue"],
|
|
1163
1174
|
onSelect: handleSubmit
|
|
@@ -1176,7 +1187,14 @@ function PromptInput() {
|
|
|
1176
1187
|
);
|
|
1177
1188
|
}
|
|
1178
1189
|
if (inputReq.promptType === "commandApproval" && inputReq.command) {
|
|
1179
|
-
return /* @__PURE__ */ jsx8(
|
|
1190
|
+
return /* @__PURE__ */ jsx8(
|
|
1191
|
+
CommandApproval,
|
|
1192
|
+
{
|
|
1193
|
+
command: inputReq.command,
|
|
1194
|
+
messages: inputReq.messages,
|
|
1195
|
+
onDecide: submitInput
|
|
1196
|
+
}
|
|
1197
|
+
);
|
|
1180
1198
|
}
|
|
1181
1199
|
if (inputReq.promptType === "acceptReject") {
|
|
1182
1200
|
const labels = inputReq.options?.length ? inputReq.options : ACCEPT_REJECT_OPTIONS;
|
|
@@ -2698,9 +2716,16 @@ function searchFilesTool(ctx) {
|
|
|
2698
2716
|
}
|
|
2699
2717
|
|
|
2700
2718
|
// src/lib/tools/runShell.ts
|
|
2701
|
-
import { tool as
|
|
2719
|
+
import { tool as tool9, generateText, Output } from "ai";
|
|
2702
2720
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2721
|
+
import z16 from "zod";
|
|
2722
|
+
import { relative as relative5 } from "node:path";
|
|
2723
|
+
|
|
2724
|
+
// src/lib/tools/reviewScript.ts
|
|
2725
|
+
import { tool as tool8 } from "ai";
|
|
2703
2726
|
import z15 from "zod";
|
|
2727
|
+
import { createHash } from "node:crypto";
|
|
2728
|
+
import { readFile as readFile7, stat as stat2 } from "node:fs/promises";
|
|
2704
2729
|
import { relative as relative4 } from "node:path";
|
|
2705
2730
|
|
|
2706
2731
|
// src/lib/tools/utils/prompt.ts
|
|
@@ -2712,6 +2737,116 @@ function serializePrompt(work) {
|
|
|
2712
2737
|
return result;
|
|
2713
2738
|
}
|
|
2714
2739
|
|
|
2740
|
+
// src/lib/tools/reviewScript.ts
|
|
2741
|
+
var reviewedCommandApprovals = /* @__PURE__ */ new WeakMap();
|
|
2742
|
+
async function fileDigest(filePath) {
|
|
2743
|
+
const content = await readFile7(filePath);
|
|
2744
|
+
return createHash("sha256").update(content).digest("hex");
|
|
2745
|
+
}
|
|
2746
|
+
function grantReviewedCommandApproval(ctx, approval) {
|
|
2747
|
+
reviewedCommandApprovals.set(ctx, approval);
|
|
2748
|
+
}
|
|
2749
|
+
function getReviewedCommandApproval(ctx, command, cwd) {
|
|
2750
|
+
const approval = reviewedCommandApprovals.get(ctx);
|
|
2751
|
+
if (approval?.command !== command || approval.cwd !== cwd) return void 0;
|
|
2752
|
+
return approval;
|
|
2753
|
+
}
|
|
2754
|
+
function clearReviewedCommandApproval(ctx) {
|
|
2755
|
+
reviewedCommandApprovals.delete(ctx);
|
|
2756
|
+
}
|
|
2757
|
+
function revokeCommandApprovals(ctx, command, cwd) {
|
|
2758
|
+
clearReviewedCommandApproval(ctx);
|
|
2759
|
+
useWizard.getState().revokeCommand(command, cwd);
|
|
2760
|
+
}
|
|
2761
|
+
async function reviewedCommandApprovalIsCurrent(approval) {
|
|
2762
|
+
const currentDigest = await fileDigest(approval.filePath).catch(() => null);
|
|
2763
|
+
return currentDigest === approval.digest;
|
|
2764
|
+
}
|
|
2765
|
+
function reviewScriptTool(ctx) {
|
|
2766
|
+
return tool8({
|
|
2767
|
+
description: "Call this as soon as the ingestion script is finished and before you run it. It summarizes the records that will be written, then asks the user to review the script and approve the exact command that will run it, so a matching runShell call needs no second approval.",
|
|
2768
|
+
inputSchema: z15.object({
|
|
2769
|
+
filePath: z15.string().describe(
|
|
2770
|
+
"Path to the script to review, relative to the project root."
|
|
2771
|
+
),
|
|
2772
|
+
command: z15.string().min(1).describe("The exact command that runShell will use to run the script."),
|
|
2773
|
+
cwd: z15.string().describe(
|
|
2774
|
+
"The exact working directory that runShell will use, relative to the current tool working directory."
|
|
2775
|
+
),
|
|
2776
|
+
entityName: z15.string().trim().min(1).max(100).regex(/^[^\r\n]+$/).describe("The exact entity name selected by the user."),
|
|
2777
|
+
usesGeneratedRecords: z15.boolean().describe(
|
|
2778
|
+
"Whether the script reads generated sample records instead of the selected real data source."
|
|
2779
|
+
)
|
|
2780
|
+
}),
|
|
2781
|
+
execute: async ({
|
|
2782
|
+
filePath,
|
|
2783
|
+
command,
|
|
2784
|
+
cwd,
|
|
2785
|
+
entityName,
|
|
2786
|
+
usesGeneratedRecords
|
|
2787
|
+
}) => {
|
|
2788
|
+
logger.info(
|
|
2789
|
+
{ filePath, command, cwd, entityName, usesGeneratedRecords },
|
|
2790
|
+
"called reviewScript tool"
|
|
2791
|
+
);
|
|
2792
|
+
const resolved2 = resolveInRoot(ctx, filePath);
|
|
2793
|
+
if (resolved2.ok === false) return resolved2.error;
|
|
2794
|
+
const resolvedCwd = resolveInRoot(ctx, cwd);
|
|
2795
|
+
if (resolvedCwd.ok === false) return resolvedCwd.error;
|
|
2796
|
+
const displayCwd = relative4(ctx.root, resolvedCwd.target) || ".";
|
|
2797
|
+
const displayFilePath = relative4(ctx.root, resolved2.target);
|
|
2798
|
+
const ingestionSummary = usesGeneratedRecords ? `This will push ${entityName} records from generated sample data to Algolia. You can replace the sample dataset with your real data source in ${displayFilePath}.` : `This will push ${entityName} records from your selected source to Algolia.`;
|
|
2799
|
+
return serializePrompt(async () => {
|
|
2800
|
+
revokeCommandApprovals(ctx, command, resolvedCwd.target);
|
|
2801
|
+
const isFile = await stat2(resolved2.target).then(
|
|
2802
|
+
(s) => s.isFile(),
|
|
2803
|
+
() => false
|
|
2804
|
+
);
|
|
2805
|
+
if (!isFile) {
|
|
2806
|
+
return `Refused: ${filePath} is not a file. Write the script first, then review the path you wrote.`;
|
|
2807
|
+
}
|
|
2808
|
+
const reviewedDigest = await fileDigest(resolved2.target).catch(
|
|
2809
|
+
() => null
|
|
2810
|
+
);
|
|
2811
|
+
if (reviewedDigest === null) {
|
|
2812
|
+
return `Refused: ${filePath} could not be read. Write the script first, then review it again.`;
|
|
2813
|
+
}
|
|
2814
|
+
const answer = await useWizard.getState().requestUserInput({
|
|
2815
|
+
prompt: "Run this command?",
|
|
2816
|
+
promptType: "commandApproval",
|
|
2817
|
+
options: [],
|
|
2818
|
+
messages: [
|
|
2819
|
+
`We have created your ingestion script. Please review it at ${displayFilePath} before approving.`
|
|
2820
|
+
],
|
|
2821
|
+
command: {
|
|
2822
|
+
command,
|
|
2823
|
+
cwd: displayCwd,
|
|
2824
|
+
explanation: ingestionSummary
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
if (answer !== "approve") {
|
|
2828
|
+
revokeCommandApprovals(ctx, command, resolvedCwd.target);
|
|
2829
|
+
return "The user declined to run this ingestion script. Do not run it.";
|
|
2830
|
+
}
|
|
2831
|
+
const approvedDigest = await fileDigest(resolved2.target).catch(
|
|
2832
|
+
() => null
|
|
2833
|
+
);
|
|
2834
|
+
if (approvedDigest !== reviewedDigest) {
|
|
2835
|
+
return "The ingestion script changed while it was being reviewed. Call reviewScript again before running it.";
|
|
2836
|
+
}
|
|
2837
|
+
ctx.reviewed.push(resolved2.target);
|
|
2838
|
+
grantReviewedCommandApproval(ctx, {
|
|
2839
|
+
command,
|
|
2840
|
+
cwd: resolvedCwd.target,
|
|
2841
|
+
filePath: resolved2.target,
|
|
2842
|
+
digest: reviewedDigest
|
|
2843
|
+
});
|
|
2844
|
+
return "The user reviewed the script and approved this exact command. Run it now with the same cwd.";
|
|
2845
|
+
});
|
|
2846
|
+
}
|
|
2847
|
+
});
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2715
2850
|
// src/lib/tools/utils/runShell.ts
|
|
2716
2851
|
import { spawn as spawn2 } from "node:child_process";
|
|
2717
2852
|
|
|
@@ -2810,7 +2945,7 @@ function storeApproval(root) {
|
|
|
2810
2945
|
return async (req) => {
|
|
2811
2946
|
const store = useWizard.getState();
|
|
2812
2947
|
if (store.isCommandApproved(req.command, req.cwd)) return "approve";
|
|
2813
|
-
const rel =
|
|
2948
|
+
const rel = relative5(root, req.cwd);
|
|
2814
2949
|
const answer = await store.requestUserInput({
|
|
2815
2950
|
prompt: "Run this command?",
|
|
2816
2951
|
promptType: "commandApproval",
|
|
@@ -2825,6 +2960,7 @@ function storeApproval(root) {
|
|
|
2825
2960
|
return "approve";
|
|
2826
2961
|
};
|
|
2827
2962
|
}
|
|
2963
|
+
var SUCCESS_EXIT_CODE = 0;
|
|
2828
2964
|
var FILE_IO_COMMANDS = /* @__PURE__ */ new Set([
|
|
2829
2965
|
"ls",
|
|
2830
2966
|
"find",
|
|
@@ -2963,9 +3099,9 @@ function fastPathSafety(command) {
|
|
|
2963
3099
|
return void 0;
|
|
2964
3100
|
}
|
|
2965
3101
|
var CLASSIFIER_MODEL = "claude-haiku-4-5";
|
|
2966
|
-
var commandSafetySchema =
|
|
2967
|
-
safe:
|
|
2968
|
-
reason:
|
|
3102
|
+
var commandSafetySchema = z16.object({
|
|
3103
|
+
safe: z16.boolean(),
|
|
3104
|
+
reason: z16.string().describe("One short sentence explaining the verdict.")
|
|
2969
3105
|
});
|
|
2970
3106
|
function defaultCreateModel() {
|
|
2971
3107
|
const token = getAuthToken();
|
|
@@ -3025,12 +3161,15 @@ async function classifyCommandSafety(createModel, command, cwd, explanation, app
|
|
|
3025
3161
|
return false;
|
|
3026
3162
|
}
|
|
3027
3163
|
}
|
|
3028
|
-
async function
|
|
3029
|
-
|
|
3030
|
-
const env = await ctx.shell.env().catch((err) => {
|
|
3164
|
+
async function resolveShellEnv(ctx, command) {
|
|
3165
|
+
return ctx.shell.env().catch((err) => {
|
|
3031
3166
|
logger.warn({ err, command }, "runShell: could not resolve command env");
|
|
3032
3167
|
return {};
|
|
3033
3168
|
});
|
|
3169
|
+
}
|
|
3170
|
+
async function runAndRecord(ctx, command, cwd, resolvedEnv) {
|
|
3171
|
+
useWizard.getState().pushNotice({ messages: [`Running: ${command}`] });
|
|
3172
|
+
const env = resolvedEnv ?? await resolveShellEnv(ctx, command);
|
|
3034
3173
|
const run2 = await (ctx.shell.run ?? runShell)(command, {
|
|
3035
3174
|
cwd,
|
|
3036
3175
|
env,
|
|
@@ -3061,6 +3200,19 @@ async function runAndRecord(ctx, command, cwd) {
|
|
|
3061
3200
|
output: run2.output
|
|
3062
3201
|
};
|
|
3063
3202
|
}
|
|
3203
|
+
async function runReviewedCommand(ctx, command, cwd) {
|
|
3204
|
+
const approval = getReviewedCommandApproval(ctx, command, cwd);
|
|
3205
|
+
if (!approval) return void 0;
|
|
3206
|
+
const env = await resolveShellEnv(ctx, command);
|
|
3207
|
+
if (!await reviewedCommandApprovalIsCurrent(approval)) {
|
|
3208
|
+
return `Refused: ${relative5(ctx.root, approval.filePath)} changed after review. Call reviewScript again before running it.`;
|
|
3209
|
+
}
|
|
3210
|
+
const result = await runAndRecord(ctx, command, cwd, env);
|
|
3211
|
+
if (result.exitCode === SUCCESS_EXIT_CODE && !result.timedOut) {
|
|
3212
|
+
clearReviewedCommandApproval(ctx);
|
|
3213
|
+
}
|
|
3214
|
+
return result;
|
|
3215
|
+
}
|
|
3064
3216
|
async function approveAndRun(ctx, command, cwd, explanation) {
|
|
3065
3217
|
const decision = await ctx.shell.approve({ command, cwd, explanation });
|
|
3066
3218
|
if (decision === "reject") {
|
|
@@ -3071,16 +3223,16 @@ async function approveAndRun(ctx, command, cwd, explanation) {
|
|
|
3071
3223
|
return runAndRecord(ctx, command, cwd);
|
|
3072
3224
|
}
|
|
3073
3225
|
function runShellTool(ctx, createModel = defaultCreateModel) {
|
|
3074
|
-
return
|
|
3226
|
+
return tool9({
|
|
3075
3227
|
description: "Run a shell command in the project. Use this for anything the project needs done in its own ecosystem: installing dependencies, running a script you wrote, running the project's lint/typecheck/test commands. Do not use this to find or read files \u2014 use listFiles, searchFiles, and readFile instead of shell file-listing, reading, or search commands (ls/find/tree/cat/head/tail/grep/rg and similar). This tool refuses all of those outright: the dedicated tools enforce the project-root boundary and secret redaction that a raw shell read would bypass, and they won't count against this tool's command budget. The user approves any command that could change the project before it runs, so write a clear `explanation`. A command judged read-only (inspection, or running tests/typecheck/lint without an autofix flag, in any language) runs immediately without approval. If the user rejects a command, do not retry it \u2014 propose a different approach.",
|
|
3076
|
-
inputSchema:
|
|
3077
|
-
command:
|
|
3228
|
+
inputSchema: z16.object({
|
|
3229
|
+
command: z16.string().describe(
|
|
3078
3230
|
"The command to run, exactly as it would be typed in a shell. Pipes, && and redirects are allowed."
|
|
3079
3231
|
),
|
|
3080
|
-
cwd:
|
|
3232
|
+
cwd: z16.string().optional().describe(
|
|
3081
3233
|
"Directory to run in, relative to the project root. Defaults to the project root."
|
|
3082
3234
|
),
|
|
3083
|
-
explanation:
|
|
3235
|
+
explanation: z16.string().describe(
|
|
3084
3236
|
"One short line telling the user what this command does and why, including any side effect (e.g. writes records to Algolia). This is what they approve against."
|
|
3085
3237
|
)
|
|
3086
3238
|
}),
|
|
@@ -3089,16 +3241,22 @@ function runShellTool(ctx, createModel = defaultCreateModel) {
|
|
|
3089
3241
|
return `Refused: command limit (${ctx.limits.shell}) reached. Stop running commands and report what you have.`;
|
|
3090
3242
|
}
|
|
3091
3243
|
const resolved2 = resolveInRoot(ctx, cwd ?? ".");
|
|
3092
|
-
if (
|
|
3244
|
+
if (resolved2.ok === false) return resolved2.error;
|
|
3093
3245
|
if (isFileIOCommand(command)) {
|
|
3094
3246
|
return "Refused: use listFiles or searchFiles to find files, and readFile to read one, instead of a shell file-listing, reading, or search command (ls/find/fd/tree/dir/locate/cat/head/tail/less/more/tac/nl/grep/egrep/fgrep/rg/ack/ag/xxd/hexdump/od/strings).";
|
|
3095
3247
|
}
|
|
3096
3248
|
logger.info({ command, cwd: resolved2.target }, "called runShell tool");
|
|
3249
|
+
const reviewed = await serializePrompt(
|
|
3250
|
+
() => runReviewedCommand(ctx, command, resolved2.target)
|
|
3251
|
+
);
|
|
3252
|
+
if (reviewed !== void 0) return reviewed;
|
|
3097
3253
|
const fast = fastPathSafety(command);
|
|
3098
3254
|
let isSafe = fast;
|
|
3255
|
+
let usedStoredApproval = false;
|
|
3099
3256
|
if (isSafe === void 0) {
|
|
3100
3257
|
const store = useWizard.getState();
|
|
3101
|
-
|
|
3258
|
+
usedStoredApproval = store.isCommandApproved(command, resolved2.target);
|
|
3259
|
+
isSafe = usedStoredApproval;
|
|
3102
3260
|
if (!isSafe) {
|
|
3103
3261
|
isSafe = await classifyCommandSafety(
|
|
3104
3262
|
createModel,
|
|
@@ -3109,54 +3267,18 @@ function runShellTool(ctx, createModel = defaultCreateModel) {
|
|
|
3109
3267
|
);
|
|
3110
3268
|
}
|
|
3111
3269
|
}
|
|
3112
|
-
if (isSafe) {
|
|
3113
|
-
return serializePrompt(
|
|
3114
|
-
() => runAndRecord(ctx, command, resolved2.target)
|
|
3115
|
-
);
|
|
3116
|
-
}
|
|
3117
|
-
return serializePrompt(
|
|
3118
|
-
() => approveAndRun(ctx, command, resolved2.target, explanation)
|
|
3119
|
-
);
|
|
3120
|
-
}
|
|
3121
|
-
});
|
|
3122
|
-
}
|
|
3123
|
-
|
|
3124
|
-
// src/lib/tools/reviewScript.ts
|
|
3125
|
-
import { tool as tool9 } from "ai";
|
|
3126
|
-
import z16 from "zod";
|
|
3127
|
-
import { stat as stat2 } from "node:fs/promises";
|
|
3128
|
-
import { relative as relative5 } from "node:path";
|
|
3129
|
-
function reviewScriptTool(ctx) {
|
|
3130
|
-
return tool9({
|
|
3131
|
-
description: "Call this as soon as the ingestion script is finished and before you run it, so the user can review it.It shows the file path and returns once they have confirmed reviewing it.",
|
|
3132
|
-
inputSchema: z16.object({
|
|
3133
|
-
filePath: z16.string().describe(
|
|
3134
|
-
"Path to the script to review, relative to the project root."
|
|
3135
|
-
)
|
|
3136
|
-
}),
|
|
3137
|
-
execute: async ({ filePath }) => {
|
|
3138
|
-
logger.info({ filePath }, "called reviewScript tool");
|
|
3139
|
-
const resolved2 = resolveInRoot(ctx, filePath);
|
|
3140
|
-
if (resolved2.ok === false) return resolved2.error;
|
|
3141
|
-
const isFile = await stat2(resolved2.target).then(
|
|
3142
|
-
(s) => s.isFile(),
|
|
3143
|
-
() => false
|
|
3144
|
-
);
|
|
3145
|
-
if (!isFile) {
|
|
3146
|
-
return `Refused: ${filePath} is not a file. Write the script first, then review the path you wrote.`;
|
|
3147
|
-
}
|
|
3148
3270
|
return serializePrompt(async () => {
|
|
3149
|
-
await
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
return
|
|
3271
|
+
const lateReview = await runReviewedCommand(
|
|
3272
|
+
ctx,
|
|
3273
|
+
command,
|
|
3274
|
+
resolved2.target
|
|
3275
|
+
);
|
|
3276
|
+
if (lateReview !== void 0) return lateReview;
|
|
3277
|
+
const storedApprovalIsCurrent = !usedStoredApproval || useWizard.getState().isCommandApproved(command, resolved2.target);
|
|
3278
|
+
if (isSafe && storedApprovalIsCurrent) {
|
|
3279
|
+
return runAndRecord(ctx, command, resolved2.target);
|
|
3280
|
+
}
|
|
3281
|
+
return approveAndRun(ctx, command, resolved2.target, explanation);
|
|
3160
3282
|
});
|
|
3161
3283
|
}
|
|
3162
3284
|
});
|
|
@@ -3651,7 +3773,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3651
3773
|
// package.json
|
|
3652
3774
|
var package_default = {
|
|
3653
3775
|
name: "@algolia/wizard",
|
|
3654
|
-
version: "0.
|
|
3776
|
+
version: "0.52.0-rc.136.364",
|
|
3655
3777
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3656
3778
|
type: "module",
|
|
3657
3779
|
engines: {
|
|
@@ -4353,8 +4475,8 @@ function ingestionInstructions(input) {
|
|
|
4353
4475
|
...algoliaClientDoc(input),
|
|
4354
4476
|
"Install the Algolia client with the project's own package manager via runShell, declaring it in whatever manifest the project uses (e.g. package.json, requirements.txt, Gemfile, go.mod, composer.json) so the dependency is not just installed ad hoc.",
|
|
4355
4477
|
`If the script loads its env vars from a file (e.g. via dotenv or an equivalent for its language) rather than the process environment directly, decide that up front and call writeCredentials on that file before you finish the script \u2014 do not wait to discover the need for it by having a writeFile call refused.`,
|
|
4356
|
-
|
|
4357
|
-
'Then run the script yourself via runShell
|
|
4478
|
+
`When the script is finished, decide the exact command and cwd you will use to run it, 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.`,
|
|
4479
|
+
'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.',
|
|
4358
4480
|
"The summary should be extremely concise.",
|
|
4359
4481
|
...sourceSpecificInstructions(input)
|
|
4360
4482
|
] : []
|
|
@@ -4734,19 +4856,33 @@ ${detail}` : ""}`
|
|
|
4734
4856
|
product_area: "AI Wizard"
|
|
4735
4857
|
});
|
|
4736
4858
|
}
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
}
|
|
4859
|
+
if (ingestScriptRan) {
|
|
4860
|
+
await ctx.requestUserInput({
|
|
4861
|
+
prompt: "Continue",
|
|
4862
|
+
promptType: "notice",
|
|
4863
|
+
options: [],
|
|
4864
|
+
messages: [
|
|
4865
|
+
ingestOutcomeMessage,
|
|
4866
|
+
"View your ingested records in the Algolia dashboard:",
|
|
4867
|
+
"https://dashboard.algolia.com/explorer/browse",
|
|
4868
|
+
"When you're ready to continue, we'll move on to search implementation."
|
|
4869
|
+
]
|
|
4870
|
+
});
|
|
4871
|
+
} else {
|
|
4872
|
+
const commandMessages = ingestCommand ? [`Ingestion command: ${ingestCommand}`] : [];
|
|
4873
|
+
await ctx.requestUserInput({
|
|
4874
|
+
prompt: "",
|
|
4875
|
+
promptType: "enterToContinue",
|
|
4876
|
+
options: [],
|
|
4877
|
+
// One message per line: Notices.tsx counts a message as one wrapped
|
|
4878
|
+
// line, so an embedded newline overflows the panel's height accounting.
|
|
4879
|
+
messages: [
|
|
4880
|
+
ingestOutcomeMessage,
|
|
4881
|
+
...ingestFailureDetail?.split("\n").filter((l) => l.trim()) ?? [],
|
|
4882
|
+
...commandMessages
|
|
4883
|
+
]
|
|
4884
|
+
});
|
|
4885
|
+
}
|
|
4750
4886
|
}
|
|
4751
4887
|
let searchConfigFile;
|
|
4752
4888
|
if (useCases.includes("search")) {
|
|
@@ -6104,7 +6240,7 @@ function App() {
|
|
|
6104
6240
|
}
|
|
6105
6241
|
|
|
6106
6242
|
// src/lib/envAppId.ts
|
|
6107
|
-
import { readFile as
|
|
6243
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
6108
6244
|
import { join as join12 } from "node:path";
|
|
6109
6245
|
var ENV_FILES = [".env", ".env.local"];
|
|
6110
6246
|
var APP_ID_LINE = /^[ \t]*(?:export[ \t]+)?([A-Z0-9_]*ALGOLIA_APP(?:LICATION)?_ID)[ \t]*=[ \t]*(.*)$/gm;
|
|
@@ -6112,7 +6248,7 @@ async function findEnvApplicationId(root = process.cwd()) {
|
|
|
6112
6248
|
for (const file of ENV_FILES) {
|
|
6113
6249
|
let content;
|
|
6114
6250
|
try {
|
|
6115
|
-
content = await
|
|
6251
|
+
content = await readFile8(join12(root, file), "utf8");
|
|
6116
6252
|
} catch (err) {
|
|
6117
6253
|
if (err.code !== "ENOENT") {
|
|
6118
6254
|
logger.warn(
|