Agent Template

SuperCoderAI

A privacy-conscious coding and conversation assistant with local chat history, complete code generation, debugging help, syntax-highlighted code blocks, and one-click code copying. Choose a local model in the AgentOp model selector to run without an external AI API.

coding chat debugging web development local AI
Triton8539 Nov 30, 2026 1 use

Preview Mode

This is a preview with sample data. The template uses placeholders like which will be replaced with actual agent data.

About This Template

SuperCoderAI is a browser-executable AI agent template built on AgentOp. It runs entirely in the browser using Python (via Pyodide) and can be deployed without a server — just download the generated HTML file and open it locally or host it anywhere.

Topics coding chat debugging web development local AI
Template Preview

Template Metadata

Slug
supercoderai
Created By
Triton8539
Created
Nov 30, 2026
Usage Count
1

Tags

coding chat debugging web development local AI

Code Statistics

HTML Lines
32
CSS Lines
1
JS Lines
157
Python Lines
8

Source Code

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="color-scheme" content="dark">
  <title>{{ agent_name }}</title>
  <style>{{ css_code }}</style>
</head>
<body>
  <div class="app-shell">
    <aside class="sidebar" aria-label="SuperCoderAI conversation history">
      <div class="brand"><span class="brand-mark" aria-hidden="true">⌘</span><div><strong>SuperCoderAI</strong><small>Think it. Build it. Refine it.</small></div></div>
      <button id="new-chat" class="new-chat" type="button">+ New coding chat</button>
      <div class="history-heading"><span>Conversations</span><button id="clear-history" class="text-button" type="button" title="Delete all saved conversations">Clear all</button></div>
      <nav id="history-list" class="history-list" aria-label="Saved coding conversations"></nav>
      <div class="privacy-note">🔒 Chats are saved in this browser. Select a local model above for API-free replies; download it once to use it offline when available.</div>
    </aside>
    <main class="workspace">
      <header class="topbar"><div><span class="eyebrow">YOUR AI CODING WORKSPACE</span><h1>SuperCoderAI</h1></div><span id="runtime-status" class="status-pill" role="status">Initializing Python…</span></header>
      <section id="chat-stage" class="chat-stage" aria-label="SuperCoderAI chat">
        <div id="results-container" class="messages" aria-live="polite">
          <div id="welcome" class="welcome"><div class="welcome-symbol">⌘</div><h2>What will you build today?</h2><p>Chat naturally, solve bugs, and turn ideas into complete, editable code.</p><div class="feature-grid"><span>🧩 Build websites &amp; apps</span><span>🛠️ Debug and fix errors</span><span>📚 Explain programming ideas</span><span>🔁 Revise earlier code</span></div><div class="suggestions"><button class="suggestion" type="button" data-example="Build a responsive portfolio website in HTML, CSS, and JavaScript.">Build a portfolio website</button><button class="suggestion" type="button" data-example="Debug this Python traceback and explain the fix.">Debug Python code</button><button class="suggestion" type="button" data-example="Write a C++ function to find the shortest path in a graph.">Write a C++ algorithm</button><button class="suggestion" type="button" data-example="Help me brainstorm an app idea, then build its first page.">Brainstorm an app</button></div></div>
        </div>
        <div id="loading-overlay" class="loading-overlay hidden" role="status"><span class="spinner" aria-hidden="true"></span><span>SuperCoderAI is thinking…</span></div>
      </section>
      <div class="composer-area"><div id="inline-error" class="inline-error hidden" role="alert"></div><form id="chat-form" class="composer"><label class="sr-only" for="chat-input">Message SuperCoderAI or paste code to debug</label><textarea id="chat-input" rows="2" placeholder="Ask SuperCoderAI anything, paste code, or request a revision…" aria-label="Message SuperCoderAI"></textarea><button id="send-button" type="submit" disabled>Send ↗</button></form><p class="composer-hint">Enter to send · Shift+Enter for a new line · Copy code from any response</p></div>
    </main>
  </div>
  <script>{{ js_code }}</script>
</body>
</html>
:root{--bg:#0a0e16;--sidebar:#101622;--panel:#111926;--raised:#192438;--border:#29354a;--text:#eef3ff;--muted:#a2afc5;--accent:#84a9ff;--accent-strong:#547af2;--green:#6ddab2;--danger:#ff9b9b;--radius:16px;--shadow:0 18px 52px rgba(0,0,0,.25);font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color-scheme:dark}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text)}button,textarea{font:inherit}button{cursor:pointer}button:disabled{opacity:.48;cursor:not-allowed}button:focus-visible,textarea:focus-visible{outline:2px solid var(--accent);outline-offset:3px}.hidden{display:none!important}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.app-shell{min-height:calc(100vh - 0px);display:grid;grid-template-columns:270px minmax(0,1fr)}.sidebar{background:var(--sidebar);border-right:1px solid var(--border);display:flex;flex-direction:column;min-height:100vh;padding:24px 16px;gap:22px}.brand{display:flex;align-items:center;gap:12px;padding:4px 7px}.brand-mark,.welcome-symbol{display:grid;place-items:center;background:linear-gradient(135deg,#718cff,#9a7bff);color:#fff;border-radius:14px;font-size:29px;font-weight:700}.brand-mark{width:43px;height:43px}.brand strong{display:block;font-size:17px;letter-spacing:-.03em}.brand small{display:block;margin-top:3px;font-size:11px;color:var(--muted)}.new-chat{padding:12px;border-radius:11px;background:var(--raised);color:var(--text);border:1px solid var(--border);text-align:left;font-weight:650}.new-chat:hover,.history-item:hover,.suggestion:hover{border-color:var(--accent);background:#202d45}.history-heading{display:flex;align-items:center;justify-content:space-between;padding:0 7px;color:var(--muted);font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.09em}.text-button{border:0;background:none;color:var(--muted);font-size:11px;text-transform:none;letter-spacing:0}.text-button:hover{color:var(--text)}.history-list{display:flex;flex-direction:column;gap:6px;overflow:auto;min-height:55px;max-height:55vh}.history-item{width:100%;padding:11px 12px;border:1px solid transparent;border-radius:10px;background:transparent;color:var(--muted);text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.history-item.active{background:#20304b;color:var(--text);border-color:#354b70}.history-empty{padding:12px;color:var(--muted);font-size:12px}.privacy-note{margin-top:auto;border-top:1px solid var(--border);padding:16px 7px 0;color:var(--muted);font-size:12px;line-height:1.6}.workspace{min-width:0;height:100vh;min-height:620px;display:flex;flex-direction:column}.topbar{min-height:90px;padding:19px 34px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:18px}.eyebrow{color:var(--accent);font-size:10px;font-weight:800;letter-spacing:.17em}.topbar h1{font-size:21px;letter-spacing:-.04em;margin:4px 0 0}.status-pill{max-width:45%;padding:8px 11px;border:1px solid var(--border);border-radius:999px;background:var(--panel);font-size:11px;color:var(--muted);text-align:right}.status-pill.ready{border-color:#367861;color:var(--green)}.chat-stage{flex:1;position:relative;min-height:0;overflow:auto}.messages{max-width:1000px;margin:auto;padding:32px 34px 60px;display:flex;flex-direction:column;gap:24px}.welcome{text-align:center;margin:clamp(30px,9vh,110px) auto 0;max-width:750px}.welcome-symbol{width:62px;height:62px;margin:0 auto 20px;font-size:40px;box-shadow:var(--shadow)}.welcome h2{font-size:clamp(27px,4vw,42px);letter-spacing:-.05em;margin:0 0 9px}.welcome p{color:var(--muted);line-height:1.6;margin:0}.feature-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:30px auto;max-width:550px;text-align:left}.feature-grid span{padding:11px 14px;border:1px solid var(--border);border-radius:11px;background:var(--panel);font-size:13px}.suggestions{display:flex;flex-wrap:wrap;gap:9px;justify-content:center}.suggestion{background:var(--panel);border:1px solid var(--border);border-radius:999px;padding:9px 13px;color:var(--text);font-size:12px}.message{display:flex;gap:14px;min-width:0}.message.user{flex-direction:row-reverse}.avatar{width:34px;height:34px;flex:none;display:grid;place-items:center;border:1px solid var(--border);border-radius:10px;background:var(--raised);color:var(--accent)}.message.user .avatar{background:#334573;color:#fff}.message-body{max-width:min(850px,90%);min-width:0}.message.user .message-body{max-width:80%;padding:12px 16px;border:1px solid #3d5279;background:#243454;border-radius:14px 4px 14px 14px}.message-label{font-size:11px;font-weight:750;color:var(--muted);margin-bottom:8px}.message.user .message-label{color:#c5d6ff}.prose{font-size:14px;line-height:1.75;overflow-wrap:anywhere;white-space:pre-wrap}.code-card{border:1px solid #35425c;border-radius:12px;background:#0c1320;margin:15px 0;overflow:hidden;box-shadow:var(--shadow)}.code-head{display:flex;align-items:center;justify-content:space-between;gap:12px;background:#1a2639;padding:9px 14px;color:#b8c9e5;font-size:12px}.copy-code{color:#d5e3ff;background:#2b3a55;border:1px solid #495d7d;border-radius:7px;padding:5px 10px;font-size:11px}.copy-code:hover{background:#3a5179}.code-card pre{margin:0;padding:17px;max-height:650px;overflow:auto;font:12.5px/1.65 ui-monospace,SFMono-Regular,Consolas,'Liberation Mono',monospace;tab-size:2;color:#dce7fb}.tok-comment{color:#7891a5}.tok-string{color:#a7db9a}.tok-keyword{color:#b69cff}.tok-number{color:#f6bc85}.loading-overlay{position:absolute;right:22px;bottom:15px;display:flex;align-items:center;gap:9px;padding:10px 14px;border:1px solid var(--border);border-radius:999px;background:var(--raised);box-shadow:var(--shadow);color:var(--muted);font-size:12px;pointer-events:none}.spinner{height:15px;width:15px;border-radius:50%;border:2px solid #526483;border-top-color:var(--accent);animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.composer-area{padding:15px 34px 20px;background:var(--bg);border-top:1px solid var(--border)}.composer{max-width:940px;margin:auto;display:flex;align-items:flex-end;gap:10px;padding:9px;border:1px solid #394862;border-radius:var(--radius);background:var(--panel);box-shadow:var(--shadow)}.composer:focus-within{border-color:var(--accent)}.composer textarea{flex:1;resize:vertical;min-height:53px;max-height:210px;background:none;border:0;color:var(--text);padding:11px;outline:none;font-size:14px;line-height:1.5}.composer textarea:focus-visible{outline:none}.composer textarea::placeholder{color:#8798b0}.composer button{flex:none;background:var(--accent-strong);border:0;color:white;border-radius:10px;padding:11px 17px;font-weight:700}.composer button:not(:disabled):hover{background:#6f91ff}.composer-hint{max-width:940px;margin:9px auto 0;text-align:center;color:var(--muted);font-size:11px}.inline-error{max-width:940px;margin:0 auto 10px;color:var(--danger);font-size:13px}@media(max-width:1200px){.app-shell{grid-template-columns:225px minmax(0,1fr)}.sidebar{padding:18px 12px}.messages{padding-left:24px;padding-right:24px}}@media(max-width:768px){.app-shell{display:block}.sidebar{min-height:0;padding:11px 15px;gap:10px;border-right:0;border-bottom:1px solid var(--border)}.sidebar .privacy-note{display:none}.sidebar .history-list{flex-direction:row;max-height:50px;min-height:0;overflow-x:auto}.history-item{width:auto;max-width:200px;flex:none}.sidebar .new-chat{padding:8px 11px}.workspace{height:calc(100dvh - 180px);min-height:450px}.topbar{padding:12px 17px;min-height:68px}.status-pill{max-width:52%;font-size:10px}.messages{padding:20px 14px 45px}.feature-grid{gap:7px}.feature-grid span{font-size:11px;padding:9px}.composer-area{padding:11px 12px}.message-body{max-width:calc(100% - 48px)}.message.user .message-body{max-width:88%}}
(() => {
  'use strict';
  const $ = (id) => document.getElementById(id);
  const stage = $('chat-stage'), results = $('results-container'), input = $('chat-input');
  const status = $('runtime-status'), error = $('inline-error'), send = $('send-button');
  const storeKey = 'supercoderai-chats-v1';
  let chats = [], activeId = null, busy = false, pythonReady = false;
  let streamingNode = null, streamingText = '';
  const escapeHtml = (s) => String(s).replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
  const isLocal = () => /local|wllama/.test(String(window.PROVIDER || '').toLowerCase());
  const modelReady = () => !isLocal() || !!(window.agentManager && window.agentManager.isLoaded);
  const ready = () => pythonReady && !!window.pyodide && modelReady();
  function setError(message) { error.textContent = message; error.classList.toggle('hidden', !message); }
  function updateStatus() {
    const text = !pythonReady || !window.pyodide ? 'Initializing Python…' : !modelReady() ? 'Load a local model above to start' : busy ? 'Generating reply…' : isLocal() ? 'Local model ready' : 'Ready to chat';
    status.textContent = text;
    status.classList.toggle('ready', ready() && !busy);
    send.disabled = busy || !ready();
    $('loading-overlay').classList.toggle('hidden', !busy);
  }
  function save() { try { localStorage.setItem(storeKey, JSON.stringify({chats, activeId})); } catch (_) { /* Storage may be unavailable. */ } }
  function load() {
    try {
      const data = JSON.parse(localStorage.getItem(storeKey) || '{}');
      chats = Array.isArray(data.chats) ? data.chats.filter(c => c && typeof c.id === 'string' && Array.isArray(c.messages)).slice(0, 30) : [];
      activeId = chats.some(c => c.id === data.activeId) ? data.activeId : (chats[0] && chats[0].id) || null;
    } catch (_) { chats = []; activeId = null; }
  }
  const current = () => chats.find(c => c.id === activeId);
  function newChat() {
    const id = String(Date.now()) + '-' + Math.random().toString(36).slice(2, 8);
    chats.unshift({id, title:'New coding chat', messages:[]});
    activeId = id; save(); renderHistory(); renderChat(); input.focus();
  }
  function renderHistory() {
    const list = $('history-list');
    list.innerHTML = chats.length ? chats.map(c => '<button type="button" class="history-item' + (c.id === activeId ? ' active' : '') + '" data-chat-id="' + escapeHtml(c.id) + '" title="' + escapeHtml(c.title) + '">' + escapeHtml(c.title) + '</button>').join('') : '<span class="history-empty">Your coding conversations appear here.</span>';
  }
  function highlight(code) {
    const re = /(\/\*[\s\S]*?\*\/|\/\/[^\n]*|#[^\n]*|<!--[^]*?-->|(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)|\b(?:function|return|const|let|var|class|def|async|await|import|from|export|if|else|elif|for|while|try|catch|except|public|private|void|int|float|bool|auto|new|this|true|false|None|null|include|struct|template)\b|\b\d+(?:\.\d+)?\b)/g;
    let out = '', last = 0, match;
    while ((match = re.exec(code))) {
      out += escapeHtml(code.slice(last, match.index));
      const tok = match[0];
      const kind = /^(\/\*|\/\/|#|<!--)/.test(tok) ? 'comment' : /^["'`]/.test(tok) ? 'string' : /^\d/.test(tok) ? 'number' : 'keyword';
      out += '<span class="tok-' + kind + '">' + escapeHtml(tok) + '</span>';
      last = re.lastIndex;
    }
    return out + escapeHtml(code.slice(last));
  }
  function formattedContent(raw) {
    const text = String(raw || '');
    const fence = /```([^\n`]*)\n([\s\S]*?)```/g;
    let html = '', last = 0, match;
    while ((match = fence.exec(text))) {
      if (match.index > last) html += '<div class="prose">' + escapeHtml(text.slice(last, match.index)) + '</div>';
      const language = match[1].trim() || 'code';
      html += '<div class="code-card"><div class="code-head"><span>' + escapeHtml(language) + '</span><button type="button" class="copy-code">Copy Code</button></div><pre><code>' + highlight(match[2]) + '</code></pre></div>';
      last = fence.lastIndex;
    }
    if (last < text.length) html += '<div class="prose">' + escapeHtml(text.slice(last)) + '</div>';
    return html || '<div class="prose"></div>';
  }
  function messageNode(role, text) {
    const node = document.createElement('article');
    node.className = 'message ' + (role === 'user' ? 'user' : 'assistant');
    node.innerHTML = '<div class="avatar" aria-hidden="true">' + (role === 'user' ? '👤' : '⌘') + '</div><div class="message-body"><div class="message-label">' + (role === 'user' ? 'You' : 'SuperCoderAI') + '</div><div class="message-content">' + formattedContent(text) + '</div></div>';
    results.appendChild(node);
    stage.scrollTop = stage.scrollHeight;
    return node;
  }
  function renderChat() {
    results.innerHTML = '';
    const messages = current()?.messages || [];
    if (!messages.length) {
      const welcome = document.createElement('div');
      welcome.id = 'welcome'; welcome.className = 'welcome';
      welcome.innerHTML = '<div class="welcome-symbol">⌘</div><h2>What will you build today?</h2><p>Chat naturally, solve bugs, and turn ideas into complete, editable code.</p><div class="feature-grid"><span>🧩 Build websites &amp; apps</span><span>🛠️ Debug and fix errors</span><span>📚 Explain programming ideas</span><span>🔁 Revise earlier code</span></div><div class="suggestions"><button class="suggestion" type="button" data-example="Build a responsive portfolio website in HTML, CSS, and JavaScript.">Build a portfolio website</button><button class="suggestion" type="button" data-example="Debug this Python traceback and explain the fix.">Debug Python code</button><button class="suggestion" type="button" data-example="Write a C++ function to find the shortest path in a graph.">Write a C++ algorithm</button><button class="suggestion" type="button" data-example="Help me brainstorm an app idea, then build its first page.">Brainstorm an app</button></div>';
      results.appendChild(welcome);
    } else messages.forEach(m => messageNode(m.role, m.text));
  }
  function buildQuery(messages, question) {
    const context = messages.slice(-8).map(m => (m.role === 'user' ? 'User: ' : 'Assistant: ') + String(m.text).slice(0, 2200)).join('\n\n');
    return (context ? 'Conversation so far (use it to understand references and code revisions):\n' + context + '\n\n' : '') + 'User: ' + question.slice(0, 10000) + '\nAssistant:';
  }
  // The runtime may stream replies through this hook. The final Python result replaces the preview.
  window.addMessage = function(type, content) {
    if (!busy || !/assistant|ai/i.test(String(type))) return;
    const part = String(content ?? '');
    streamingText = part.startsWith(streamingText) ? part : streamingText + part;
    if (!streamingNode) streamingNode = messageNode('assistant', streamingText);
    else streamingNode.querySelector('.message-content').innerHTML = formattedContent(streamingText);
    stage.scrollTop = stage.scrollHeight;
  };
  function finishReply(text) {
    if (streamingNode) streamingNode.querySelector('.message-content').innerHTML = formattedContent(text);
    else messageNode('assistant', text);
    streamingNode = null; streamingText = '';
  }
  async function submitChat(event) {
    event.preventDefault();
    if (busy) return;
    // Read the live DOM value first, then validate before invoking Python.
    const question = input.value.trim();
    if (!question) { setError('Write a question or paste code for SuperCoderAI first.'); input.focus(); return; }
    if (!pythonReady || !window.pyodide) { setError('SuperCoderAI is still initializing Python. Please wait.'); return; }
    if (!modelReady()) { setError('Select and load a local model in the bar above before sending a message.'); return; }
    setError('');
    if (!current()) newChat();
    const chat = current();
    const query = buildQuery(chat.messages, question);
    chat.messages.push({role:'user', text:question});
    if (chat.messages.filter(m => m.role === 'user').length === 1) chat.title = question.replace(/\s+/g, ' ').slice(0, 48);
    const welcome = $('welcome'); if (welcome) welcome.remove();
    messageNode('user', question);
    input.value = ''; save(); renderHistory();
    busy = true; streamingNode = null; streamingText = ''; updateStatus();
    try {
      window.pyodide.globals.set('user_query', query);
      const result = await window.pyodide.runPythonAsync('await process_user_query(user_query)');
      const answer = String(result ?? '').trim();
      if (!answer) throw new Error('The model returned an empty reply. Try again or reload the model.');
      finishReply(answer);
      chat.messages.push({role:'assistant', text:answer}); save();
    } catch (err) {
      if (streamingNode) streamingNode.remove();
      streamingNode = null; streamingText = '';
      setError('SuperCoderAI could not reply: ' + (err?.message || String(err)) + '. Check that the model is loaded, then try again.');
    } finally { busy = false; updateStatus(); stage.scrollTop = stage.scrollHeight; }
  }
  async function copyCode(button) {
    const code = button.closest('.code-card')?.querySelector('code')?.textContent || '';
    if (!code) return;
    try {
      if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(code);
      else throw new Error('Clipboard API unavailable');
    } catch (_) {
      const temp = document.createElement('textarea'); temp.value = code; temp.style.position = 'fixed'; temp.style.opacity = '0';
      document.body.appendChild(temp); temp.select();
      const success = document.execCommand('copy'); temp.remove();
      if (!success) { setError('Could not copy code automatically. Select the code and copy it manually.'); return; }
    }
    button.textContent = 'Copied ✓'; setTimeout(() => { if (button.isConnected) button.textContent = 'Copy Code'; }, 1700);
  }
  $('chat-form').addEventListener('submit', submitChat);
  input.addEventListener('keydown', event => { if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) { event.preventDefault(); $('chat-form').requestSubmit(); } });
  input.addEventListener('input', () => { if (!error.classList.contains('hidden')) setError(''); });
  $('new-chat').addEventListener('click', () => { if (!busy) { newChat(); setError(''); } });
  $('clear-history').addEventListener('click', () => { if (busy || !chats.length) return; if (!confirm('Delete all SuperCoderAI conversations saved in this browser?')) return; chats = []; activeId = null; save(); renderHistory(); renderChat(); setError(''); });
  $('history-list').addEventListener('click', e => { const item = e.target.closest('[data-chat-id]'); if (!item || busy) return; activeId = item.dataset.chatId; save(); renderHistory(); renderChat(); setError(''); });
  results.addEventListener('click', e => { const copy = e.target.closest('.copy-code'); if (copy) { copyCode(copy); return; } const suggestion = e.target.closest('.suggestion'); if (suggestion && !busy) { input.value = suggestion.dataset.example; input.focus(); setError(''); } });
  document.addEventListener('pyodide-ready', () => { pythonReady = true; updateStatus(); });
  load(); renderHistory(); renderChat();
  if (window.pyodideReady) pythonReady = true;
  updateStatus();
  setInterval(() => { if (window.pyodideReady) pythonReady = true; updateStatus(); }, 1200);
})();
async def process_user_query(query: str) -> str:
    """Continue the coding conversation using the configured real AI model.

    Args:
        query: Recent conversation context followed by the current user message.
    """
    prompt = query[-18000:]
    return await agentop_llm.generate(prompt, globals().get("TEMPLATE_SYSTEM_PROMPT", ""))