mirror of
https://github.com/multipleof4/.sune.git
synced 2026-01-13 15:47:53 +00:00
1 line
4.9 KiB
Plaintext
1 line
4.9 KiB
Plaintext
[{"id":"jbcwown","name":"Inline Commit","pinned":false,"avatar":"","url":"gh://multipleof4/.sune/inline-commit.sune","updatedAt":1757665491777,"settings":{"model":"google/gemini-2.5-pro","temperature":"","top_p":"","top_k":"","frequency_penalty":"","repetition_penalty":"","min_p":"","top_a":"","verbosity":"","reasoning_effort":"default","system_prompt":"","html":"<!--\nSune: GitHub Commit Helper\nVersion: 1.5\n-->\n<div id=\"sune_github_commit\" x-data=\"{v:'1.5'}\" class=\"hidden\"></div>\n<script>\n(()=>{\n const suneEl=document.getElementById('sune_github_commit');\n if(!suneEl){console.error(\"Sune container not found.\");return}\n const SUNE_NAME='[Sune: GitHub Commit Helper]', SUNE_V=suneEl.getAttribute('x-data').match(/v:'(.*?)'/)[1];\n console.log(`${SUNE_NAME} Initializing v${SUNE_V}`);\n\n const commitFile=async(btn,owner,repo,branch,path,content)=>{\n console.log(`${SUNE_NAME} commitFile called:`,{owner,repo,branch,path});\n const token=window.USER?.githubToken;\n if(!token){alert('GitHub token not set in Account Settings > API.');return}\n \n btn.disabled=true;\n btn.innerHTML='<span class=\"relative flex h-3 w-3\"><span class=\"animate-ping absolute inline-flex h-full w-full rounded-full bg-sky-400 opacity-75\"></span><span class=\"relative inline-flex rounded-full h-3 w-3 bg-sky-500\"></span></span> Committing...';\n\n const URL=`https://api.github.com/repos/${owner}/${repo}/contents/${path}`, H={'Authorization':`Bearer ${token}`,'Accept':'application/vnd.github.v3+json'};\n try{\n let sha;\n const r=await fetch(`${URL}?ref=${branch}`,{headers:H});\n if(r.ok)sha=(await r.json()).sha;\n else if(r.status!==404)throw new Error(`GET failed: ${r.statusText}`);\n\n const msg=`feat: update ${path.split('/').pop()}`, b64c=btoa(unescape(encodeURIComponent(content)));\n const body={message:msg,content:b64c,sha,branch};\n const pr=await fetch(URL,{method:'PUT',headers:H,body:JSON.stringify(body)});\n \n if(!pr.ok)throw new Error(`PUT failed: ${(await pr.json()).message}`);\n \n btn.className=btn.className.replace(/bg-slate-100 text-slate-700 hover:bg-slate-200/,'bg-green-100 text-green-800');\n btn.innerHTML='<i data-lucide=\"check\" class=\"h-3.5 w-3.5\"></i> Success';\n }catch(err){\n console.error(`${SUNE_NAME} GitHub Commit Failed:`,err);\n btn.className=btn.className.replace(/bg-slate-100 text-slate-700 hover:bg-slate-200/,'bg-red-100 text-red-800');\n btn.innerHTML='<i data-lucide=\"x\" class=\"h-3.5 w-3.5\"></i> Failed';\n setTimeout(()=>{\n btn.disabled=false;\n btn.className='ml-2 inline-flex items-center gap-1.5 rounded-md bg-slate-100 px-2 py-1 text-xs font-medium text-slate-700 hover:bg-slate-200 transition-colors';\n btn.innerHTML='<i data-lucide=\"github\" class=\"h-3.5 w-3.5\"></i> Commit';\n window.lucide?.createIcons();\n },3e3);\n }finally{window.lucide?.createIcons()}\n };\n\n const processBubble=bubble=>{\n if(!bubble)return;\n bubble.querySelectorAll('pre').forEach(pre=>{\n const p=pre.previousElementSibling;\n if(p?.tagName!=='P'||p.querySelector('button.commit-btn'))return;\n const m=p.innerHTML.match(/`([a-zA-Z0-9.\\-_]+)\\/([a-zA-Z0-9.\\-_]+)@([a-zA-Z0-9.\\-_]+)\\/([^`]+)`/);\n if(!m)return;\n const[_,owner,repo,branch,path]=m, code=pre.querySelector('code')?.innerText;\n if(!code)return;\n\n const btn=document.createElement('button');\n btn.className='commit-btn ml-2 inline-flex items-center gap-1.5 rounded-md bg-slate-100 px-2 py-1 text-xs font-medium text-slate-700 hover:bg-slate-200 transition-colors';\n btn.innerHTML='<i data-lucide=\"github\" class=\"h-3.5 w-3.5\"></i> Commit';\n btn.onclick=()=>commitFile(btn,owner,repo,branch,path,code);\n p.append(btn);\n window.lucide?.createIcons();\n });\n };\n\n const scanExisting=()=>{\n document.querySelectorAll('#messages .msg-bubble:not([class*=\"bg-gray-50\"])').forEach(processBubble);\n };\n \n const observer=new MutationObserver(mutations=>{\n for(const m of mutations){\n for(const node of m.addedNodes){\n if(node.nodeType===1){\n const bubble=node.querySelector?.('.msg-bubble:not([class*=\"bg-gray-50\"])');\n if(bubble)processBubble(bubble);\n }\n }\n }\n });\n\n const chatContainer=window.el?.messages;\n if(chatContainer){\n observer.observe(chatContainer,{childList:true,subtree:true});\n scanExisting(); // Initial scan for any messages already present\n console.log(`${SUNE_NAME} Observer attached and initial scan complete.`);\n }\n\n suneEl.addEventListener('sune:unmount',()=>{\n observer.disconnect();\n console.log(`${SUNE_NAME} Unmounted and observer disconnected.`);\n });\n})();\n</script>\n","extension_html":"<sune src='https://raw.githubusercontent.com/sune-org/store/refs/heads/main/sync.sune' private></sune>","hide_composer":false},"storage":{}}] |