A browser userscript that enables AI assistants to securely interact with git repositories via YAML-style commands, with comprehensive safety measures and real-time feedback.
Go to file
rob a65a453feb Update src/ai-repo-commander.user.js
1. Queue Configuration (lines 59-62)

QUEUE_MIN_DELAY_MS: 800 - Minimum delay between command executions
QUEUE_MAX_PER_MINUTE: 15 - Rate limiting cap
QUEUE_MAX_PER_MESSAGE: 5 - Maximum commands per assistant message
QUEUE_WAIT_FOR_COMPOSER_MS: 6000 - Timeout for waiting for composer ready state

2. ExecutionQueue Class (lines 830-862)

Self-contained queue with rate limiting
Automatically drains commands with proper delays
Respects per-minute rate limits
Provides size change callbacks for UI updates

3. Multi-Command Detection (lines 328-352)

extractAllCompleteBlocks() - Finds all @bridge@ blocks in text
findAllCommandsInMessage() - Extracts all commands from a message element
attachQueueBadge() - Shows visual indicator of queued commands
waitForComposerReady() - Waits for safe state before pasting

4. Enhanced History with Per-Command Deduplication (lines 619-685)

Extended fingerprinting with optional suffix for multi-command support
Each command in a message gets unique tracking (e.g., #1, #2, etc.)

5. Queue Integration in Scanning (lines 1116-1165)

Automatically detects and queues multiple commands
Shows badge indicating how many commands were queued
Respects QUEUE_MAX_PER_MESSAGE limit
enqueueCommand() method handles individual command execution

6. Enhanced Emergency Stop (lines 1323-1345)

Clears the entire queue when STOP is activated
Reports how many commands were cancelled

7. UI Improvements

"Clear Queue" button in header showing current queue size
Queue settings in Tools & Settings panel
Real-time queue size updates

8. Global API (line 1384)

window.AI_REPO_QUEUE.clear() - Clear all queued commands
window.AI_REPO_QUEUE.size() - Get current queue size
window.AI_REPO_QUEUE.cancelOne(predicate) - Cancel specific command

The script now handles multiple commands in a single assistant message gracefully, with proper rate limiting, visual feedback, and robust error handling!
2025-10-09 23:56:52 +00:00
Docs Update Docs/Technical_Design_Document.md 2025-10-06 17:58:55 +00:00
src Update src/ai-repo-commander.user.js 2025-10-09 23:56:52 +00:00
README.md "docs: replace README with plain-text v1.4.1 (safe formatting)" 2025-10-09 07:50:19 +00:00

README.md

AI Repo Commander

A safety-first userscript that lets AI assistants securely interact with git repositories using YAML-style commands. It provides strong guardrails, persistent de-duplication, a draggable debug panel with tools and settings, and robust paste/autosubmit for get_file.

Highlights:

  • Code-block only execution (only fenced YAML with the bridge header runs)
  • Safety-first: STOP switch, strict validation, debounce plus settle
  • Persistent de-duplication per conversation (30-day TTL)
  • Streaming-safe: waits for final text before executing
  • Clear feedback: inline status and desktop notifications
  • Cross-platform: ChatGPT, Claude, Gemini
  • Tools & Settings panel: bridge key editor, config JSON, clear history
  • Robust paste and auto-submit with fallbacks for get_file

Quick Start:

  1. Install Tampermonkey or Violentmonkey.
  2. Create a new userscript and paste src/ai-repo-commander.user.js.
  3. Ask the assistant to produce a YAML block beginning with the bridge header and ending with the terminator.
  4. Enter your bridge key when prompted (you can store it in the panel).
  5. Adjust settings in Tools and Settings as needed.

Default Configuration (excerpt): ENABLE_API: true DEBUG_MODE: true ASSISTANT_ONLY: true PROCESS_EXISTING: false DEBOUNCE_DELAY: 3000 REQUIRE_TERMINATOR: true SETTLE_CHECK_MS: 800 SETTLE_POLL_MS: 200 API_TIMEOUT_MS: 60000 MAX_RETRIES: 2 DEDUPE_TTL_MS: 2592000000 COLD_START_MS: 2000 SHOW_EXECUTED_MARKER: true CLEANUP_AFTER_MS: 30000 CLEANUP_INTERVAL_MS: 60000 APPEND_TRAILING_NEWLINE: true AUTO_SUBMIT: true POST_PASTE_DELAY_MS: 250 SUBMIT_MODE: button_first STUCK_AFTER_MS: 600000 SCAN_DEBOUNCE_MS: 250 FAST_WARN_MS: 50 SLOW_WARN_MS: 60000

Supported Actions (required fields): get_file: action, repo, path list_files: action, repo, path create_file: action, repo, path, content update_file: action, repo, path, content delete_file: action, repo, path create_branch: action, repo, branch (source_branch defaults to main) create_pr: action, repo, title, head, base merge_pr: action, repo, pr_number close_pr: action, repo, pr_number create_issue: action, repo, title comment_issue: action, repo, issue_number, body close_issue: action, repo, issue_number create_tag: action, repo, tag, target create_release: action, repo, tag_name, name rollback: action, repo, commit_sha

Operation Summary:

  1. Monitor assistant messages
  2. Detect a complete YAML command: header plus terminator
  3. Debounce and settle, then re-validate
  4. Execute via the bridge with retries and timeouts
  5. Show inline status and store dedupe record
  6. Expose a Run Again button for intentional re-execution

Runtime Helpers:

  • AI_REPO_STOP(): emergency stop
  • AI_REPO_CLEAR_HISTORY(): clear dedupe history
  • window.AI_REPO_COMMANDER: monitor, config, tests, history

Security Model:

  • Bridge key stored locally and masked, never logged
  • Field validation including path safety and typed values
  • Assistant-only and code-block-only execution by default
  • STOP immediately halts scanning and API calls

Changelog v1.4.1 (summary):

  • Tools and Settings panel (bridge key editor, clear history, JSON config)
  • Parser hardening for multiline content and body/message fields
  • New routes: PRs, Issues, Releases, Tags, Rollback
  • Per-conversation dedupe with Run Again UI
  • Streaming settle improvements and debounce
  • Auto-submit and paste fallback sequence
  • Configurable timeouts and retry policy