Surf commited on
Commit
ed1d299
·
1 Parent(s): d3535bf

重组原有写作功能为统一工作台顶部模块

Browse files
Files changed (1) hide show
  1. fanqie/workspace.html +32 -3
fanqie/workspace.html CHANGED
@@ -4,14 +4,26 @@
4
  <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
5
  <title>AI 小说创作工作台</title>
6
  <style>
7
- :root{color-scheme:dark;--bg:#0f1117;--panel:#191c25;--panel2:#141720;--line:#2b3140;--text:#eef1f7;--muted:#9aa4b7;--accent:#ff6b4a;--blue:#87a7ff;--green:#5ed39a;--danger:#ff8585}*{box-sizing:border-box}body{margin:0;background:linear-gradient(140deg,#1e1724 0,#0f1117 35%);color:var(--text);font:14px/1.55 system-ui,-apple-system,"PingFang SC","Microsoft YaHei",sans-serif}button,input,textarea,select{font:inherit}button{cursor:pointer}.app{min-height:100vh}.top{height:64px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 22px;background:#13151dcc;backdrop-filter:blur(10px);position:sticky;top:0;z-index:5}.brand{display:flex;align-items:center;gap:12px}.brand-mark{width:34px;height:34px;border-radius:10px;background:var(--accent);display:grid;place-items:center;color:#23100a;font-weight:900}.brand h1{font-size:17px;margin:0}.brand p{font-size:11px;color:var(--muted);margin:1px 0 0}.top-actions{display:flex;gap:8px}.link{color:var(--muted);text-decoration:none;border:1px solid var(--line);padding:7px 10px;border-radius:8px}.link:hover{color:var(--text);border-color:var(--blue)}.global-nav{display:flex;gap:7px;align-items:center;flex-wrap:wrap;padding:10px 22px;background:#171a24;border-bottom:1px solid var(--line);position:sticky;top:64px;z-index:4}.global-nav a{color:#cbd3e5;text-decoration:none;border:1px solid #30384c;background:#202635;border-radius:8px;padding:6px 10px;font-size:12px;white-space:nowrap}.global-nav a:hover,.global-nav a.current{color:#fff;border-color:var(--accent);background:#30232c}.global-nav .section-label{color:var(--muted);font-size:12px;margin-right:3px}.layout{display:grid;grid-template-columns:280px minmax(0,1fr);min-height:calc(100vh - 64px)}aside{border-right:1px solid var(--line);padding:18px 14px;background:#11141bdd}.aside-title{display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:12px;margin-bottom:10px}.project-list{display:grid;gap:7px}.project-item{width:100%;text-align:left;border:1px solid transparent;background:transparent;color:var(--text);padding:10px;border-radius:9px}.project-item:hover,.project-item.active{background:#242938;border-color:#3b4660}.project-item b{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.project-item small{color:var(--muted);display:block;margin-top:2px}.main{padding:24px;max-width:1280px;width:100%;margin:0 auto}.empty{max-width:760px;margin:9vh auto;text-align:center}.empty h2{font-size:28px;margin:14px 0 8px}.empty p{color:var(--muted)}.panel{border:1px solid var(--line);background:rgba(25,28,37,.9);border-radius:14px;padding:18px;margin-bottom:16px}.project-head{display:flex;justify-content:space-between;gap:15px;align-items:flex-start;margin-bottom:18px}.project-head h2{margin:0 0 5px;font-size:24px}.project-head p{margin:0;color:var(--muted);max-width:800px}.status{font-size:12px;color:var(--muted);min-height:18px}.status.error{color:var(--danger)}.status.ok{color:var(--green)}.tabs{display:flex;gap:5px;flex-wrap:wrap;border-bottom:1px solid var(--line);margin-bottom:16px}.tab{background:transparent;border:0;border-bottom:2px solid transparent;color:var(--muted);padding:9px 12px}.tab:hover,.tab.active{color:var(--text);border-color:var(--accent)}.tab-pane{display:none}.tab-pane.active{display:block}.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.field{display:grid;gap:5px}.field.full{grid-column:1/-1}.field label{color:#cbd2df;font-size:12px;font-weight:650}.field input,.field textarea,.field select{width:100%;background:#10131a;color:var(--text);border:1px solid var(--line);border-radius:8px;padding:9px 10px;outline:none}.field input:focus,.field textarea:focus,.field select:focus{border-color:var(--blue)}textarea{min-height:100px;resize:vertical}.json{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;min-height:150px}.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-top:14px}.btn{border:1px solid var(--line);border-radius:8px;background:#242938;color:var(--text);padding:8px 12px}.btn:hover{border-color:var(--blue);background:#2b3347}.btn.primary{background:var(--accent);border-color:var(--accent);color:#220e08;font-weight:750}.btn.green{background:#1f5944;border-color:#347c61}.btn.danger{color:#ffadad}.muted{color:var(--muted);font-size:12px}.notice{border-left:3px solid var(--blue);background:#1a2130;padding:10px 12px;color:#c8d3ed;border-radius:6px;font-size:13px;margin-bottom:14px}.cards{display:grid;gap:9px}.card{border:1px solid var(--line);border-radius:10px;padding:11px;background:var(--panel2)}.card.selected{border-color:var(--accent);box-shadow:0 0 0 1px #ff6b4a55}.card h4{margin:0 0 4px}.card p{margin:4px 0;color:#cbd1dc;font-size:13px;white-space:pre-wrap;max-height:150px;overflow:auto}.card footer{color:var(--muted);font-size:11px}.chapter-layout{display:grid;grid-template-columns:260px minmax(0,1fr);gap:14px}.chapter-list{display:grid;gap:7px;align-content:start}.chapter-item{text-align:left;border:1px solid var(--line);background:#141720;color:var(--text);border-radius:8px;padding:9px}.chapter-item.active{border-color:var(--accent);background:#29202a}.chapter-item small{display:block;color:var(--muted)}.version-list{display:flex;gap:7px;flex-wrap:wrap;margin:8px 0}.version-chip{border:1px solid var(--line);background:#141720;color:#cdd4e5;border-radius:7px;padding:6px 8px;font-size:12px}.version-chip.active{border-color:var(--green);color:var(--green)}.check{border-radius:8px;padding:10px;margin-top:10px;background:#121820;border:1px solid var(--line)}.check.pass{border-color:#347c61}.check.warning{border-color:#9b7b36}.check.error{border-color:#8b4545}.check ul{margin:7px 0 0;padding-left:20px}.hidden{display:none!important}.pill{font-size:11px;border:1px solid var(--line);border-radius:999px;padding:2px 7px;color:var(--muted)}.table{width:100%;border-collapse:collapse}.table td,.table th{text-align:left;border-bottom:1px solid var(--line);padding:8px}.table th{font-size:12px;color:var(--muted)}.tools-frame{width:100%;height:calc(100vh - 190px);min-height:760px;border:1px solid var(--line);border-radius:12px;background:#10131a}@media(max-width:900px){.layout{grid-template-columns:1fr}aside{border-right:0;border-bottom:1px solid var(--line);padding:12px}.project-list{display:flex;overflow:auto}.project-item{min-width:210px}.main{padding:15px}.grid,.grid.three{grid-template-columns:1fr}.chapter-layout{grid-template-columns:1fr}.top{padding:0 12px}.top-actions .link:nth-child(2){display:none}}
8
  </style>
9
  </head>
10
  <body>
11
  <div class="app">
12
- <header class="top"><div class="brand"><div class="brand-mark">AI</div><div><h1>AI 小说创作工作台</h1><p>项目、作品圣经、大纲、章节、版本与检查结果全部保存到 R2</p></div></div><div class="top-actions"><a class="link" href="/fanqie/batches">素材批次</a></div></header><nav class="global-nav" aria-label="全局写作工具"><span class="section-label">全局工具:</span><a href="/fanqie/workspace" class="current">项目工作台</a><a href="/fanqie/tools#home">🧭 起步路线</a><a href="/fanqie/tools#flow">🗺️ 新手全流程</a><a href="/fanqie/tools#ai">🤖 AI 写作实操</a><a href="/fanqie/tools#redlines">⛔ 禁写红线库</a><a href="/fanqie/tools#check">✅ 发布前自查</a><a href="/fanqie/tools#structure">🧱 结构模板</a><a href="/fanqie/tools#materials">🗂️ 素材库</a><a href="/fanqie/tools#motifs">🧬 母题库</a><a href="/fanqie/tools#auto">🪄 自动组稿</a><a href="/fanqie/tools#weave">🧵 素材串联创作</a></nav>
13
  <div class="layout"><aside><div class="aside-title"><span>我的作品</span><button class="btn" id="new-project">+ 新建</button></div><div id="project-list" class="project-list"></div><div id="aside-status" class="status" style="margin-top:12px"></div></aside>
14
  <main class="main"><div id="auth-box" class="panel"><h2 style="margin:0 0 5px">连接工作台</h2><p class="muted">输入当前网页访问密码。密码只用于请求受保护接口,不会写入作品数据。</p><div class="row"><input id="password" type="password" placeholder="网页访问密码" style="flex:1;min-width:220px;background:#10131a;color:var(--text);border:1px solid var(--line);padding:9px;border-radius:8px"><button class="btn primary" id="unlock">连接</button></div><div id="auth-status" class="status"></div></div>
 
 
 
 
 
 
 
 
 
 
 
 
15
  <div id="empty" class="empty hidden"><div style="font-size:50px">📖</div><h2>先建立一部作品</h2><p>创建后,作品信息、人物、时间线、大纲、章节和版本都会保存到 R2。以后你可以直接在对话中让我继续写,我会按项目 ID 读取并修改这里的数据。</p><button class="btn primary" id="empty-new">新建小说项目</button></div>
16
  <div id="workspace" class="hidden"><div class="project-head"><div><h2 id="project-title">—</h2><p id="project-meta">—</p></div><div><span class="pill" id="project-id">—</span><div id="save-status" class="status"></div></div></div><nav class="tabs"><button class="tab active" data-tab="overview">作品信息</button><button class="tab" data-tab="bible">作品圣经</button><button class="tab" data-tab="outline">总纲与卷章</button><button class="tab" data-tab="materials">参考素材</button><button class="tab" data-tab="chapters">章节与版本</button><button class="tab" data-tab="requests">给 Surf 的指令</button></nav>
17
  <section id="tab-overview" class="tab-pane active"><div class="notice">你不需要把内容复制给其它 AI。以后在当前对话中告诉 Surf 作品 ID 和写作要求,我会读取本项目内容,生成或修改结果,并通过项目接口保存回 R2。</div><div class="panel"><h3>作品基本信息</h3><div class="grid"><div class="field"><label>作品名称</label><input id="f-title"></div><div class="field"><label>题材</label><input id="f-genre" placeholder="都市情感、悬疑、古言……"></div><div class="field"><label>目标平台</label><input id="f-platform" placeholder="番茄小说"></div><div class="field"><label>目标字数</label><input id="f-words" type="number" min="0" placeholder="150000"></div><div class="field"><label>叙事视角</label><input id="f-pov" placeholder="男主第一人称 / 第三人称有限视角"></div><div class="field"><label>文风</label><input id="f-style" placeholder="现实、克制、快节奏、强钩子……"></div><div class="field full"><label>一句话创意</label><textarea id="f-premise" style="min-height:80px"></textarea></div></div><div class="actions"><button class="btn primary" id="save-project">保存作品信息</button></div></div><div class="panel"><h3>写作指令</h3><p class="muted">这里的指令会保存到 R2,方便 Surf 读取。保存后仍需在对话中告诉我“处理这个项目的待处理指令”。</p><div class="field"><label>本次想让 Surf 做什么</label><textarea id="request-text" placeholder="例如:根据当前作品圣经,生成第一章章纲和三个场景卡。"></textarea></div><div class="actions"><button class="btn green" id="save-request">保存指令到 R2</button></div><div id="request-status" class="status"></div></div></section>
@@ -57,8 +69,25 @@ async function compareVersions(){try{const a=$('compare-a').value,b=$('compare-b
57
  async function runCheck(){try{const d=await api('/projects/'+current.project_id+'/chapters/'+currentChapter.chapter_id+'/check',{method:'POST',body:'{}'});$('check-result').innerHTML=`<div class="check ${d.status}"><b>基础检查:${d.status}</b><ul>${(d.issues||[]).map(x=>`<li>${esc(x.message)}</li>`).join('')||'<li>没有发现基础问题</li>'}</ul><div class="muted">${esc(d.note||'')}</div></div>`}catch(e){$('check-result').textContent=e.message}}
58
  async function saveRequest(){try{const text=$('request-text').value.trim();if(!text)return;await api('/projects/'+current.project_id+'/requests',{method:'POST',body:JSON.stringify({instruction:text,type:'writing',chapter_id:currentChapter?.chapter_id||null})});$('request-text').value='';msg('request-status','指令已保存到 R2,请在当前对话告诉 Surf 读取此项目的待处理指令。');await loadRequests()}catch(e){msg('request-status',e.message,true)}}
59
  async function loadRequests(){if(!current)return;try{const d=await api('/projects/'+current.project_id+'/requests');$('requests-list').innerHTML=(d.requests||[]).map(r=>`<tr><td>${new Date(r.created_at).toLocaleString()}</td><td>${esc(r.type)}</td><td>${esc(r.chapter_id||'全书')}</td><td>${esc(r.instruction)}</td><td>${esc(r.status)}</td></tr>`).join('')||'<tr><td colspan="5" class="muted">暂无指令</td></tr>'}catch(e){}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  function setTab(name){document.querySelectorAll('.tab').forEach(x=>x.classList.toggle('active',x.dataset.tab===name));document.querySelectorAll('.tab-pane').forEach(x=>x.classList.toggle('active',x.id==='tab-'+name));if(name==='chapters')renderChapters();if(name==='requests')loadRequests()}
61
- $('unlock').onclick=async()=>{password=$('password').value.trim();if(!password)return msg('auth-status','请输入密码',true);try{await api('/projects');localStorage.setItem(PW_KEY,password);$('auth-box').classList.add('hidden');await loadProjects()}catch(e){msg('auth-status','密码或 R2 连接不正确:'+e.message,true)}};$('password').onkeydown=e=>{if(e.key==='Enter')$('unlock').click()};$('new-project').onclick=createProject;$('empty-new').onclick=createProject;$('save-project').onclick=saveProject;$('save-bible').onclick=saveBible;$('save-outline').onclick=saveOutline;$('material-search').onclick=searchMaterials;$('material-query').onkeydown=e=>{if(e.key==='Enter')searchMaterials()};$('save-materials').onclick=saveMaterials;$('new-chapter').onclick=createChapter;$('save-request').onclick=saveRequest;document.querySelectorAll('.tab').forEach(x=>x.onclick=()=>setTab(x.dataset.tab));if(password)$('unlock').click();
62
  })()
63
  </script>
64
  </body></html>
 
4
  <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
5
  <title>AI 小说创作工作台</title>
6
  <style>
7
+ :root{color-scheme:dark;--bg:#0f1117;--panel:#191c25;--panel2:#141720;--line:#2b3140;--text:#eef1f7;--muted:#9aa4b7;--accent:#ff6b4a;--blue:#87a7ff;--green:#5ed39a;--danger:#ff8585}*{box-sizing:border-box}body{margin:0;background:linear-gradient(140deg,#1e1724 0,#0f1117 35%);color:var(--text);font:14px/1.55 system-ui,-apple-system,"PingFang SC","Microsoft YaHei",sans-serif}button,input,textarea,select{font:inherit}button{cursor:pointer}.app{min-height:100vh}.top{height:64px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 22px;background:#13151dcc;backdrop-filter:blur(10px);position:sticky;top:0;z-index:5}.brand{display:flex;align-items:center;gap:12px}.brand-mark{width:34px;height:34px;border-radius:10px;background:var(--accent);display:grid;place-items:center;color:#23100a;font-weight:900}.brand h1{font-size:17px;margin:0}.brand p{font-size:11px;color:var(--muted);margin:1px 0 0}.top-actions{display:flex;gap:8px}.link{color:var(--muted);text-decoration:none;border:1px solid var(--line);padding:7px 10px;border-radius:8px}.link:hover{color:var(--text);border-color:var(--blue)}.global-nav{display:flex;gap:7px;align-items:center;flex-wrap:wrap;padding:10px 22px;background:#171a24;border-bottom:1px solid var(--line);position:sticky;top:64px;z-index:4}.global-nav button{color:#cbd3e5;text-decoration:none;border:1px solid #30384c;background:#202635;border-radius:8px;padding:6px 10px;font-size:12px;white-space:nowrap;cursor:pointer}.global-nav button:hover,.global-nav button.current{color:#fff;border-color:var(--accent);background:#30232c}.global-nav .section-label{color:var(--muted);font-size:12px;margin-right:3px}.layout{display:grid;grid-template-columns:280px minmax(0,1fr);min-height:calc(100vh - 64px)}aside{border-right:1px solid var(--line);padding:18px 14px;background:#11141bdd}.aside-title{display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:12px;margin-bottom:10px}.project-list{display:grid;gap:7px}.project-item{width:100%;text-align:left;border:1px solid transparent;background:transparent;color:var(--text);padding:10px;border-radius:9px}.project-item:hover,.project-item.active{background:#242938;border-color:#3b4660}.project-item b{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.project-item small{color:var(--muted);display:block;margin-top:2px}.main{padding:24px;max-width:1280px;width:100%;margin:0 auto}.empty{max-width:760px;margin:9vh auto;text-align:center}.empty h2{font-size:28px;margin:14px 0 8px}.empty p{color:var(--muted)}.panel{border:1px solid var(--line);background:rgba(25,28,37,.9);border-radius:14px;padding:18px;margin-bottom:16px}.project-head{display:flex;justify-content:space-between;gap:15px;align-items:flex-start;margin-bottom:18px}.project-head h2{margin:0 0 5px;font-size:24px}.project-head p{margin:0;color:var(--muted);max-width:800px}.status{font-size:12px;color:var(--muted);min-height:18px}.status.error{color:var(--danger)}.status.ok{color:var(--green)}.tabs{display:flex;gap:5px;flex-wrap:wrap;border-bottom:1px solid var(--line);margin-bottom:16px}.tab{background:transparent;border:0;border-bottom:2px solid transparent;color:var(--muted);padding:9px 12px}.tab:hover,.tab.active{color:var(--text);border-color:var(--accent)}.tab-pane{display:none}.tab-pane.active{display:block}.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.field{display:grid;gap:5px}.field.full{grid-column:1/-1}.field label{color:#cbd2df;font-size:12px;font-weight:650}.field input,.field textarea,.field select{width:100%;background:#10131a;color:var(--text);border:1px solid var(--line);border-radius:8px;padding:9px 10px;outline:none}.field input:focus,.field textarea:focus,.field select:focus{border-color:var(--blue)}textarea{min-height:100px;resize:vertical}.json{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;min-height:150px}.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-top:14px}.btn{border:1px solid var(--line);border-radius:8px;background:#242938;color:var(--text);padding:8px 12px}.btn:hover{border-color:var(--blue);background:#2b3347}.btn.primary{background:var(--accent);border-color:var(--accent);color:#220e08;font-weight:750}.btn.green{background:#1f5944;border-color:#347c61}.btn.danger{color:#ffadad}.muted{color:var(--muted);font-size:12px}.notice{border-left:3px solid var(--blue);background:#1a2130;padding:10px 12px;color:#c8d3ed;border-radius:6px;font-size:13px;margin-bottom:14px}.cards{display:grid;gap:9px}.card{border:1px solid var(--line);border-radius:10px;padding:11px;background:var(--panel2)}.card.selected{border-color:var(--accent);box-shadow:0 0 0 1px #ff6b4a55}.card h4{margin:0 0 4px}.card p{margin:4px 0;color:#cbd1dc;font-size:13px;white-space:pre-wrap;max-height:150px;overflow:auto}.card footer{color:var(--muted);font-size:11px}.chapter-layout{display:grid;grid-template-columns:260px minmax(0,1fr);gap:14px}.chapter-list{display:grid;gap:7px;align-content:start}.chapter-item{text-align:left;border:1px solid var(--line);background:#141720;color:var(--text);border-radius:8px;padding:9px}.chapter-item.active{border-color:var(--accent);background:#29202a}.chapter-item small{display:block;color:var(--muted)}.version-list{display:flex;gap:7px;flex-wrap:wrap;margin:8px 0}.version-chip{border:1px solid var(--line);background:#141720;color:#cdd4e5;border-radius:7px;padding:6px 8px;font-size:12px}.version-chip.active{border-color:var(--green);color:var(--green)}.check{border-radius:8px;padding:10px;margin-top:10px;background:#121820;border:1px solid var(--line)}.check.pass{border-color:#347c61}.check.warning{border-color:#9b7b36}.check.error{border-color:#8b4545}.check ul{margin:7px 0 0;padding-left:20px}.hidden{display:none!important}.pill{font-size:11px;border:1px solid var(--line);border-radius:999px;padding:2px 7px;color:var(--muted)}.table{width:100%;border-collapse:collapse}.table td,.table th{text-align:left;border-bottom:1px solid var(--line);padding:8px}.table th{font-size:12px;color:var(--muted)}.tools-frame{width:100%;height:calc(100vh - 190px);min-height:760px;border:1px solid var(--line);border-radius:12px;background:#10131a}.global-tools{display:none}.global-section{display:none}.global-section.active{display:block}.tool-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.tool-card{border:1px solid var(--line);border-radius:10px;padding:14px;background:var(--panel2)}.tool-card h3{margin:0 0 6px}.tool-card p{margin:4px 0;color:#cbd1dc;font-size:13px}.tool-list{margin:8px 0;padding-left:20px;color:#cbd1dc}.tool-chip{border:1px solid var(--line);border-radius:999px;background:#202635;color:#cbd3e5;padding:5px 9px;cursor:pointer}.tool-chip.active{border-color:var(--accent);color:#fff}.tool-output{white-space:pre-wrap;background:#10131a;border:1px solid var(--line);border-radius:8px;padding:12px;min-height:120px;max-height:520px;overflow:auto}.global-results{display:grid;gap:9px;margin-top:12px}@media(max-width:900px){.layout{grid-template-columns:1fr}aside{border-right:0;border-bottom:1px solid var(--line);padding:12px}.project-list{display:flex;overflow:auto}.project-item{min-width:210px}.main{padding:15px}.grid,.grid.three{grid-template-columns:1fr}.chapter-layout{grid-template-columns:1fr}.top{padding:0 12px}.top-actions .link:nth-child(2){display:none}}
8
  </style>
9
  </head>
10
  <body>
11
  <div class="app">
12
+ <header class="top"><div class="brand"><div class="brand-mark">AI</div><div><h1>AI 小说创作工作台</h1><p>项目、作品圣经、大纲、章节、版本与检查结果全部保存到 R2</p></div></div><div class="top-actions"><a class="link" href="/fanqie/batches">素材批次</a></div></header><nav class="global-nav" aria-label="全局写作工具"><span class="section-label">全局工具:</span><button class="global-nav-btn current" data-global="project">项目工作台</button><button class="global-nav-btn" data-global="home">🧭 起步路线</button><button class="global-nav-btn" data-global="flow">🗺️ 新手全流程</button><button class="global-nav-btn" data-global="ai">🤖 AI 写作实操</button><button class="global-nav-btn" data-global="redlines">⛔ 禁写红线库</button><button class="global-nav-btn" data-global="check">✅ 发布前自查</button><button class="global-nav-btn" data-global="structure">🧱 结构模板</button><button class="global-nav-btn" data-global="materials">🗂️ 素材库</button><button class="global-nav-btn" data-global="motifs">🧬 母题库</button><button class="global-nav-btn" data-global="auto">🪄 自动组稿</button><button class="global-nav-btn" data-global="weave">🧵 素材串联创作</button></nav>
13
  <div class="layout"><aside><div class="aside-title"><span>我的作品</span><button class="btn" id="new-project">+ 新建</button></div><div id="project-list" class="project-list"></div><div id="aside-status" class="status" style="margin-top:12px"></div></aside>
14
  <main class="main"><div id="auth-box" class="panel"><h2 style="margin:0 0 5px">连接工作台</h2><p class="muted">输入当前网页访问密码。密码只用于请求受保护接口,不会写入作品数据。</p><div class="row"><input id="password" type="password" placeholder="网页访问密码" style="flex:1;min-width:220px;background:#10131a;color:var(--text);border:1px solid var(--line);padding:9px;border-radius:8px"><button class="btn primary" id="unlock">连接</button></div><div id="auth-status" class="status"></div></div>
15
+ <div id="global-tools" class="global-tools">
16
+ <section id="global-home" class="global-section active"><div class="panel"><h2 style="margin-top:0">起步路线</h2><p class="muted">这里是所有项目共用的写作工具。项目工作台负责保存作品状态;下面的素材、母题、组稿和自查工具不绑定某一个项目。</p><div class="tool-grid"><div class="tool-card"><h3>① 定义作品</h3><p>先在项目工作台建立作品,填写题材、目标平台、字数、视角、文风和一句话创意。</p><button class="btn primary" data-global="project">进入项目工作台</button></div><div class="tool-card"><h3>② 找灵感</h3><p>搜索素材、查看母题、使用自动组稿,再把真正有用的 1-3 条素材加入当前项目。</p><button class="btn" data-global="materials">打开素材库</button></div><div class="tool-card"><h3>③ 写成正文</h3><p>由 Surf 读取项目圣经、章纲和参考素材,生成或修改章节,并直接保存到 R2。</p><button class="btn" data-global="auto">打开自动组稿</button></div></div></div><div class="panel"><h3>全局工具工作方式</h3><ul class="tool-list"><li>原有工具属于平台级能力,可以服务多个小说项目。</li><li>选中的参考素材只有在保存到某个项目后,才进入该项目上下文。</li><li>自动组稿可以先独立探索,也可以一键采用到当前项目。</li><li>正文、人物、大纲和版本始终以 project_id 为边界保存到 R2。</li></ul></div></section>
17
+ <section id="global-flow" class="global-section"><div class="panel"><h2 style="margin-top:0">新手全流程</h2><div class="tool-grid"><div class="tool-card"><h3>1. 选题</h3><p>明确题材、读者、平台、篇幅和一句话卖点。</p></div><div class="tool-card"><h3>2. 搭骨架</h3><p>确定核心冲突、主线、结局方向、人物目标和三幕结构。</p></div><div class="tool-card"><h3>3. 做圣经</h3><p>把人物、关系、时间线、伏笔和禁区保存为长期设定。</p></div><div class="tool-card"><h3>4. 拆章节</h3><p>按卷、故事线、章节和场景拆解,不直接让 AI 一次写完整本书。</p></div><div class="tool-card"><h3>5. 写正文</h3><p>先章纲,再场景卡,最后正文;每次写完都保存一个版本。</p></div><div class="tool-card"><h3>6. 查和改</h3><p>检查人物、时间线、伏笔和主线推进,再回滚或建立新版本。</p></div></div></div></section>
18
+ <section id="global-ai" class="global-section"><div class="panel"><h2 style="margin-top:0">AI 写作实操</h2><div class="notice">这里不再把结果交给其它 AI。你可以把需求保存到当前项目,随后在当前对话告诉 Surf;我会读取项目并直接写回 R2。</div><div class="grid"><div class="field"><label>当前创意或问题</label><textarea id="tool-ai-idea" placeholder="例如��男主参加爷爷葬礼,发现遗嘱里没有自己的名字。"></textarea></div><div class="field"><label>希望 Surf 执行的任务</label><textarea id="tool-ai-task" placeholder="生成核心冲突、人物卡、三幕结构,暂时不要写正文。"></textarea></div><div class="field full"><label>结构化写作指令预览</label><div id="tool-ai-output" class="tool-output">填写上面两项后点击生成。</div></div></div><div class="actions"><button class="btn primary" id="tool-ai-build">生成指令预览</button><button class="btn green" id="tool-ai-save">保存到当前项目</button><span id="tool-ai-status" class="status"></span></div></div></section>
19
+ <section id="global-redlines" class="global-section"><div class="panel"><h2 style="margin-top:0">禁写红线库</h2><p class="muted">素材和正文进入作品前都要进行匿名化、虚构化和安全改写。以下规则是全局规则,不属于单个项目。</p><div class="tool-grid"><div class="tool-card"><h3>真人与隐私</h3><p>不直接使用真实姓名、联系方式、单位、住址和可识别个人经历。</p></div><div class="tool-card"><h3>危险内容</h3><p>不复述详细自残、违法、诈骗、毒赌或伤害方法;只保留抽象冲突。</p></div><div class="tool-card"><h3>素材改编</h3><p>保留冲突和情绪,不复制原文句子,不把多个现实人物直接合并。</p></div></div></div></section>
20
+ <section id="global-check" class="global-section"><div class="panel"><h2 style="margin-top:0">发布前自查</h2><p class="muted">把一段正文粘贴到这里,先做本地规则扫描。具体人物、时间线和伏笔检查由 Surf 结合项目数据执行。</p><div class="field"><label>待检查正文</label><textarea id="global-check-text" style="min-height:280px" placeholder="粘贴章节正文……"></textarea></div><div class="actions"><button class="btn primary" id="global-check-run">开始检查</button></div><div id="global-check-result" class="check"></div></div></section>
21
+ <section id="global-structure" class="global-section"><div class="panel"><h2 style="margin-top:0">结构模板</h2><p class="muted">选择模板后可以应用到当前项目的总纲,不会覆盖已有正文。</p><div class="tool-grid"><div class="tool-card"><h3>现实情感三幕</h3><p>日常裂缝 → 秘密曝光 → 关系重建或彻底决裂。</p><button class="btn" data-template="realistic">应用到当前项目</button></div><div class="tool-card"><h3>悬疑揭密</h3><p>异常线索 → 多次误导 → 真相揭示与代价。</p><button class="btn" data-template="mystery">应用到当前项目</button></div><div class="tool-card"><h3>成长逆袭</h3><p>低谷受阻 → 主动选择 → 反击和新的代价。</p><button class="btn" data-template="growth">应用到当前项目</button></div></div><div id="structure-status" class="status"></div></div></section>
22
+ <section id="global-materials" class="global-section"><div class="panel"><h2 style="margin-top:0">素材库</h2><p class="muted">这是全局素材检索。搜索结果不会自动绑定项目,选中后点击“加入当前项目”才会保存到当前作品。</p><div class="row"><input id="global-material-query" placeholder="搜索爷爷、葬礼、遗嘱、失业、反转……" style="flex:1;background:#10131a;color:var(--text);border:1px solid var(--line);border-radius:8px;padding:10px"><button class="btn primary" id="global-material-search">搜索</button></div><div id="global-material-results" class="global-results"></div><div class="actions"><button class="btn green" id="global-material-add">加入当前项目(最多 3 条)</button><span id="global-material-status" class="status"></span></div></div></section>
23
+ <section id="global-motifs" class="global-section"><div class="panel"><h2 style="margin-top:0">母题库</h2><p class="muted">母题是全局检索和创作参考,不属于单个项目。点击母题查看母题卡,再决定是否加入当前作品。</p><div id="global-motif-list" class="row"></div><div id="global-motif-detail" class="panel hidden" style="margin-top:14px"></div></div></section>
24
+ <section id="global-auto" class="global-section"><div class="panel"><h2 style="margin-top:0">自动组稿</h2><p class="muted">输入一句创意,系统调用现有素材和母题库生成故事线参考。采用后可以把结果写入当前项目。</p><div class="grid"><div class="field"><label>一句创意</label><textarea id="global-auto-idea" placeholder="例如:男主回乡参加爷爷葬礼,却发现爷爷留下的遗嘱里没有自己的名字。"></textarea></div><div class="field"><label>题材</label><input id="global-auto-genre" value="都市情感 / 家庭悬疑"></div></div><div class="actions"><button class="btn primary" id="global-auto-run">生成组稿</button><button class="btn green" id="global-auto-adopt">采用到当前项目</button><span id="global-auto-status" class="status"></span></div><div id="global-auto-result" class="tool-output" style="margin-top:12px">还没有组稿结果。</div></div></section>
25
+ <section id="global-weave" class="global-section"><div class="panel"><h2 style="margin-top:0">素材串联创作</h2><p class="muted">当前项目选择的参考素材会显示在这里。素材篮和母题检索属于全局服务,但写入作品前必须明确选择目标项目。</p><div id="global-weave-materials" class="cards"></div><div class="field" style="margin-top:12px"><label>想让 Surf 如何串联这些素材</label><textarea id="global-weave-instruction" placeholder="例如:提取爷爷与男主的关系变化,生成三章故事线,不要直接复制原文。"></textarea></div><div class="actions"><button class="btn" id="global-weave-refresh">刷新当前项目素材</button><button class="btn green" id="global-weave-save">保存串联任务到当前项目</button><span id="global-weave-status" class="status"></span></div></div></section>
26
+ </div>
27
  <div id="empty" class="empty hidden"><div style="font-size:50px">📖</div><h2>先建立一部作品</h2><p>创建后,作品信息、人物、时间线、大纲、章节和版本都会保存到 R2。以后你可以直接在对话中让我继续写,我会按项目 ID 读取并修改这里的数据。</p><button class="btn primary" id="empty-new">新建小说项目</button></div>
28
  <div id="workspace" class="hidden"><div class="project-head"><div><h2 id="project-title">—</h2><p id="project-meta">—</p></div><div><span class="pill" id="project-id">—</span><div id="save-status" class="status"></div></div></div><nav class="tabs"><button class="tab active" data-tab="overview">作品信息</button><button class="tab" data-tab="bible">作品圣经</button><button class="tab" data-tab="outline">总纲与卷章</button><button class="tab" data-tab="materials">参考素材</button><button class="tab" data-tab="chapters">章节与版本</button><button class="tab" data-tab="requests">给 Surf 的指令</button></nav>
29
  <section id="tab-overview" class="tab-pane active"><div class="notice">你不需要把内容复制给其它 AI。以后在当前对话中告诉 Surf 作品 ID 和写作要求,我会读取本项目内容,生成或修改结果,并通过项目接口保存回 R2。</div><div class="panel"><h3>作品基本信息</h3><div class="grid"><div class="field"><label>作品名称</label><input id="f-title"></div><div class="field"><label>题材</label><input id="f-genre" placeholder="都市情感、悬疑、古言……"></div><div class="field"><label>目标平台</label><input id="f-platform" placeholder="番茄小说"></div><div class="field"><label>目标字数</label><input id="f-words" type="number" min="0" placeholder="150000"></div><div class="field"><label>叙事视角</label><input id="f-pov" placeholder="男主第一人称 / 第三人称有限视角"></div><div class="field"><label>文风</label><input id="f-style" placeholder="现实、克制、快节奏、强钩子……"></div><div class="field full"><label>一句话创意</label><textarea id="f-premise" style="min-height:80px"></textarea></div></div><div class="actions"><button class="btn primary" id="save-project">保存作品信息</button></div></div><div class="panel"><h3>写作指令</h3><p class="muted">这里的指令会保存到 R2,方便 Surf 读取。保存后仍需在对话中告诉我“处理这个项目的待处理指令”。</p><div class="field"><label>本次想让 Surf 做什么</label><textarea id="request-text" placeholder="例如:根据当前作品圣经,生成第一章章纲和三个场景卡。"></textarea></div><div class="actions"><button class="btn green" id="save-request">保存指令到 R2</button></div><div id="request-status" class="status"></div></div></section>
 
69
  async function runCheck(){try{const d=await api('/projects/'+current.project_id+'/chapters/'+currentChapter.chapter_id+'/check',{method:'POST',body:'{}'});$('check-result').innerHTML=`<div class="check ${d.status}"><b>基础检查:${d.status}</b><ul>${(d.issues||[]).map(x=>`<li>${esc(x.message)}</li>`).join('')||'<li>没有发现基础问题</li>'}</ul><div class="muted">${esc(d.note||'')}</div></div>`}catch(e){$('check-result').textContent=e.message}}
70
  async function saveRequest(){try{const text=$('request-text').value.trim();if(!text)return;await api('/projects/'+current.project_id+'/requests',{method:'POST',body:JSON.stringify({instruction:text,type:'writing',chapter_id:currentChapter?.chapter_id||null})});$('request-text').value='';msg('request-status','指令已保存到 R2,请在当前对话告诉 Surf 读取此项目的待处理指令。');await loadRequests()}catch(e){msg('request-status',e.message,true)}}
71
  async function loadRequests(){if(!current)return;try{const d=await api('/projects/'+current.project_id+'/requests');$('requests-list').innerHTML=(d.requests||[]).map(r=>`<tr><td>${new Date(r.created_at).toLocaleString()}</td><td>${esc(r.type)}</td><td>${esc(r.chapter_id||'全书')}</td><td>${esc(r.instruction)}</td><td>${esc(r.status)}</td></tr>`).join('')||'<tr><td colspan="5" class="muted">暂无指令</td></tr>'}catch(e){}}
72
+ let globalMaterialPick=[],globalMaterialItems=[],globalCompose=null,motifsLoaded=false
73
+ function showGlobal(name){document.querySelectorAll('.global-nav-btn').forEach(b=>b.classList.toggle('current',b.dataset.global===name));if(name==='project'){$('global-tools').style.display='none';if(current)showWorkspace(true);else showWorkspace(false);return}$('global-tools').style.display='block';$('empty').classList.add('hidden');$('workspace').classList.add('hidden');document.querySelectorAll('.global-section').forEach(s=>s.classList.toggle('active',s.id==='global-'+name));if(name==='motifs')loadGlobalMotifs();if(name==='weave')refreshGlobalWeave()}
74
+ function toolRequestText(){return `创意:${$('tool-ai-idea').value.trim()}\n任务:${$('tool-ai-task').value.trim()}\n\n要求:读取当前 project_id 的作品圣经、总纲和已选参考素材;只提取可迁移元素,不复制真人、真实地点和隐私;生成结构化结果并保存到 R2。`}
75
+ function buildToolPrompt(){const text=toolRequestText();$('tool-ai-output').textContent=text;return text}
76
+ async function saveToolRequest(){try{if(!current){msg('tool-ai-status','请先在项目工作台选择一个项目',true);return}const text=buildToolPrompt();if(!$('tool-ai-task').value.trim())throw Error('请先填写任务');await api('/projects/'+current.project_id+'/requests',{method:'POST',body:JSON.stringify({instruction:text,type:'global-tool',chapter_id:currentChapter?.chapter_id||null})});msg('tool-ai-status','已保存到当前项目 R2;现在可以在对话中让我处理这个项目')}catch(e){msg('tool-ai-status',e.message,true)}}
77
+ async function searchGlobalMaterials(){try{const q=$('global-material-query').value.trim();if(!q)return;const d=await api('/materials/search?q='+encodeURIComponent(q)+'&size=10');globalMaterialItems=d.items||[];renderGlobalMaterials()}catch(e){msg('global-material-status',e.message,true)}}
78
+ function renderGlobalMaterials(){$('global-material-results').innerHTML=globalMaterialItems.length?globalMaterialItems.map(x=>`<div class="card ${globalMaterialPick.some(y=>y.uid===x.uid)?'selected':''}"><div class="row"><input type="checkbox" data-gmid="${esc(x.uid)}" ${globalMaterialPick.some(y=>y.uid===x.uid)?'checked':''}><h4>${esc(x.sum||x.uid)}</h4></div><p>${esc(x.text||'')}</p><footer>${esc(x.uid)} · ${esc(x.g||'')} · ${esc(x.k||'')}</footer></div>`).join(''):'<div class="muted">请输入关键词搜索全局素材。</div>';document.querySelectorAll('[data-gmid]').forEach(c=>c.onchange=()=>{const x=globalMaterialItems.find(y=>y.uid===c.dataset.gmid);if(c.checked){if(globalMaterialPick.length>=3){c.checked=false;alert('每个项目最多选择 3 条参考素材');return}globalMaterialPick=[...globalMaterialPick,x]}else globalMaterialPick=globalMaterialPick.filter(y=>y.uid!==c.dataset.gmid);renderGlobalMaterials()})}
79
+ async function addGlobalMaterials(){try{if(!current){msg('global-material-status','请先选择当前项目',true);return}const merged=[...selectedMaterials];for(const item of globalMaterialPick)if(!merged.some(x=>x.uid===item.uid)&&merged.length<3)merged.push(item);selectedMaterials=merged;await saveMaterials();msg('global-material-status','已加入当前项目:'+merged.map(x=>x.uid).join('、'))}catch(e){msg('global-material-status',e.message,true)}}
80
+ async function loadGlobalMotifs(){if(motifsLoaded)return;try{const d=await api('/materials/motifs');const list=d.motifs||[];$('global-motif-list').innerHTML=list.map(m=>`<button class="tool-chip" data-motif="${esc(m.id)}">${esc(m.t)} <span class="muted">${m.n||0}</span></button>`).join('');document.querySelectorAll('[data-motif]').forEach(b=>b.onclick=()=>loadMotifDetail(b.dataset.motif));motifsLoaded=true}catch(e){$('global-motif-list').textContent=e.message}}
81
+ async function loadMotifDetail(id){try{const d=await api('/materials/motif?id='+encodeURIComponent(id));const c=d.card||{};$('global-motif-detail').classList.remove('hidden');$('global-motif-detail').innerHTML=`<h3>${esc(d.title||id)}</h3><p>${esc(c.summary||'暂无母题卡')}</p><p class="muted">骨架:${esc((c.skeleton||[]).join(' → '))}</p><p class="muted">常见人物:${esc((c.people||[]).map(x=>x.role).join('、'))}</p><p class="muted">开篇钩子:${esc((c.hooks||[]).slice(0,3).join(';'))}</p>`}catch(e){$('global-motif-detail').textContent=e.message}}
82
+ async function runGlobalAuto(){try{const idea=$('global-auto-idea').value.trim();if(!idea){msg('global-auto-status','请先输入一句创意',true);return}globalCompose=await api('/materials/compose?idea='+encodeURIComponent(idea));const d=globalCompose;const lines=['识别母题:'+(d.motifs||[]).map(x=>x.t).join('、'),'匹配素材:'+(d.pool?.matched||0)+' 条',''];for(const [role,item] of Object.entries(d.picks||{}))lines.push(`${role}:${item.sum||item.uid}\n${(item.text||'').slice(0,260)}`);$('global-auto-result').textContent=lines.join('\n');msg('global-auto-status','组稿完成')}catch(e){msg('global-auto-status',e.message,true)}}
83
+ async function adoptGlobalAuto(){try{if(!current){msg('global-auto-status','请先选择当前项目',true);return}if(!globalCompose){await runGlobalAuto();if(!globalCompose)return}const picks=Object.values(globalCompose.picks||{}).filter(x=>x.uid).slice(0,3);selectedMaterials=picks;await saveMaterials();const d=await api('/projects/'+current.project_id);const motifText=(globalCompose.motifs||[]).map(x=>x.t).join(' + ');await api('/projects/'+current.project_id,{method:'PATCH',body:JSON.stringify({premise:$('global-auto-idea').value.trim()})});await api('/projects/'+current.project_id+'/bible',{method:'PUT',body:JSON.stringify({...d.bible,story_core:motifText||d.bible.story_core,main_plot:(picks.map(x=>x.sum).join(';')||d.bible.main_plot)})});msg('global-auto-status','已采用到当前项目并保存到 R2')}catch(e){msg('global-auto-status',e.message,true)}}
84
+ const checkRules=[['真人/品牌/平台',/微信|微博|抖音|小红书|淘宝|支付宝|医院|学校|身份证|手机号/gi],['危险内容',/自杀|自残|诈骗|网赌|毒品|炸弹|杀人方法/gi],['AI 套话',/在这个世界上|命运的齿轮|嘴角勾起一抹|眼神中闪过一丝/gi]]
85
+ function runGlobalCheck(){const text=$('global-check-text').value;const issues=[];for(const [name,re] of checkRules){const hits=text.match(re);if(hits)issues.push(`${name}:${[...new Set(hits)].join('、')}`)}$('global-check-result').className='check '+(issues.length?'warning':'pass');$('global-check-result').innerHTML=issues.length?'<b>发现需要复核的内容</b><ul>'+issues.map(x=>`<li>${esc(x)}</li>`).join('')+'</ul><div class="muted">这里只做提示,不自动删除正文;请让 Surf 结合项目设定判断是否需要改写。</div>':'<b>基础扫描通过</b><div class="muted">未发现当前规则中的明显命中,仍建议进行人物、时间线和伏笔检查。</div>'}
86
+ async function applyTemplate(kind){try{if(!current){msg('structure-status','请先选择当前项目',true);return}const templates={realistic:{three_act:[{act:1,goal:'日常关系出现裂缝',turning_point:'秘密或事件被迫曝光'},{act:2,goal:'人物尝试修复但冲突升级',turning_point:'关键关系彻底改变'},{act:3,goal:'人物做出最终选择',ending:'关系重建或彻底决裂'}]},mystery:{three_act:[{act:1,goal:'发现异常线索',turning_point:'出现第一个嫌疑人'},{act:2,goal:'线索互相矛盾',turning_point:'主角发现自己也被隐瞒'},{act:3,goal:'真相揭示并付出代价',ending:'留下余波或新的问题'}]},growth:{three_act:[{act:1,goal:'主角处于低谷',turning_point:'被迫做出主动选择'},{act:2,goal:'能力和关系同时受到考验',turning_point:'第一次反击失败'},{act:3,goal:'主角承担代价完成反击',ending:'获得新生活但保留成长痕迹'}]}};const d=await api('/projects/'+current.project_id);await api('/projects/'+current.project_id+'/outline',{method:'PUT',body:JSON.stringify({...d.outline,three_act:templates[kind].three_act})});msg('structure-status','结构模板已写入当前项目 R2')}catch(e){msg('structure-status',e.message,true)}}
87
+ async function refreshGlobalWeave(){if(!current){$('global-weave-materials').innerHTML='<div class="muted">请先选择一个项目。</div>';return}try{const d=await api('/projects/'+current.project_id+'/materials');selectedMaterials=d.items||[];$('global-weave-materials').innerHTML=selectedMaterials.length?selectedMaterials.map(x=>`<div class="card selected"><h4>${esc(x.sum||x.uid)}</h4><p>${esc((x.text||'').slice(0,500))}</p><footer>${esc(x.uid)}</footer></div>`).join(''):'<div class="muted">当前项目还没有参考素材。</div>'}catch(e){msg('global-weave-status',e.message,true)}}
88
+ async function saveGlobalWeave(){try{if(!current){msg('global-weave-status','请先选择当前项目',true);return}const instruction=$('global-weave-instruction').value.trim();if(!instruction){msg('global-weave-status','请先填写串联要求',true);return}await api('/projects/'+current.project_id+'/requests',{method:'POST',body:JSON.stringify({instruction,type:'weave',chapter_id:currentChapter?.chapter_id||null})});msg('global-weave-status','串联任务已保存到 R2,请在对话中让我处理当前项目')}catch(e){msg('global-weave-status',e.message,true)}}
89
  function setTab(name){document.querySelectorAll('.tab').forEach(x=>x.classList.toggle('active',x.dataset.tab===name));document.querySelectorAll('.tab-pane').forEach(x=>x.classList.toggle('active',x.id==='tab-'+name));if(name==='chapters')renderChapters();if(name==='requests')loadRequests()}
90
+ $('unlock').onclick=async()=>{password=$('password').value.trim();if(!password)return msg('auth-status','请输入密码',true);try{await api('/projects');localStorage.setItem(PW_KEY,password);$('auth-box').classList.add('hidden');await loadProjects()}catch(e){msg('auth-status','密码或 R2 连接不正确:'+e.message,true)}};$('password').onkeydown=e=>{if(e.key==='Enter')$('unlock').click()};$('new-project').onclick=createProject;$('empty-new').onclick=createProject;$('save-project').onclick=saveProject;$('save-bible').onclick=saveBible;$('save-outline').onclick=saveOutline;$('material-search').onclick=searchMaterials;$('material-query').onkeydown=e=>{if(e.key==='Enter')searchMaterials()};$('save-materials').onclick=saveMaterials;$('new-chapter').onclick=createChapter;$('save-request').onclick=saveRequest;document.querySelectorAll('.tab').forEach(x=>x.onclick=()=>setTab(x.dataset.tab));document.querySelectorAll('[data-global]').forEach(x=>x.onclick=()=>showGlobal(x.dataset.global));$('tool-ai-build').onclick=buildToolPrompt;$('tool-ai-save').onclick=saveToolRequest;$('global-material-search').onclick=searchGlobalMaterials;$('global-material-query').onkeydown=e=>{if(e.key==='Enter')searchGlobalMaterials()};$('global-material-add').onclick=addGlobalMaterials;$('global-auto-run').onclick=runGlobalAuto;$('global-auto-adopt').onclick=adoptGlobalAuto;$('global-check-run').onclick=runGlobalCheck;$('global-weave-refresh').onclick=refreshGlobalWeave;$('global-weave-save').onclick=saveGlobalWeave;document.querySelectorAll('[data-template]').forEach(x=>x.onclick=()=>applyTemplate(x.dataset.template));if(password)$('unlock').click();
91
  })()
92
  </script>
93
  </body></html>