knowyourbusiness 0.3.1

Git-backed, searchable knowledge base and incident tracker for AI agent fleets
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>KYB — Fleet Memory & Control Room</title>
  <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='6' fill='%23111520'/><path d='M8 7h4v7l6-7h5l-7 7.5L24 25h-5l-6-8.5V25H8V7z' fill='%2300b3c4'/></svg>">
  <style>
<!-- @css -->
  </style>
</head>
<body>

  <!-- Top Navigation Header -->
  <header>
    <a href="#/search" class="brand">
      <div class="brand-logo">KYB</div>
      <div class="brand-title">Know Your Business</div>
    </a>

    <nav class="nav-tabs">
      <a href="#/search" class="nav-tab active" data-tab="search" title="Knowledge">
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1-2.5-2.5Z"/><path d="M6 6h10"/><path d="M6 10h10"/></svg>
        <span>Knowledge</span>
        <span class="tab-badge" id="badgeKnowledgeCount">0</span>
      </a>
      <a href="#/incidents" class="nav-tab" data-tab="incidents" title="Incidents">
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
        <span>Incidents</span>
        <span class="tab-badge red" id="badgeIncidentsCount">0</span>
      </a>
      <a href="#/tasks" class="nav-tab" data-tab="tasks" title="Tasks">
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="m9 12 2 2 4-4"/></svg>
        <span>Tasks</span>
        <span class="tab-badge" id="badgeTasksCount">0</span>
      </a>
      <a href="#/services" class="nav-tab" data-tab="services" title="Services">
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="7" rx="2"></rect><rect x="2" y="14" width="20" height="7" rx="2"></rect><line x1="6" y1="6.5" x2="6.01" y2="6.5"></line><line x1="6" y1="17.5" x2="6.01" y2="17.5"></line></svg>
        <span>Services</span>
        <span class="tab-badge" id="badgeServicesCount">0</span>
      </a>
      <a href="#/feed" class="nav-tab" data-tab="feed" title="Activity">
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></svg>
        <span>Activity</span>
        <span class="tab-badge" id="badgeFeedCount">0</span>
      </a>
    </nav>

    <div class="header-controls">
      <div class="search-box">
        <svg class="search-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>
        <input type="text" id="globalSearch" class="search-input" placeholder="Search fleet memory...">
        <span class="kbd-shortcut">/</span>
      </div>
      <button class="btn primary sm" data-write id="btnOpenNew" onclick="openNewModal()">+ New</button>
      <button class="btn sm icon-only" title="Keyboard Shortcuts (?)" onclick="openShortcutsModal()"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="20" height="16" rx="2"/><line x1="6" y1="8" x2="6" y2="8.01"/><line x1="10" y1="8" x2="10" y2="8.01"/><line x1="14" y1="8" x2="14" y2="8.01"/><line x1="18" y1="8" x2="18" y2="8.01"/><line x1="6" y1="12" x2="6" y2="12.01"/><line x1="10" y1="12" x2="10" y2="12.01"/><line x1="14" y1="12" x2="14" y2="12.01"/><line x1="18" y1="12" x2="18" y2="12.01"/><line x1="7" y1="16" x2="17" y2="16"/></svg></button>
      <button class="btn sm icon-only" id="refreshBtn" title="Force Refresh (R)" onclick="manualRefresh()"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38l5.67-5.67"/></svg></button>
      <button class="system-status" id="whoBtn" title="Who is signed in at this console" onclick="openTokenModal()">
        <span class="status-dot"></span>
        <span id="daemonLabel">Connected</span><span id="whoLabel"></span><span class="sync">· synced <span id="statLastSync">just now</span></span>
      </button>
    </div>
  </header>

  <!-- Metrics Subheader -->

  <!-- Main Content Area -->
  <main>

    <!-- ==================== TAB 1: KNOWLEDGE & SEARCH ==================== -->
    <div id="tab-search" class="tab-content active">
      <div class="explorer-layout">
        <!-- Left Master List -->
        <div class="explorer-pane">
          <div class="pane-header">
            <div class="filter-chips">
              <span class="chip active" data-filter="all">All</span>
              <span class="chip" data-filter="knowledge">Knowledge</span>
              <span class="chip" data-filter="incident">Incidents</span>
              <span class="chip" data-filter="task">Tasks</span>
            </div>
            <div class="pane-sort-bar">
              <span id="listCountLabel">0 items</span>
              <div style="display:flex; align-items:center; gap:6px;">
                <span>Sort:</span>
                <select id="sortSelect" class="select-sm" onchange="renderKnowledgeList()">
                  <option value="newest">Newest first</option>
                  <option value="oldest">Oldest first</option>
                  <option value="az">Title A-Z</option>
                </select>
              </div>
            </div>
            <div id="tagPills" style="display:flex; flex-wrap:wrap; gap:4px; max-height: 48px; overflow-y:auto;"></div>
          </div>
          <div class="pane-list" id="knowledgeList">
            <div style="padding: 24px; text-align:center; color: var(--text-muted);">Loading knowledge base...</div>
          </div>
        </div>

        <!-- Right Detail View -->
        <div class="explorer-pane">
          <div id="detailView" style="display:flex; flex-direction:column; height:100%;">
            <div class="detail-empty">
              <svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
              <div>Select an entry from the list or press <kbd style="background:var(--border); padding:2px 6px; border-radius:4px;">J</kbd> / <kbd style="background:var(--border); padding:2px 6px; border-radius:4px;">K</kbd> to navigate.</div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- ==================== TAB 2: INCIDENTS ==================== -->
    <div id="tab-incidents" class="tab-content">
      <div class="inc">
        <div class="inc-queue" id="incQueue"></div>
        <div class="inc-top" id="incTop"></div>
        <div id="incidentRows"></div>
        <div class="inc-hint">
          <span><kbd>j</kbd> <kbd>k</kbd> move</span><span><kbd>&#9166;</kbd> open</span><span><kbd>r</kbd> resolve</span>
          <span><kbd>d</kbd> diff</span><span><kbd>h</kbd> history</span><span><kbd>esc</kbd> clear queue</span>
        </div>
      </div>
    </div>

    <!-- ==================== TAB 3: TASKS ==================== -->
    <div id="tab-tasks" class="tab-content">
      <div class="inc">
        <div class="inc-queue" id="taskQueue"></div>
        <div class="inc-top" id="taskTop"></div>
        <div id="taskRows"></div>
        <div class="inc-hint">
          <span><kbd>j</kbd> <kbd>k</kbd> move</span><span><kbd>&#9166;</kbd> open</span><span><kbd>m</kbd> move to&hellip;</span>
          <span><kbd>x</kbd> done</span><span><kbd>e</kbd> edit</span><span><kbd>d</kbd> diff</span><span><kbd>h</kbd> history</span><span><kbd>esc</kbd> clear queue</span>
        </div>
      </div>
    </div>

    <!-- ==================== TAB 4: SERVICES AND HOSTS ==================== -->
    <div id="tab-services" class="tab-content">
      <div class="places">
        <div class="places-list" id="placesList"></div>
        <div class="places-detail" id="placeDetail"></div>
      </div>
    </div>

    <!-- ==================== TAB 5: CHANGE LEDGER ==================== -->
    <div id="tab-feed" class="tab-content">
      <div class="led">
        <div class="led-top" id="ledTop"></div>
        <div id="ledBody"></div>
      </div>
    </div>

  <!-- ==================== MODALS ==================== -->

  <!-- 1. New Entry Modal -->
  <div class="modal-backdrop" id="newModal" onclick="handleBackdropClick(event, 'newModal')">
    <div class="modal-card">
      <div class="modal-header">
        <div class="modal-title" id="newModalTitle">New note</div>
        <span class="segs modal-switch">
          <button class="chip active" id="modalTypeKnowledge" onclick="switchNewModalType('knowledge')">Knowledge</button>
          <button class="chip" id="modalTypeIncident" onclick="switchNewModalType('incident')">Incident</button>
          <button class="chip" id="modalTypeTask" onclick="switchNewModalType('task')">Task</button>
        </span>
        <button class="modal-close" onclick="closeModal('newModal')">✕</button>
      </div>

      <div class="modal-body" id="newModalBody">
        <!-- Dynamic Form Fields rendered by JS -->
      </div>

      <div class="modal-footer">
        <span class="foot-hint" id="newModalHint"></span>
        <button class="btn ghost" onclick="closeModal('newModal')">Cancel</button>
        <button class="btn primary" id="newModalSubmitBtn" onclick="submitNewModal()">Save Entry</button>
      </div>
    </div>
  </div>

  <!-- 2. Resolve Incident Modal -->
  <div class="modal-backdrop" id="resolveIncidentModal" onclick="handleBackdropClick(event, 'resolveIncidentModal')">
    <div class="modal-card">
      <div class="modal-header">
        <div class="modal-title" id="resolveIncidentTitle">Resolve incident</div>
        <span class="mono modal-key" id="resolveIncidentTargetText"></span>
        <button class="modal-close" onclick="closeModal('resolveIncidentModal')">✕</button>
      </div>
      <div class="modal-body">
        <div class="form-group">
          <label class="form-label">What fixed it</label>
          <textarea class="form-textarea" id="resolveIncidentOutcome" placeholder="The cause and the change that fixed it. This is what the next person reads."></textarea>
        </div>
      </div>
      <div class="modal-footer">
        <span class="foot-hint">The report leaves the open list and stays searchable.</span>
        <button class="btn ghost" onclick="closeModal('resolveIncidentModal')">Cancel</button>
        <button class="btn success" onclick="submitResolveIncident()">Resolve and archive</button>
      </div>
    </div>
  </div>

  <!-- 3. Resolve Task Modal -->
  <div class="modal-backdrop" id="resolveTaskModal" onclick="handleBackdropClick(event, 'resolveTaskModal')">
    <div class="modal-card">
      <div class="modal-header">
        <div class="modal-title" id="resolveTaskTitle">Finish task</div>
        <span class="mono modal-key" id="resolveTaskTargetText"></span>
        <button class="modal-close" onclick="closeModal('resolveTaskModal')">✕</button>
      </div>
      <div class="modal-body">
        <div class="form-group">
          <label class="form-label">What came out of it</label>
          <textarea class="form-textarea" id="resolveTaskOutcome" placeholder="The result, how it was verified, a link if there is one."></textarea>
        </div>
      </div>
      <div class="modal-footer">
        <span class="foot-hint">The task is archived and stays searchable.</span>
        <button class="btn ghost" onclick="closeModal('resolveTaskModal')">Cancel</button>
        <button class="btn success" onclick="submitResolveTask()">Mark done</button>
      </div>
    </div>
  </div>

  <!-- 3b. Block Task Modal -->
  <div class="modal-backdrop" id="blockTaskModal" onclick="handleBackdropClick(event, 'blockTaskModal')">
    <div class="modal-card">
      <div class="modal-header">
        <div class="modal-title" id="blockTaskTitle">Block task</div>
        <span class="mono modal-key" id="blockTaskTargetText"></span>
        <button class="modal-close" onclick="closeModal('blockTaskModal')">✕</button>
      </div>
      <div class="modal-body">
        <div class="form-group">
          <label class="form-label">What is blocking it</label>
          <textarea class="form-textarea" id="blockTaskReason" placeholder="Who or what has to happen first."></textarea>
        </div>
      </div>
      <div class="modal-footer">
        <span class="foot-hint">The reason shows on the task until it is unblocked.</span>
        <button class="btn ghost" onclick="closeModal('blockTaskModal')">Cancel</button>
        <button class="btn warning" onclick="submitBlockTask()">Block</button>
      </div>
    </div>
  </div>

  <!-- 3c. Token Modal -->
  <div class="modal-backdrop" id="tokenModal" onclick="handleBackdropClick(event, 'tokenModal')">
    <div class="modal-card" style="max-width: 480px;">
      <div class="modal-header">
        <div class="modal-title">Access token</div>
        <button class="modal-close" onclick="closeModal('tokenModal')">✕</button>
      </div>
      <div class="modal-body">
        <div class="form-target" id="tokenWhy"></div>
        <div class="form-group">
          <label class="form-label">Token</label>
          <input type="password" class="form-input mono" id="tokenInput" placeholder="kyb_..." autocomplete="off">
          <div class="form-err" id="tokenErr"></div>
        </div>
      </div>
      <div class="modal-footer">
        <button class="btn" onclick="forgetToken()">Forget token</button>
        <button class="btn primary" onclick="submitToken()">Use this token</button>
      </div>
    </div>
  </div>

  <!-- 4. Keyboard Shortcuts Modal -->
  <div class="modal-backdrop" id="shortcutsModal" onclick="handleBackdropClick(event, 'shortcutsModal')">
    <div class="modal-card" style="max-width: 480px;">
      <div class="modal-header">
        <div class="modal-title">Keyboard Shortcuts</div>
        <button class="modal-close" onclick="closeModal('shortcutsModal')">✕</button>
      </div>
      <div class="modal-body" style="font-size:13px;">
        <table style="width:100%; border-collapse:collapse;">
          <tr style="border-bottom:1px solid var(--border);">
            <td style="padding:8px 0;"><kbd class="kbd-shortcut" style="position:static;">/</kbd></td>
            <td>Focus fleet search input</td>
          </tr>
          <tr style="border-bottom:1px solid var(--border);">
            <td style="padding:8px 0;"><kbd class="kbd-shortcut" style="position:static;">1</kbd> .. <kbd class="kbd-shortcut" style="position:static;">5</kbd></td>
            <td>Switch tabs (Knowledge, Incidents, Tasks, Services, Activity)</td>
          </tr>
          <tr style="border-bottom:1px solid var(--border);">
            <td style="padding:8px 0;"><kbd class="kbd-shortcut" style="position:static;">N</kbd></td>
            <td>Quick create new Knowledge / Incident / Task</td>
          </tr>
          <tr style="border-bottom:1px solid var(--border);">
            <td style="padding:8px 0;"><kbd class="kbd-shortcut" style="position:static;">E</kbd></td>
            <td>Edit current entry</td>
          </tr>
          <tr style="border-bottom:1px solid var(--border);">
            <td style="padding:8px 0;"><kbd class="kbd-shortcut" style="position:static;">R</kbd></td>
            <td>Force instant sync & refresh</td>
          </tr>
          <tr style="border-bottom:1px solid var(--border);">
            <td style="padding:8px 0;"><kbd class="kbd-shortcut" style="position:static;">J</kbd> / <kbd class="kbd-shortcut" style="position:static;">K</kbd></td>
            <td>Next / Previous entry in Knowledge list</td>
          </tr>
          <tr style="border-bottom:1px solid var(--border);">
            <td style="padding:8px 0;"><kbd class="kbd-shortcut" style="position:static;">?</kbd></td>
            <td>Toggle this shortcuts dialog</td>
          </tr>
          <tr>
            <td style="padding:8px 0;"><kbd class="kbd-shortcut" style="position:static;">Esc</kbd></td>
            <td>Close open modal or clear search</td>
          </tr>
        </table>
      </div>
      <div class="modal-footer">
        <button class="btn" onclick="closeModal('shortcutsModal')">Close</button>
      </div>
    </div>
  </div>

  <!-- 5. Edit Entry Modal -->
  <div class="modal-backdrop" id="editModal" onclick="handleBackdropClick(event, 'editModal')">
    <div class="modal-card">
      <div class="modal-header">
        <div class="modal-title" id="editModalTitle">Edit Entry</div>
        <button class="modal-close" onclick="closeModal('editModal')">✕</button>
      </div>
      <div class="modal-body" id="editModalBody">
        <!-- Rendered by openEditModal -->
      </div>
      <div class="modal-footer">
        <button class="btn ghost" onclick="closeModal('editModal')">Cancel</button>
        <button class="btn primary" id="editModalSubmitBtn" onclick="submitEditModal()">Save</button>
      </div>
    </div>
  </div>

  <!-- Toast Notification Container -->
  <div id="toastContainer"></div>

  <!-- ==================== LOGIC & SCRIPT ==================== -->
  <script>
<!-- @js -->
  </script>
</body>
</html>