specpilot 2.14.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +19 -19
  2. package/dist/cli.js +3 -3
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/add-specs.d.ts +1 -2
  5. package/dist/commands/add-specs.d.ts.map +1 -1
  6. package/dist/commands/add-specs.js +1 -1
  7. package/dist/commands/add-specs.js.map +1 -1
  8. package/dist/commands/init.d.ts.map +1 -1
  9. package/dist/commands/init.js +27 -33
  10. package/dist/commands/init.js.map +1 -1
  11. package/dist/commands/serve.d.ts.map +1 -1
  12. package/dist/commands/serve.js +6 -4
  13. package/dist/commands/serve.js.map +1 -1
  14. package/dist/core/chatFlow.js +2 -2
  15. package/dist/core/chatFlow.js.map +1 -1
  16. package/dist/core/slashCommands.d.ts.map +1 -1
  17. package/dist/core/slashCommands.js +0 -1
  18. package/dist/core/slashCommands.js.map +1 -1
  19. package/dist/utils/mcpLocal.d.ts +10 -0
  20. package/dist/utils/mcpLocal.d.ts.map +1 -1
  21. package/dist/utils/mcpLocal.js +61 -2
  22. package/dist/utils/mcpLocal.js.map +1 -1
  23. package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
  24. package/dist/utils/slashCommandGenerator.js +6 -0
  25. package/dist/utils/slashCommandGenerator.js.map +1 -1
  26. package/dist/utils/specServer.d.ts +4 -4
  27. package/dist/utils/specServer.d.ts.map +1 -1
  28. package/dist/utils/specServer.js +187 -115
  29. package/dist/utils/specServer.js.map +1 -1
  30. package/dist/utils/specSetup.d.ts +21 -23
  31. package/dist/utils/specSetup.d.ts.map +1 -1
  32. package/dist/utils/specSetup.js +63 -56
  33. package/dist/utils/specSetup.js.map +1 -1
  34. package/dist/utils/specValidator.d.ts.map +1 -1
  35. package/dist/utils/specValidator.js +5 -2
  36. package/dist/utils/specValidator.js.map +1 -1
  37. package/package.json +1 -1
  38. package/ui/app.css +40 -110
  39. package/ui/app.js +113 -304
  40. package/ui/index.html +21 -27
  41. package/ui/route.js +3 -101
package/ui/app.js CHANGED
@@ -10,6 +10,8 @@ const toast=(m,action)=>{
10
10
  toastEl.classList.add('show');clearTimeout(toastT);toastT=setTimeout(()=>toastEl.classList.remove('show'),action?8000:2600);};
11
11
  /* Task moves (BL-053) are on only when the server put a token in the page (not with --read-only). */
12
12
  const TOKEN=(document.querySelector('meta[name="specpilot-token"]')||{}).content||null;
13
+ /* /mcp is on (BL-PM-007), and whose token it takes: `page` or `env` (SPECPILOT_MCP_TOKEN). */
14
+ const MCP=(document.querySelector('meta[name="specpilot-mcp"]')||{}).content||null;
13
15
  const MOVABLE={backlog:true,currentSprint:true};
14
16
  const chev='<svg class="ico chev" aria-hidden="true" focusable="false"><use href="#i-chev"/></svg>';
15
17
 
@@ -84,22 +86,19 @@ function syncNav(){
84
86
  }
85
87
  function go(v,keep,sub){
86
88
  if(v==='file'){if(!DATA||!sub)v='board';else curFile=sub;}
87
- else if(NOPROJ.includes(v)){if(!TOKEN)v='board';} // no Home and no new-project chat with --read-only
89
+ else if(NOPROJ.includes(v)){if(!TOKEN)v='board';} // no Home and no #new with --read-only
88
90
  else if(!VIEWS[v]||v==='setup')v='board';
89
91
  if(!NOPROJ.includes(v)&&DATA&&DATA.project.specs===false)v='setup'; // no .specs/ yet: every route of the project shows the setup view (BL-055)
90
92
  curView=v;
91
- $('#win').classList.toggle('home',v==='home');$('#win').classList.toggle('inchat',v==='new'||v==='setup'); // not `chat`: the chat's own rules are `.chat .x` and must not reach the rail
92
- $$('.content>.view').forEach(e=>e.classList.toggle('on',e.id==='v-'+(v==='new'||v==='setup'?'chat':v))); // one chat section for both flows (BL-PM-004)
93
+ $('#win').classList.toggle('home',v==='home');$('#win').classList.toggle('insetup',v==='new'||v==='setup');
94
+ $$('.content>.view').forEach(e=>e.classList.toggle('on',e.id==='v-'+(v==='new'?'setup':v))); // one Setup view for both (BL-103)
93
95
  syncNav();
94
- $('#title').textContent=v==='file'?(TITLES[sub]||sub):v==='setup'?projectLabel(DATA.projects[PROJECT]):v==='new'?'New project':VIEWS[v];
95
- $('#chatSub').hidden=!(v==='new'||v==='setup');if(v!=='new'&&v!=='setup'){$('#chatRestart').hidden=$('#chatClose').hidden=true;chat=null;}
96
- if(v!=='new'&&browseCtl&&browseBtn&&browseBtn.id==='chatBrowse')browseCtl.abort(); // leaving the chat closes its folder dialog (BL-097)
96
+ $('#title').textContent=v==='file'?(TITLES[sub]||sub):VIEWS[v];$('#crumb').hidden=true;
97
+ if(v!=='new'&&browseCtl&&browseBtn&&browseBtn.id==='suBrowse')browseCtl.abort(); // leaving #new closes its folder dialog (BL-097)
97
98
  $('#modeSeg').hidden=v!=='board';$('#newTask').hidden=!(TOKEN&&v==='board');$('#editorBtn').hidden=NOPROJ.includes(v);syncIde();
98
99
  setNav(false);closeInsp();
99
- if(v!=='file'||sub!==fileNoteFor)clearFileNote();
100
100
  if(v==='home')loadRecent();
101
- if(v==='setup')renderChat(false);
102
- if(v==='new')renderChat(true);
101
+ if(v==='setup'||v==='new')renderSetup();
103
102
  if(v==='file')renderFile(sub);
104
103
  if(v==='explorer')renderExplorer();
105
104
  if(v==='security')renderSecurity();
@@ -117,7 +116,7 @@ function setHash(v,sub){const h='#'+(PROJECT&&!NOPROJ.includes(v)?PROJECT+'/':''
117
116
  try{history.replaceState(null,'',h);}catch(e){urlOk=false;}}
118
117
  function route(){
119
118
  const r=resolveRoute(curHash(),DATA?DATA.files:{},DATA?DATA.projects.length:1,!!TOKEN);
120
- if(NOPROJ.includes(r.view)){go(r.view);return;} // Home and the new-project chat belong to no project: the shown one stays loaded behind them
119
+ if(NOPROJ.includes(r.view)){go(r.view);return;} // Home and #new belong to no project: the shown one stays loaded behind them
121
120
  if(r.project!==PROJECT){switchProject(r.project,true);return;}
122
121
  if(r.view==='board'&&r.sub==='board'){mode='board';$$('#modeSeg button').forEach(x=>x.classList.toggle('on',x.dataset.m==='board'));renderTasks();}
123
122
  go(r.view,true,r.sub);
@@ -383,7 +382,7 @@ document.addEventListener('keydown',e=>{
383
382
  const mod=e.metaKey||e.ctrlKey;const inField=/INPUT|SELECT|TEXTAREA/.test(e.target.tagName);
384
383
  if(mod&&e.key.toLowerCase()==='k'){e.preventDefault();palVeil.classList.contains('open')?closePal():openPal();return}
385
384
  if(mod&&/^[1-9]$/.test(e.key)){e.preventDefault();const n=NAV[+e.key-1];if(n)go(n[0],false,n[1]);return}
386
- if(e.key==='Escape'){if(!ideMenu.hidden){closeIde(true);return}hideTip();closeInsp();closePal();closeSheet();closeNewTask();if(chat&&chat.st.editing&&!chatBusy){chat.st.editing=null;comp=null;drawChat();}setNav(false);return}
385
+ if(e.key==='Escape'){if(!ideMenu.hidden){closeIde(true);return}hideTip();closeInsp();closePal();closeSheet();closeNewTask();setNav(false);return}
387
386
  if(inField||mod||e.altKey||taskVeil.classList.contains('open'))return;
388
387
  if(e.key==='h'&&TOKEN&&!openVeil.classList.contains('open')){go('home');return;}
389
388
  if(/^[1-9]$/.test(e.key)){const n=NAV[+e.key-1];if(n)go(n[0],false,n[1]);}
@@ -486,298 +485,106 @@ $('#taskCancel').onclick=closeNewTask;
486
485
  taskVeil.onclick=e=>{if(e.target===taskVeil)closeNewTask();};
487
486
  $('#taskForm').onsubmit=e=>{e.preventDefault();addTask();};
488
487
 
489
- /* ---------------- setup chat (BL-055, BL-PM-004) ----------------
490
- The init.specpilot.dev chat over the CLI's own questions: for a new project (#new) and for a named
491
- folder with no .specs/ yet (its setup view). The questions, their chat lines, choices, steps and file
492
- lists come from GET /api/setup or GET /api/projects/new; the page adds only the strings REQ-002.H.17
493
- and H.27 list, and its own parent-folder question. What can be decided without the DOM is in route.js. */
494
- let fileNoteFor=null;
495
- function clearFileNote(){const n=$('#fileNote');n.hidden=true;n.innerHTML='';fileNoteFor=null;}
496
- function setFileNote(path,lines){const n=$('#fileNote');n.innerHTML=lines.map(l=>`<p class="note" translate="no">${esc(l)}</p>`).join('');n.hidden=false;fileNoteFor=path;}
497
- /* Above onboarding.md after a setup or a create: what was kept, and the Codex notice. */
498
- function noteCreated(res){
499
- go('file',false,'development/onboarding.md');
500
- const lines=[];
501
- if(res.kept&&res.kept.length)lines.push('Kept as they were: '+res.kept.join(', ')+'. Run specpilot backfill there to add missing SpecPilot sections to the instruction and command files.');
502
- if(res.notice)lines.push(res.notice);
503
- if(lines.length)setFileNote('development/onboarding.md',lines);
504
- }
505
- async function getQuestions(url){
506
- try{const r=await fetch(url,{cache:'no-store'});if(r.ok)return await r.json();return r.status===404?null:{error:(await r.json().catch(()=>({}))).error||'HTTP '+r.status};}
507
- catch(e){return {error:'The server did not answer.'};}
508
- }
509
- /* The page's own question of a new project; every other one is the server's or the chat core's. */
510
- const PARENT_Q={key:'parent',message:'Parent folder',label:'Folder',required:true,chat:"Nice, {name}. Where should it live? I'll create {name}/ inside this folder.",placeholder:'~/dev'};
511
- const CC=window.SpecPilotChat; // the chat core (BL-PM-004b): src/core/chatFlow.ts, served as /assets/chat-core.js
512
- /* Answers live in the page only: saved setups were removed on purpose (BL-PM-016); a key an older page left is removed once. */
513
- try{localStorage.removeItem('sp-setups');}catch(e){}
514
- // `seed`: what the detector filled in for guided setup (REQ-002.H.35), a normal answer the user can change
515
- const freshSetup=(kind,root,id,seed={})=>({id:id||(kind==='setup'?'s:'+root:'n'+Date.now().toString(36)+Math.random().toString(36).slice(2,6)),kind,root,answers:{...JSON.parse(JSON.stringify(seed))},seed,editing:null,started:false,seeded:{},preview:{done:false,changed:false},finished:false});
516
- const live={}; // the setups open in this page, by id
517
- let curNew=null; // the new-project setup #new shows
518
- let chat=null,chatBusy=false,comp=null;
519
- /* Shown by go(): the chat for a new project, or for the project without .specs/. */
520
- async function renderChat(isNew){
521
- const pj=PROJECT,note=$('#chatNote');
522
- $('#intro').hidden=$('#thread').hidden=$('#composer').hidden=note.hidden=true;$('#chatRestart').hidden=$('#chatClose').hidden=true;$('#cbody').hidden=true;
523
- chat=null;comp=null;
524
- if(!TOKEN){note.textContent='Started with --read-only, so nothing can be set up here.';note.hidden=false;return;}
525
- const q=await getQuestions(isNew?'/api/projects/new':'/api/setup?project='+pj);
526
- if(PROJECT!==pj||curView!==(isNew?'new':'setup'))return;
527
- if(!q)return; // 404: not a folder named on the command line, so nothing to set up
528
- if(q.error){note.textContent=q.error;note.hidden=false;return;}
529
- let st;
530
- if(isNew){
531
- if(!curNew||!live[curNew]){st=freshSetup('new');curNew=st.id;live[st.id]=st;}
532
- st=live[curNew];
533
- }else{
534
- const root=DATA.projects[pj].root,id='s:'+root;
535
- st=live[id]||(live[id]=freshSetup('setup',root,id,seededAnswers(q.detected)));
536
- }
537
- chat={id:st.id,isNew,project:pj,q,st};
538
- $('#cbody').hidden=false;
539
- drawChat();
540
- }
541
- /* The questions to ask now: the server's (the CLI's) through flowQuestions(), placed and completed by the chat core. */
542
- function chatAsk(){
543
- const st=chat.st,first=chat.isNew?[{...PARENT_Q,step:chat.q.steps[0]}]:[];
544
- return CC.chatQuestions([...first,...chat.q.questions],flowQuestions(chat.q,st.answers,first),st.answers,chat.isNew?'new':'setup',chat.q.files.outside);
545
- }
546
- /* What fills {name} and {language} in the bot lines. */
547
- function chatCtx(){
548
- const a=chat.st.answers,lq=chat.q.questions.find(x=>x.key==='language'),c=lq&&lq.choices.find(x=>x.value===a.language);
549
- return {name:chat.isNew?a.name:projectLabel(DATA.projects[chat.project]),language:c?c.name:(chat.q.detected?chat.q.detected.language:'')};
550
- }
551
- /* What the detector filled in, for threadRows() and recapCards(): its rows, and the seeded answers not changed since. */
552
- const chatDet=()=>chat.isNew?null:{rows:chat.q.detected?chat.q.detected.rows||[]:[],keys:detectedKeys(chat.st.seed,chat.st.answers)};
553
- function drawChat(){
554
- const st=chat.st,isNew=chat.isNew,ctx=chatCtx();
555
- $('#chatRestart').hidden=!st.started;$('#chatClose').hidden=!isNew;
556
- $('#title').textContent=isNew?(st.answers.name||'New project'):projectLabel(DATA.projects[chat.project]);
557
- if(!st.started){ // the intro
558
- $('#intro').hidden=false;$('#thread').hidden=$('#composer').hidden=true;$('#chatSub').textContent='';$('#barI').style.width='0';$('#v-chat .bar').setAttribute('aria-valuenow','0');
559
- const mono=t=>`<span class="mono" translate="no">${esc(t)}</span>`;
560
- // guided setup opens with its paragraph as the heading and no fine print (BL-PM-016); the New Project intro is as before
561
- const setupLine=`There is no ${mono('.specs/')} folder in ${mono(DATA.projects[chat.project].root)} yet. I'll ask the same questions as ${mono('specpilot add-specs')}, one at a time, then write it and the files for your AI IDE. Existing files are never changed.`;
562
- $('#introH').innerHTML=isNew?"Hey, I'm SpecPilot 👋":setupLine;$('#introH').classList.toggle('para',!isNew);
563
- $('#introText').hidden=!isNew;$('#introText').innerHTML=isNew?'I turn your project requirements into a complete, structured spec suite - requirements, architecture, tests - and keep it in sync as you build.':'';
564
- $('#introFine').hidden=!isNew;
565
- $('#introText2').hidden=!isNew;$('#introText2').innerHTML=`I write your ${mono('.specs/')} folder, filled in from your answers, plus the files that keep your AI IDE following it.`;
566
- const det=$('#introDetected');det.hidden=!(chat.q.detected);det.textContent=chat.q.detected?chat.q.detected.line:'';
567
- $('#nameLbl').hidden=$('#nameIn').parentElement.hidden=!isNew;$('#setupStart').hidden=isNew;$('#nameErr').textContent='';
568
- if(isNew){$('#nameIn').value=st.answers.name||'';$('#nameGo').disabled=!$('#nameIn').value.trim();}
569
- setTimeout(()=>{if(chat&&!chat.st.started)(isNew?$('#nameIn'):$('#setupStart')).focus();},50);
570
- return;
571
- }
572
- $('#intro').hidden=true;$('#thread').hidden=$('#composer').hidden=false;
573
- const list=chatAsk(),cur=nextQuestion(list,st.answers,st.editing),steps=[...new Set(list.map(x=>x.step))],done=list.filter(x=>answered(x,st.answers)).length;
574
- st.finished=!cur;
575
- const bar=$('#v-chat .bar'),pct=Math.round(done/list.length*100);$('#barI').style.width=pct+'%';bar.setAttribute('aria-valuenow',pct);
576
- $('#chatSub').textContent=cur?`Step ${steps.indexOf(cur.step)+1} of ${steps.length} · ${cur.step}`:'Review';
577
- const det=chatDet(),detTag='<span class="det">detected</span>';
578
- let html=threadRows(chat.q,list,st.answers,cur,ctx,isNew,det).map(r=>
579
- r.kind==='divider'?`<div class="divider"><span>${esc(r.text)}</span></div>`
580
- :r.kind==='note'?`<p class="cnote">${esc(r.text)}</p>`
581
- :r.kind==='bot'?`<div class="bot"><svg class="logo" aria-hidden="true" focusable="false"><use href="#logo"/></svg><div class="msg">${esc(r.text)}${r.cli?`<span class="cli" translate="no">${esc(r.cli)}</span>`:''}${r.caption?`<span class="cap" translate="no">${esc(r.caption)}</span>`:''}</div></div>`
582
- :r.key===null?`<div class="me fixed"><span class="b">${esc(r.text)}</span>${detTag}</div>` // detected, not editable
583
- :`<div class="me${r.skipped?' skipped':''}"><button type="button" class="b${r.mono?' mono':''}" data-k="${esc(r.key)}" aria-label="Your answer: ${esc(r.text)}${r.detected?', detected':''}. Edit">${esc(r.text)}</button><span class="ed" aria-hidden="true">${r.detected?detTag+' ':''}✎ tap to edit</span></div>`).join('');
584
- if(!cur){
585
- const files=previewFiles(chat.q,st.answers),pv=st.preview,again=pv.done&&pv.changed;
586
- html+=`<div class="recap"><svg class="logo" aria-hidden="true" focusable="false"><use href="#logo"/></svg><div class="card">That's everything I need. Here's a quick recap:<div class="pen">✎ Click any answer to change it. You come straight back here.</div><div class="grid">${recapCards(list,st.answers,det).map(c=>`<div class="rc"><div class="t">${esc(c.title)}</div>${c.rows.map(r=>r.key===null?`<div class="l fixed"><span>${esc(r.label)} ${detTag}</span><span translate="no">${esc(r.value)}</span></div>`:`<button type="button" class="l" data-k="${esc(r.key)}"><span>${esc(r.label)}${r.detected?' '+detTag:''}</span><span translate="no">${esc(r.value)}</span></button>`).join('')}</div>`).join('')}</div>${again?'<p class="chg">Answers changed since the last preview. Preview again to see the new files.</p>':''}<details id="pv"><summary>${again?'Preview again':'Preview files'} (${files.length})</summary><ul translate="no" id="pvList">${files.map(f=>`<li>${esc(f.path)}${f.kept?' <span class="kept">Already here, will be kept</span>':''}</li>`).join('')}</ul></details><button type="button" class="btn pri" id="chatCreate">${isNew?'Create Project':'Create .specs/'}</button><p class="err" id="chatErr" role="alert"></p></div></div>`;
488
+ /* ---------------- Setup view (BL-103) ----------------
489
+ A project without .specs/ (Open, Clone, a folder named on the command line) and #new: the user's AI IDE
490
+ sets it up over /mcp, and this view says how. It sends no answers and writes no spec; the only request
491
+ is #new's pending path (POST /api/projects/pending). The Progress rows follow `event: setup`, which the
492
+ server's setup tools send (BL-104): state and counts only, kept in the page, so a reload starts them over. */
493
+ const mono=t=>`<span class="mono" translate="no">${esc(t)}</span>`;
494
+ const clonedFrom={}; // root → the URL this page cloned it from since it loaded: the Clone lead
495
+ const pend={name:'',parent:'',target:null,seq:0}; // #new's fields and its registered target
496
+ const ROWS=['read','questions','write','validate'];
497
+ const progress={}; // 'p<n>' or 'pending' → {row: {state, data}}
498
+ const progressKey=()=>curView==='new'?'pending':'p'+PROJECT;
499
+ function rowText(row,d){
500
+ if(row==='read')return `${d.detected} detected`;
501
+ if(row==='questions')return `${d.fromCode} from the code, ${d.fromUser} from you`+(d.fromUser&&d.topics&&d.topics.length?` (${d.topics.join(', ')})`:'');
502
+ if(row==='write')return `${d.files} files`;
503
+ return `${d.errors} errors, ${d.warnings} warnings`;
504
+ }
505
+ function drawProgress(){
506
+ const p=progress[progressKey()]||{};
507
+ $$('#suProgress li').forEach((li,i)=>{const r=p[ROWS[i]],st=r?r.state:'idle';
508
+ li.className=st==='running'?'run':st==='done'?'done':'wait';
509
+ let d=li.querySelector('.d');if(!d){d=document.createElement('span');d.className='d';li.appendChild(d);}
510
+ d.textContent=st==='done'?rowText(ROWS[i],r.data):'';});
511
+ }
512
+ /* An `event: setup` from the stream: the row of the folder it names; the last one of a new project opens it. */
513
+ function onSetupEvent(raw){
514
+ let d;try{d=JSON.parse(raw);}catch(_){return;}
515
+ if(!d||ROWS.indexOf(d.row)<0)return;
516
+ const key=d.pending?'pending':typeof d.project==='number'?'p'+d.project:null;if(!key)return;
517
+ (progress[key]=progress[key]||{})[d.row]={state:d.state,data:d};
518
+ if((curView==='setup'||curView==='new')&&key===progressKey())drawProgress();
519
+ if(d.pending&&typeof d.project==='number'&&d.row==='validate'&&d.state==='done'){
520
+ delete progress.pending;pend.target=null;pend.name=pend.parent='';
521
+ if(curView==='new')switchProject(d.project);
587
522
  }
588
- $('#msgs').innerHTML=html;
589
- const pvEl=$('#pv');if(pvEl)pvEl.addEventListener('toggle',()=>{if(pvEl.open)loadPreview();});
590
- drawComposer(cur);
591
- const th=$('#thread');th.scrollTop=th.scrollHeight;
592
523
  }
593
- /* The request body of a create or a preview: the CLI's answers, the optional fields and the folded context answers. */
594
- function chatBody(){
595
- const asked=chatAsk(),st=chat.st;
596
- const body={...flowBody(asked.filter(x=>!x.core),st.answers),...CC.requestFields(asked,st.answers,chat.isNew?'new':'setup')};
597
- if(chat.isNew)body.name=st.answers.name;
598
- return body;
599
- }
600
- /* The recap's preview: POST /api/preview with the create body, each file then shown as render() gives it. */
601
- async function loadPreview(){
602
- const c=chat,body=chatBody(),list=$('#pvList');if(!list)return;
603
- if(c.isNew)delete body.parent;
524
+ const MCP_ON=!!(TOKEN&&MCP);
525
+ function suStatus(){
526
+ const c=DATA&&DATA.mcp&&DATA.mcp.client,el=$('#suStatus');
527
+ el.textContent=!MCP_ON?'':c?(c.name?'Connected · '+c.name:'Connected'):'Waiting for a connection';
528
+ el.classList.toggle('ok',!!c);
529
+ }
530
+ function suPrompt(){
531
+ const isNew=curView==='new';
532
+ $('#suPrompt').textContent=isNew?`Start a SpecPilot project called ${pend.name} in ${pend.parent}`:'Set up SpecPilot for '+DATA.project.root;
533
+ $('#suPromptCopy').disabled=!MCP_ON||isNew&&!pend.target;
534
+ const c=$('#crumb');c.hidden=isNew&&!pend.target;c.textContent=(isNew?pend.target:DATA.project.root)+' · no specs yet';
535
+ }
536
+ function renderSetup(){
537
+ const isNew=curView==='new',p=DATA.project,v=$('#v-setup');
538
+ const named=isNew||p.named!==false; // the current-directory default keeps REQ-002.H.17's heading only
539
+ $('#title').textContent=!named?`No .specs/ folder in ${DATA.projects[PROJECT].root}`:isNew?'Start a new project with SpecPilot':'Set up SpecPilot for this project';
540
+ const off=!TOKEN||!named;
541
+ [...v.children].forEach(el=>{if(el.id!=='suNote')el.hidden=off;});
542
+ $('#suNote').hidden=TOKEN||!named;$('#suNote').textContent='Started with --read-only, so nothing can be set up here.';
543
+ if(off){$('#crumb').hidden=!named;if(named)$('#crumb').textContent=p.root+' · no specs yet';return;}
544
+ const name=String(p.root).split(/[/\\]/).filter(Boolean).pop()||p.root,url=clonedFrom[p.root];
545
+ const tail=' Your AI IDE sets them up: it reads the code, answers what it can, and asks you the rest.';
546
+ $('#suLead').innerHTML=isNew?'Name the project and choose where it goes. Your AI IDE creates it and writes the specs from your answers.'
547
+ :url?`Cloned ${mono(url)}. It has no SpecPilot specs yet.${tail}`:`${mono(name)} has no SpecPilot specs yet.${tail}`;
548
+ $('#suNew').hidden=!isNew;
549
+ if(isNew){$('#suName').value=pend.name;$('#suParent').value=pend.parent;}
550
+ $('#suOff').hidden=MCP_ON;
551
+ $$('#v-setup .step').forEach(el=>{el.classList.toggle('off',!MCP_ON);el.inert=!MCP_ON;});
552
+ $('#suConfigBox').hidden=!MCP_ON;
553
+ if(MCP_ON){const env=MCP==='env',line=mcpConfigLine(location.host,env?'${SPECPILOT_MCP_TOKEN}':TOKEN);
554
+ $('#suConfig').textContent=JSON.stringify(JSON.parse(line),null,2);$('#suConfig').dataset.line=line;$('#suMcpNote').textContent=$('#mcpNote').textContent;}
555
+ else $('#suMcpNote').textContent='';
556
+ $('#suFoot').innerHTML=`Prefer the terminal? ${mono(isNew?'specpilot init':'specpilot add-specs')} in that folder asks the same questions one by one.`;
557
+ suStatus();suPrompt();drawProgress();
558
+ }
559
+ function copyText(text){(navigator.clipboard?navigator.clipboard.writeText(text):Promise.reject()).then(()=>toast('Copied.'),()=>toast('Could not copy. Select the line and copy it.'));}
560
+ $('#suConfigCopy').onclick=()=>copyText($('#suConfig').dataset.line);
561
+ $('#suPromptCopy').onclick=()=>copyText($('#suPrompt').textContent);
562
+ /* #new: when the name passes init's rule and a parent is typed, register <parent>/<name> as the one pending path. */
563
+ async function registerPending(){
564
+ const seq=++pend.seq,body={parent:pend.parent.trim(),name:pend.name};
604
565
  let r,res={};
605
- try{r=await fetch(c.isNew?'/api/preview':'/api/preview?project='+c.project,{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN},body:JSON.stringify(body)});res=await r.json().catch(()=>({}));}
566
+ try{r=await fetch('/api/projects/pending',{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN},body:JSON.stringify(body)});res=await r.json().catch(()=>({}));}
606
567
  catch(e){r=null;}
607
- if(chat!==c||!$('#pvList'))return;
608
- if(!r||r.status!==200){$('#pvList').insertAdjacentHTML('beforebegin',`<p class="err">${esc(r?res.error||`The preview could not be made (HTTP ${r.status}).`:'The server did not answer.')}</p>`);return;}
609
- const kept=new Set(res.kept||[]);
610
- $('#pvList').outerHTML=`<div class="pvl" id="pvList" translate="no">${res.files.map(f=>`<details class="pf"><summary>${esc(f.path)}${kept.has(f.path)?' <span class="kept">Already here, will be kept</span>':''}</summary>${kept.has(f.path)?'':/\.md$/.test(f.path)?`<div class="md">${md(f.content)}</div>`:`<pre>${esc(f.content)}</pre>`}</details>`).join('')}</div>`;
611
- if(c.st.preview.changed||!c.st.preview.done)c.st.preview={done:true,changed:false};
612
- const chg=$('#msgs .chg');if(chg)chg.remove();const sum=$('#pv summary');if(sum)sum.textContent=`Preview files (${res.files.length})`;
613
- }
614
-
615
- /* ---- the composer: one state per shown question (`comp`), drawn from the question and redrawn on every change */
616
- const isMulti=t=>t==='multi'||t==='grouped-multi'||t==='platform-grid';
617
- function initComp(cur){
618
- const a=chat.st.answers,stored=cur.answered?a[cur.key]:undefined,seed=stored===undefined?cur.seed:stored;
619
- const c={key:cur.key,tab:null,custom:'',showCustom:false};
620
- if(cur.type==='categorized')c.v=JSON.parse(JSON.stringify(seed||{}));
621
- else if(isMulti(cur.type))c.v=Array.isArray(seed)?[...seed]:[];
622
- else if(cur.type==='text'||cur.type==='tabbed-chips')c.v=typeof stored==='string'&&stored!==cur.todo?stored:'';
623
- else{c.v=typeof seed==='string'?seed:'';const ids=compOptions(cur).map(o=>o.id);if(cur.custom&&c.v&&!ids.includes(c.v)){c.custom=c.v;c.showCustom=true;c.v='';}}
624
- const opts=compOptions(cur),sel=Array.isArray(c.v)?c.v:[c.v];
625
- const withSel=opts.find(o=>o.group&&sel.includes(o.id))||opts.find(o=>o.group&&o.badge==='recommended')||opts.find(o=>o.group);
626
- c.tab=cur.type==='categorized'?(cur.categories[0]&&cur.categories[0].id):withSel?withSel.group:null;
627
- if(cur.type==='platform-grid'){const tabs=CC.platformGridGroups(a.projectCategory||null,c.v);c.tab=tabs.find(t=>c.v.some(id=>CC.PLATFORM_GROUPS.find(g=>g.group===t).items.some(i=>i.id===id)))||tabs[0];}
628
- return c;
629
- }
630
- const compOptions=cur=>cur.core?(cur.options||[]):choiceOptions(cur);
631
- function drawComposer(cur){
632
- const st=chat.st,c=$('#comp'),editing=!!st.editing;
633
- if(!cur){comp=null;c.innerHTML=`<div class="act"><span class="hint">All answered. Review above, then ${chat.isNew?'Create Project':'Create .specs/'}.</span></div>`;return;}
634
- if(!comp||comp.key!==cur.key)comp=initComp(cur);
635
- const label=esc(cur.message||cur.chat||cur.label),k=comp,acts=(extra,ok)=>`<div class="act"><span class="hint">${editing?'Changing an earlier answer':''}</span><span class="err" id="compErr" role="alert"></span>${editing?'<button type="button" class="btn" id="chatCancel">Cancel</button>':''}${extra||''}<button type="submit" class="btn pri" id="chatGo"${ok?'':' disabled'}>${isMulti(cur.type)&&k.v.length?`Continue (${k.v.length+(k.custom.trim()?1:0)})`:'Continue'}</button></div>`;
636
- const skip=cur.required?'':'<button type="button" class="btn" id="chatSkip">Skip</button>';
637
- const other=cur.custom?`<button type="button" class="chip other" id="chatOther" aria-pressed="${k.showCustom}"><b>${cur.type==='grouped-multi'?'Add custom user type':'Other: ___'}</b></button>`:'';
638
- const customIn=k.showCustom?`<div class="crow"><input type="text" id="chatCustom" maxlength="100" placeholder="Type your own" aria-label="Your own answer" value="${esc(k.custom)}"></div>`:'';
639
- const note=cur.note?`<p class="cnote">${esc(cur.note)}</p>`:'';
640
- let h='';
641
- if(cur.type==='text'){
642
- const max=cur.key==='parent'?4096:cur.key==='handle'?39:cur.key==='nonGoals'?870:1000;
643
- h=`<div class="crow"><input type="text" id="chatIn" class="${cur.key==='parent'||cur.key==='handle'?'mono':''}" placeholder="${esc(cur.placeholder||'')}" aria-label="${label}" aria-describedby="compErr" maxlength="${max}"${cur.required?' aria-required="true"':''} value="${esc(k.v)}">${cur.key==='parent'?'<button type="button" class="btn" id="chatBrowse">Browse…</button>':''}</div>`
644
- +acts((cur.todo?'<button type="button" class="btn" id="chatTodo">Not sure - skip for now</button>':'')+skip,true);
645
- }else if(cur.type==='tabbed-chips'){
646
- const groups=[...new Set(cur.options.map(o=>o.group))],tab=k.tab||groups[0];
647
- h=`<p class="lbl">Pick a starter project type from below</p>${tabsHtml(groups.map(g=>({id:g,label:g})),tab)}<div class="chips" role="group" aria-label="${label}">${cur.options.filter(o=>o.group===tab).map(o=>optionHtml(o,k.v===o.id)).join('')}</div><p class="lbl">Or describe your project idea in plain words below</p><div class="crow"><input type="text" id="chatIn" placeholder="${esc(cur.placeholder||'')}" aria-label="${label}" aria-describedby="compErr" maxlength="1000" aria-required="true" value="${esc(k.v)}"></div>`+acts('',true);
648
- }else if(cur.type==='platform-grid'){
649
- const tabs=CC.platformGridGroups(st.answers.projectCategory||null,k.v),tab=tabs.includes(k.tab)?k.tab:tabs[0],g=CC.PLATFORM_GROUPS.find(x=>x.group===tab);
650
- const line=CC.bundleLine(k.v);
651
- h=tabsHtml(tabs.map(t=>{const grp=CC.PLATFORM_GROUPS.find(x=>x.group===t);return {id:t,label:`${grp.emoji} ${t}`,count:k.v.filter(id=>grp.items.some(i=>i.id===id)).length};}),tab)
652
- +`<div class="chips grid2" role="group" aria-label="${label}">${g?g.items.map(i=>optionHtml({id:i.id,label:i.label,emoji:i.emoji,description:`[${i.lang}]`},k.v.includes(i.id))).join(''):''}</div>${line?`<p class="cnote">${esc(line)}</p>`:''}`+acts('',k.v.length>0);
653
- }else if(cur.type==='categorized'){
654
- const cats=cur.categories,tab=cats.some(x=>x.id===k.tab)?k.tab:cats[0]&&cats[0].id,cat=cats.find(x=>x.id===tab);
655
- h=tabsHtml(cats.map(x=>({id:x.id,label:`${x.emoji} ${x.label}`,count:(k.v[x.id]||[]).length})),tab)
656
- +`<div class="chips" role="group" aria-label="${label}">${cat?cat.options.map(o=>optionHtml({id:o,label:o,emoji:o==='None'?'➖':''},(k.v[cat.id]||[]).includes(o))).join(''):''}</div>`+acts('<button type="button" class="btn" id="chatNone">None of these apply →</button>',true);
657
- }else{
658
- const opts=compOptions(cur),sel=isMulti(cur.type)?k.v:[k.v],extra=isMulti(cur.type)?k.v.filter(v=>!opts.some(o=>o.id===v)).map(v=>({id:v,label:v})):[];
659
- const grouped=cur.type!=='grouped-multi'&&opts.some(o=>o.group),groups=[...new Set(opts.filter(o=>o.group).map(o=>o.group))],tab=groups.includes(k.tab)?k.tab:groups[0];
660
- let body;
661
- if(cur.type==='grouped-multi')body=groups.map(g=>`<p class="lbl">${esc(g)}</p><div class="chips">${opts.filter(o=>o.group===g).map(o=>optionHtml(o,sel.includes(o.id))).join('')}</div>`).join('')
662
- +`<div class="chips">${[...opts.filter(o=>!o.group),...extra].map(o=>optionHtml(o,sel.includes(o.id))).join('')}${other}</div>`;
663
- else body=(grouped?tabsHtml(groups.map(g=>({id:g,label:g,count:opts.filter(o=>o.group===g&&sel.includes(o.id)).length})),tab):'')
664
- +`<div class="chips${cur.type==='cards'||opts.some(o=>o.description)?' grid2':''}" role="group" aria-label="${label}">${opts.filter(o=>!grouped||o.group===tab).map(o=>optionHtml(o,sel.includes(o.id))).join('')}</div>`
665
- +`<div class="chips">${(grouped?opts.filter(o=>!o.group):[]).concat(extra).map(o=>optionHtml(o,sel.includes(o.id))).join('')}${other}</div>`;
666
- const any=isMulti(cur.type)?k.v.length>0||!!k.custom.trim():!!k.v||!!(k.showCustom&&k.custom.trim());
667
- h=note+body+customIn+acts(isMulti(cur.type)?'':skip,any||isMulti(cur.type)&&!cur.required);
668
- }
669
- c.innerHTML=h;
670
- }
671
- /* An answer: stored, stale seeds replaced, the preview marked out of date, the setup saved, and the chat moves on. */
672
- function chatAnswer(cur,value){
673
- const st=chat.st;
674
- Object.assign(st.answers,cur.core?CC.answerPatch(cur.key,value,st.answers):{[cur.key]:value});
675
- if(cur.seed!==undefined&&JSON.stringify(value)===JSON.stringify(cur.seed))st.seeded[cur.key]=value;else delete st.seeded[cur.key];
676
- const r=CC.reseed(chatAsk(),st.answers,st.seeded);st.answers=r.answers;st.seeded=r.seeded;
677
- if(st.preview.done)st.preview.changed=true;
678
- st.editing=null;comp=null;drawChat();
679
- }
680
- function chatEdit(key){
681
- if(chatBusy)return;
682
- comp=null;
683
- if(key==='name'){chat.st.started=false;drawChat();return;}
684
- chat.st.editing=key;drawChat();
685
- }
686
- /* The same POST the forms sent: /api/setup for a folder without .specs/, /api/projects/new for a new project. */
687
- async function chatCreate(){
688
- if(chatBusy)return;
689
- const c=chat,root=DATA.projects[c.project].root,btn=$('#chatCreate'),err=$('#chatErr');
690
- chatBusy=true;btn.disabled=true;err.textContent='';
691
- const body=chatBody();
692
- let r,res={};
693
- try{
694
- r=await fetch(c.isNew?'/api/projects/new':'/api/setup?project='+c.project,{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN},body:JSON.stringify(body)});
695
- res=await r.json().catch(()=>({}));
696
- }catch(e){r=null;}
697
- chatBusy=false;
698
- if(chat!==c)return; // the view changed meanwhile
699
- btn.disabled=false;
700
- if(!r){err.textContent=c.isNew?'The server did not answer.':'The server did not answer. Nothing was set up.';return;}
701
- const done=()=>{delete live[c.st.id];if(curNew===c.st.id)curNew=null;};
702
- if(c.isNew){
703
- const o=openOutcome(r.status,res,true);
704
- if(o.project===null){err.textContent=r.status===413?'The answers are too long to send. Shorten the longest ones and try again.':o.toast;return;}
705
- if(r.status===200)done();
706
- await showOutcome(o);
707
- if(r.status===200)noteCreated(res);
708
- return;
709
- }
710
- if(r.status!==200&&!(r.status===409&&res.specs)){err.textContent=res.error||`Nothing was set up (HTTP ${r.status}).`;return;}
711
- done();
712
- if(PROJECT!==c.project)return;
713
- await apply(res.specs,null);
714
- if(r.status!==200){toast(res.error||`Nothing was set up (HTTP ${r.status}).`);return;}
715
- toast('.specs/ created in '+root);
716
- noteCreated(res);
717
- $('#content').focus();
718
- }
719
- $('#introForm').onsubmit=e=>{
720
- e.preventDefault();if(!chat)return;
721
- if(chat.isNew){
722
- const v=$('#nameIn').value.trim(),problem=answerError({key:'name',required:true},v);
723
- if(problem){$('#nameErr').textContent=problem;$('#nameIn').focus();return;}
724
- chat.st.answers.name=v;
725
- }
726
- chat.st.started=true;chat.st.editing=null;drawChat();
727
- };
728
- $('#nameIn').addEventListener('input',()=>{$('#nameGo').disabled=!$('#nameIn').value.trim();$('#nameErr').textContent='';});
729
- $('#setupStart').onclick=()=>$('#introForm').requestSubmit();
730
- const curQuestion=()=>chat&&nextQuestion(chatAsk(),chat.st.answers,chat.st.editing);
731
- $('#comp').onsubmit=e=>{
732
- e.preventDefault();if(!chat||chatBusy||!comp)return;
733
- const cur=curQuestion();if(!cur||cur.key!==comp.key)return;
734
- const fail=m=>{$('#compErr').textContent=m;const i=$('#chatIn');if(i){i.setAttribute('aria-invalid','true');i.focus();}};
735
- if(cur.type==='text'||cur.type==='tabbed-chips'){
736
- const v=$('#chatIn').value,problem=answerError(cur,v);
737
- if(problem)return fail(problem);
738
- return chatAnswer(cur,v.trim());
739
- }
740
- const custom=comp.custom.trim();
741
- if(cur.type==='categorized')return chatAnswer(cur,comp.v);
742
- if(isMulti(cur.type)){
743
- const v=custom&&!comp.v.includes(custom)?[...comp.v,custom]:comp.v;
744
- if(cur.required&&!v.length)return;
745
- return chatAnswer(cur,v);
746
- }
747
- const v=comp.showCustom&&custom?custom:comp.v;
748
- if(v)chatAnswer(cur,v);
749
- };
750
- $('#comp').addEventListener('click',e=>{
751
- if(!chat||!comp)return;
752
- const cur=curQuestion();if(!cur)return;
753
- const t=e.target.closest('button');if(!t)return;
754
- const redraw=sel=>{drawComposer(cur);const el=sel&&$(`#comp ${sel}`);if(el)el.focus();};
755
- if(t.dataset.tab!==undefined){comp.tab=t.dataset.tab;return redraw(`.tab[data-tab="${CSS.escape(t.dataset.tab)}"]`);}
756
- if(t.id==='chatOther'){comp.showCustom=!comp.showCustom;if(!isMulti(cur.type)&&comp.showCustom)comp.v='';return redraw(comp.showCustom?'#chatCustom':'#chatOther');}
757
- if(t.id==='chatSkip'){if(!cur.required)chatAnswer(cur,isMulti(cur.type)?[]:'');return;}
758
- if(t.id==='chatTodo'){chatAnswer(cur,cur.todo);return;}
759
- if(t.id==='chatBrowse'){const k=comp;browseFolder(t,()=>comp===k?$('#chatIn'):null,p=>{k.v=p;});return;}
760
- if(t.id==='chatNone'){chatAnswer(cur,CC.noneOfThese(comp.v,CC.visibleCategories(chat.st.answers.projectCategory||null,CC.hasMobilePlatform(chat.st.answers.platforms||[]))));return;}
761
- if(t.id==='chatCancel'){const k=chat.st.editing;chat.st.editing=null;comp=null;drawChat();const b=$(`#msgs [data-k="${k}"]`);if(b)b.focus();return;}
762
- const v=t.dataset.v;if(v===undefined)return;
763
- if(cur.type==='tabbed-chips'){comp.v=v;$('#chatIn').value=v;}
764
- else if(cur.type==='platform-grid')comp.v=CC.togglePlatform(comp.v,v);
765
- else if(cur.type==='categorized')comp.v=CC.toggleIntegration(comp.v,comp.tab||cur.categories[0].id,v);
766
- else if(isMulti(cur.type))comp.v=comp.v.includes(v)?comp.v.filter(x=>x!==v):[...comp.v,v];
767
- else{comp.v=v;comp.showCustom=false;}
768
- redraw(`.chip[data-v="${CSS.escape(v)}"]`);
769
- });
770
- $('#comp').addEventListener('input',e=>{
771
- if(!comp)return;
772
- if(e.target.id==='chatIn'){$('#compErr').textContent='';e.target.removeAttribute('aria-invalid');comp.v=e.target.value;}
773
- if(e.target.id==='chatCustom'){comp.custom=e.target.value;const go=$('#chatGo');if(go&&comp.custom.trim())go.disabled=false;}
774
- });
775
- $('#msgs').addEventListener('click',e=>{
776
- if(e.target.id==='chatCreate'){chatCreate();return;}
777
- const b=e.target.closest('[data-k]');if(b)chatEdit(b.dataset.k);
778
- });
779
- $('#chatRestart').onclick=()=>{if(!chat||chatBusy)return;chat.st=live[chat.st.id]=freshSetup(chat.st.kind,chat.st.root,chat.st.id,chat.st.seed);comp=null;drawChat();};
780
- $('#chatClose').onclick=()=>{if(!chatBusy)go('home');};
568
+ if(seq!==pend.seq)return; // the fields changed meanwhile
569
+ pend.target=r&&r.status===200?res.target:null;
570
+ delete progress.pending; // a new target starts its rows over
571
+ $('#suErr').textContent=!r?'The server did not answer.':r.status===200?'':res.error||`The folder was not accepted (HTTP ${r.status}).`;
572
+ if(curView==='new')suPrompt();
573
+ }
574
+ /* While typing: the line follows the fields and Copy waits; on `change` (or a Browse… pick) the path is registered (BL-104). */
575
+ function fieldsTyped(){
576
+ pend.name=$('#suName').value.trim();pend.parent=$('#suParent').value;pend.target=null;pend.seq++;
577
+ const e=pend.name?projectNameError(pend.name):null;
578
+ $('#suErr').textContent=e?e.message+'.':'';
579
+ suPrompt();
580
+ return !e&&pend.name&&pend.parent.trim();
581
+ }
582
+ function fieldsChanged(){if(fieldsTyped())registerPending();}
583
+ $('#suName').addEventListener('input',fieldsTyped);
584
+ $('#suParent').addEventListener('input',fieldsTyped);
585
+ $('#suName').addEventListener('change',fieldsChanged);
586
+ $('#suParent').addEventListener('change',fieldsChanged);
587
+ $('#suBrowse').onclick=()=>browseFolder($('#suBrowse'),()=>curView==='new'?$('#suParent'):null,()=>fieldsChanged());
781
588
 
782
589
  /* ---------------- live reload (BL-052) ----------------
783
590
  On a change event: re-fetch, redraw in place. Route, scroll, open inspector, selected row
@@ -843,6 +650,8 @@ function listen(){
843
650
  if(es)es.close(); // one stream, for the shown project
844
651
  es=new EventSource('/api/events?'+pq());let dropped=false;
845
652
  es.addEventListener('clone',e=>onCloneEvent(e.data));
653
+ es.addEventListener('setup',e=>onSetupEvent(e.data));
654
+ es.addEventListener('mcp',e=>{let d=null;try{d=JSON.parse(e.data);}catch(_){}if(d&&DATA){DATA.mcp=d;if(curView==='setup'||curView==='new')suStatus();}});
846
655
  es.addEventListener('change',e=>{let paths=null;try{paths=JSON.parse(e.data).paths;}catch(_){}refresh(Array.isArray(paths)?paths:null);});
847
656
  es.onerror=()=>{dropped=true;}; // EventSource retries by itself
848
657
  es.onopen=()=>{if(dropped){dropped=false;refresh(null);}}; // catch up on anything missed
@@ -870,7 +679,7 @@ $('#projList').addEventListener('click',e=>{const b=e.target.closest('[data-proj
870
679
  /* ---------------- open a project (BL-067) ----------------
871
680
  The + tile opens the mockup's sheet on its Folder tab. The list is GET /api/projects; opening is
872
681
  POST /api/projects, which serves one more folder and remembers it; Remove from list edits the
873
- registry only. A new project (BL-PM-003) starts in the setup chat above since BL-PM-004. The Clone tab
682
+ registry only. A new project starts in the Setup view above (BL-103). The Clone tab
874
683
  (BL-PM-002) POSTs /api/projects/clone, which runs git clone and opens the folder; closing the sheet
875
684
  meanwhile aborts the request, and the server then removes what was downloaded. Nothing here is
876
685
  file content; the strings are the ones REQ-002.H.21, H.24 and H.26 list. */
@@ -878,9 +687,8 @@ const openVeil=$('#openVeil'),addBtn=$('#addBtn'),pathIn=$('#pathIn');
878
687
  const TABS=['folder','clone'],GO={folder:'Open',clone:'Clone Repository'};
879
688
  let openBusy=false,sheetFrom=$('#homeOpen'),sheetTab='folder',cloneCtl=null,browseCtl=null,browseBtn=null,cloneNamed=false,cloneTick=null,cloneT0=0,cloneProg=null;
880
689
  if(TOKEN){addBtn.hidden=false;homeBtn.hidden=false;$('#cmdRegen').hidden=false;$('#rail>.logo').remove();} // the Home tile takes the logo's place (BL-PM-001)
881
- /* Connect Your AI IDE (BL-PM-007): the config line for this server's /mcp, only with --mcp. No status:
690
+ /* Connect Your AI IDE (BL-PM-007): the config line for this server's /mcp, unless --no-mcp (BL-105). No status here:
882
691
  the page cannot know whether an IDE uses it. `env`: the token is SPECPILOT_MCP_TOKEN, so the line names it. */
883
- const MCP=(document.querySelector('meta[name="specpilot-mcp"]')||{}).content||null;
884
692
  if(TOKEN&&MCP){
885
693
  const env=MCP==='env';
886
694
  $('#mcpLine').textContent=mcpConfigLine(location.host,env?'${SPECPILOT_MCP_TOKEN}':TOKEN);
@@ -978,6 +786,7 @@ async function cloneRepo(){
978
786
  }catch(e){setCloning(null);if(!ctl.signal.aborted)toast('The server did not answer.');return;}
979
787
  setCloning(null);
980
788
  if(ctl.signal.aborted)return; // the sheet was closed: the server removes the clone
789
+ if(r.status===200)clonedFrom[res.specs.project.root]=body.url; // the Setup view's Clone lead (BL-103)
981
790
  await showOutcome(openOutcome(r.status,res,'cloned'));
982
791
  }
983
792
  /* Browse… (BL-PM-011, BL-097): the server opens the system's folder dialog; the folder picked fills the
@@ -987,7 +796,7 @@ function setBrowsing(ctl,btn){
987
796
  const b=browseBtn;b.disabled=!!ctl||(b.id==='cloneBrowseBtn'&&!!cloneCtl); // a running clone keeps its sheet's button off
988
797
  if(ctl)b.setAttribute('aria-busy','true');else b.removeAttribute('aria-busy');
989
798
  }
990
- /* `field()` is looked up after the answer: the chat may have redrawn its text box meanwhile. `pick` also sees the path. */
799
+ /* `field()` is looked up after the answer: the view may have changed meanwhile. `pick` also sees the path. */
991
800
  async function browseFolder(btn,field,pick){
992
801
  if(browseCtl)return;
993
802
  const ctl=new AbortController();setBrowsing(ctl,btn);
@@ -998,7 +807,7 @@ async function browseFolder(btn,field,pick){
998
807
  res=await r.json().catch(()=>({}));
999
808
  }catch(e){setBrowsing(null);if(!ctl.signal.aborted){toast('The server did not answer.');back();}return;}
1000
809
  setBrowsing(null);
1001
- if(ctl.signal.aborted)return; // the sheet was closed or the chat left: the server closes the dialog
810
+ if(ctl.signal.aborted)return; // the sheet was closed or #new left: the server closes the dialog
1002
811
  if(r.status!==200){toast(res.error||`Nothing was chosen (HTTP ${r.status}).`);back();return;}
1003
812
  const f=res.path&&field();
1004
813
  if(f){f.value=res.path;if(pick)pick(res.path);f.focus();}else back();