Skip to content

hashgraph-online/awesome-codex-plugins / plugins/beastlabai/multi-llm-plugin/skills/multi-llm

multi-llm

Flagged

Orchestrate plan reviews, task generation, implementation and code reviews across several LLM CLIs in parallel, or ask every model one free-text question about a plan. Use when the user says: review my plan, multi-llm, run a code review, generate tasks from a plan, implement this plan, ask the models about my plan.

FileKindSize
SKILL.mdskill md4.0 KB
apply_code_fixes_orchestrator.pyscript56.6 KB
apply_commit_fixes_orchestrator.pyscript2.3 KB
apply_suggestions_orchestrator.pyscript4.5 KB
apply_task_suggestions_orchestrator.pyscript19.1 KB
ask_orchestrator.pyscript162.5 KB
assets/icons/Anthropic.svgother584 B
assets/icons/Codex.svgother1.3 KB
assets/icons/Copilot.svgother1.5 KB
assets/icons/Cursor.svgother793 B
assets/icons/GoogleGemini.svgother623 B
assets/icons/Goose.svgother3.2 KB
assets/icons/Kilocode.svgother531 B
assets/icons/MiniMax.pngbinary1.5 KB
assets/icons/Mistral.svgother717 B
assets/icons/MoonshotAI.svgother957 B
assets/icons/Nvidia.svgother2.4 KB
assets/icons/OhMyPi.svgother434 B
assets/icons/OpenAI.svgother1.7 KB
assets/icons/Opencode.svgother325 B
assets/icons/Pi.svgother440 B
assets/icons/Qwen.svgother1.7 KB
assets/icons/Zhipu.pngbinary442 B
assets/icons/xAI.svgother343 B
assets/omp/overlay.ymlconfig2.4 KB
check_workflow_prerequisites.pyscript74.5 KB
code_review_orchestrator.pyscript324.0 KB
display_decisions.pyscript9.8 KB
finalize_tracking.pyscript1.3 KB
full_workflow_orchestrator.pyscript58.8 KB
generate_tasks_orchestrator.pyscript44.2 KB
hosts/capabilities.yamlconfig49.9 KB
hosts/codex/plugin-skill.md.tmplother2.8 KB
hosts/codex/shim.md.tmplother7.3 KB
hosts/opencode/plugin-command.md.tmplother2.2 KB
hosts/opencode/shim.md.tmplother6.8 KB
hosts/render_capabilities.pyscript48.4 KB
hosts/snippets/poll-loop.mdmarkdown4.4 KB
hosts/snippets/uv-preflight.mdmarkdown2.2 KB
hosts/uv-missing.txtmarkdown1.5 KB
implement_orchestrator.pyscript156.0 KB
improve_code_orchestrator.pyscript1.6 KB
improve_commits_orchestrator.pyscript2.5 KB
improve_plan_orchestrator.pyscript1.6 KB
init_config.pyscript57.6 KB
instructions/apply-code-fixes.mdmarkdown52.0 KB
instructions/apply-commit-fixes.mdmarkdown10.3 KB
instructions/apply-suggestions.mdmarkdown48.2 KB
instructions/apply-task-suggestions.mdmarkdown53.9 KB
instructions/ask.mdmarkdown27.6 KB
instructions/full-workflow.mdmarkdown24.6 KB
instructions/generate-tasks.mdmarkdown18.1 KB
instructions/implement.mdmarkdown54.0 KB
instructions/improve-code.mdmarkdown25.0 KB
instructions/improve-commits.mdmarkdown24.8 KB
instructions/improve-plan.mdmarkdown26.2 KB
instructions/init-config.mdmarkdown6.6 KB
instructions/review-code.mdmarkdown43.5 KB
instructions/review-commits.mdmarkdown11.4 KB
instructions/review-plan.mdmarkdown38.4 KB
instructions/review-tasks.mdmarkdown37.8 KB
modes.pyscript58.8 KB
multi_llm.pyscript101.1 KB
prompts/ask.txtmarkdown948 B
prompts/code_review.txtmarkdown4.5 KB
prompts/commit_review.txtmarkdown6.2 KB
prompts/consolidate_suggestions.txtmarkdown3.1 KB
prompts/implementation_task.txtmarkdown1.4 KB
prompts/plan_review.txtmarkdown8.0 KB
prompts/task_review.txtmarkdown8.3 KB
providers.yamlconfig19.6 KB
pyproject.tomlmanifest6.8 KB
references/apply-write-executor.mdmarkdown3.0 KB
references/consolidation.mdmarkdown5.6 KB
references/host-capabilities.mdmarkdown13.5 KB
references/human-decision-batch.mdmarkdown17.2 KB
references/implement-prerequisites.mdmarkdown6.0 KB
references/implement-write-executor.mdmarkdown4.9 KB
references/interrupted-run-recovery.mdmarkdown3.1 KB
references/own-check.mdmarkdown4.3 KB
references/resume-detection.mdmarkdown8.5 KB
references/revalidation.mdmarkdown6.9 KB
references/review-code-apply-fixes.mdmarkdown4.3 KB
references/salvage-handling.mdmarkdown12.5 KB
references/summary-format.mdmarkdown10.0 KB
references/uv-check.mdmarkdown5.7 KB
references/wave-batching.mdmarkdown5.2 KB
review_commits_orchestrator.pyscript2.3 KB
review_plan_orchestrator.pyexecutablescript22.3 KB
review_tasks_orchestrator.pyscript10.7 KB
schemas/cascade_record.schema.jsonconfig6.6 KB
schemas/code_review_issues.schema.jsonconfig2.0 KB
schemas/consolidated.schema.jsonconfig6.8 KB
schemas/consolidation_batch.schema.jsonconfig3.7 KB
schemas/generated_tasks.schema.jsonconfig3.1 KB
schemas/host_capabilities.schema.jsonconfig38.3 KB
schemas/human_decision_verdicts.schema.jsonconfig2.6 KB
schemas/result_line.schema.jsonconfig10.1 KB
schemas/review_suggestions.schema.jsonconfig2.4 KB
schemas/state_file.schema.jsonconfig21.5 KB
schemas/status_file.schema.jsonconfig24.9 KB
schemas/status_json.schema.jsonconfig10.8 KB
schemas/subagent_tasks.schema.jsonconfig20.5 KB
schemas/task_decomposition.schema.jsonconfig1.2 KB
schemas/write_batch_result.schema.jsonconfig8.8 KB
templates/config/providers.override.yamlconfig17.2 KB
templates/consolidated_report_template.htmlother44.1 KB
templates/pr_report_template.htmlother181.2 KB
templates/report_template.htmlother67.5 KB
templates/shared/report_core.cssother4.1 KB
templates/shared/report_core.jsscript25.5 KB
update_plan_tasks.pyscript20.9 KB
utils/__init__.pyscript284 B
utils/advisory.pyscript4.8 KB
utils/apply_orchestrator_base.pyscript220.6 KB
utils/apply_output_helpers.pyscript10.9 KB
utils/apply_path_helpers.pyscript683 B
utils/apply_report.pyscript51.2 KB
utils/apply_selection_helpers.pyscript6.8 KB
utils/apply_suggestion_phase.pyscript11.7 KB
utils/atomic_io.pyscript12.9 KB
utils/attempt_classifier.pyscript31.4 KB
utils/backup.pyscript2.0 KB
utils/batch_done.pyscript79.2 KB
utils/batch_ledger.pyscript27.4 KB
utils/batch_prompt.pyscript29.3 KB
utils/batch_prompt_builder.pyscript12.2 KB
utils/batch_reply.pyscript32.9 KB
utils/cascade_archive.pyscript50.6 KB
utils/cascade_ledger.pyscript39.3 KB
utils/cascade_provenance.pyscript22.0 KB
utils/check_records.pyscript59.3 KB
utils/check_reply.pyscript9.5 KB
utils/check_tree.pyscript1.2 KB
utils/cli_common.pyscript91.2 KB
utils/cli_version_cache.pyscript14.0 KB
utils/clock.pyscript3.5 KB
utils/code_fix_batcher.pyscript30.6 KB
utils/codex_trust.pyscript12.9 KB
utils/commit_apply.pyscript73.3 KB
utils/commit_attribution.pyscript21.2 KB
utils/commit_brief.pyscript32.2 KB
utils/commit_front_door.pyscript81.6 KB
utils/commit_paths.pyscript18.0 KB
utils/commit_range.pyscript61.2 KB
utils/commit_report.pyscript19.9 KB
utils/commit_review.pyscript413 B
utils/commit_spelling.pyscript7.9 KB
utils/commit_write_guard.pyscript9.9 KB
utils/concurrency.pyscript11.6 KB
utils/consolidation.pyscript87.3 KB
utils/detach.pyscript186.8 KB
utils/dispatch_spawn.pyscript56.3 KB
utils/doctor.pyscript76.7 KB
utils/env_vars.pyscript20.5 KB
utils/failure_capture.pyscript10.1 KB
utils/file_discovery.pyscript11.0 KB
utils/filtering.pyscript19.9 KB
utils/git_diff.pyscript23.6 KB
utils/git_utils.pyscript86.6 KB
utils/held_folder.pyscript21.3 KB
utils/host_capabilities.pyscript48.0 KB
utils/host_install.pyscript77.6 KB
utils/host_paths.pyscript12.0 KB
utils/host_routes/__init__.pyscript5.7 KB
utils/host_routes/codex.pyscript18.3 KB
utils/host_routes/npm.pyscript12.2 KB
utils/host_shim.pyscript14.7 KB
utils/html_report_generator.pyscript118.9 KB
utils/human_decisions.pyscript38.3 KB
utils/human_task_plan.pyscript30.2 KB
utils/importance.pyscript6.2 KB
utils/improve_cascade.pyscript63.7 KB
utils/improve_cascade_next.pyscript22.2 KB
utils/improve_steps.pyscript32.4 KB
utils/improve_workflow.pyscript114.4 KB
utils/interactive.pyscript31.6 KB
utils/json_extractor.pyscript61.5 KB
utils/judge_vocab.pyscript5.3 KB
utils/known_checks.pyscript37.5 KB
utils/landlock_dispatch.pyscript103.8 KB
utils/landlock_exec.pyscript21.4 KB
utils/launch_limiter.pyscript13.5 KB
utils/llm_client.pyscript126.9 KB
utils/manual_tasks.pyscript14.9 KB
utils/metrics.pyscript68.1 KB
utils/next_phase.pyscript96.1 KB
utils/next_phase_words.pyscript6.4 KB
utils/output_handler.pyscript23.2 KB
utils/phase_walk.pyscript6.4 KB
utils/plan_updater.pyscript17.9 KB
utils/positionals.pyscript5.8 KB
utils/prior_changes.pyscript28.7 KB
utils/probe_state.pyscript17.9 KB
utils/process_capture.pyscript37.6 KB
utils/process_control.pyscript228.7 KB
utils/process_state.pyscript6.6 KB
utils/progress_tracker.pyscript92.2 KB
utils/prompt_channels.pyscript34.1 KB
utils/prompt_files.pyscript24.5 KB

templates/shared/report_core.js

View on GitHub
// The script the three report pages share: report.html (flat and PR styles)
// and consolidated-report.html. The generator inlines it into each page as a
// script element of its own, before the page's script, so a report stays one
// file that loads nothing (docs/development.md#shared-report-code).
//
// It only declares: nothing here runs while the page loads. What it reads
// when called comes from the page's script: `reportData` (the embedded
// payload), and `selections`, `getStorageKey()` and `selectionsFile(now)`
// (see Selections below). A function a page needs differently stays in that
// page's template.

// BEGIN SAFE MARKDOWN
// Model, plan and repository text is untrusted, and so is every field that
// carries it: titles, statuses, importances, model names, ids, paths. Each
// reaches the page one way only (docs/development.md#vendored-report-scripts):
// a markdown body through renderMarkdown; any other text, and every quoted
// attribute value, through escapeHtml (escapeAttr is the same escaper, named
// for attribute sites); a value inside an inline handler's JS string through
// escapeJsAttr. A class name never comes from data: the badge helpers map a
// status or an importance onto a fixed list.
function escapeHtml(text) {
  if (text === null || text === undefined) return '';
  return String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
    .replace(/"/g, '&quot;').replace(/'/g, '&#39;');
}

function escapeAttr(text) {
  return escapeHtml(text);
}

// A value inside a single-quoted JS string in an inline handler
// (onclick="f('…')"). The browser decodes the attribute's entities before
// the handler runs, so escapeAttr alone would hand a quote back to the JS
// parser: escape for the JS string first, then for the attribute.
function escapeJsAttr(text) {
  if (text === null || text === undefined) return '';
  return escapeAttr(String(text).replace(/\\/g, '\\\\').replace(/'/g, '\\\'')
    .replace(/\r/g, '\\r').replace(/\n/g, '\\n')
    .replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029'));
}

function getImportanceBadgeClass(importance) {
  switch (importance === null || importance === undefined ? '' : String(importance).toUpperCase()) {
    case 'HIGH': return 'badge-importance-high';
    case 'MEDIUM': return 'badge-importance-medium';
    case 'LOW': return 'badge-importance-low';
    default: return 'badge-category';
  }
}

function getValidationBadgeClass(status) {
  switch (status) {
    case 'valid': return 'badge-validation-valid';
    case 'invalid': return 'badge-validation-invalid';
    case 'needs-human-decision': return 'badge-validation-needs-human';
    case 'validation_failed': return 'badge-validation-failed';
    default: return 'badge-category';
  }
}

// marked renders a markdown body, then DOMPurify keeps only the markdown
// vocabulary below: no script, handler, style, image, form control, id,
// class or data attribute, and only safe link URLs. Without both libraries
// the text is escaped instead. The generator inlines them.
function renderMarkdown(text) {
  if (!text) return '';
  if (typeof marked !== 'undefined' && typeof marked.parse === 'function' &&
      typeof DOMPurify !== 'undefined' && typeof DOMPurify.sanitize === 'function' &&
      DOMPurify.isSupported === true) {
    try {
      return DOMPurify.sanitize(marked.parse(String(text), { breaks: true }), {
        ALLOWED_TAGS: ['a', 'abbr', 'b', 'blockquote', 'br', 'code', 'dd', 'del', 'details',
          'div', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'ins', 'kbd',
          'li', 'mark', 'ol', 'p', 'pre', 'q', 's', 'samp', 'small', 'span', 'strong', 'sub',
          'summary', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'u', 'ul',
          'var'],
        ALLOWED_ATTR: ['align', 'colspan', 'href', 'open', 'rowspan', 'start', 'title'],
        ALLOW_DATA_ATTR: false,
        ALLOW_ARIA_ATTR: false
      });
    } catch (e) { /* fall through to the escaped text */ }
  }
  return '<p>' + escapeHtml(text).replace(/\n/g, '<br>') + '</p>';
}
// END SAFE MARKDOWN

// ================================================================
// Model badges
// ================================================================
function getModelBadgeHtml(modelString) {
  var metadata = reportData && reportData.modelMetadata ? reportData.modelMetadata[modelString] : null;
  if (!metadata) {
    return '<span class="badge badge-model" style="background: #6B7280;">' + escapeHtml(modelString) + '</span>';
  }
  var html = '<span class="model-badge-group">';
  // The provider icon, when it differs from the model's.
  if (metadata.provider_icon) {
    html += '<img class="model-icon" src="' + escapeAttr(metadata.provider_icon) + '" alt="" />';
  }
  if (metadata.icon) {
    html += '<img class="model-icon" src="' + escapeAttr(metadata.icon) + '" alt="" />';
  }
  if (metadata.provider) {
    html += '<span class="badge badge-provider" style="background: ' + escapeAttr(metadata.provider_color) + ';">' +
            escapeHtml(metadata.provider) + '</span>';
  }
  html += '<span class="badge badge-model" style="background: ' + escapeAttr(metadata.model_color || '#6B7280') + ';">' +
          escapeHtml(metadata.model || modelString) + '</span>';
  // What this slot spent, when the adapter reported it. The text is
  // `usage_label`, rendered server-side by the one `describe_usage` the
  // markdown report and the failed-slot log line also use; the pages never
  // re-derive it from `metadata.usage`, so every surface says one cost. A
  // model that reported nothing has no key and renders no badge, never
  // `$0.00`, which would claim a free run.
  if (metadata.usage_label) {
    html += '<span class="badge badge-usage" style="background: #6B7280;" title="Estimated from the CLI\'s own price catalog, not a vendor invoice">' +
            escapeHtml(metadata.usage_label) + '</span>';
  }
  html += '</span>';
  return html;
}

// One `reportData.notices` list renders the same bar on every page.
function renderNotices() {
  if (!reportData) return;
  var container = document.getElementById('report-notices');
  if (!container) return;
  var html = '';
  var notices = reportData.notices || [];
  notices.forEach(function(n) {
    var cls = 'report-notice';
    if (n.type === 'info') cls += ' info';
    else if (n.type === 'warning') cls += ' warning';
    html += '<div class="' + cls + '">' + escapeHtml(n.message) + '</div>';
  });
  container.innerHTML = html;
}

// ================================================================
// Selections: what the reader skipped, overrode, edited and labelled.
// The page declares `selections` (the fields it keeps, with their empty
// values), `getStorageKey()` (its localStorage key) and
// `selectionsFile(now)` (the file name and content Export saves, which its
// apply phase reads). A stored selection restores only the fields the page
// declares, each of the declared kind, and never a scope or policy field
// (stripScopeSelectionFields).
// ================================================================
function migrateLegacyOverrides(overrides) {
  if (!overrides) return;
  Object.keys(overrides).forEach(function(k) {
    if (overrides[k] === 'claude_decide') overrides[k] = 'judge_decide';
  });
}

function loadSelections() {
  var parsed = null;
  try {
    var stored = localStorage.getItem(getStorageKey());
    if (stored) parsed = stripScopeSelectionFields(JSON.parse(stored));
  } catch (e) {
    console.error('Failed to load selections:', e);
  }
  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return;
  // A v1 selection listed skipped ids in arrays.
  ['skipped_groups', 'skipped_suggestions'].forEach(function(key) {
    if (!Array.isArray(parsed[key])) return;
    var migrated = {};
    parsed[key].forEach(function(id) { migrated[String(id)] = true; });
    parsed[key] = migrated;
  });
  // A selection saved before the judge rename says 'claude_decide' (utils/judge_vocab.py).
  migrateLegacyOverrides(parsed.validation_overrides);
  Object.keys(selections).forEach(function(key) {
    if (!Object.prototype.hasOwnProperty.call(parsed, key)) return;
    var current = selections[key];
    var value = parsed[key];
    var wantsObject = current !== null && typeof current === 'object';
    if (wantsObject && (value === null || typeof value !== 'object' || Array.isArray(value))) return;
    selections[key] = value;
  });
}

function saveSelections() {
  try {
    localStorage.setItem(getStorageKey(), JSON.stringify(selections));
  } catch (e) {
    console.error('Failed to save selections:', e);
  }
}

function downloadJson(filename, value) {
  var blob = new Blob([JSON.stringify(value, null, 2)], { type: 'application/json' });
  var url = URL.createObjectURL(blob);
  var a = document.createElement('a');
  a.href = url;
  a.download = filename;
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);
  URL.revokeObjectURL(url);
}

function exportSelections() {
  var now = new Date().toISOString();
  selections.last_file_export_at = now;
  var file = selectionsFile(now);
  saveSelections();
  downloadJson(file.name, file.data);
  updateExportIndicator();
}

function timeAgo(isoString) {
  if (!isoString) return '';
  var diff = Date.now() - new Date(isoString).getTime();
  var seconds = Math.floor(diff / 1000);
  if (seconds < 60) return 'just now';
  var minutes = Math.floor(seconds / 60);
  if (minutes < 60) return minutes + 'm ago';
  var hours = Math.floor(minutes / 60);
  if (hours < 24) return hours + 'h ago';
  var days = Math.floor(hours / 24);
  return days + 'd ago';
}

function updateExportIndicator() {
  var el = document.getElementById('export-indicator');
  if (!el) return;
  if (selections.last_file_export_at) {
    el.textContent = '✓ Exported ' + timeAgo(selections.last_file_export_at);
    el.style.display = '';
  } else {
    el.style.display = 'none';
  }
}

// ================================================================
// Card order (the flat and consolidated pages; the PR page orders its own
// views). The group cards in #groups-container go in the generator's order
// ('original') or by priority: validation status, then importance, through
// the generator's rank table (reportData.sortConfig), then the generator's
// order. *first*, when given, compares two cards before the ranks do. The
// choice is saved under *storageKey*.
// ================================================================
function sortRanks() {
  var config = (typeof reportData !== 'undefined' && reportData && reportData.sortConfig) || null;
  if (config && config.validationOrder && config.importanceOrder) {
    return {
      validationOrder: config.validationOrder,
      importanceOrder: config.importanceOrder,
      unknownStatusRank: config.unknownStatusRank || 5,
      unknownImportanceRank: config.unknownImportanceRank || 3
    };
  }
  console.warn('sortConfig missing or malformed, using hardcoded defaults');
  return {
    validationOrder: {"needs-human-decision": 0, "valid": 1, "validation_failed": 2, "invalid": 3, "pending": 4},
    importanceOrder: {"HIGH": 0, "MEDIUM": 1, "LOW": 2, "": 3},
    unknownStatusRank: 5,
    unknownImportanceRank: 3
  };
}

function sortGroupCards(value, storageKey, first) {
  var container = document.getElementById('groups-container') || document.querySelector('.groups-container');
  if (!container) return;
  var cards = Array.from(container.querySelectorAll('.group-card'));
  if (cards.length === 0) return;
  var ranks = sortRanks();
  function rank(table, key, unknown) {
    return (key in table) ? table[key] : unknown;
  }
  function originalIndex(card) {
    return parseInt(card.dataset.originalIndex) || 0;
  }
  cards.sort(function(a, b) {
    if (first) {
      var firstOrder = first(a, b);
      if (firstOrder !== 0) return firstOrder;
    }
    if (value === 'original') return originalIndex(a) - originalIndex(b);
    var byStatus = rank(ranks.validationOrder, a.dataset.validation || '', ranks.unknownStatusRank) -
      rank(ranks.validationOrder, b.dataset.validation || '', ranks.unknownStatusRank);
    if (byStatus !== 0) return byStatus;
    var byImportance = rank(ranks.importanceOrder, a.dataset.importance || '', ranks.unknownImportanceRank) -
      rank(ranks.importanceOrder, b.dataset.importance || '', ranks.unknownImportanceRank);
    if (byImportance !== 0) return byImportance;
    return originalIndex(a) - originalIndex(b);
  });
  cards.forEach(function(card) { container.appendChild(card); });
  try {
    localStorage.setItem(storageKey, value);
  } catch (e) { /* localStorage unavailable */ }
}

// ================================================================
// Commit review (the flat and PR pages; plans/review-commits.md §2.10).
// Everything here reads reportData.commitRange, which the generator
// stores only for a commit review, so a plan's report renders none of it.
// ================================================================
function commitKeyOf(group) {
  return (group && group.introducedBy) ? group.introducedBy : 'unattributed';
}

function commitRankOf(key) {
  var cr = reportData && reportData.commitRange;
  var commits = (cr && cr.commits) || [];
  for (var i = 0; i < commits.length; i++) {
    if (commits[i].sha === key) return i;
  }
  return commits.length + (key === 'unattributed' ? 1 : 0);
}

function introducedByHtml(group) {
  if (!reportData || !reportData.commitRange || !group || !group.introducedBy) return '';
  var source = group.introducedBySource || '';
  if (source === 'none' || !source) return '';
  var html = '<div class="introduced-by">Introduced by <code>' +
    escapeHtml(group.introducedByShort || String(group.introducedBy).substring(0, 7)) + '</code>';
  if (group.introducedBySubject) html += ' — ' + escapeHtml(group.introducedBySubject);
  if (source === 'model' || source === 'model-drifted') {
    html += ' <span class="introduced-by-model" title="The reviewing model named this commit; git blame did not measure it">(model)</span>';
  }
  return html + '</div>';
}

// The distinct file paths a group's suggestions cite, line ranges dropped.
function groupFiles(group) {
  var files = [];
  ((group && group.suggestions) || []).forEach(function(s) {
    var ref = s.fileRef || '';
    var path = ref.replace(/:\d+(-\d+)?$/, '');
    if (path && files.indexOf(path) === -1) files.push(path);
  });
  return files;
}

// A path absent at `head` on a pinned review: its header carries the same
// words as its validation excerpt (plans/review-commits.md §2.5), "deleted
// in <range>", "renamed to <new> in <range>" or "absent at <head7>". The
// generator stores them as fileContexts[path].label; a plan's report has none.
function fileLabelHtml(fileRef) {
  var path = String(fileRef || '').replace(/:\d+(-\d+)?$/, '');
  var entry = ((reportData && reportData.fileContexts) || {})[path];
  var label = (entry && !Array.isArray(entry)) ? entry.label : '';
  if (!label) return '';
  return ' <span class="file-absent-label">(' + escapeHtml(label) + ')</span>';
}

// The badge for *paths* (a group's files, or one file's) when any of them
// differs on disk from the reviewed head.
function driftBadgeHtml(paths) {
  var cr = reportData && reportData.commitRange;
  if (!cr || !cr.drifted || !cr.drifted.length) return '';
  var hit = (paths || []).some(function(path) { return cr.drifted.indexOf(path) !== -1; });
  if (!hit) return '';
  var head7 = String(cr.head || '').substring(0, 7);
  return '<span class="badge badge-drift" title="This file differs on disk from ' + escapeAttr(head7) +
    ': a skip or apply decision on it is skipped anyway by the apply\'s guard">changed on disk since ' +
    escapeHtml(head7) + '</span>';
}

// ================================================================
// Scope tags (plans/scope-policy-and-report-tags.md §6). BEGIN SCOPE TAGS
// Tags describe proposals:
// they never change validity or selection, and no selection — restored
// from localStorage or imported — ever changes a tag. Every word comes
// from reportData (written by the generator); a payload without scope
// data (a legacy report) reads `Scope unclear` throughout.
// ================================================================
var SCOPE_LABELS = { in_scope: 'Within scope', scope_extension: 'Scope extension', unclear: 'Scope unclear' };
var SCOPE_CLASSES = { in_scope: 'scope-in', scope_extension: 'scope-extension', unclear: 'scope-unclear' };
var SCOPE_DEFERRED = 'Deferred: scope preservation requested';
var SCOPE_LEGACY_LINE = 'Scope policy: expand. This report predates scope classification, so every tag reads Scope unclear.';

function scopeAttr(text) {
  if (text === null || text === undefined) return '';
  return escapeHtml(String(text)).replace(/"/g, '&quot;').replace(/'/g, '&#39;');
}

function scopeSelectorValue(text) {
  return String(text === null || text === undefined ? '' : text).replace(/\\/g, '\\\\').replace(/"/g, '\\"');
}

function scopeRelation(relation) {
  return Object.prototype.hasOwnProperty.call(SCOPE_LABELS, relation) ? relation : 'unclear';
}

function scopeBadgeHtml(relation, qualifier, title) {
  var rel = scopeRelation(relation);
  var text = SCOPE_LABELS[rel] + (qualifier ? ' (' + qualifier + ')' : '');
  return '<span class="badge scope-badge ' + SCOPE_CLASSES[rel] + '" title="' +
    scopeAttr(title || text) + '">' + escapeHtml(text) + '</span>';
}

function scopeDeferredHtml(text, title) {
  return '<span class="badge scope-badge scope-deferred" title="' + scopeAttr(title || text) + '">' +
    escapeHtml(text) + '</span>';
}

// An edited description changes the proposal its classification was made for.
function scopeSuggestionEdited(s) {
  if (!s || !selections || !selections.edited_descriptions) return false;
  var edited = selections.edited_descriptions[s.id];
  return edited !== undefined && edited !== (s.description || s.content || '');
}

function scopeGroupEdited(group) {
  return ((group && group.suggestions) || []).some(scopeSuggestionEdited);
}

// The reviewer's own tag: provisional, never authority.
function scopeMemberBadges(s) {
  var e = (s && s.scope) || {};
  var classified = !!e.classified;
  var qualifier = 'provisional' + (scopeSuggestionEdited(s) ? '; may be stale: description edited' : '');
  var reason = classified ? (e.reason || '') : 'not classified';
  return scopeBadgeHtml(classified ? e.relation : 'unclear', qualifier,
    'Reviewer classification (provisional)' + (reason ? ': ' + reason : ''));
}

function scopeMemberHtml(s) {
  return '<span class="scope-tags" data-scope-suggestion="' + scopeAttr((s && s.id) || '') + '">' +
    scopeMemberBadges(s) + '</span>';
}

// The group's validated tag as this page can vouch for it now.
function scopeGroupView(group) {
  var e = (group && group.scope) || null;
  var edited = scopeGroupEdited(group);
  if (!e) {
    return { relation: 'unclear', qualifier: 'not classified', decision: null,
             title: 'No validated scope classification', reason: 'no validated scope classification' };
  }
  var state = e.authority || 'missing';
  var classifiedLabel = SCOPE_LABELS[scopeRelation(e.classifiedRelation || e.relation)];
  var view = { relation: 'unclear', decision: e.decision || null, reason: e.reason || '' };
  if (state === 'bound' && edited) {
    view.qualifier = 'may be stale: description edited';
    view.reason = 'validated as ' + classifiedLabel + ' before this description was edited' +
      (e.reason ? ': ' + e.reason : '');
    if (view.decision && view.decision.policy === 'preserve') {
      view.decision = { policy: 'preserve', outcome: 'deferred',
                        reason: SCOPE_DEFERRED + ': the proposal changed after its scope was validated' };
    }
  } else if (state === 'bound') {
    view.relation = e.relation;
    view.qualifier = 'validated';
  } else if (state === 'stale') {
    view.qualifier = 'may be stale';
    view.reason = 'validated as ' + classifiedLabel + ' before the proposal changed' +
      (e.classifiedReason ? ': ' + e.classifiedReason : '');
  } else {
    view.qualifier = state === 'missing' ? 'not classified' : 'not bound';
  }
  view.title = 'Group scope (' + view.qualifier + ')' + (view.reason ? ': ' + view.reason : '');
  return view;
}

function scopeGroupBadges(group) {
  var view = scopeGroupView(group);
  var html = scopeBadgeHtml(view.relation, view.qualifier, view.title);
  var d = view.decision;
  // Under preserve a deferral shows whatever the validity is; the
  // selection controls stay usable for a later policy override.
  if (d && d.policy === 'preserve' && d.outcome === 'deferred') {
    html += scopeDeferredHtml(SCOPE_DEFERRED, d.reason || SCOPE_DEFERRED);
  }
  return html;
}

// Keyed by the stable group hash only: a hash-less legacy group is never
// re-rendered in place (no key could tell two of them apart).
function scopeGroupHtml(group) {
  var key = (group && group.groupHash) || '';
  return '<span class="scope-tags"' + (key ? ' data-scope-group="' + scopeAttr(key) + '"' : '') + '>' +
    scopeGroupBadges(group) + '</span>';
}

function scopeDetailBody(group) {
  var view = scopeGroupView(group);
  var e = (group && group.scope) || {};
  var html = '<div class="scope-line"><strong>Scope (' + escapeHtml(view.qualifier) + '):</strong> ' +
    escapeHtml(SCOPE_LABELS[scopeRelation(view.relation)]) +
    (view.reason ? ' &mdash; ' + escapeHtml(view.reason) : '') + '</div>';
  if (e.reference) html += '<div class="scope-line"><strong>Baseline reference:</strong> ' + escapeHtml(e.reference) + '</div>';
  if (e.selectedRemedy && e.authority === 'bound') {
    html += '<div class="scope-line"><strong>Selected remedy:</strong> ' + escapeHtml(e.selectedRemedy) + '</div>';
  }
  var d = view.decision;
  if (d && d.policy === 'preserve') {
    html += '<div class="scope-line"><strong>Scope outcome:</strong> ' +
      escapeHtml(d.outcome === 'deferred' ? (d.reason || SCOPE_DEFERRED) : 'Eligible under scope preservation') + '</div>';
  }
  return html;
}

function scopeDetailHtml(group) {
  var view = scopeGroupView(group);
  return '<details class="scope-section"><summary>Scope: ' +
    escapeHtml(SCOPE_LABELS[scopeRelation(view.relation)] + ' (' + view.qualifier + ')') + '</summary>' +
    '<div class="scope-detail"' + (group && group.groupHash ? ' data-scope-detail="' + scopeAttr(group.groupHash) + '"' : '') + '>' +
    scopeDetailBody(group) + '</div></details>';
}

// An umbrella's tag is derived from its underlying groups; each keeps its own.
function scopeUmbrellaBadges(entry) {
  var e = entry || null;
  if (!e) return scopeBadgeHtml('unclear', 'derived', 'No scope data for this consolidated group');
  var qualifier = 'derived' + (e.mixed ? '; mixed members' : '');
  var html = scopeBadgeHtml(e.relation, qualifier, (e.label || SCOPE_LABELS[scopeRelation(e.relation)]) +
    ': ' + (e.reason || '') + ' (each underlying group keeps its own tag and decision)');
  var deferred = e.deferred || [];
  if (deferred.length) {
    html += scopeDeferredHtml(SCOPE_DEFERRED + ' (' + deferred.length + ' of ' + (e.members || deferred.length) + ')',
      SCOPE_DEFERRED + ': ' + deferred.join(', '));
  }
  return html;
}

function scopeSummaryHtml() {
  var block = (reportData && reportData.scopePolicy) || null;
  var line = block ? (block.policyLine || '') : SCOPE_LEGACY_LINE;
  var html = '<div class="scope-summary"><div class="scope-policy-line">' + escapeHtml(line) + '</div>';
  if (block) {
    var c = block.counts || {};
    html += '<div class="scope-counts">' +
      scopeBadgeHtml('in_scope', '', SCOPE_LABELS.in_scope) + ' ' + (c.in_scope || 0) + ' ' +
      scopeBadgeHtml('scope_extension', '', SCOPE_LABELS.scope_extension) + ' ' + (c.scope_extension || 0) + ' ' +
      scopeBadgeHtml('unclear', '', SCOPE_LABELS.unclear) + ' ' + (c.unclear || 0) +
      ' <span class="scope-count-note">(validated, distinct groups)</span>';
    if (block.effectivePolicy === 'preserve') {
      html += ' ' + scopeDeferredHtml(SCOPE_DEFERRED, SCOPE_DEFERRED) + ' ' + (c.deferred || 0);
    }
    html += '</div><div class="scope-legend">' + escapeHtml(String(block.legend || '').replace(/`/g, '')) + '</div>';
  }
  return html + '</div>';
}

// An edit changes the classification's proposal: re-render its tags in place.
function refreshScopeTags(suggestionId) {
  if (!reportData || !document.querySelectorAll) return;
  var seen = {};
  (reportData.groups || []).forEach(function(group) {
    var member = (group.suggestions || []).filter(function(s) { return s.id === suggestionId; })[0];
    if (!member) return;
    document.querySelectorAll('.scope-tags[data-scope-suggestion="' + scopeSelectorValue(suggestionId) + '"]').forEach(function(el) {
      el.innerHTML = scopeMemberBadges(member);
    });
    var key = group.groupHash || '';
    if (!key || seen[key]) return;
    seen[key] = true;
    document.querySelectorAll('.scope-tags[data-scope-group="' + scopeSelectorValue(key) + '"]').forEach(function(el) {
      el.innerHTML = scopeGroupBadges(group);
    });
    document.querySelectorAll('.scope-detail[data-scope-detail="' + scopeSelectorValue(key) + '"]').forEach(function(el) {
      el.innerHTML = scopeDetailBody(group);
    });
  });
}

// Selection files carry ids and choices only; a scope- or policy-like key
// in a stored or imported selection is dropped, never rendered or exported.
function stripScopeSelectionFields(parsed) {
  if (!parsed || typeof parsed !== 'object') return parsed;
  Object.keys(parsed).forEach(function(k) {
    var key = String(k).replace(/-/g, '_').toLowerCase();
    if (key.indexOf('scope') === 0 || key.indexOf('selected_remedy') === 0 || key.indexOf('selectedremedy') === 0) {
      delete parsed[k];
    }
  });
  return parsed;
}
// END SCOPE TAGS

// The flat and consolidated pages' summary panel.
function renderScopeSummary() {
  var container = document.getElementById('scope-summary');
  if (container) container.innerHTML = scopeSummaryHtml();
}
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall