This pass rewrites comment-only ANT-ONLY markers to neutral internal-only language across the source tree without changing runtime strings, flags, commands, or protocol identifiers. The goal is to lower obvious internal prose leakage while keeping the diff mechanically safe and easy to review. Constraint: Phase B is limited to comments/prose only; runtime strings and user-facing labels remain deferred Rejected: Broad search-and-replace across strings and command descriptions | too risky for a prose-only pass Confidence: high Scope-risk: narrow Reversibility: clean Directive: Remaining ANT-ONLY hits are mostly runtime/user-facing strings and should be handled separately from comment cleanup Tested: bun run build Tested: bun run smoke Tested: bun run verify:privacy Tested: bun run test:provider Tested: bun run test:provider-recommendation Not-tested: Full repo typecheck (upstream baseline remains noisy) Co-authored-by: anandh8x <test@example.com>
91 lines
3.2 KiB
TypeScript
91 lines
3.2 KiB
TypeScript
import { POWERSHELL_TOOL_NAME } from '../../../tools/PowerShellTool/toolName.js';
|
|
import type { PermissionUpdate } from '../../../utils/permissions/PermissionUpdateSchema.js';
|
|
import { shouldShowAlwaysAllowOptions } from '../../../utils/permissions/permissionsLoader.js';
|
|
import type { OptionWithDescription } from '../../CustomSelect/select.js';
|
|
import { generateShellSuggestionsLabel } from '../shellPermissionHelpers.js';
|
|
export type PowerShellToolUseOption = 'yes' | 'yes-apply-suggestions' | 'yes-prefix-edited' | 'no';
|
|
export function powershellToolUseOptions({
|
|
suggestions = [],
|
|
onRejectFeedbackChange,
|
|
onAcceptFeedbackChange,
|
|
yesInputMode = false,
|
|
noInputMode = false,
|
|
editablePrefix,
|
|
onEditablePrefixChange
|
|
}: {
|
|
suggestions?: PermissionUpdate[];
|
|
onRejectFeedbackChange: (value: string) => void;
|
|
onAcceptFeedbackChange: (value: string) => void;
|
|
yesInputMode?: boolean;
|
|
noInputMode?: boolean;
|
|
editablePrefix?: string;
|
|
onEditablePrefixChange?: (value: string) => void;
|
|
}): OptionWithDescription<PowerShellToolUseOption>[] {
|
|
const options: OptionWithDescription<PowerShellToolUseOption>[] = [];
|
|
if (yesInputMode) {
|
|
options.push({
|
|
type: 'input',
|
|
label: 'Yes',
|
|
value: 'yes',
|
|
placeholder: 'and tell Claude what to do next',
|
|
onChange: onAcceptFeedbackChange,
|
|
allowEmptySubmitToCancel: true
|
|
});
|
|
} else {
|
|
options.push({
|
|
label: 'Yes',
|
|
value: 'yes'
|
|
});
|
|
}
|
|
|
|
// Note: No sandbox toggle for PowerShell - sandbox is not supported on Windows
|
|
// Note: No classifier-reviewed option for PowerShell (internal-only feature for Bash)
|
|
|
|
// Only show "always allow" options when not restricted by allowManagedPermissionRulesOnly.
|
|
// Prefer the editable prefix input (static extractor + user edits) over the
|
|
// non-editable suggestions label. The editable input can't represent
|
|
// directory permissions or Read-tool rules, so fall back to the label when
|
|
// those are present.
|
|
if (shouldShowAlwaysAllowOptions() && suggestions.length > 0) {
|
|
const hasNonPowerShellSuggestions = suggestions.some(s => s.type === 'addDirectories' || s.type === 'addRules' && s.rules?.some(r => r.toolName !== POWERSHELL_TOOL_NAME));
|
|
if (editablePrefix !== undefined && onEditablePrefixChange && !hasNonPowerShellSuggestions) {
|
|
options.push({
|
|
type: 'input',
|
|
label: 'Yes, and don\u2019t ask again for',
|
|
value: 'yes-prefix-edited',
|
|
placeholder: 'command prefix (e.g., Get-Process:*)',
|
|
initialValue: editablePrefix,
|
|
onChange: onEditablePrefixChange,
|
|
allowEmptySubmitToCancel: true,
|
|
showLabelWithValue: true,
|
|
labelValueSeparator: ': ',
|
|
resetCursorOnUpdate: true
|
|
});
|
|
} else {
|
|
const label = generateShellSuggestionsLabel(suggestions, POWERSHELL_TOOL_NAME);
|
|
if (label) {
|
|
options.push({
|
|
label,
|
|
value: 'yes-apply-suggestions'
|
|
});
|
|
}
|
|
}
|
|
}
|
|
if (noInputMode) {
|
|
options.push({
|
|
type: 'input',
|
|
label: 'No',
|
|
value: 'no',
|
|
placeholder: 'and tell Claude what to do differently',
|
|
onChange: onRejectFeedbackChange,
|
|
allowEmptySubmitToCancel: true
|
|
});
|
|
} else {
|
|
options.push({
|
|
label: 'No',
|
|
value: 'no'
|
|
});
|
|
}
|
|
return options;
|
|
}
|