@algolia/wizard 0.63.0 → 0.65.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 +102 -21
- package/package.json +6 -6
package/dist/main.js
CHANGED
|
@@ -1760,7 +1760,7 @@ function identify(traits) {
|
|
|
1760
1760
|
// package.json
|
|
1761
1761
|
var package_default = {
|
|
1762
1762
|
name: "@algolia/wizard",
|
|
1763
|
-
version: "0.
|
|
1763
|
+
version: "0.65.0",
|
|
1764
1764
|
description: "Magically implement Algolia functionality in your codebase",
|
|
1765
1765
|
type: "module",
|
|
1766
1766
|
engines: {
|
|
@@ -1804,17 +1804,17 @@ var package_default = {
|
|
|
1804
1804
|
"lint-staged": "^17.0.8",
|
|
1805
1805
|
tsx: "^4.22.3",
|
|
1806
1806
|
typescript: "^6.0.3",
|
|
1807
|
-
vitest: "^4.1.
|
|
1807
|
+
vitest: "^4.1.11"
|
|
1808
1808
|
},
|
|
1809
1809
|
dependencies: {
|
|
1810
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
1811
|
-
"@ai-sdk/openai-compatible": "^2.0.
|
|
1810
|
+
"@ai-sdk/anthropic": "^3.0.118",
|
|
1811
|
+
"@ai-sdk/openai-compatible": "^2.0.75",
|
|
1812
1812
|
"@hono/node-server": "^2.0.10",
|
|
1813
1813
|
"@segment/analytics-node": "^3.1.0",
|
|
1814
|
-
ai: "^6.0.
|
|
1814
|
+
ai: "^6.0.283",
|
|
1815
1815
|
"cross-keychain": "^1.1.0",
|
|
1816
1816
|
dotenv: "^17.4.2",
|
|
1817
|
-
hono: "^4.
|
|
1817
|
+
hono: "^4.13.8",
|
|
1818
1818
|
ink: "^7.0.5",
|
|
1819
1819
|
"ink-picture": "^2.1.0",
|
|
1820
1820
|
"ink-spinner": "^5.0.0",
|
|
@@ -1834,6 +1834,16 @@ function defineStep(step) {
|
|
|
1834
1834
|
return { visible: true, ...step };
|
|
1835
1835
|
}
|
|
1836
1836
|
var nowIso = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
1837
|
+
var ReturnToStepSignal = class extends Error {
|
|
1838
|
+
constructor(targetIndex, stepId) {
|
|
1839
|
+
super(`returnToStep: ${stepId}`);
|
|
1840
|
+
this.targetIndex = targetIndex;
|
|
1841
|
+
this.stepId = stepId;
|
|
1842
|
+
this.name = "ReturnToStepSignal";
|
|
1843
|
+
}
|
|
1844
|
+
targetIndex;
|
|
1845
|
+
stepId;
|
|
1846
|
+
};
|
|
1837
1847
|
function ensureExecutedStepCount(state) {
|
|
1838
1848
|
if (state.executedStepCount == null) {
|
|
1839
1849
|
state.executedStepCount = state.steps.filter(
|
|
@@ -1954,12 +1964,37 @@ async function makeContext(state) {
|
|
|
1954
1964
|
setUserInput: (key, value) => {
|
|
1955
1965
|
state.userInputs[key] = value;
|
|
1956
1966
|
},
|
|
1967
|
+
getUserInput: (key) => state.userInputs[key],
|
|
1957
1968
|
recordStepExecution: (count = 1) => {
|
|
1958
1969
|
state.executedStepCount = (state.executedStepCount ?? 0) + count;
|
|
1959
1970
|
},
|
|
1971
|
+
returnToStep: (stepId) => {
|
|
1972
|
+
const targetIndex = state.steps.findIndex((s) => s.id === stepId);
|
|
1973
|
+
if (targetIndex === -1) {
|
|
1974
|
+
throw new Error(`returnToStep: unknown step id "${stepId}"`);
|
|
1975
|
+
}
|
|
1976
|
+
if (targetIndex >= state.currentStepIndex) {
|
|
1977
|
+
throw new Error(
|
|
1978
|
+
`returnToStep: "${stepId}" is not before the running step "${state.steps[state.currentStepIndex]?.id}"`
|
|
1979
|
+
);
|
|
1980
|
+
}
|
|
1981
|
+
throw new ReturnToStepSignal(targetIndex, stepId);
|
|
1982
|
+
},
|
|
1960
1983
|
config: await loadConfig()
|
|
1961
1984
|
};
|
|
1962
1985
|
}
|
|
1986
|
+
async function rewindTo(state, targetIndex, fromIndex) {
|
|
1987
|
+
for (let i = targetIndex; i <= fromIndex; i++) {
|
|
1988
|
+
const record = state.steps[i];
|
|
1989
|
+
record.status = "pending";
|
|
1990
|
+
delete record.output;
|
|
1991
|
+
delete record.error;
|
|
1992
|
+
}
|
|
1993
|
+
state.currentStepIndex = targetIndex;
|
|
1994
|
+
state.updatedAt = nowIso();
|
|
1995
|
+
useWizard.getState().syncSteps([...state.steps], targetIndex);
|
|
1996
|
+
await saveWorkflowState(state);
|
|
1997
|
+
}
|
|
1963
1998
|
async function runStep(state, index, step, appId) {
|
|
1964
1999
|
const store = useWizard.getState();
|
|
1965
2000
|
const record = state.steps[index];
|
|
@@ -1981,9 +2016,18 @@ async function runStep(state, index, step, appId) {
|
|
|
1981
2016
|
await saveWorkflowState(state);
|
|
1982
2017
|
await markInteraction();
|
|
1983
2018
|
const ctx = await makeContext(state);
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
2019
|
+
let output;
|
|
2020
|
+
try {
|
|
2021
|
+
const raw = await step.run(ctx);
|
|
2022
|
+
output = step.outputSchema.parse(raw);
|
|
2023
|
+
await step.onStepComplete?.(output, ctx);
|
|
2024
|
+
} catch (err) {
|
|
2025
|
+
if (err instanceof ReturnToStepSignal) {
|
|
2026
|
+
await rewindTo(state, err.targetIndex, index);
|
|
2027
|
+
return err.targetIndex;
|
|
2028
|
+
}
|
|
2029
|
+
throw err;
|
|
2030
|
+
}
|
|
1987
2031
|
record.status = "done";
|
|
1988
2032
|
record.output = output;
|
|
1989
2033
|
state.updatedAt = nowIso();
|
|
@@ -1996,6 +2040,7 @@ async function runStep(state, index, step, appId) {
|
|
|
1996
2040
|
actionTitle: step.title,
|
|
1997
2041
|
durationMs: Date.now() - startedAt
|
|
1998
2042
|
});
|
|
2043
|
+
return void 0;
|
|
1999
2044
|
}
|
|
2000
2045
|
var RESUME_OPTION = "Resume";
|
|
2001
2046
|
var START_NEW_OPTION = "Start a new one";
|
|
@@ -2040,8 +2085,10 @@ async function runWorkflow(workflow, appId, options) {
|
|
|
2040
2085
|
wizard_version: package_default.version,
|
|
2041
2086
|
os: process.platform
|
|
2042
2087
|
});
|
|
2043
|
-
|
|
2044
|
-
|
|
2088
|
+
let i = state.currentStepIndex;
|
|
2089
|
+
while (i < workflow.steps.length) {
|
|
2090
|
+
const rewoundTo = await runStep(state, i, workflow.steps[i], appId);
|
|
2091
|
+
i = rewoundTo ?? i + 1;
|
|
2045
2092
|
}
|
|
2046
2093
|
const totalDurationMs = Date.now() - Date.parse(state.startedAt);
|
|
2047
2094
|
const stepCount = state.executedStepCount ?? state.steps.filter((s) => s.status === "done" && isStepVisible(s)).length;
|
|
@@ -5529,10 +5576,11 @@ async function selectPlaybookStep(ctx, requestedSlug) {
|
|
|
5529
5576
|
if (slugs.length === 0) {
|
|
5530
5577
|
throw new Error("No playbooks are available.");
|
|
5531
5578
|
}
|
|
5532
|
-
|
|
5579
|
+
const alreadyChose = typeof ctx.getUserInput("playbookSlug") === "string";
|
|
5580
|
+
if (!alreadyChose && requestedSlug && slugs.includes(requestedSlug)) {
|
|
5533
5581
|
return persistSlug(ctx, requestedSlug);
|
|
5534
5582
|
}
|
|
5535
|
-
const messages = requestedSlug ? [
|
|
5583
|
+
const messages = !alreadyChose && requestedSlug ? [
|
|
5536
5584
|
`"${requestedSlug}" is not a valid playbook. Choose one of the available playbooks:`
|
|
5537
5585
|
] : ["Choose a playbook:"];
|
|
5538
5586
|
const selection = await ctx.requestUserInput({
|
|
@@ -5547,6 +5595,28 @@ async function selectPlaybookStep(ctx, requestedSlug) {
|
|
|
5547
5595
|
return persistSlug(ctx, selection);
|
|
5548
5596
|
}
|
|
5549
5597
|
|
|
5598
|
+
// src/actions/playbookSteps/confirmPlaybook.ts
|
|
5599
|
+
import { z as z33 } from "zod";
|
|
5600
|
+
var confirmPlaybookSchema = z33.void();
|
|
5601
|
+
var CONTINUE_OPTION = "Looks good, continue";
|
|
5602
|
+
var GO_BACK_OPTION = "Go back";
|
|
5603
|
+
async function confirmPlaybookStep(ctx) {
|
|
5604
|
+
const { slug } = ctx.getStepOutput("select-playbook");
|
|
5605
|
+
const selection = await ctx.requestUserInput({
|
|
5606
|
+
prompt: "Ready to continue?",
|
|
5607
|
+
promptType: "multipleChoice",
|
|
5608
|
+
options: [CONTINUE_OPTION, GO_BACK_OPTION],
|
|
5609
|
+
messages: [`Playbook: ${slug}`],
|
|
5610
|
+
helpText: "Going back re-opens the playbook catalogue."
|
|
5611
|
+
});
|
|
5612
|
+
if (typeof selection !== "string") {
|
|
5613
|
+
throw new Error("confirm-playbook received an unexpected result");
|
|
5614
|
+
}
|
|
5615
|
+
if (selection === GO_BACK_OPTION) {
|
|
5616
|
+
return ctx.returnToStep("select-playbook");
|
|
5617
|
+
}
|
|
5618
|
+
}
|
|
5619
|
+
|
|
5550
5620
|
// src/lib/cli.ts
|
|
5551
5621
|
var USAGE = `Usage: wizard [workflow-id] [options]
|
|
5552
5622
|
wizard playbook [playbook-slug] [options]
|
|
@@ -5613,6 +5683,13 @@ var playbookWorkflow = {
|
|
|
5613
5683
|
title: "Select playbook",
|
|
5614
5684
|
outputSchema: selectPlaybookSchema,
|
|
5615
5685
|
run: (ctx) => selectPlaybookStep(ctx, getPlaybookSlugArg())
|
|
5686
|
+
}),
|
|
5687
|
+
defineStep({
|
|
5688
|
+
id: "confirm-playbook",
|
|
5689
|
+
title: "Confirm selections",
|
|
5690
|
+
outputSchema: confirmPlaybookSchema,
|
|
5691
|
+
visible: false,
|
|
5692
|
+
run: (ctx) => confirmPlaybookStep(ctx)
|
|
5616
5693
|
})
|
|
5617
5694
|
]
|
|
5618
5695
|
};
|
|
@@ -6827,9 +6904,13 @@ var SEEDS = {
|
|
|
6827
6904
|
review
|
|
6828
6905
|
},
|
|
6829
6906
|
playbook: {
|
|
6830
|
-
"select-playbook": selectPlaybook
|
|
6907
|
+
"select-playbook": selectPlaybook,
|
|
6908
|
+
"confirm-playbook": void 0
|
|
6831
6909
|
}
|
|
6832
6910
|
};
|
|
6911
|
+
var SEED_ALGOLIA_STATE = {
|
|
6912
|
+
playbook: { appId: "SEEDAPPID" }
|
|
6913
|
+
};
|
|
6833
6914
|
var SEED_USER_INPUTS = {
|
|
6834
6915
|
default: {
|
|
6835
6916
|
index: selectIndex.selection,
|
|
@@ -6881,7 +6962,7 @@ function buildSeedState(workflow, startIndex) {
|
|
|
6881
6962
|
updatedAt: now,
|
|
6882
6963
|
currentStepIndex: startIndex,
|
|
6883
6964
|
steps,
|
|
6884
|
-
algoliaState: {},
|
|
6965
|
+
algoliaState: startIndex > 0 ? { ...SEED_ALGOLIA_STATE[workflow.id] } : {},
|
|
6885
6966
|
userInputs: startIndex > 0 ? { ...SEED_USER_INPUTS[workflow.id] } : {}
|
|
6886
6967
|
};
|
|
6887
6968
|
}
|
|
@@ -6993,7 +7074,7 @@ function delay(ms) {
|
|
|
6993
7074
|
// package.json with { type: 'json' }
|
|
6994
7075
|
var package_default2 = {
|
|
6995
7076
|
name: "@algolia/wizard",
|
|
6996
|
-
version: "0.
|
|
7077
|
+
version: "0.65.0",
|
|
6997
7078
|
description: "Magically implement Algolia functionality in your codebase",
|
|
6998
7079
|
type: "module",
|
|
6999
7080
|
engines: {
|
|
@@ -7037,17 +7118,17 @@ var package_default2 = {
|
|
|
7037
7118
|
"lint-staged": "^17.0.8",
|
|
7038
7119
|
tsx: "^4.22.3",
|
|
7039
7120
|
typescript: "^6.0.3",
|
|
7040
|
-
vitest: "^4.1.
|
|
7121
|
+
vitest: "^4.1.11"
|
|
7041
7122
|
},
|
|
7042
7123
|
dependencies: {
|
|
7043
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
7044
|
-
"@ai-sdk/openai-compatible": "^2.0.
|
|
7124
|
+
"@ai-sdk/anthropic": "^3.0.118",
|
|
7125
|
+
"@ai-sdk/openai-compatible": "^2.0.75",
|
|
7045
7126
|
"@hono/node-server": "^2.0.10",
|
|
7046
7127
|
"@segment/analytics-node": "^3.1.0",
|
|
7047
|
-
ai: "^6.0.
|
|
7128
|
+
ai: "^6.0.283",
|
|
7048
7129
|
"cross-keychain": "^1.1.0",
|
|
7049
7130
|
dotenv: "^17.4.2",
|
|
7050
|
-
hono: "^4.
|
|
7131
|
+
hono: "^4.13.8",
|
|
7051
7132
|
ink: "^7.0.5",
|
|
7052
7133
|
"ink-picture": "^2.1.0",
|
|
7053
7134
|
"ink-spinner": "^5.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algolia/wizard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"description": "Magically implement Algolia functionality in your codebase",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -44,17 +44,17 @@
|
|
|
44
44
|
"lint-staged": "^17.0.8",
|
|
45
45
|
"tsx": "^4.22.3",
|
|
46
46
|
"typescript": "^6.0.3",
|
|
47
|
-
"vitest": "^4.1.
|
|
47
|
+
"vitest": "^4.1.11"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
51
|
-
"@ai-sdk/openai-compatible": "^2.0.
|
|
50
|
+
"@ai-sdk/anthropic": "^3.0.118",
|
|
51
|
+
"@ai-sdk/openai-compatible": "^2.0.75",
|
|
52
52
|
"@hono/node-server": "^2.0.10",
|
|
53
53
|
"@segment/analytics-node": "^3.1.0",
|
|
54
|
-
"ai": "^6.0.
|
|
54
|
+
"ai": "^6.0.283",
|
|
55
55
|
"cross-keychain": "^1.1.0",
|
|
56
56
|
"dotenv": "^17.4.2",
|
|
57
|
-
"hono": "^4.
|
|
57
|
+
"hono": "^4.13.8",
|
|
58
58
|
"ink": "^7.0.5",
|
|
59
59
|
"ink-picture": "^2.1.0",
|
|
60
60
|
"ink-spinner": "^5.0.0",
|