Skip to content

hoatv2211/GameStudio-CodexKIT / skills/studio-goal-progress

studio-goal-progress

Verified

Use when a KIT-managed Codex or Hermes Goal needs evidence-backed percentage, ETA range, live read-only progress views, or portable append-only progress recovery.

assets/app.js

View on GitHub
// Generated by scripts/sync_skill_resources.py. Do not edit manually.

(() => {
  "use strict";

  const dashboard = document.querySelector("#dashboard");
  const liveStatus = document.querySelector("#live-status");
  const packetRows = document.querySelector("#packet-rows");
  const packetEmpty = document.querySelector("#packet-empty");
  const timeline = document.querySelector("#timeline");
  const etaHistory = document.querySelector("#eta-history");
  const revisionHistory = document.querySelector("#revision-history");
  const contextContent = document.querySelector("#context-content");
  const contextRequiredFacts = document.querySelector("#context-required-facts");
  const historyWarning = document.querySelector("#history-warning");
  const narrowViewport = window.matchMedia("(max-width: 720px)");
  let snapshot = null;
  let packetFilter = "all";
  let contextProjection = "brief";

  const setText = (selector, value, fallback = "Unavailable") => {
    const node = document.querySelector(selector);
    if (node) {
      node.textContent = value === null || value === undefined || value === "" ? fallback : String(value);
    }
  };

  const statusIsActive = (status) => ["running", "blocked", "waiting_input"].includes(status);

  const renderEvidence = (container, evidence) => {
    container.replaceChildren();
    (evidence || []).forEach((record) => {
      const item = document.createElement("li");
      const label = document.createElement("strong");
      const summary = document.createElement("span");
      label.textContent = `${record.label || "Unverified"} · ${record.id || "evidence"}: `;
      summary.textContent = record.summary || "No public evidence summary.";
      item.append(label, summary);
      if (record.command) {
        const command = document.createElement("code");
        command.textContent = ` ${record.command}`;
        item.append(command);
      }
      if (record.artifact_href) {
        const link = document.createElement("a");
        link.href = record.artifact_href;
        link.textContent = ` Open ${record.artifact_path || "artifact"}`;
        item.append(link);
      }
      container.append(item);
    });
  };

  const renderPackets = () => {
    const packets = snapshot?.state?.packets || [];
    const canonical = [...packets].sort((left, right) => Number(left.order) - Number(right.order));
    const promoteActive = dashboard.dataset.view === "compact" || narrowViewport.matches;
    const ordered = promoteActive
      ? [...canonical].sort((left, right) => Number(statusIsActive(right.status)) - Number(statusIsActive(left.status)))
      : canonical;
    const visible = ordered.filter((packet) => {
      if (packetFilter === "active") return statusIsActive(packet.status);
      if (packetFilter === "verified") return packet.status === "verified";
      return true;
    });

    packetRows.replaceChildren();
    packetEmpty.hidden = visible.length !== 0;
    visible.forEach((packet, index) => {
      const row = document.createElement("tr");
      row.dataset.active = String(statusIsActive(packet.status));
      row.style.setProperty("--row-index", String(index));
      const historyPartial = packet.history_status === "partial";
      const evidenceSummary = (packet.evidence || []).map((record) => `${record.label}: ${record.summary}`).join(" | ");
      const evidenceDisplay = historyPartial
        ? evidenceSummary ? `Recent only: ${evidenceSummary}` : "Unavailable (history partial)"
        : evidenceSummary;
      const attemptDisplay = historyPartial ? "Unavailable (history partial)" : packet.attempt ?? 0;
      const elapsedDisplay = historyPartial ? "Unavailable (history partial)" : `${packet.elapsed_seconds ?? 0}s`;
      [packet.order, packet.id, packet.objective, packet.owner, packet.status, packet.progress_weight, attemptDisplay, elapsedDisplay, evidenceDisplay].forEach((value, cellIndex) => {
        const cell = document.createElement("td");
        cell.textContent = value === null || value === undefined ? "" : String(value);
        if (cellIndex === 4) {
          cell.className = "status-label";
          cell.dataset.state = String(value || "unknown");
        }
        if (cellIndex === 8) cell.className = "packet-evidence";
        row.append(cell);
      });
      packetRows.append(row);
    });

    const active = ordered.find((packet) => statusIsActive(packet.status));
    setText("#active-objective", active?.objective, "No active packet reported.");
    setText("#active-owner", active?.owner, "None");
    setText("#active-status", active?.status, "Idle");
    const activeHistoryPartial = active?.history_status === "partial";
    setText("#active-attempt", activeHistoryPartial ? "Unavailable (history partial)" : active?.attempt, "0");
    setText("#active-elapsed", activeHistoryPartial ? "Unavailable (history partial)" : `${active?.elapsed_seconds ?? 0} seconds`);

    const diagnostics = document.querySelector("#diagnostics");
    diagnostics.replaceChildren();
    (snapshot?.state?.diagnostics || []).forEach((diagnostic) => {
      const item = document.createElement("li");
      const historyLabel = diagnostic.history_status === "partial" ? " · recent history partial" : "";
      item.textContent = `${diagnostic.status || "blocked"} · ${diagnostic.packet_id || "packet"}${historyLabel}: ${diagnostic.summary || "No public diagnostic summary."}`;
      diagnostics.append(item);
    });
  };

  const renderTimeline = () => {
    timeline.replaceChildren();
    const events = [...(snapshot?.events || [])].reverse();
    events.forEach((event) => {
      const item = document.createElement("li");
      const time = document.createElement("time");
      const content = document.createElement("div");
      const type = document.createElement("strong");
      const summary = document.createElement("span");
      time.dateTime = String(event.emitted_at || "");
      time.textContent = event.emitted_at || "Time unavailable";
      type.textContent = `${event.sequence || "?"} ${event.event_type || "event"}`;
      summary.textContent = event.summary || "No public summary.";
      content.append(type, summary);
      item.append(time, content);
      timeline.append(item);
    });
  };

  const renderContext = () => {
    const projection = snapshot?.context?.[contextProjection];
    contextContent.textContent = projection?.text || "No context projection available.";
    setText("#context-status", projection?.status);
    setText("#context-budget", projection ? `${projection.count ?? "?"} ${projection.count_kind || "units"}; target ${projection.target ?? "?"}; hard cap ${projection.hard_cap ?? "?"}` : null);
    setText("#context-evidence", projection?.evidence_label);
    const warning = document.querySelector("#context-warning");
    warning.textContent = projection?.presentation_warning || "";
    warning.hidden = !projection?.presentation_warning;
    contextRequiredFacts.replaceChildren();
    (projection?.required_fact_refs || []).forEach((reference) => {
      const item = document.createElement("li");
      item.textContent = reference;
      contextRequiredFacts.append(item);
    });
  };

  const renderHistory = () => {
    revisionHistory.replaceChildren();
    (snapshot?.state?.revision_history || []).forEach((revision) => {
      const item = document.createElement("li");
      const heading = document.createElement("strong");
      const detail = document.createElement("span");
      const consequences = [
        revision.progress_recalculated === true ? "Progress recalculated" : null,
        revision.eta_recalculated === true ? "ETA recalculated" : null,
      ].filter(Boolean).join(" · ");
      heading.textContent = `Plan ${revision.previous_plan_version ?? "?"} to ${revision.plan_version ?? "?"}`;
      detail.textContent = ` Sequence ${revision.sequence ?? "?"} · ${revision.revision_reason || "Reason unavailable"} · approval ${revision.approval_ref || "Unverified"} · previous manifest SHA-256 ${revision.previous_manifest_hash || "Unavailable"} · new manifest SHA-256 ${revision.new_manifest_hash || "Unavailable"}${consequences ? ` · ${consequences}` : ""}`;
      item.append(heading, detail);
      revisionHistory.append(item);
    });
    etaHistory.replaceChildren();
    const recentEtaHistory = snapshot?.state?.eta_recent_trigger_history;
    (recentEtaHistory?.entries || []).forEach((entry) => {
      const item = document.createElement("li");
      item.textContent = `Sequence ${entry.sequence ?? "?"} · plan ${entry.plan_version ?? "?"} · ${entry.trigger || "recalculated"} · ${entry.emitted_at || "time unavailable"}`;
      etaHistory.append(item);
    });
  };

  const renderHistoryWindow = () => {
    const history_window = snapshot?.history_window || {};
    historyWarning.hidden = history_window.partial !== true;
    if (historyWarning.hidden) return;
    const reasons = (history_window.truncated_by || []).join(" and ") || "bounded limits";
    const first = history_window.first_available_sequence ?? "unknown";
    const last = history_window.last_available_sequence ?? "unknown";
    setText(
      "#history-window",
      `Partial detail: ${reasons} truncation. Showing up to ${history_window.max_events ?? "?"} events / ${history_window.max_bytes ?? "?"} bytes, available sequence ${first}-${last}. Attempt and elapsed are unavailable; evidence and ETA triggers are recent only.`
    );
  };

  const renderIntegration = () => {
    const container = document.querySelector("#integration-status");
    container.replaceChildren();
    const integration = snapshot?.integration || {};
    Object.entries(integration).forEach(([key, value]) => {
      const row = document.createElement("div");
      const term = document.createElement("dt");
      const detail = document.createElement("dd");
      term.textContent = key.replaceAll("_", " ");
      detail.textContent = Array.isArray(value) ? value.join(", ") : String(value);
      row.append(term, detail);
      container.append(row);
    });
  };

  const render = () => {
    const state = snapshot.state;
    const progress = Math.max(0, Math.min(100, Number(state.progress?.display_percent || 0)));
    const dial = document.querySelector("#progress-dial");
    dial.style.setProperty("--progress", `${progress * 3.6}deg`);
    dial.setAttribute("aria-valuenow", String(progress));
    setText("#progress-number", progress, "0");
    setText("#goal-title", snapshot.session?.title, "Untitled goal");
    setText("#goal-meta", `${snapshot.session?.goal_id || "Unknown goal"} | ${snapshot.session?.repository_snapshot || "Unknown snapshot"}`);
    setText("#goal-state", state.goal_state);
    setText("#next-action", state.next_action);
    setText("#plan-version", state.plan_version);
    setText("#last-updated", snapshot.session?.updated_at);
    setText("#stale-status", state.stale ? "STALE" : "Current");
    renderEvidence(document.querySelector("#latest-evidence"), state.latest_evidence);
    setText("#eta-summary", state.eta?.summary, "No ETA summary available.");
    setText("#eta-basis", JSON.stringify(state.eta || {}, null, 2), "No timing basis available.");
    renderPackets();
    renderTimeline();
    renderContext();
    renderHistory();
    renderHistoryWindow();
    renderIntegration();
  };

  const loadState = async () => {
    liveStatus.textContent = "Refreshing verified state";
    try {
      const response = await fetch("/api/state");
      if (!response.ok) throw new Error(`HTTP ${response.status}`);
      snapshot = await response.json();
      render();
      liveStatus.textContent = `Connected. State updated ${snapshot.session?.updated_at || "now"}.`;
    } catch (_error) {
      liveStatus.textContent = "State refresh failed. Waiting for the local runtime.";
    }
  };

  document.querySelectorAll("[data-filter]").forEach((button) => {
    button.addEventListener("click", () => {
      packetFilter = button.dataset.filter;
      document.querySelectorAll("[data-filter]").forEach((candidate) => {
        candidate.setAttribute("aria-pressed", String(candidate === button));
      });
      if (snapshot) renderPackets();
    });
  });

  const contextTabs = [...document.querySelectorAll("[data-context]")];
  const selectContext = (button, moveFocus = false) => {
    contextProjection = button.dataset.context;
    contextTabs.forEach((candidate) => {
      candidate.setAttribute("aria-selected", String(candidate === button));
      candidate.tabIndex = candidate === button ? 0 : -1;
    });
    contextContent.setAttribute("aria-labelledby", button.id);
    if (snapshot) renderContext();
    if (moveFocus) button.focus();
  };

  contextTabs.forEach((button, index) => {
    button.addEventListener("click", () => selectContext(button));
    button.addEventListener("keydown", (event) => {
      let targetIndex = null;
      if (event.key === "ArrowRight") targetIndex = (index + 1) % contextTabs.length;
      if (event.key === "ArrowLeft") targetIndex = (index - 1 + contextTabs.length) % contextTabs.length;
      if (event.key === "Home") targetIndex = 0;
      if (event.key === "End") targetIndex = contextTabs.length - 1;
      if (targetIndex !== null) {
        event.preventDefault();
        selectContext(contextTabs[targetIndex], true);
      }
    });
  });

  narrowViewport.addEventListener("change", () => {
    if (snapshot) renderPackets();
  });

  dashboard.dataset.view = location.pathname === "/compact" ? "compact" : "full";
  loadState();
  const events = new EventSource("/api/events");
  events.addEventListener("state", loadState);
  events.addEventListener("open", loadState);
  events.addEventListener("error", loadState);
})();
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall