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