@algolia/wizard 0.90.0 → 0.91.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 +62 -32
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1514,6 +1514,15 @@ function PromptInput() {
|
|
|
1514
1514
|
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", children: [
|
|
1515
1515
|
inputReq.error && /* @__PURE__ */ jsx9(Text11, { color: COLORS.danger, children: inputReq.error }),
|
|
1516
1516
|
inputReq.messages?.map((m, i) => /* @__PURE__ */ jsx9(Text11, { color: COLORS.muted, children: m }, `msg-${i}`)),
|
|
1517
|
+
inputReq.suggestion && /* @__PURE__ */ jsxs10(Text11, { color: COLORS.muted, children: [
|
|
1518
|
+
"Press",
|
|
1519
|
+
" ",
|
|
1520
|
+
/* @__PURE__ */ jsx9(Text11, { color: COLORS.accent, bold: true, children: "Enter" }),
|
|
1521
|
+
" ",
|
|
1522
|
+
"to use",
|
|
1523
|
+
" ",
|
|
1524
|
+
/* @__PURE__ */ jsx9(Text11, { color: COLORS.accent, bold: true, children: inputReq.suggestion })
|
|
1525
|
+
] }),
|
|
1517
1526
|
/* @__PURE__ */ jsxs10(Box10, { children: [
|
|
1518
1527
|
/* @__PURE__ */ jsxs10(Text11, { color: COLORS.primary, children: [
|
|
1519
1528
|
inputReq.prompt,
|
|
@@ -2358,7 +2367,7 @@ async function ensureApplication(resumeAppId) {
|
|
|
2358
2367
|
// package.json
|
|
2359
2368
|
var package_default = {
|
|
2360
2369
|
name: "@algolia/wizard",
|
|
2361
|
-
version: "0.
|
|
2370
|
+
version: "0.91.0",
|
|
2362
2371
|
description: "Magically implement Algolia functionality in your codebase",
|
|
2363
2372
|
type: "module",
|
|
2364
2373
|
engines: {
|
|
@@ -2831,6 +2840,9 @@ async function runWorkflow(workflow, startWorkflowAppId, options) {
|
|
|
2831
2840
|
}
|
|
2832
2841
|
}
|
|
2833
2842
|
|
|
2843
|
+
// src/actions/selectIndex.ts
|
|
2844
|
+
import { basename } from "node:path";
|
|
2845
|
+
|
|
2834
2846
|
// src/actions/listIndices.ts
|
|
2835
2847
|
import { z as z5 } from "zod";
|
|
2836
2848
|
var indicesListSchema = z5.object({
|
|
@@ -2865,11 +2877,27 @@ function indexNameError(name) {
|
|
|
2865
2877
|
return "Index name cannot end with .txt, .bin, or .idx.";
|
|
2866
2878
|
return void 0;
|
|
2867
2879
|
}
|
|
2880
|
+
function slug(text) {
|
|
2881
|
+
return text.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
2882
|
+
}
|
|
2883
|
+
function suggestIndexName(project, entity, taken) {
|
|
2884
|
+
const base = ([slug(project), slug(entity ?? "")].filter(Boolean).join("_") || "records").slice(0, MAX_INDEX_NAME_LENGTH);
|
|
2885
|
+
let name = base;
|
|
2886
|
+
for (let n = 2; taken.includes(name); n++) {
|
|
2887
|
+
const suffix = `_${n}`;
|
|
2888
|
+
name = base.slice(0, MAX_INDEX_NAME_LENGTH - suffix.length) + suffix;
|
|
2889
|
+
}
|
|
2890
|
+
return name;
|
|
2891
|
+
}
|
|
2868
2892
|
var selectIndexStep = async (ctx) => {
|
|
2869
2893
|
await requireApplication(ctx.appId);
|
|
2870
2894
|
const indices = await listIndices();
|
|
2871
2895
|
const names = indices.map((i) => i.name);
|
|
2872
2896
|
const hasIndices = names.length > 0;
|
|
2897
|
+
const entity = ctx.getStepOutput(
|
|
2898
|
+
"confirm-entities"
|
|
2899
|
+
)?.confirmedEntities?.[0]?.name;
|
|
2900
|
+
const suggested = suggestIndexName(basename(process.cwd()), entity, names);
|
|
2873
2901
|
let error;
|
|
2874
2902
|
let chosen;
|
|
2875
2903
|
while (chosen === void 0) {
|
|
@@ -2886,6 +2914,7 @@ var selectIndexStep = async (ctx) => {
|
|
|
2886
2914
|
messages: [
|
|
2887
2915
|
"This app has no existing indices \u2014 enter a name to create one."
|
|
2888
2916
|
],
|
|
2917
|
+
suggestion: suggested,
|
|
2889
2918
|
error
|
|
2890
2919
|
});
|
|
2891
2920
|
if (typeof selection !== "string") {
|
|
@@ -2894,17 +2923,18 @@ var selectIndexStep = async (ctx) => {
|
|
|
2894
2923
|
let candidate;
|
|
2895
2924
|
let isNewName = true;
|
|
2896
2925
|
if (!hasIndices) {
|
|
2897
|
-
candidate = selection.trim();
|
|
2926
|
+
candidate = selection.trim() || suggested;
|
|
2898
2927
|
} else if (selection === CREATE_NEW_INDEX) {
|
|
2899
2928
|
const name = await ctx.requestUserInput({
|
|
2900
2929
|
prompt: "Name the new index:",
|
|
2901
2930
|
promptType: "textInput",
|
|
2902
|
-
options: []
|
|
2931
|
+
options: [],
|
|
2932
|
+
suggestion: suggested
|
|
2903
2933
|
});
|
|
2904
2934
|
if (typeof name !== "string") {
|
|
2905
2935
|
throw new Error("selectIndex received an unexpected non-text result");
|
|
2906
2936
|
}
|
|
2907
|
-
candidate = name.trim();
|
|
2937
|
+
candidate = name.trim() || suggested;
|
|
2908
2938
|
} else {
|
|
2909
2939
|
candidate = selection;
|
|
2910
2940
|
isNewName = false;
|
|
@@ -3140,14 +3170,14 @@ import z9 from "zod";
|
|
|
3140
3170
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
3141
3171
|
|
|
3142
3172
|
// src/lib/tools/env.ts
|
|
3143
|
-
import { basename } from "node:path";
|
|
3173
|
+
import { basename as basename2 } from "node:path";
|
|
3144
3174
|
function isEnvFile(filePath) {
|
|
3145
|
-
const name =
|
|
3175
|
+
const name = basename2(filePath);
|
|
3146
3176
|
return name === ".env" || name.startsWith(".env.");
|
|
3147
3177
|
}
|
|
3148
3178
|
function isSecretEnvFile(filePath) {
|
|
3149
3179
|
if (!isEnvFile(filePath)) return false;
|
|
3150
|
-
const name =
|
|
3180
|
+
const name = basename2(filePath);
|
|
3151
3181
|
return !/\.(example|sample|template)$/.test(name);
|
|
3152
3182
|
}
|
|
3153
3183
|
function secretEnvWriteRefusal(filePath) {
|
|
@@ -3782,7 +3812,7 @@ import { execFile as execFile2 } from "node:child_process";
|
|
|
3782
3812
|
import { tool as tool8 } from "ai";
|
|
3783
3813
|
import z15 from "zod";
|
|
3784
3814
|
import { lstat as lstat3, readdir as readdir2, readFile as readFile8, realpath, stat as stat2 } from "node:fs/promises";
|
|
3785
|
-
import { basename as
|
|
3815
|
+
import { basename as basename3, isAbsolute as isAbsolute2, join as join8, relative as relative4, sep as sep2 } from "node:path";
|
|
3786
3816
|
import { performance } from "node:perf_hooks";
|
|
3787
3817
|
import { Worker } from "node:worker_threads";
|
|
3788
3818
|
var MAX_GIT_OUTPUT_BYTES = 32e6;
|
|
@@ -4125,7 +4155,7 @@ async function safeSearchPath(rootPath, file) {
|
|
|
4125
4155
|
}
|
|
4126
4156
|
async function searchableFiles(root, target) {
|
|
4127
4157
|
try {
|
|
4128
|
-
if (SKIP_FILES.has(
|
|
4158
|
+
if (SKIP_FILES.has(basename3(target)) && (await lstat3(target)).isFile()) {
|
|
4129
4159
|
return [target];
|
|
4130
4160
|
}
|
|
4131
4161
|
const gitRoot = await gitRootForTarget(root, target);
|
|
@@ -4304,7 +4334,7 @@ import { tool as tool9 } from "ai";
|
|
|
4304
4334
|
import z16 from "zod";
|
|
4305
4335
|
import { createHash as createHash2 } from "node:crypto";
|
|
4306
4336
|
import { readFile as readFile9, stat as stat3 } from "node:fs/promises";
|
|
4307
|
-
import { basename as
|
|
4337
|
+
import { basename as basename4, relative as relative5, resolve as resolve3 } from "node:path";
|
|
4308
4338
|
|
|
4309
4339
|
// src/lib/tools/utils/prompt.ts
|
|
4310
4340
|
var chain = Promise.resolve();
|
|
@@ -4402,7 +4432,7 @@ function commandDiffersFromReviewedScript(ctx, command, cwd) {
|
|
|
4402
4432
|
if (approval.command === command && approval.cwd === cwd) return false;
|
|
4403
4433
|
if (approval.command === command) return true;
|
|
4404
4434
|
const scriptReferences = [
|
|
4405
|
-
|
|
4435
|
+
basename4(approval.filePath),
|
|
4406
4436
|
relative5(ctx.root, approval.filePath),
|
|
4407
4437
|
".algolia-wizard"
|
|
4408
4438
|
];
|
|
@@ -5123,8 +5153,8 @@ function generateRecordTool(ctx, createModel = defaultCreateModel2) {
|
|
|
5123
5153
|
...record,
|
|
5124
5154
|
objectID: nanoid2()
|
|
5125
5155
|
}));
|
|
5126
|
-
const
|
|
5127
|
-
const relPath = `${DATA_DIR}/${
|
|
5156
|
+
const slug2 = entityName.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
5157
|
+
const relPath = `${DATA_DIR}/${slug2}.json`;
|
|
5128
5158
|
const resolved2 = resolveInRoot(ctx, relPath);
|
|
5129
5159
|
if (resolved2.ok === false) return resolved2.error;
|
|
5130
5160
|
const writeError = await safeWriteFile(
|
|
@@ -6077,7 +6107,7 @@ import {
|
|
|
6077
6107
|
// src/lib/git.ts
|
|
6078
6108
|
import { execFile as execFile3 } from "node:child_process";
|
|
6079
6109
|
import { copyFile, mkdir as mkdir4, stat as stat4 } from "node:fs/promises";
|
|
6080
|
-
import { basename as
|
|
6110
|
+
import { basename as basename5, dirname as dirname3, isAbsolute as isAbsolute3, join as join9, resolve as resolve4 } from "node:path";
|
|
6081
6111
|
var MAX_BUFFER = 32 * 1024 * 1024;
|
|
6082
6112
|
function git(args) {
|
|
6083
6113
|
return new Promise((resolve6, reject) => {
|
|
@@ -6114,7 +6144,7 @@ async function copyUploadIntoProject(repoRoot, ingestDir, sourcePath) {
|
|
|
6114
6144
|
} catch {
|
|
6115
6145
|
return { ok: false, reason: `"${sourcePath}" does not exist` };
|
|
6116
6146
|
}
|
|
6117
|
-
const relPath = join9(ingestDir,
|
|
6147
|
+
const relPath = join9(ingestDir, basename5(source));
|
|
6118
6148
|
const dest = join9(repoRoot, relPath);
|
|
6119
6149
|
if (resolve4(source) === resolve4(dest)) {
|
|
6120
6150
|
return { ok: true, relPath };
|
|
@@ -6685,8 +6715,8 @@ async function firstRecordIn(filePath) {
|
|
|
6685
6715
|
async function ingestedRecordSample(repoRoot, entityName, uploadFilePath) {
|
|
6686
6716
|
const candidates = [];
|
|
6687
6717
|
if (entityName) {
|
|
6688
|
-
const
|
|
6689
|
-
candidates.push(join11(repoRoot, INGEST_DIR, "data", `${
|
|
6718
|
+
const slug2 = entityName.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
6719
|
+
candidates.push(join11(repoRoot, INGEST_DIR, "data", `${slug2}.json`));
|
|
6690
6720
|
}
|
|
6691
6721
|
if (uploadFilePath?.toLowerCase().endsWith(".json")) {
|
|
6692
6722
|
candidates.push(join11(repoRoot, uploadFilePath));
|
|
@@ -7623,9 +7653,9 @@ async function getPlaybooks() {
|
|
|
7623
7653
|
);
|
|
7624
7654
|
return data;
|
|
7625
7655
|
}
|
|
7626
|
-
async function createPlaybookExecution(appId,
|
|
7656
|
+
async function createPlaybookExecution(appId, slug2, indexName, options) {
|
|
7627
7657
|
const { data } = await dashboardRequest(
|
|
7628
|
-
`/api/1/playbook-integrations/applications/${appId}/playbooks/${
|
|
7658
|
+
`/api/1/playbook-integrations/applications/${appId}/playbooks/${slug2}/executions`,
|
|
7629
7659
|
playbookExecutionCreateResponseSchema,
|
|
7630
7660
|
{
|
|
7631
7661
|
method: "POST",
|
|
@@ -7666,9 +7696,9 @@ async function assessPlaybookExecution(uuid) {
|
|
|
7666
7696
|
var selectPlaybookSchema = z33.object({
|
|
7667
7697
|
slug: z33.string()
|
|
7668
7698
|
});
|
|
7669
|
-
function persistSlug(ctx,
|
|
7670
|
-
ctx.setUserInput("playbookSlug",
|
|
7671
|
-
return { slug };
|
|
7699
|
+
function persistSlug(ctx, slug2) {
|
|
7700
|
+
ctx.setUserInput("playbookSlug", slug2);
|
|
7701
|
+
return { slug: slug2 };
|
|
7672
7702
|
}
|
|
7673
7703
|
async function selectPlaybookStep(ctx, requestedSlug) {
|
|
7674
7704
|
const playbooks = await getPlaybooks();
|
|
@@ -7799,13 +7829,13 @@ async function confirmIndexStep(ctx) {
|
|
|
7799
7829
|
if (!sampleIndex) {
|
|
7800
7830
|
return null;
|
|
7801
7831
|
}
|
|
7802
|
-
const { slug } = ctx.getStepOutput("select-playbook");
|
|
7832
|
+
const { slug: slug2 } = ctx.getStepOutput("select-playbook");
|
|
7803
7833
|
const selection = await ctx.requestUserInput({
|
|
7804
7834
|
prompt: "Ready to create sample index?",
|
|
7805
7835
|
promptType: "multipleChoice",
|
|
7806
7836
|
options: [CONTINUE_OPTION, GO_BACK_OPTION2],
|
|
7807
7837
|
messages: [
|
|
7808
|
-
`A new index called "algolia_playbooks_${
|
|
7838
|
+
`A new index called "algolia_playbooks_${slug2}_sample_index" will be created with sample ${slug2} data.`
|
|
7809
7839
|
],
|
|
7810
7840
|
helpText: "Going back lets you choose a different index."
|
|
7811
7841
|
});
|
|
@@ -7957,13 +7987,13 @@ var POLL_NOTICES = [
|
|
|
7957
7987
|
{ message: "detecting required fields\u2026" }
|
|
7958
7988
|
];
|
|
7959
7989
|
async function dataAssessmentStep(ctx) {
|
|
7960
|
-
const { slug } = ctx.getStepOutput("select-playbook");
|
|
7990
|
+
const { slug: slug2 } = ctx.getStepOutput("select-playbook");
|
|
7961
7991
|
const { indexName, existingExecution } = indexForAssessment(ctx);
|
|
7962
7992
|
if (existingExecution) return existingExecution;
|
|
7963
7993
|
try {
|
|
7964
7994
|
showNotice(ctx, CREATING_EXECUTION_NOTICE);
|
|
7965
7995
|
const { id: appId } = await requireApplication();
|
|
7966
|
-
const execution = await resolveExecution(ctx, appId,
|
|
7996
|
+
const execution = await resolveExecution(ctx, appId, slug2, indexName);
|
|
7967
7997
|
const assessed = await runAssessment(ctx, execution, indexName);
|
|
7968
7998
|
ctx.clearNotices();
|
|
7969
7999
|
await promptReady(ctx, assessed);
|
|
@@ -8068,24 +8098,24 @@ function unexpectedAssessmentStatus(status) {
|
|
|
8068
8098
|
`data-assessment received an unexpected assessment status: ${status}`
|
|
8069
8099
|
);
|
|
8070
8100
|
}
|
|
8071
|
-
async function resolveExecution(ctx, appId,
|
|
8072
|
-
const created = await createWithRecovery(ctx, appId,
|
|
8101
|
+
async function resolveExecution(ctx, appId, slug2, indexName) {
|
|
8102
|
+
const created = await createWithRecovery(ctx, appId, slug2, indexName);
|
|
8073
8103
|
if (!created.resumed) return created;
|
|
8074
8104
|
const choice = await promptResumeExecution(ctx, indexName);
|
|
8075
8105
|
if (choice === CONTINUE_EXECUTION_OPTION) return created;
|
|
8076
8106
|
if (choice === RESTART_OPTION) {
|
|
8077
|
-
return createWithRecovery(ctx, appId,
|
|
8107
|
+
return createWithRecovery(ctx, appId, slug2, indexName, { forceNew: true });
|
|
8078
8108
|
}
|
|
8079
8109
|
if (choice === GO_BACK_OPTION3) {
|
|
8080
8110
|
return ctx.returnToStep("select-index");
|
|
8081
8111
|
}
|
|
8082
8112
|
throw new Error("data-assessment received an unexpected execution choice");
|
|
8083
8113
|
}
|
|
8084
|
-
async function createWithRecovery(ctx, appId,
|
|
8114
|
+
async function createWithRecovery(ctx, appId, slug2, indexName, options) {
|
|
8085
8115
|
return retryOnDashboardError(
|
|
8086
8116
|
() => {
|
|
8087
8117
|
showNotice(ctx, CREATING_EXECUTION_NOTICE);
|
|
8088
|
-
return createPlaybookExecution(appId,
|
|
8118
|
+
return createPlaybookExecution(appId, slug2, indexName, options);
|
|
8089
8119
|
},
|
|
8090
8120
|
onRequestFailure(ctx, indexName)
|
|
8091
8121
|
);
|
|
@@ -9764,7 +9794,7 @@ async function resetProjectState() {
|
|
|
9764
9794
|
// package.json with { type: 'json' }
|
|
9765
9795
|
var package_default2 = {
|
|
9766
9796
|
name: "@algolia/wizard",
|
|
9767
|
-
version: "0.
|
|
9797
|
+
version: "0.91.0",
|
|
9768
9798
|
description: "Magically implement Algolia functionality in your codebase",
|
|
9769
9799
|
type: "module",
|
|
9770
9800
|
engines: {
|