feat(phase4): !auto on/off 명령어 - Discord에서 Antigravity 자동승인 토글

This commit is contained in:
2026-03-07 13:01:07 +09:00
parent 8b3d723650
commit de6f1c7ffd
3 changed files with 83 additions and 7 deletions

Binary file not shown.

View File

@@ -157,7 +157,7 @@ async function handleResponse(filePath: string) {
/**
* Handle a text command from Discord.
* Types the text into the active editor or chat input.
* Supports special commands (!auto on/off) and general text relay.
*/
async function handleCommand(filePath: string) {
try {
@@ -170,14 +170,24 @@ async function handleCommand(filePath: string) {
if (command.consumed || !command.text) { return; }
console.log(`Gravity Bridge: command received — "${command.text.substring(0, 50)}..."`);
const text = command.text.trim();
console.log(`Gravity Bridge: command received — "${text.substring(0, 50)}"`);
// Type into the active text input (chat panel)
// Special command: auto-approve toggle
if (text === '!auto on' || text === '!auto off') {
const enabled = text === '!auto on';
await toggleAutoApprove(enabled);
// Mark as consumed
command.consumed = true;
fs.writeFileSync(filePath, JSON.stringify(command, null, 2), 'utf-8');
return;
}
// General text: type into chat panel
await vscode.commands.executeCommand('workbench.action.chat.open');
// Small delay for chat panel to open
await new Promise(resolve => setTimeout(resolve, 500));
// Type the text using clipboard
const oldClipboard = await vscode.env.clipboard.readText();
await vscode.env.clipboard.writeText(command.text);
await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
@@ -193,6 +203,50 @@ async function handleCommand(filePath: string) {
}
}
/**
* Toggle Antigravity's auto-approve settings.
*/
async function toggleAutoApprove(enabled: boolean) {
const config = vscode.workspace.getConfiguration();
try {
// Core auto-approve settings
await config.update('chat.tools.autoApprove', enabled, vscode.ConfigurationTarget.Global);
await config.update('chat.agent.autoApprove', enabled, vscode.ConfigurationTarget.Global);
// Terminal auto-execution
if (enabled) {
await config.update('chat.tools.terminal.enableAutoApprove', true, vscode.ConfigurationTarget.Global);
}
// File edits auto-accept
await config.update('autoAcceptV2.autoAcceptFileEdits', enabled, vscode.ConfigurationTarget.Global);
// Update status bar
statusBar.text = enabled
? '$(radio-tower) Bridge: Auto ✅'
: '$(radio-tower) Bridge: Manual 🔒';
const mode = enabled ? '자동 승인 ON 🟢' : '수동 승인 OFF 🔴';
vscode.window.showInformationMessage(`Gravity Bridge: ${mode}`);
console.log(`Gravity Bridge: auto-approve set to ${enabled}`);
// Write status back to bridge for bot to report
const statusPath = path.join(bridgePath, 'commands', `auto-status-${Date.now()}.json`);
fs.writeFileSync(statusPath, JSON.stringify({
id: `auto-status-${Date.now()}`,
text: `[SYSTEM] Auto-approve: ${enabled ? 'ON' : 'OFF'}`,
timestamp: Date.now() / 1000,
consumed: true,
auto_approve: enabled,
}, null, 2), 'utf-8');
} catch (err) {
console.error('Gravity Bridge: failed to toggle auto-approve', err);
vscode.window.showErrorMessage(`Auto-approve toggle failed: ${err}`);
}
}
/**
* Simulate approval — try multiple strategies.
*/