@algolia/wizard 0.79.0 → 0.80.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 +71 -23
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2306,7 +2306,7 @@ async function ensureApplication(resumeAppId) {
|
|
|
2306
2306
|
// package.json
|
|
2307
2307
|
var package_default = {
|
|
2308
2308
|
name: "@algolia/wizard",
|
|
2309
|
-
version: "0.
|
|
2309
|
+
version: "0.80.0",
|
|
2310
2310
|
description: "Magically implement Algolia functionality in your codebase",
|
|
2311
2311
|
type: "module",
|
|
2312
2312
|
engines: {
|
|
@@ -3858,6 +3858,14 @@ function reviewScriptTool(ctx) {
|
|
|
3858
3858
|
});
|
|
3859
3859
|
}
|
|
3860
3860
|
|
|
3861
|
+
// src/lib/tools/utils/redactSecrets.ts
|
|
3862
|
+
function redactSecrets(output, secrets) {
|
|
3863
|
+
return [...new Set(Object.values(secrets).filter(Boolean))].sort((a, b) => b.length - a.length).reduce(
|
|
3864
|
+
(redacted, secret) => redacted.split(secret).join("[REDACTED]"),
|
|
3865
|
+
output
|
|
3866
|
+
);
|
|
3867
|
+
}
|
|
3868
|
+
|
|
3861
3869
|
// src/lib/tools/utils/runShell.ts
|
|
3862
3870
|
import { spawn as spawn2 } from "node:child_process";
|
|
3863
3871
|
|
|
@@ -3879,9 +3887,14 @@ var DEFAULT_SHELL_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
|
3879
3887
|
async function refuseByDefault() {
|
|
3880
3888
|
return "reject";
|
|
3881
3889
|
}
|
|
3890
|
+
async function emptyShellEnv() {
|
|
3891
|
+
await Promise.resolve();
|
|
3892
|
+
return {};
|
|
3893
|
+
}
|
|
3882
3894
|
function createShellContext(overrides = {}) {
|
|
3883
3895
|
return {
|
|
3884
|
-
env:
|
|
3896
|
+
env: emptyShellEnv,
|
|
3897
|
+
secretEnv: emptyShellEnv,
|
|
3885
3898
|
timeoutMs: DEFAULT_SHELL_TIMEOUT_MS,
|
|
3886
3899
|
executions: [],
|
|
3887
3900
|
approve: refuseByDefault,
|
|
@@ -3924,7 +3937,9 @@ function runShell(command, opts) {
|
|
|
3924
3937
|
clearTimeout(killTimer);
|
|
3925
3938
|
resolve6({
|
|
3926
3939
|
exitCode,
|
|
3927
|
-
output: truncateText(
|
|
3940
|
+
output: truncateText(
|
|
3941
|
+
redactSecrets(output.trim(), opts.secrets ?? {})
|
|
3942
|
+
),
|
|
3928
3943
|
timedOut,
|
|
3929
3944
|
durationMs: Date.now() - startedAt
|
|
3930
3945
|
});
|
|
@@ -4250,13 +4265,22 @@ async function resolveShellEnv(ctx, command) {
|
|
|
4250
4265
|
return {};
|
|
4251
4266
|
});
|
|
4252
4267
|
}
|
|
4253
|
-
async function
|
|
4268
|
+
async function resolveSecretShellEnv(ctx, command) {
|
|
4269
|
+
return ctx.shell.secretEnv().catch((err) => {
|
|
4270
|
+
logger.warn(
|
|
4271
|
+
{ err, command },
|
|
4272
|
+
"runShell: could not resolve secret command env"
|
|
4273
|
+
);
|
|
4274
|
+
return {};
|
|
4275
|
+
});
|
|
4276
|
+
}
|
|
4277
|
+
async function runAndRecord(ctx, command, environment) {
|
|
4254
4278
|
useWizard.getState().pushNotice({ messages: [`Running: ${command}`] });
|
|
4255
|
-
const env = resolvedEnv ?? await resolveShellEnv(ctx, command);
|
|
4256
4279
|
const run2 = await (ctx.shell.run ?? runShell)(command, {
|
|
4257
|
-
cwd,
|
|
4258
|
-
env,
|
|
4259
|
-
timeoutMs: ctx.shell.timeoutMs
|
|
4280
|
+
cwd: environment.cwd,
|
|
4281
|
+
env: environment.values,
|
|
4282
|
+
timeoutMs: ctx.shell.timeoutMs,
|
|
4283
|
+
secrets: environment.secrets
|
|
4260
4284
|
});
|
|
4261
4285
|
logger.info(
|
|
4262
4286
|
{
|
|
@@ -4268,29 +4292,40 @@ async function runAndRecord(ctx, command, cwd, resolvedEnv) {
|
|
|
4268
4292
|
"runShell finished"
|
|
4269
4293
|
);
|
|
4270
4294
|
await markInteraction();
|
|
4295
|
+
const output = redactSecrets(run2.output, environment.secrets);
|
|
4271
4296
|
ctx.shell.executions.push({
|
|
4272
4297
|
command,
|
|
4273
|
-
cwd,
|
|
4298
|
+
cwd: environment.cwd,
|
|
4274
4299
|
approved: true,
|
|
4275
4300
|
exitCode: run2.exitCode,
|
|
4276
|
-
output
|
|
4301
|
+
output,
|
|
4277
4302
|
timedOut: run2.timedOut,
|
|
4278
4303
|
durationMs: run2.durationMs
|
|
4279
4304
|
});
|
|
4280
4305
|
return {
|
|
4281
4306
|
exitCode: run2.exitCode,
|
|
4282
4307
|
timedOut: run2.timedOut,
|
|
4283
|
-
output
|
|
4308
|
+
output
|
|
4284
4309
|
};
|
|
4285
4310
|
}
|
|
4286
4311
|
async function runReviewedCommand(ctx, command, cwd) {
|
|
4287
4312
|
const approval = getReviewedCommandApproval(ctx, command, cwd);
|
|
4288
4313
|
if (!approval) return void 0;
|
|
4289
|
-
const env = await resolveShellEnv(ctx, command);
|
|
4290
4314
|
if (!await reviewedCommandApprovalIsCurrent(approval)) {
|
|
4291
4315
|
return `Refused: ${relative5(ctx.root, approval.filePath)} changed after review. Call reviewScript again before running it.`;
|
|
4292
4316
|
}
|
|
4293
|
-
const
|
|
4317
|
+
const [env, secrets] = await Promise.all([
|
|
4318
|
+
resolveShellEnv(ctx, command),
|
|
4319
|
+
resolveSecretShellEnv(ctx, command)
|
|
4320
|
+
]);
|
|
4321
|
+
if (!await reviewedCommandApprovalIsCurrent(approval)) {
|
|
4322
|
+
return `Refused: ${relative5(ctx.root, approval.filePath)} changed after review. Call reviewScript again before running it.`;
|
|
4323
|
+
}
|
|
4324
|
+
const result = await runAndRecord(
|
|
4325
|
+
ctx,
|
|
4326
|
+
command,
|
|
4327
|
+
{ cwd, values: { ...env, ...secrets }, secrets }
|
|
4328
|
+
);
|
|
4294
4329
|
if (result.exitCode === SUCCESS_EXIT_CODE && !result.timedOut) {
|
|
4295
4330
|
clearReviewedCommandApproval(ctx);
|
|
4296
4331
|
}
|
|
@@ -4303,7 +4338,14 @@ async function approveAndRun(ctx, command, cwd, explanation) {
|
|
|
4303
4338
|
logger.info({ command }, "runShell: user rejected the command");
|
|
4304
4339
|
return "The user rejected this command. Do not retry it. Propose a different command, or report the limitation via reportStatus.";
|
|
4305
4340
|
}
|
|
4306
|
-
return
|
|
4341
|
+
return runUnreviewedCommand(ctx, command, cwd);
|
|
4342
|
+
}
|
|
4343
|
+
async function runUnreviewedCommand(ctx, command, cwd) {
|
|
4344
|
+
const [env, secrets] = await Promise.all([
|
|
4345
|
+
resolveShellEnv(ctx, command),
|
|
4346
|
+
resolveSecretShellEnv(ctx, command)
|
|
4347
|
+
]);
|
|
4348
|
+
return runAndRecord(ctx, command, { cwd, values: env, secrets });
|
|
4307
4349
|
}
|
|
4308
4350
|
function runShellTool(ctx, createModel = defaultCreateModel) {
|
|
4309
4351
|
return tool9({
|
|
@@ -4362,7 +4404,7 @@ function runShellTool(ctx, createModel = defaultCreateModel) {
|
|
|
4362
4404
|
if (lateReview !== void 0) return lateReview;
|
|
4363
4405
|
const storedApprovalIsCurrent = !usedStoredApproval || useWizard.getState().isCommandApproved(command, resolved2.target);
|
|
4364
4406
|
if (isSafe && storedApprovalIsCurrent) {
|
|
4365
|
-
return
|
|
4407
|
+
return runUnreviewedCommand(ctx, command, resolved2.target);
|
|
4366
4408
|
}
|
|
4367
4409
|
return approveAndRun(ctx, command, resolved2.target, explanation);
|
|
4368
4410
|
});
|
|
@@ -5867,12 +5909,12 @@ function ingestFailure(attempt, executions) {
|
|
|
5867
5909
|
}
|
|
5868
5910
|
return { reason: `it failed (exit ${attempt.exitCode ?? "unknown"})`, detail };
|
|
5869
5911
|
}
|
|
5870
|
-
function makeToolContext(root, appId, env = async () => ({})) {
|
|
5912
|
+
function makeToolContext(root, appId, env = async () => ({}), secretEnv = async () => ({})) {
|
|
5871
5913
|
return {
|
|
5872
5914
|
...createToolContext(
|
|
5873
5915
|
DEFAULT_TOOL_LIMITS,
|
|
5874
5916
|
root,
|
|
5875
|
-
createShellContext({ env, approve: storeApproval(root) })
|
|
5917
|
+
createShellContext({ env, secretEnv, approve: storeApproval(root) })
|
|
5876
5918
|
),
|
|
5877
5919
|
appId
|
|
5878
5920
|
};
|
|
@@ -6096,11 +6138,17 @@ async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES) {
|
|
|
6096
6138
|
let ingestDurationMs;
|
|
6097
6139
|
let ingestOutcomeMessage;
|
|
6098
6140
|
const ingestKeyAppId = ingestAppId;
|
|
6099
|
-
const ingestionTools = ingestKeyAppId && ingestWriteKey ? makeToolContext(
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6141
|
+
const ingestionTools = ingestKeyAppId && ingestWriteKey ? makeToolContext(
|
|
6142
|
+
repoRoot,
|
|
6143
|
+
ctx.appId,
|
|
6144
|
+
async () => ({
|
|
6145
|
+
[APP_ID_VAR]: ingestKeyAppId,
|
|
6146
|
+
[INDEX_NAME_VAR]: targetIndex
|
|
6147
|
+
}),
|
|
6148
|
+
async () => ({
|
|
6149
|
+
[API_KEY_VAR]: ingestWriteKey
|
|
6150
|
+
})
|
|
6151
|
+
) : makeToolContext(repoRoot, ctx.appId);
|
|
6104
6152
|
async function runImplementationUseCase(currentUseCase, extraInstructions = [], isRetry = false) {
|
|
6105
6153
|
if (agentRuns > 0) ctx.recordStepExecution();
|
|
6106
6154
|
agentRuns += 1;
|
|
@@ -8515,7 +8563,7 @@ async function resetProjectState() {
|
|
|
8515
8563
|
// package.json with { type: 'json' }
|
|
8516
8564
|
var package_default2 = {
|
|
8517
8565
|
name: "@algolia/wizard",
|
|
8518
|
-
version: "0.
|
|
8566
|
+
version: "0.80.0",
|
|
8519
8567
|
description: "Magically implement Algolia functionality in your codebase",
|
|
8520
8568
|
type: "module",
|
|
8521
8569
|
engines: {
|