File size: 3,011 Bytes
2516c8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

const vscode = require('vscode');
const fs = require('fs');
const path = require('path');

let autoAcceptInterval = null;
let enabled = true;
let statusBarItem;

// All known Antigravity accept/run commands that dismiss permission dialogs.
// These are fired in parallel every tick to catch any pending approval request.
const ACCEPT_COMMANDS = [
    // Terminal command approvals (covers "Run command?" dialogs for git, npm, etc.)
    'antigravity.terminalCommand.accept',
    'antigravity.terminalCommand.run',

    // General command approvals
    'antigravity.command.accept',

    // Diff-hunk approvals (auto-accept code changes)
    'antigravity.prioritized.agentAcceptFocusedHunk',
];

function activate(context) {
    // Dump all available commands for debugging / future reference
    vscode.commands.getCommands(true).then(cmds => {
        try {
            fs.writeFileSync(
                path.join(process.env.USERPROFILE, '.gemini', 'antigravity', 'commands_dump.json'),
                JSON.stringify(cmds, null, 2)
            );
        } catch (e) { }
    });

    // Register toggle command
    let disposable = vscode.commands.registerCommand('unlimited.toggle', function () {
        enabled = !enabled;
        updateStatusBar();
        if (enabled) {
            vscode.window.showInformationMessage('Auto-Skip: ON');
        } else {
            vscode.window.showInformationMessage('Auto-Skip: OFF');
        }
    });
    context.subscriptions.push(disposable);

    try {
        // Create Right Item (High Priority)
        // Alignment Right, Priority 10000 ensures it is the first/left-most item in the Right block
        statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 10000);
        statusBarItem.command = 'unlimited.toggle';
        context.subscriptions.push(statusBarItem);

        updateStatusBar();
        statusBarItem.show();
    } catch (e) {
        // Silent failure in production to avoid harassing user
    }

    // Start the loop
    startLoop();
}

function updateStatusBar() {
    if (!statusBarItem) return;

    if (enabled) {
        statusBarItem.text = "Auto-Skip: ON";
        statusBarItem.tooltip = "Unlimited Auto-Skip is Executing (Click to Pause)";
        statusBarItem.backgroundColor = undefined;
    } else {
        statusBarItem.text = "Auto-Skip: OFF";
        statusBarItem.tooltip = "Unlimited Auto-Skip is Paused (Click to Resume)";
        statusBarItem.backgroundColor = new vscode.ThemeColor('statusBarItem.warningBackground');
    }
}

function startLoop() {
    autoAcceptInterval = setInterval(async () => {
        if (!enabled) return;

        // Fire all accept commands in parallel for speed
        await Promise.allSettled(
            ACCEPT_COMMANDS.map(cmd => vscode.commands.executeCommand(cmd))
        );
    }, 300);
}

function deactivate() {
    if (autoAcceptInterval) {
        clearInterval(autoAcceptInterval);
    }
}

module.exports = {
    activate,
    deactivate
}