specpilot 2.12.0 → 2.14.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 (77) hide show
  1. package/README.md +48 -9
  2. package/dist/cli.js +2 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/backfill.d.ts.map +1 -1
  5. package/dist/commands/backfill.js +24 -13
  6. package/dist/commands/backfill.js.map +1 -1
  7. package/dist/commands/serve.d.ts +8 -1
  8. package/dist/commands/serve.d.ts.map +1 -1
  9. package/dist/commands/serve.js +89 -3
  10. package/dist/commands/serve.js.map +1 -1
  11. package/dist/core/agentConfig.d.ts +10 -0
  12. package/dist/core/agentConfig.d.ts.map +1 -1
  13. package/dist/core/agentConfig.js +47 -3
  14. package/dist/core/agentConfig.js.map +1 -1
  15. package/dist/core/ideConfig.d.ts.map +1 -1
  16. package/dist/core/ideConfig.js +2 -1
  17. package/dist/core/ideConfig.js.map +1 -1
  18. package/dist/core/slashCommands.d.ts.map +1 -1
  19. package/dist/core/slashCommands.js +25 -16
  20. package/dist/core/slashCommands.js.map +1 -1
  21. package/dist/core/specFiles.js +3 -0
  22. package/dist/core/specFiles.js.map +1 -1
  23. package/dist/core/templateEngine.d.ts +5 -0
  24. package/dist/core/templateEngine.d.ts.map +1 -1
  25. package/dist/core/templateEngine.js +13 -1
  26. package/dist/core/templateEngine.js.map +1 -1
  27. package/dist/utils/addSpecsQuestions.d.ts.map +1 -1
  28. package/dist/utils/addSpecsQuestions.js +2 -0
  29. package/dist/utils/addSpecsQuestions.js.map +1 -1
  30. package/dist/utils/folderPicker.d.ts +28 -0
  31. package/dist/utils/folderPicker.d.ts.map +1 -0
  32. package/dist/utils/folderPicker.js +96 -0
  33. package/dist/utils/folderPicker.js.map +1 -0
  34. package/dist/utils/gitClone.d.ts +4 -1
  35. package/dist/utils/gitClone.d.ts.map +1 -1
  36. package/dist/utils/gitClone.js +35 -4
  37. package/dist/utils/gitClone.js.map +1 -1
  38. package/dist/utils/mcpLocal.d.ts +46 -0
  39. package/dist/utils/mcpLocal.d.ts.map +1 -0
  40. package/dist/utils/mcpLocal.js +220 -0
  41. package/dist/utils/mcpLocal.js.map +1 -0
  42. package/dist/utils/projectDetector.d.ts +15 -0
  43. package/dist/utils/projectDetector.d.ts.map +1 -1
  44. package/dist/utils/projectDetector.js +105 -4
  45. package/dist/utils/projectDetector.js.map +1 -1
  46. package/dist/utils/slashCommandGenerator.d.ts +21 -0
  47. package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
  48. package/dist/utils/slashCommandGenerator.js +166 -0
  49. package/dist/utils/slashCommandGenerator.js.map +1 -1
  50. package/dist/utils/specArchiver.d.ts.map +1 -1
  51. package/dist/utils/specArchiver.js +2 -1
  52. package/dist/utils/specArchiver.js.map +1 -1
  53. package/dist/utils/specBackfiller.d.ts +9 -3
  54. package/dist/utils/specBackfiller.d.ts.map +1 -1
  55. package/dist/utils/specBackfiller.js +52 -48
  56. package/dist/utils/specBackfiller.js.map +1 -1
  57. package/dist/utils/specPaths.d.ts +3 -2
  58. package/dist/utils/specPaths.d.ts.map +1 -1
  59. package/dist/utils/specPaths.js +6 -4
  60. package/dist/utils/specPaths.js.map +1 -1
  61. package/dist/utils/specServer.d.ts +15 -3
  62. package/dist/utils/specServer.d.ts.map +1 -1
  63. package/dist/utils/specServer.js +220 -20
  64. package/dist/utils/specServer.js.map +1 -1
  65. package/dist/utils/specSetup.d.ts +11 -0
  66. package/dist/utils/specSetup.d.ts.map +1 -1
  67. package/dist/utils/specSetup.js +14 -1
  68. package/dist/utils/specSetup.js.map +1 -1
  69. package/package.json +5 -2
  70. package/ui/app.css +23 -17
  71. package/ui/app.js +159 -69
  72. package/ui/index.html +10 -8
  73. package/ui/route.js +56 -31
  74. package/dist/__tests__/fixtures/allFields.d.ts +0 -3
  75. package/dist/__tests__/fixtures/allFields.d.ts.map +0 -1
  76. package/dist/__tests__/fixtures/allFields.js +0 -31
  77. package/dist/__tests__/fixtures/allFields.js.map +0 -1
package/ui/app.js CHANGED
@@ -18,6 +18,20 @@ let theme=null;try{theme=localStorage.getItem('sp-theme');}catch(e){}
18
18
  function setMeta(light){const m=document.querySelector('meta[name=theme-color]');if(m)m.content=light?'#f8fafc':'#0f172a';}
19
19
  if(theme==='light'){document.documentElement.setAttribute('data-theme','light');setMeta(true);}
20
20
  $('#themeBtn').onclick=()=>{const light=document.documentElement.getAttribute('data-theme')==='light';if(light)document.documentElement.removeAttribute('data-theme');else document.documentElement.setAttribute('data-theme','light');setMeta(!light);try{light?localStorage.removeItem('sp-theme'):localStorage.setItem('sp-theme','light');}catch(e){}toast('Appearance: '+(light?'dark':'light'));};
21
+ /* Quit (BL-098): the route `specpilot serve --stop` uses; the server then stops as on Ctrl+C. This page
22
+ closes its stream and says so; other open pages see a dropped stream, as before. */
23
+ let stopped=false;
24
+ if(TOKEN)$('#quitBtn').hidden=false;
25
+ $('#quitBtn').onclick=async()=>{
26
+ if(!confirm('Quit SpecPilot? Open pages stop updating.'))return;
27
+ let r;
28
+ try{r=await fetch('/api/quit',{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN},body:'{}'});}
29
+ catch(e){return toast('The server did not answer.');}
30
+ if(r.status!==202){const t=await r.text().catch(()=>'');let m=t;try{m=JSON.parse(t).error||t;}catch(e){}return toast(m.trim()||'The server did not stop.');}
31
+ stopped=true;if(es){es.close();es=null;}
32
+ const p=document.createElement('p');p.className='stopped';p.setAttribute('role','status');p.textContent='SpecPilot has stopped. Run specpilot serve to start it again.';
33
+ document.querySelector('main.pane').replaceChildren(p);
34
+ };
21
35
 
22
36
  /* ---------------- data: fetched, never embedded ---------------- */
23
37
  let DATA=null;
@@ -47,7 +61,7 @@ function renderProject(){
47
61
  return `<button class="tile blue${cur?' cur':''}" data-project="${i}" data-tip="${esc(n)}" data-path="${esc(q.root+(q.branch?' · '+q.branch:''))}" aria-label="${esc(n)}"${cur?' aria-current="true"':''}><span aria-hidden="true">${esc(initials(n))}</span></button>`;}).join('');
48
62
  $('#curGrp').textContent=name;$('#curGrp').title=p.root;
49
63
  $('#curBranch').textContent=p.branch||'';
50
- $('#subName').textContent=name;$('#subPath').textContent=where;$('#editorBtn').href=editorUrl(p.root);
64
+ $('#subName').textContent=name;$('#subPath').textContent=where;$('#editorBtn').href=editorUrl(p.root);syncIde();
51
65
  $('#footAddr').textContent=$('#homeAddr').textContent=location.host;$('#footVer').textContent=$('#homeVer').textContent='v'+p.specpilotVersion;
52
66
  document.title=name+' · SpecPilot Local';
53
67
  }
@@ -78,8 +92,9 @@ function go(v,keep,sub){
78
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)
79
93
  syncNav();
80
94
  $('#title').textContent=v==='file'?(TITLES[sub]||sub):v==='setup'?projectLabel(DATA.projects[PROJECT]):v==='new'?'New project':VIEWS[v];
81
- $('#chatSub').hidden=!(v==='new'||v==='setup');if(v!=='new'&&v!=='setup'){$('#chatRestart').hidden=$('#chatClose').hidden=$('#chatSetups').hidden=true;chat=null;}
82
- $('#modeSeg').hidden=v!=='board';$('#newTask').hidden=!(TOKEN&&v==='board');$('#editorBtn').hidden=NOPROJ.includes(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)
97
+ $('#modeSeg').hidden=v!=='board';$('#newTask').hidden=!(TOKEN&&v==='board');$('#editorBtn').hidden=NOPROJ.includes(v);syncIde();
83
98
  setNav(false);closeInsp();
84
99
  if(v!=='file'||sub!==fileNoteFor)clearFileNote();
85
100
  if(v==='home')loadRecent();
@@ -221,7 +236,9 @@ async function renderFile(path){
221
236
  if(src===null){$('#fmBox').innerHTML='';$('#fileBody').innerHTML=gone('.specs/'+path);return;}
222
237
  const isYaml=/\.ya?ml$/.test(path);
223
238
  const {fm,body}=isYaml?{fm:'',body:src}:splitFm(src);
224
- $('#fmBox').innerHTML=fm?`<div class="gh">Front matter <span class="cnt" translate="no">.specs/${esc(path)}</span></div><div class="box"><pre class="raw" translate="no">${esc(fm)}</pre></div>`:'';
239
+ const ed=`<a class="more" href="${esc(editorUrl(DATA.project.root+'/.specs/'+path))}">Open in VS Code</a>`; // BL-PM-013
240
+ $('#fmBox').innerHTML=fm?`<div class="gh">Front matter <span class="cnt" translate="no">.specs/${esc(path)}</span>${ed}</div><div class="box"><pre class="raw" translate="no">${esc(fm)}</pre></div>`
241
+ :`<div class="gh"><span class="cnt" translate="no">.specs/${esc(path)}</span>${ed}</div>`;
225
242
  $('#fileBody').innerHTML=isYaml?`<pre translate="no">${esc(src)}</pre>`:md(body);
226
243
  }
227
244
  const gone=goneHtml; // one definition of the "no longer exists" markup: ui/route.js
@@ -297,11 +314,56 @@ async function openFile(path,quiet){
297
314
  const head=`<div class="ih"><span class="id" translate="no">${esc(path)}</span><button type="button" class="ib x" id="inspX" aria-label="Close Details"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-x"/></svg></button></div>`;
298
315
  if(src===null){insp.innerHTML=head+`<div class="ib2">${gone(path)}</div>`;openInsp(quiet);return;}
299
316
  const {fm,body}=splitFm(src);
300
- insp.innerHTML=head+`<div class="ib2">${fm?`<div class="gl"><div class="gh">Front matter</div><div class="box"><pre class="raw" translate="no">${esc(fm)}</pre></div></div>`:''}<div class="md doc">${md(body)}</div></div>`;
317
+ insp.innerHTML=head+`<div class="ib2">${fm?`<div class="gl"><div class="gh">Front matter</div><div class="box"><pre class="raw" translate="no">${esc(fm)}</pre></div></div>`:''}<div class="md doc">${md(body)}</div><div class="actions"><a class="btn sm" href="${esc(editorUrl(DATA.project.root+'/'+path))}">Open in VS Code</a></div></div>`;
301
318
  openInsp(quiet);
302
319
  }
303
320
  document.addEventListener('click',e=>{const b=e.target.closest&&e.target.closest('[data-open]');if(b)openFile(b.dataset.open);});
304
321
 
322
+ /* Open in AI IDE (BL-PM-010): Cursor by its URL schemes when the project has SpecPilot's Cursor rules
323
+ file (`project.cursor`), and the onboarding prompt while development/onboarding.md exists. */
324
+ const ONB='development/onboarding.md',ideBtn=$('#ideBtn'),ideMenu=$('#ideMenu');
325
+ const hasOnb=()=>!!DATA&&ONB in DATA.files;
326
+ /* On every view switch and redraw: an open menu would hold another view's or project's items. */
327
+ function syncIde(){
328
+ closeIde(false);
329
+ $('#ideWrap').hidden=!DATA||NOPROJ.includes(curView)||!(DATA.project.cursor||hasOnb());
330
+ }
331
+ function closeIde(refocus){
332
+ if(ideMenu.hidden)return;
333
+ ideMenu.hidden=true;ideBtn.setAttribute('aria-expanded','false');
334
+ if(refocus)ideBtn.focus();
335
+ }
336
+ function copyPrompt(text,note){
337
+ const claude=DATA.nav.instructions.some(f=>f.path==='CLAUDE.md'&&f.exists);
338
+ (navigator.clipboard?navigator.clipboard.writeText(text):Promise.reject())
339
+ .then(()=>toast(note||(claude?`Copied. Paste it into Claude Code started in ${DATA.project.root}, or into your IDE’s chat.`:'Copied. Paste it into your IDE’s chat.')),
340
+ ()=>toast('Could not copy. Open development/onboarding.md and copy it.'));
341
+ }
342
+ async function openIde(){
343
+ const pj=PROJECT,cur=DATA.project.cursor;let prompt=null;
344
+ if(hasOnb())try{prompt=onboardingPrompt(await getText('.specs/'+ONB));}catch(e){toast(e.message);}
345
+ if(PROJECT!==pj||$('#ideWrap').hidden||!ideMenu.hidden)return; // switched away, or a second click opened it meanwhile
346
+ const item=(tag,attrs,label)=>`<${tag} role="menuitem" ${attrs}>${esc(label)}</${tag}>`;
347
+ const link=prompt!==null&&cur?cursorPromptUrl(prompt):null;
348
+ ideMenu.innerHTML=[
349
+ cur?item('a',`href="${esc(editorUrl(DATA.project.root,0,'cursor'))}"`,'Open in Cursor'):'',
350
+ prompt!==null&&cur?(link?item('a',`href="${esc(link)}"`,'Send onboarding prompt to Cursor'):item('button','type="button" data-copy="long"','Send onboarding prompt to Cursor')):'',
351
+ prompt!==null?item('button','type="button" data-copy="all"','Copy onboarding prompt'):'',
352
+ ].join('');
353
+ if(!ideMenu.children.length)return;
354
+ $$('[role=menuitem]',ideMenu).forEach(m=>m.onclick=()=>{
355
+ if(m.dataset.copy)copyPrompt(prompt,m.dataset.copy==='long'?'The prompt is too long for a Cursor link. Copied; paste it into Cursor’s chat.':'');
356
+ closeIde(false);
357
+ });
358
+ ideMenu.hidden=false;ideBtn.setAttribute('aria-expanded','true');ideMenu.firstElementChild.focus();
359
+ }
360
+ ideBtn.onclick=()=>ideMenu.hidden?openIde():closeIde(true);
361
+ ideMenu.addEventListener('keydown',e=>{
362
+ const it=$$('[role=menuitem]',ideMenu),i=it.indexOf(document.activeElement);
363
+ if(e.key==='ArrowDown'||e.key==='ArrowUp'){e.preventDefault();it[(i+(e.key==='ArrowDown'?1:it.length-1))%it.length].focus();}
364
+ });
365
+ document.addEventListener('click',e=>{if(!ideMenu.hidden&&!e.target.closest('#ideWrap'))closeIde(false);});
366
+
305
367
  /* ---------------- palette + keys ---------------- */
306
368
  const palVeil=$('#palVeil'),palIn=$('#palIn'),palList=$('#palList');
307
369
  function items(q){q=q.toLowerCase();
@@ -321,7 +383,7 @@ document.addEventListener('keydown',e=>{
321
383
  const mod=e.metaKey||e.ctrlKey;const inField=/INPUT|SELECT|TEXTAREA/.test(e.target.tagName);
322
384
  if(mod&&e.key.toLowerCase()==='k'){e.preventDefault();palVeil.classList.contains('open')?closePal():openPal();return}
323
385
  if(mod&&/^[1-9]$/.test(e.key)){e.preventDefault();const n=NAV[+e.key-1];if(n)go(n[0],false,n[1]);return}
324
- if(e.key==='Escape'){hideTip();closeInsp();closePal();closeSheet();closeNewTask();if(chat&&chat.st.editing&&!chatBusy){chat.st.editing=null;comp=null;drawChat();}setNav(false);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}
325
387
  if(inField||mod||e.altKey||taskVeil.classList.contains('open'))return;
326
388
  if(e.key==='h'&&TOKEN&&!openVeil.classList.contains('open')){go('home');return;}
327
389
  if(/^[1-9]$/.test(e.key)){const n=NAV[+e.key-1];if(n)go(n[0],false,n[1]);}
@@ -447,21 +509,17 @@ async function getQuestions(url){
447
509
  /* The page's own question of a new project; every other one is the server's or the chat core's. */
448
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'};
449
511
  const CC=window.SpecPilotChat; // the chat core (BL-PM-004b): src/core/chatFlow.ts, served as /assets/chat-core.js
450
- /* Saved setups (BL-PM-004b): every setup the chat has started, kept in this browser under sp-setups. */
451
- let storeOk=true,setups=[];
452
- try{setups=setupsLoad(localStorage.getItem(SETUPS_KEY));}catch(e){storeOk=false;}
453
- function storeSetups(){try{localStorage.setItem(SETUPS_KEY,JSON.stringify(setups));}catch(e){storeOk=false;}}
454
- function saveSetup(st){if(!st.started)return;st.updatedAt=Date.now();setups=setupsPut(setups,setupRecord(st));storeSetups();}
455
- function dropSetup(id){setups=setupsRemove(setups,id);storeSetups();}
456
- const freshSetup=(kind,root,id)=>({id:id||(kind==='setup'?'s:'+root:'n'+Date.now().toString(36)+Math.random().toString(36).slice(2,6)),kind,root,answers:{},editing:null,started:false,seeded:{},preview:{done:false,changed:false},finished:false});
457
- const restoreSetup=e=>({...JSON.parse(JSON.stringify(e)),editing:null});
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});
458
516
  const live={}; // the setups open in this page, by id
459
517
  let curNew=null; // the new-project setup #new shows
460
518
  let chat=null,chatBusy=false,comp=null;
461
519
  /* Shown by go(): the chat for a new project, or for the project without .specs/. */
462
520
  async function renderChat(isNew){
463
521
  const pj=PROJECT,note=$('#chatNote');
464
- $('#intro').hidden=$('#thread').hidden=$('#composer').hidden=note.hidden=true;$('#chatRestart').hidden=$('#chatClose').hidden=$('#chatSetups').hidden=true;$('#cbody').hidden=true;
522
+ $('#intro').hidden=$('#thread').hidden=$('#composer').hidden=note.hidden=true;$('#chatRestart').hidden=$('#chatClose').hidden=true;$('#cbody').hidden=true;
465
523
  chat=null;comp=null;
466
524
  if(!TOKEN){note.textContent='Started with --read-only, so nothing can be set up here.';note.hidden=false;return;}
467
525
  const q=await getQuestions(isNew?'/api/projects/new':'/api/setup?project='+pj);
@@ -470,11 +528,11 @@ async function renderChat(isNew){
470
528
  if(q.error){note.textContent=q.error;note.hidden=false;return;}
471
529
  let st;
472
530
  if(isNew){
473
- if(!curNew||!live[curNew]){const rec=curNew&&setups.find(e=>e.id===curNew);st=rec?restoreSetup(rec):freshSetup('new');curNew=st.id;live[st.id]=st;}
531
+ if(!curNew||!live[curNew]){st=freshSetup('new');curNew=st.id;live[st.id]=st;}
474
532
  st=live[curNew];
475
533
  }else{
476
- const root=DATA.projects[pj].root,id='s:'+root,rec=setups.find(e=>e.id===id);
477
- st=live[id]||(live[id]=rec?restoreSetup(rec):freshSetup('setup',root));
534
+ const root=DATA.projects[pj].root,id='s:'+root;
535
+ st=live[id]||(live[id]=freshSetup('setup',root,id,seededAnswers(q.detected)));
478
536
  }
479
537
  chat={id:st.id,isNew,project:pj,q,st};
480
538
  $('#cbody').hidden=false;
@@ -490,27 +548,20 @@ function chatCtx(){
490
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);
491
549
  return {name:chat.isNew?a.name:projectLabel(DATA.projects[chat.project]),language:c?c.name:(chat.q.detected?chat.q.detected.language:'')};
492
550
  }
493
- /* The list of saved setups beside the thread. */
494
- function drawSetups(){
495
- const el=$('#setupList');
496
- if(!storeOk){el.innerHTML='<p class="note">Setups cannot be saved in this browser.</p>';return;}
497
- const served=root=>DATA.projects.findIndex(p=>p.root===root);
498
- el.innerHTML=setups.length?setups.map(e=>{
499
- const off=e.kind==='setup'&&served(e.root)<0,t=setupTitle(e);
500
- return `<div class="srow2${chat&&chat.st.id===e.id?' cur':''}"><button type="button" class="go" data-setup="${esc(e.id)}"${off?' disabled':''}><span class="t" translate="no">${esc(t)}</span><span class="d">${esc(off?`Open ${e.root} to resume`:`${setupStatus(e)} · ${when(new Date(e.updatedAt).toISOString())}`)}</span></button><button type="button" class="rm" data-rm-setup="${esc(e.id)}" aria-label="Remove ${esc(t)}">Remove</button></div>`;
501
- }).join(''):'<p class="note">No saved setups yet.</p>';
502
- }
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)};
503
553
  function drawChat(){
504
554
  const st=chat.st,isNew=chat.isNew,ctx=chatCtx();
505
- $('#chatRestart').hidden=!st.started;$('#chatClose').hidden=!isNew;$('#chatSetups').hidden=false;
555
+ $('#chatRestart').hidden=!st.started;$('#chatClose').hidden=!isNew;
506
556
  $('#title').textContent=isNew?(st.answers.name||'New project'):projectLabel(DATA.projects[chat.project]);
507
- drawSetups();
508
557
  if(!st.started){ // the intro
509
558
  $('#intro').hidden=false;$('#thread').hidden=$('#composer').hidden=true;$('#chatSub').textContent='';$('#barI').style.width='0';$('#v-chat .bar').setAttribute('aria-valuenow','0');
510
559
  const mono=t=>`<span class="mono" translate="no">${esc(t)}</span>`;
511
- $('#introH').textContent=isNew?"Hey, I'm SpecPilot 👋":"Hey, I'm SpecPilot";
512
- $('#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.'
513
- :`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.`;
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;
514
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.`;
515
566
  const det=$('#introDetected');det.hidden=!(chat.q.detected);det.textContent=chat.q.detected?chat.q.detected.line:'';
516
567
  $('#nameLbl').hidden=$('#nameIn').parentElement.hidden=!isNew;$('#setupStart').hidden=isNew;$('#nameErr').textContent='';
@@ -520,17 +571,19 @@ function drawChat(){
520
571
  }
521
572
  $('#intro').hidden=true;$('#thread').hidden=$('#composer').hidden=false;
522
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;
523
- if(st.finished!==!cur){st.finished=!cur;saveSetup(st);drawSetups();}
574
+ st.finished=!cur;
524
575
  const bar=$('#v-chat .bar'),pct=Math.round(done/list.length*100);$('#barI').style.width=pct+'%';bar.setAttribute('aria-valuenow',pct);
525
576
  $('#chatSub').textContent=cur?`Step ${steps.indexOf(cur.step)+1} of ${steps.length} · ${cur.step}`:'Review';
526
- let html=threadRows(chat.q,list,st.answers,cur,ctx,isNew).map(r=>
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=>
527
579
  r.kind==='divider'?`<div class="divider"><span>${esc(r.text)}</span></div>`
528
580
  :r.kind==='note'?`<p class="cnote">${esc(r.text)}</p>`
529
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>`
530
- :`<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)}. Edit">${esc(r.text)}</button><span class="ed" aria-hidden="true">✎ tap to edit</span></div>`).join('');
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('');
531
584
  if(!cur){
532
585
  const files=previewFiles(chat.q,st.answers),pv=st.preview,again=pv.done&&pv.changed;
533
- 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).map(c=>`<div class="rc"><div class="t">${esc(c.title)}</div>${c.rows.map(r=>`<button type="button" class="l" data-k="${esc(r.key)}"><span>${esc(r.label)}</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>`;
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>`;
534
587
  }
535
588
  $('#msgs').innerHTML=html;
536
589
  const pvEl=$('#pv');if(pvEl)pvEl.addEventListener('toggle',()=>{if(pvEl.open)loadPreview();});
@@ -555,7 +608,7 @@ async function loadPreview(){
555
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;}
556
609
  const kept=new Set(res.kept||[]);
557
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>`;
558
- if(c.st.preview.changed||!c.st.preview.done){c.st.preview={done:true,changed:false};saveSetup(c.st);}
611
+ if(c.st.preview.changed||!c.st.preview.done)c.st.preview={done:true,changed:false};
559
612
  const chg=$('#msgs .chg');if(chg)chg.remove();const sum=$('#pv summary');if(sum)sum.textContent=`Preview files (${res.files.length})`;
560
613
  }
561
614
 
@@ -587,7 +640,7 @@ function drawComposer(cur){
587
640
  let h='';
588
641
  if(cur.type==='text'){
589
642
  const max=cur.key==='parent'?4096:cur.key==='handle'?39:cur.key==='nonGoals'?870:1000;
590
- 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)}"></div>`
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>`
591
644
  +acts((cur.todo?'<button type="button" class="btn" id="chatTodo">Not sure - skip for now</button>':'')+skip,true);
592
645
  }else if(cur.type==='tabbed-chips'){
593
646
  const groups=[...new Set(cur.options.map(o=>o.group))],tab=k.tab||groups[0];
@@ -622,7 +675,7 @@ function chatAnswer(cur,value){
622
675
  if(cur.seed!==undefined&&JSON.stringify(value)===JSON.stringify(cur.seed))st.seeded[cur.key]=value;else delete st.seeded[cur.key];
623
676
  const r=CC.reseed(chatAsk(),st.answers,st.seeded);st.answers=r.answers;st.seeded=r.seeded;
624
677
  if(st.preview.done)st.preview.changed=true;
625
- st.editing=null;comp=null;saveSetup(st);drawChat();
678
+ st.editing=null;comp=null;drawChat();
626
679
  }
627
680
  function chatEdit(key){
628
681
  if(chatBusy)return;
@@ -645,7 +698,7 @@ async function chatCreate(){
645
698
  if(chat!==c)return; // the view changed meanwhile
646
699
  btn.disabled=false;
647
700
  if(!r){err.textContent=c.isNew?'The server did not answer.':'The server did not answer. Nothing was set up.';return;}
648
- const done=()=>{dropSetup(c.st.id);delete live[c.st.id];if(curNew===c.st.id)curNew=null;};
701
+ const done=()=>{delete live[c.st.id];if(curNew===c.st.id)curNew=null;};
649
702
  if(c.isNew){
650
703
  const o=openOutcome(r.status,res,true);
651
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;}
@@ -670,7 +723,7 @@ $('#introForm').onsubmit=e=>{
670
723
  if(problem){$('#nameErr').textContent=problem;$('#nameIn').focus();return;}
671
724
  chat.st.answers.name=v;
672
725
  }
673
- chat.st.started=true;chat.st.editing=null;saveSetup(chat.st);drawChat();
726
+ chat.st.started=true;chat.st.editing=null;drawChat();
674
727
  };
675
728
  $('#nameIn').addEventListener('input',()=>{$('#nameGo').disabled=!$('#nameIn').value.trim();$('#nameErr').textContent='';});
676
729
  $('#setupStart').onclick=()=>$('#introForm').requestSubmit();
@@ -703,6 +756,7 @@ $('#comp').addEventListener('click',e=>{
703
756
  if(t.id==='chatOther'){comp.showCustom=!comp.showCustom;if(!isMulti(cur.type)&&comp.showCustom)comp.v='';return redraw(comp.showCustom?'#chatCustom':'#chatOther');}
704
757
  if(t.id==='chatSkip'){if(!cur.required)chatAnswer(cur,isMulti(cur.type)?[]:'');return;}
705
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;}
706
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;}
707
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;}
708
762
  const v=t.dataset.v;if(v===undefined)return;
@@ -722,24 +776,7 @@ $('#msgs').addEventListener('click',e=>{
722
776
  if(e.target.id==='chatCreate'){chatCreate();return;}
723
777
  const b=e.target.closest('[data-k]');if(b)chatEdit(b.dataset.k);
724
778
  });
725
- $('#setupList').addEventListener('click',e=>{
726
- if(chatBusy)return;
727
- const rm=e.target.closest('[data-rm-setup]');
728
- if(rm){
729
- if(!confirm('Remove this setup?'))return;
730
- const id=rm.dataset.rmSetup;dropSetup(id);delete live[id];
731
- if(chat&&chat.st.id===id){if(curNew===id)curNew=null;renderChat(chat.isNew);}else drawSetups();
732
- return;
733
- }
734
- const b=e.target.closest('[data-setup]');if(!b)return;
735
- const s=setups.find(x=>x.id===b.dataset.setup);if(!s)return;
736
- $('#cbody').classList.remove('lst');
737
- if(s.kind==='new'){curNew=s.id;if(curView==='new')renderChat(true);else go('new');return;}
738
- const i=DATA.projects.findIndex(p=>p.root===s.root);if(i>=0)location.hash='#'+i+'/board';
739
- });
740
- $('#setupNew').onclick=()=>{if(chatBusy)return;curNew=null;$('#cbody').classList.remove('lst');if(curView==='new')renderChat(true);else go('new');};
741
- $('#chatSetups').onclick=()=>$('#cbody').classList.toggle('lst');
742
- $('#chatRestart').onclick=()=>{if(!chat||chatBusy)return;dropSetup(chat.st.id);chat.st=live[chat.st.id]=freshSetup(chat.st.kind,chat.st.root,chat.st.id);comp=null;drawChat();};
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();};
743
780
  $('#chatClose').onclick=()=>{if(!chatBusy)go('home');};
744
781
 
745
782
  /* ---------------- live reload (BL-052) ----------------
@@ -774,7 +811,7 @@ async function redraw(paths){
774
811
  if(p!==PROJECT)return; // switched projects meanwhile
775
812
  // The poller's echo of a move this page just made: same tasks.md hash, nothing to redraw.
776
813
  if(paths&&paths.length&&paths.every(p=>p==='.specs/planning/tasks.md')&&DATA&&DATA.tasks&&d.tasks&&d.tasks.sha256===DATA.tasks.sha256)return;
777
- await apply(d,paths);
814
+ await apply(d,paths);document.documentElement.dataset.rev=+(document.documentElement.dataset.rev||0)+1; // live reloads drawn: the browser tests wait on it
778
815
  }
779
816
  /* Draw a fresh /api/specs payload in place: same route, scroll, inspector, selection and focus. */
780
817
  async function apply(d,paths){
@@ -802,9 +839,10 @@ async function apply(d,paths){
802
839
  }
803
840
  let es=null;
804
841
  function listen(){
805
- if(!window.EventSource)return;
842
+ if(stopped||!window.EventSource)return;
806
843
  if(es)es.close(); // one stream, for the shown project
807
844
  es=new EventSource('/api/events?'+pq());let dropped=false;
845
+ es.addEventListener('clone',e=>onCloneEvent(e.data));
808
846
  es.addEventListener('change',e=>{let paths=null;try{paths=JSON.parse(e.data).paths;}catch(_){}refresh(Array.isArray(paths)?paths:null);});
809
847
  es.onerror=()=>{dropped=true;}; // EventSource retries by itself
810
848
  es.onopen=()=>{if(dropped){dropped=false;refresh(null);}}; // catch up on anything missed
@@ -838,8 +876,21 @@ $('#projList').addEventListener('click',e=>{const b=e.target.closest('[data-proj
838
876
  file content; the strings are the ones REQ-002.H.21, H.24 and H.26 list. */
839
877
  const openVeil=$('#openVeil'),addBtn=$('#addBtn'),pathIn=$('#pathIn');
840
878
  const TABS=['folder','clone'],GO={folder:'Open',clone:'Clone Repository'};
841
- let openBusy=false,sheetFrom=$('#homeOpen'),sheetTab='folder',cloneCtl=null,cloneNamed=false,cloneTick=null;
879
+ let openBusy=false,sheetFrom=$('#homeOpen'),sheetTab='folder',cloneCtl=null,browseCtl=null,browseBtn=null,cloneNamed=false,cloneTick=null,cloneT0=0,cloneProg=null;
842
880
  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:
882
+ 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
+ if(TOKEN&&MCP){
885
+ const env=MCP==='env';
886
+ $('#mcpLine').textContent=mcpConfigLine(location.host,env?'${SPECPILOT_MCP_TOKEN}':TOKEN);
887
+ $('#mcpNote').textContent=env
888
+ ?'Add this to your IDE\u2019s MCP settings or to .mcp.json in your project. Claude Code fills in ${SPECPILOT_MCP_TOKEN} from the environment; for other IDEs, put the token in its place.'
889
+ :'Add this to your IDE\u2019s MCP settings, or to .mcp.json in your project and add .mcp.json to .gitignore. The token changes each time specpilot serve starts.';
890
+ $('#homeMcp').hidden=false;
891
+ $('#mcpCopy').onclick=()=>(navigator.clipboard?navigator.clipboard.writeText($('#mcpLine').textContent):Promise.reject())
892
+ .then(()=>toast('Copied.'),()=>toast('Could not copy. Select the line and copy it.'));
893
+ }
843
894
  function openSheet(from,tab){
844
895
  hideTip();sheetFrom=from;openVeil.classList.add('open');
845
896
  $$('#openForm .field input').forEach(el=>{el.value='';});cloneNamed=false;
@@ -852,7 +903,7 @@ function setTab(t){
852
903
  $('#openGo').textContent=GO[t];
853
904
  if(t==='folder')loadRecent();
854
905
  }
855
- function closeSheet(){if(!openVeil.classList.contains('open'))return;if(cloneCtl)cloneCtl.abort();openVeil.classList.remove('open');sheetFrom.focus();}
906
+ function closeSheet(){if(!openVeil.classList.contains('open'))return;if(cloneCtl)cloneCtl.abort();if(browseCtl)browseCtl.abort();openVeil.classList.remove('open');sheetFrom.focus();}
856
907
  /* The registry as GET /api/projects sends it: in the sheet, or on Home (BL-PM-001), where a row opens
857
908
  its folder at once and a served project also shows the branch the rail tooltip shows. */
858
909
  function drawRecent(reg,home){
@@ -895,12 +946,26 @@ async function showOutcome(o){
895
946
  function setCloning(ctl){
896
947
  cloneCtl=ctl;openBusy=!!ctl;
897
948
  $('#openGo').disabled=!!ctl;
898
- $$('#paneClone input, #openTabs button').forEach(el=>{el.disabled=!!ctl;});
899
- // An indeterminate bar and the time since the click: the page knows nothing else about a running clone.
900
- clearInterval(cloneTick);cloneTick=null;$('#cloneStatus').hidden=!ctl;
949
+ $$('#paneClone input, #cloneBrowseBtn, #openTabs button').forEach(el=>{el.disabled=!!ctl;});
950
+ // The time since the click, and an indeterminate bar until git gives a percentage (BL-PM-009).
951
+ clearInterval(cloneTick);cloneTick=null;cloneProg=null;$('#cloneStatus').hidden=!ctl;
901
952
  if(!ctl)return;
902
- const t0=Date.now(),tick=()=>{const s=Math.floor((Date.now()-t0)/1000);$('#cloneTime').textContent=`Cloning… ${Math.floor(s/60)}:${String(s%60).padStart(2,'0')}`;};
903
- tick();cloneTick=setInterval(tick,1000);
953
+ cloneT0=Date.now();drawCloning();cloneTick=setInterval(drawCloning,1000);
954
+ }
955
+ function drawCloning(){
956
+ const bar=$('#cloneStatus .bar'),p=cloneProg;
957
+ $('#cloneTime').textContent=cloneStatus(Math.floor((Date.now()-cloneT0)/1000),p);
958
+ bar.classList.toggle('det',!!p);
959
+ if(p){
960
+ bar.setAttribute('aria-valuemin','0');bar.setAttribute('aria-valuemax','100');bar.setAttribute('aria-valuenow',String(p.percent));
961
+ bar.setAttribute('aria-valuetext',`${CLONE_STAGES[p.stage]} ${p.percent}%`);bar.style.setProperty('--pct',p.percent+'%');
962
+ }else{['aria-valuemin','aria-valuemax','aria-valuenow','aria-valuetext'].forEach(a=>bar.removeAttribute(a));bar.style.removeProperty('--pct');}
963
+ }
964
+ /* A `clone` event from the stream: only while this page is cloning (not another tab's clone, not after the answer). */
965
+ function onCloneEvent(data){
966
+ const p=cloneProgress(data);
967
+ if(!cloneCtl||!p)return;
968
+ cloneProg=p;drawCloning();
904
969
  }
905
970
  async function cloneRepo(){
906
971
  if(openBusy)return;
@@ -915,6 +980,29 @@ async function cloneRepo(){
915
980
  if(ctl.signal.aborted)return; // the sheet was closed: the server removes the clone
916
981
  await showOutcome(openOutcome(r.status,res,'cloned'));
917
982
  }
983
+ /* Browse… (BL-PM-011, BL-097): the server opens the system's folder dialog; the folder picked fills the
984
+ button's field, and nothing is sent until the user does. One dialog at a time for the whole page. */
985
+ function setBrowsing(ctl,btn){
986
+ browseCtl=ctl;if(btn)browseBtn=btn;
987
+ const b=browseBtn;b.disabled=!!ctl||(b.id==='cloneBrowseBtn'&&!!cloneCtl); // a running clone keeps its sheet's button off
988
+ if(ctl)b.setAttribute('aria-busy','true');else b.removeAttribute('aria-busy');
989
+ }
990
+ /* `field()` is looked up after the answer: the chat may have redrawn its text box meanwhile. `pick` also sees the path. */
991
+ async function browseFolder(btn,field,pick){
992
+ if(browseCtl)return;
993
+ const ctl=new AbortController();setBrowsing(ctl,btn);
994
+ const back=()=>{if(btn.isConnected)btn.focus();};
995
+ let r,res={};
996
+ try{
997
+ r=await fetch('/api/projects/browse',{method:'POST',cache:'no-store',signal:ctl.signal,headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN},body:'{}'});
998
+ res=await r.json().catch(()=>({}));
999
+ }catch(e){setBrowsing(null);if(!ctl.signal.aborted){toast('The server did not answer.');back();}return;}
1000
+ setBrowsing(null);
1001
+ if(ctl.signal.aborted)return; // the sheet was closed or the chat left: the server closes the dialog
1002
+ if(r.status!==200){toast(res.error||`Nothing was chosen (HTTP ${r.status}).`);back();return;}
1003
+ const f=res.path&&field();
1004
+ if(f){f.value=res.path;if(pick)pick(res.path);f.focus();}else back();
1005
+ }
918
1006
  async function removeRecent(path){
919
1007
  let out;
920
1008
  try{out=await postPath(path,'/api/projects/remove');}catch(e){toast('The server did not answer.');return;}
@@ -939,6 +1027,8 @@ $('#homeBox').addEventListener('click',e=>{
939
1027
  const row=e.target.closest('[data-path]');if(row)openPath(row.dataset.path);
940
1028
  });
941
1029
  $('#openCancel').onclick=closeSheet;
1030
+ $('#browseBtn').onclick=()=>browseFolder($('#browseBtn'),()=>pathIn);
1031
+ $('#cloneBrowseBtn').onclick=()=>browseFolder($('#cloneBrowseBtn'),()=>$('#cloneParentIn'));
942
1032
  openVeil.onclick=e=>{if(e.target===openVeil)closeSheet();};
943
1033
  $('#openForm').onsubmit=e=>{e.preventDefault();if(sheetTab==='clone')cloneRepo();else openPath(pathIn.value.trim());};
944
1034
  $('#recentBox').addEventListener('click',e=>{
package/ui/index.html CHANGED
@@ -6,6 +6,7 @@
6
6
  <title>SpecPilot Local</title>
7
7
  <meta name="theme-color" content="#0f172a">
8
8
  <!-- specpilot-token -->
9
+ <!-- specpilot-mcp -->
9
10
  <link rel="icon" href="/assets/favicon.svg" type="image/svg+xml">
10
11
  <link rel="stylesheet" href="/assets/app.css">
11
12
  <script src="/assets/md.js" defer></script>
@@ -67,6 +68,7 @@
67
68
  <symbol id="i-chev" viewBox="0 0 24 24"><path d="M9 6l6 6-6 6"/></symbol>
68
69
  <symbol id="i-arrow" viewBox="0 0 24 24"><path d="M5 12h14M13 6l6 6-6 6"/></symbol>
69
70
  <symbol id="i-check" viewBox="0 0 24 24"><path d="M5 12l5 5L20 7"/></symbol>
71
+ <symbol id="i-power" viewBox="0 0 24 24"><path d="M12 3v9M6.3 6.3a8 8 0 1 0 11.4 0"/></symbol>
70
72
  </defs></svg>
71
73
 
72
74
  <a class="skip" href="#content">Skip to Content</a>
@@ -79,6 +81,7 @@
79
81
  <button class="tile act" id="addBtn" aria-label="Add a project" data-tip="Add a project" hidden><svg aria-hidden="true" focusable="false"><use href="#i-plus"/></svg></button>
80
82
  <div class="rfoot">
81
83
  <button class="tile ghost" id="themeBtn" aria-label="Switch between light and dark" data-tip="Light / dark"><svg aria-hidden="true" focusable="false"><use href="#i-sun"/></svg></button>
84
+ <button class="tile ghost" id="quitBtn" aria-label="Quit SpecPilot" data-tip="Quit SpecPilot" hidden><svg aria-hidden="true" focusable="false"><use href="#i-power"/></svg></button>
82
85
  </div>
83
86
  </nav>
84
87
  <aside class="src" id="src">
@@ -116,8 +119,9 @@
116
119
  <div class="right">
117
120
  <div class="seg" id="modeSeg"><button class="on" data-m="list">List</button><button data-m="board">Board</button></div>
118
121
  <a class="ib" id="editorBtn" hidden aria-label="Open in VS Code" title="Open in VS Code"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-ext"/></svg></a>
122
+ <div class="idewrap" id="ideWrap" hidden><button type="button" class="ib" id="ideBtn" aria-haspopup="menu" aria-expanded="false" aria-controls="ideMenu" aria-label="Open in AI IDE" title="Open in AI IDE"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-spark"/></svg></button><div class="idemenu" id="ideMenu" role="menu" aria-label="Open in AI IDE" hidden></div></div>
119
123
  <button type="button" class="btn line sm" id="newTask" hidden><svg class="ico ico-13" aria-hidden="true" focusable="false"><use href="#i-plus"/></svg>New Task</button>
120
- <button type="button" class="btn" id="chatSetups" hidden aria-controls="setups">Setups</button><button type="button" class="btn" id="chatRestart" hidden>Start over</button><button type="button" class="btn" id="chatClose" hidden>Close</button>
124
+ <button type="button" class="btn" id="chatRestart" hidden>Start over</button><button type="button" class="btn" id="chatClose" hidden>Close</button>
121
125
  </div>
122
126
  </div>
123
127
  <div class="content" id="content" tabindex="-1">
@@ -136,6 +140,8 @@
136
140
  <div class="row"><span class="ic2"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-shield"/></svg></span><div class="body"><div class="ttl">Nothing leaves this machine</div><div class="det">Runs on localhost, no account, no telemetry. No <span class="mono" translate="no">.specs/</span> yet? The guided setup writes one for you.</div></div></div>
137
141
  </div></div>
138
142
  <div class="gl recents"><div class="gh">Recent projects <span class="cnt" id="homePath" translate="no"></span></div><div class="box" id="homeBox"></div></div>
143
+ <!-- BL-PM-007: only with specpilot serve --mcp -->
144
+ <div class="gl" id="homeMcp" hidden><div class="gh">Connect Your AI IDE <span class="cnt">optional, one line</span></div><div class="box"><div class="mcp"><code class="v" id="mcpLine" translate="no"></code><button type="button" class="btn sm" id="mcpCopy">Copy</button></div></div><p class="note" id="mcpNote"></p></div>
139
145
  <div class="fine"><i aria-hidden="true"></i><span>Server running on <span class="mono" id="homeAddr" translate="no"></span> · <span id="homeVer" translate="no"></span></span></div>
140
146
  </section>
141
147
 
@@ -168,15 +174,11 @@
168
174
  <div class="bar" role="progressbar" aria-label="Setup progress" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><i id="barI"></i></div>
169
175
  <p class="note" id="chatNote" hidden></p>
170
176
  <div class="cbody" id="cbody" hidden>
171
- <aside class="setups" id="setups" aria-label="Saved setups">
172
- <div class="sh"><span>Setups</span><button type="button" class="btn sm" id="setupNew">New setup</button></div>
173
- <div id="setupList"></div>
174
- </aside>
175
177
  <div class="cmain">
176
178
  <section class="intro" id="intro" hidden>
177
179
  <svg class="big" aria-hidden="true" focusable="false"><use href="#logo"/></svg>
178
180
  <div><h2 id="introH">Hey, I'm SpecPilot</h2><p id="introText"></p><p id="introText2" hidden></p><p class="note" id="introDetected" hidden translate="no"></p></div>
179
- <div class="fine">Runs on this machine. Nothing leaves it.</div>
181
+ <div class="fine" id="introFine">Runs on this machine. Nothing leaves it.</div>
180
182
  <form class="start" id="introForm" autocomplete="off">
181
183
  <div class="lbl" id="nameLbl">Name your project to start</div>
182
184
  <div class="row"><input class="cfield mono" id="nameIn" name="project-name" type="text" placeholder="e.g. parcel-track" spellcheck="false" maxlength="214" aria-labelledby="nameLbl" aria-describedby="nameErr"><button type="submit" class="send" id="nameGo" aria-label="Start">→</button></div>
@@ -227,14 +229,14 @@
227
229
  <form class="sb" id="openForm" autocomplete="off">
228
230
  <div class="tabs" id="openTabs" role="tablist" aria-labelledby="openTitle"><button type="button" class="on" role="tab" id="tabFolder" data-t="folder" aria-controls="paneFolder" aria-selected="true">Folder</button><button type="button" role="tab" id="tabClone" data-t="clone" aria-controls="paneClone" aria-selected="false" tabindex="-1">Clone</button></div>
229
231
  <div class="pane" id="paneFolder" role="tabpanel" aria-labelledby="tabFolder">
230
- <div class="gl"><div class="box"><div class="field"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-folder"/></svg><input id="pathIn" name="folder-path" type="text" spellcheck="false" aria-label="Folder path" placeholder="/path/to/project or ~/project"></div></div></div>
232
+ <div class="gl"><div class="box"><div class="field"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-folder"/></svg><input id="pathIn" name="folder-path" type="text" spellcheck="false" aria-label="Folder path" placeholder="/path/to/project or ~/project"><button type="button" class="btn" id="browseBtn">Browse…</button></div></div></div>
231
233
  <div class="gl"><div class="gh">Recent projects <span class="cnt" id="recentPath" translate="no"></span></div><div class="box" id="recentBox"></div></div>
232
234
  </div>
233
235
  <div class="pane" id="paneClone" role="tabpanel" aria-labelledby="tabClone" hidden>
234
236
  <p class="note">Runs git clone on this machine, then opens the folder. Submodules are not cloned.</p>
235
237
  <div class="gl"><div class="box">
236
238
  <div class="field"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-git"/></svg><input id="cloneIn" name="repo-url" type="text" inputmode="url" spellcheck="false" aria-label="Repository URL" placeholder="https://github.com/owner/repo.git or git@github.com:owner/repo.git" maxlength="2048"></div>
237
- <div class="field"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-folder"/></svg><input id="cloneParentIn" name="clone-parent" type="text" spellcheck="false" aria-label="Parent folder" placeholder="/path/to/folder or ~/folder"></div>
239
+ <div class="field"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-folder"/></svg><input id="cloneParentIn" name="clone-parent" type="text" spellcheck="false" aria-label="Parent folder" placeholder="/path/to/folder or ~/folder"><button type="button" class="btn" id="cloneBrowseBtn">Browse…</button></div>
238
240
  <div class="field"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-plus"/></svg><input id="cloneNameIn" name="clone-name" type="text" spellcheck="false" aria-label="Folder name" placeholder="the repository's name" maxlength="214"></div>
239
241
  </div></div>
240
242
  </div>