' =================================================================== ' File: main.puml ' Purpose: Single source of truth for module-level activity + per-method sequences. ' Module: main.js — Legacy entry + convenience API; wires observer and exposes helpers. ' Edit rules: Follow the legend at bottom; preserve VIEW/METHOD anchors for automation. ' =================================================================== ' Neutral defaults — typography/layout only (keeps partition colors intact) skinparam Shadowing false skinparam SequenceMessageAlign center skinparam SequenceLifeLineBorderColor #666666 skinparam SequenceLifeLineBorderThickness 1 ' ==== VIEW: Branch Flow (main.js) ========================================== @startuml title main.js — Branch Flow (full module) start :main; fork ' -------- AIRepoCommander.constructor() -------- partition "AIRepoCommander.constructor()" #E7FAE3 { :constructor; :isInitialized=false; observer=null;\nprocessed=WeakSet();\nmessageSelectors=[assistant selectors]; kill } fork again ' -------- initialize() -------- partition "initialize()" #FFF6D1 { :initialize; :guard: if already initialized -> warn + return;\nlog meta+debug+api;\nlog config summary; :startObserver(); if cfg.ui.processExisting -> scanExisting(); exposeAPI();\nset isInitialized=true; log initialized; trace globals; kill } fork again ' -------- startObserver() -------- partition "startObserver()" #FFE1DB { :startObserver; :create MutationObserver(cb);\ncb skips when runtime.paused;\ncount assistant messages (direct + nested); call processMessage(el);\nobserve document.body {childList,subtree};\nlog started; kill } fork again ' -------- isAssistantMessage(el) -------- partition "isAssistantMessage(el)" #DCF9EE { :isAssistantMessage; :return any selector matches(el); kill } fork again ' -------- processMessage(el) -------- partition "processMessage(el)" #FFE6F0 { :processMessage; :skip if processed.has(el);\ncommands=extractCommands(el);\nif none -> trace & return;\nmark processed; cap to cfg.queue.maxPerMessage; :for each cmd i: if history.isProcessed(el,i) -> addRetryButton(); else run(el,cmd,i); kill } fork again ' -------- extractCommands(el) -------- partition "extractCommands(el)" #E6F3FF { :extractCommands; :regex /@bridge@[\\s\\S]*?@end@/g over el.textContent;\nreturn blocks[]; kill } fork again ' -------- run(el, commandText, index) -------- partition "run(el, commandText, index)" #F0E6FA { :run; :trace + markProcessed(el,index);\nparsed = PARSER.parse(commandText);\nvalidation = PARSER.validate(parsed); :if !validation.isValid -> error + addRetryButton();\nif example -> info + return;\noptional debounce via cfg.execution.debounceDelay; :label = `Command ${i+1}`; EXECUTOR.execute(parsed, el, label);\nlog success; catch -> error + addRetryButton(); kill } fork again ' -------- addRetryButton(el, txt, idx) -------- partition "addRetryButton(el, txt, idx)" #E7FAF7 { :addRetryButton; :create