feat(phase4): !auto on/off 명령어 - Discord에서 Antigravity 자동승인 토글
This commit is contained in:
26
bot.py
26
bot.py
@@ -445,8 +445,30 @@ class GravityBot(commands.Bot):
|
|||||||
conv_id = cid
|
conv_id = cid
|
||||||
break
|
break
|
||||||
|
|
||||||
if conv_id and message.content.strip():
|
text = message.content.strip()
|
||||||
self.bridge.write_command(conv_id, message.content.strip())
|
|
||||||
|
# Special command: !auto on/off
|
||||||
|
if text in ("!auto on", "!auto off"):
|
||||||
|
if conv_id:
|
||||||
|
self.bridge.write_command(conv_id, text)
|
||||||
|
enabled = text == "!auto on"
|
||||||
|
emoji = "🟢" if enabled else "🔴"
|
||||||
|
mode = "자동 승인" if enabled else "수동 승인"
|
||||||
|
embed = discord.Embed(
|
||||||
|
title=f"{emoji} {mode} 모드",
|
||||||
|
description=f"Antigravity IDE 설정이 변경됩니다.\n"
|
||||||
|
f"`chat.tools.autoApprove = {enabled}`\n"
|
||||||
|
f"`chat.agent.autoApprove = {enabled}`",
|
||||||
|
color=discord.Color.green() if enabled else discord.Color.red(),
|
||||||
|
)
|
||||||
|
await message.channel.send(embed=embed)
|
||||||
|
else:
|
||||||
|
await message.reply("⚠️ 채널에 연결된 세션이 없습니다.")
|
||||||
|
return
|
||||||
|
|
||||||
|
# General text relay
|
||||||
|
if conv_id and text:
|
||||||
|
self.bridge.write_command(conv_id, text)
|
||||||
await message.add_reaction("📨")
|
await message.add_reaction("📨")
|
||||||
|
|
||||||
await self.process_commands(message)
|
await self.process_commands(message)
|
||||||
|
|||||||
Binary file not shown.
@@ -157,7 +157,7 @@ async function handleResponse(filePath: string) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a text command from Discord.
|
* 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) {
|
async function handleCommand(filePath: string) {
|
||||||
try {
|
try {
|
||||||
@@ -170,14 +170,24 @@ async function handleCommand(filePath: string) {
|
|||||||
|
|
||||||
if (command.consumed || !command.text) { return; }
|
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');
|
await vscode.commands.executeCommand('workbench.action.chat.open');
|
||||||
// Small delay for chat panel to open
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 500));
|
await new Promise(resolve => setTimeout(resolve, 500));
|
||||||
|
|
||||||
// Type the text using clipboard
|
|
||||||
const oldClipboard = await vscode.env.clipboard.readText();
|
const oldClipboard = await vscode.env.clipboard.readText();
|
||||||
await vscode.env.clipboard.writeText(command.text);
|
await vscode.env.clipboard.writeText(command.text);
|
||||||
await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
|
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.
|
* Simulate approval — try multiple strategies.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user