increased logging

This commit is contained in:
rob 2025-10-16 00:30:10 -03:00
parent f49d61f14d
commit 0ac583fec4
1 changed files with 69 additions and 41 deletions

View File

@ -1,77 +1,105 @@
// ==CONFIG START== // ==CONFIG START==
(function () { (function () {
// LocalStorage keys used by this userscript. These names are stable across versions.
// - history: per-conversation dedupe records (fingerprints of executed commands)
// - cfg: persisted user configuration (excluding transient runtime flags)
// - panel: debug panel UI state (position, collapsed state, selected tab)
const STORAGE_KEYS = { const STORAGE_KEYS = {
history: 'ai_repo_commander_executed', history: 'ai_repo_commander_executed',
cfg: 'ai_repo_commander_cfg', cfg: 'ai_repo_commander_cfg',
panel: 'ai_repo_commander_panel_state' panel: 'ai_repo_commander_panel_state'
}; };
/**
* DEFAULT_CONFIG holds all tunable settings for AI Repo Commander.
* Access values via: window.AI_REPO_CONFIG.get('path.to.key')
* Update at runtime via: window.AI_REPO_CONFIG.set('path.to.key', value)
*
* Sections:
* - meta: Script metadata (version only)
* - api: Bridge/API behavior (timeouts, retries, key)
* - debug: Logging and debug panel settings
* - execution: Detector and processing timings / hardening
* - queue: Rate limiting for executing commands
* - ui: Paste/submit behavior and UX toggles
* - storage: Dedupe/cleanup persistence settings
* - response: Paste buffer behavior for long responses
* - runtime: Transient flags (not persisted)
*/
const DEFAULT_CONFIG = { const DEFAULT_CONFIG = {
// Script/version metadata. Not used for logic; useful for UI and logs.
meta: { version: '1.6.2' }, meta: { version: '1.6.2' },
// Bridge/API call settings used by command-executor.js
api: { api: {
enabled: true, enabled: true, // Master switch: if false, actions are mocked locally (no network)
timeout: 60000, timeout: 60000, // Request timeout for GM_xmlhttpRequest, in milliseconds
maxRetries: 2, maxRetries: 2, // Number of retries after the initial attempt (total attempts = 1 + maxRetries)
bridgeKey: '' bridgeKey: '' // Secret key sent as X-Bridge-Key header. Prompted if empty when enabled
}, },
// Debug logging configuration and debug panel behavior
debug: { debug: {
enabled: true, enabled: true, // Toggle logging/panel features globally
level: 3, // 0=off, 1=errors, 2=warn, 3=info, 4=verbose, 5=trace level: 3, // 0=off, 1=error, 2=warn, 3=info, 4=verbose, 5=trace (see logger.js)
watchMs: 120000, watchMs: 120000, // Time window used by Logger.logLoop to limit repeated logs
maxLines: 400, maxLines: 400, // Max log entries kept in memory (oldest are dropped)
showPanel: true showPanel: true // Show the draggable Logs/Tools panel when true
}, },
// Execution hardening and detector timing options (see detector.js)
execution: { execution: {
debounceDelay: 6500, debounceDelay: 6500, // Wait after a new assistant message to allow streaming to finish
settleCheckMs: 1300, settleCheckMs: 1300, // Stable-window length to consider text "settled" after last change
settlePollMs: 250, settlePollMs: 250, // How often to poll the DOM during the settle window
requireTerminator: true, requireTerminator: true, // Require @end@ terminator inside blocks before attempting to execute
coldStartMs: 2000, coldStartMs: 2000, // Initial delay after page load to avoid immediate re-execution
stuckAfterMs: 10 * 60 * 1000, stuckAfterMs: 10 * 60 * 1000, // Consider a long-running flow "stuck" after this time (for warnings)
scanDebounceMs: 400, scanDebounceMs: 400, // Debounce for scanning existing content or rapid changes
fastWarnMs: 50, fastWarnMs: 50, // Threshold for logging fast operations as timing markers
slowWarnMs: 60000, slowWarnMs: 60000, // Threshold for warning on slow operations
clusterRescanMs: 1000, clusterRescanMs: 1000, // Interval to rescan neighboring assistant messages for chained blocks
clusterMaxLookahead: 3 clusterMaxLookahead: 3 // How many subsequent assistant messages to peek when clustering
}, },
// Queue/rate-limiting settings (see queue.js)
queue: { queue: {
minDelayMs: 1500, minDelayMs: 1500, // Minimum delay between two executed commands
maxPerMinute: 15, maxPerMinute: 15, // Rate cap: maximum commands started per rolling minute
maxPerMessage: 5, maxPerMessage: 5, // Safety limit: maximum commands taken from a single assistant message
waitForComposerMs: 12000 waitForComposerMs: 12000 // How long to wait for the chat composer to be ready before giving up
}, },
// UI behavior around pasting into the composer and submitting
ui: { ui: {
autoSubmit: true, autoSubmit: true, // If true, attempt to submit after pasting (button click or Enter key)
appendTrailingNewline: true, appendTrailingNewline: true, // Append a newline to pasted content to preserve code fences in some editors
postPasteDelayMs: 600, postPasteDelayMs: 600, // Small delay after paste before trying to click Send/press Enter
showExecutedMarker: true, showExecutedMarker: true, // Visually mark messages that had commands executed (left border/title)
processExisting: false, processExisting: false, // On init, optionally scan and process messages already on the page
submitMode: 'button_first', submitMode: 'button_first', // Submit strategy: 'button_first' tries button, then falls back to Enter
maxComposerWaitMs: 15 * 60 * 1000, maxComposerWaitMs: 15 * 60 * 1000, // Global max wait for composer availability in edge cases
submitMaxRetries: 12 submitMaxRetries: 12 // How many times to retry submit attempts (e.g., flaky Send button)
}, },
// Persistence and housekeeping settings for localStorage
storage: { storage: {
dedupeTtlMs: 30 * 24 * 60 * 60 * 1000, // 30 days dedupeTtlMs: 30 * 24 * 60 * 60 * 1000, // 30 days; prevent re-execution in the same conversation within TTL
cleanupAfterMs: 30000, cleanupAfterMs: 30000, // Delay before running a cleanup pass after startup
cleanupIntervalMs: 60000 cleanupIntervalMs: 60000 // How frequently to run periodic cleanup of stale records
}, },
// Response paste buffer settings (see response-buffer.js)
response: { response: {
bufferFlushDelayMs: 500, bufferFlushDelayMs: 500, // Delay before flushing buffered chunks to paste (to batch sibling results)
sectionHeadings: true, sectionHeadings: true, // When true, prepend small headings when pasting multiple sections
maxPasteChars: 250000, maxPasteChars: 250000, // Maximum characters to paste at once; larger results are split
splitLongResponses: true splitLongResponses: true // Split long responses into multiple pastes when exceeding maxPasteChars
}, },
// Runtime state (not persisted) // Runtime state (not persisted) — toggled by UI/console helpers
runtime: { runtime: {
paused: false paused: false // When true, detectors ignore new mutations; queue continues unless stopped
} }
}; };