Skip to content

Commit 26c0ffa

Browse files
NagyViktNagyVikt
andauthored
Require explicit interactive consent before self-updating status runs (#15)
Users reported accidental updates when no input was intended. The update check now always prompts in interactive terminals and only honors MUSAFETY_AUTO_UPDATE_APPROVAL in non-interactive runs. Constraint: Keep non-interactive automation support for CI/scripting Rejected: Remove env-based auto-approval entirely | would break existing unattended workflows Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep interactive update decisions explicit unless a user passes a command flag for opt-in behavior Tested: npm test (43/43); pseudo-interactive run with MUSAFETY_AUTO_UPDATE_APPROVAL=yes showed prompt and skipped on blank input Not-tested: Real human tty keystroke path in all terminal emulators Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
1 parent d328398 commit 26c0ffa

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

bin/multiagent-safety.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,12 +1262,12 @@ function maybeSelfUpdateBeforeStatus() {
12621262
return;
12631263
}
12641264

1265-
const shouldUpdate = autoApproval != null
1266-
? autoApproval
1267-
: promptYesNo(
1265+
const shouldUpdate = interactive
1266+
? promptYesNo(
12681267
`Update now? (${NPM_BIN} i -g ${packageJson.name}@latest)`,
12691268
false,
1270-
);
1269+
)
1270+
: autoApproval;
12711271

12721272
if (!shouldUpdate) {
12731273
console.log(`[${TOOL_NAME}] Skipped update.`);

test/install.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ test('self-update prompt defaults to no when approval is not preconfigured', ()
364364
const source = fs.readFileSync(cliPath, 'utf8');
365365
assert.match(
366366
source,
367-
/promptYesNo\(\s*`Update now\?\s*\(\$\{NPM_BIN\} i -g \$\{packageJson\.name\}@latest\)`\s*,\s*false,\s*\)/s,
367+
/const shouldUpdate = interactive\s*\?\s*promptYesNo\(\s*`Update now\?\s*\(\$\{NPM_BIN\} i -g \$\{packageJson\.name\}@latest\)`\s*,\s*false,\s*\)\s*:\s*autoApproval;/s,
368368
);
369369
});
370370

0 commit comments

Comments
 (0)