specpilot 2.11.0 → 2.13.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 (55) hide show
  1. package/README.md +48 -11
  2. package/dist/cli.js +1 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/serve.d.ts +5 -0
  5. package/dist/commands/serve.d.ts.map +1 -1
  6. package/dist/commands/serve.js +21 -4
  7. package/dist/commands/serve.js.map +1 -1
  8. package/dist/core/ideConfig.d.ts.map +1 -1
  9. package/dist/core/ideConfig.js +2 -1
  10. package/dist/core/ideConfig.js.map +1 -1
  11. package/dist/utils/gitClone.d.ts +4 -1
  12. package/dist/utils/gitClone.d.ts.map +1 -1
  13. package/dist/utils/gitClone.js +35 -4
  14. package/dist/utils/gitClone.js.map +1 -1
  15. package/dist/utils/mcpLocal.d.ts +46 -0
  16. package/dist/utils/mcpLocal.d.ts.map +1 -0
  17. package/dist/utils/mcpLocal.js +220 -0
  18. package/dist/utils/mcpLocal.js.map +1 -0
  19. package/dist/utils/projectDetector.d.ts +4 -0
  20. package/dist/utils/projectDetector.d.ts.map +1 -1
  21. package/dist/utils/projectDetector.js +19 -4
  22. package/dist/utils/projectDetector.js.map +1 -1
  23. package/dist/utils/slashCommandGenerator.d.ts +7 -1
  24. package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
  25. package/dist/utils/slashCommandGenerator.js +95 -28
  26. package/dist/utils/slashCommandGenerator.js.map +1 -1
  27. package/dist/utils/specBackfiller.d.ts +1 -1
  28. package/dist/utils/specBackfiller.d.ts.map +1 -1
  29. package/dist/utils/specBackfiller.js.map +1 -1
  30. package/dist/utils/specPaths.d.ts +3 -2
  31. package/dist/utils/specPaths.d.ts.map +1 -1
  32. package/dist/utils/specPaths.js +6 -4
  33. package/dist/utils/specPaths.js.map +1 -1
  34. package/dist/utils/specReader.d.ts +4 -0
  35. package/dist/utils/specReader.d.ts.map +1 -1
  36. package/dist/utils/specReader.js +4 -4
  37. package/dist/utils/specReader.js.map +1 -1
  38. package/dist/utils/specServer.d.ts +33 -3
  39. package/dist/utils/specServer.d.ts.map +1 -1
  40. package/dist/utils/specServer.js +245 -16
  41. package/dist/utils/specServer.js.map +1 -1
  42. package/dist/utils/specSetup.d.ts +11 -0
  43. package/dist/utils/specSetup.d.ts.map +1 -1
  44. package/dist/utils/specSetup.js +9 -1
  45. package/dist/utils/specSetup.js.map +1 -1
  46. package/dist/utils/taskMover.d.ts +42 -0
  47. package/dist/utils/taskMover.d.ts.map +1 -1
  48. package/dist/utils/taskMover.js +177 -25
  49. package/dist/utils/taskMover.js.map +1 -1
  50. package/package.json +5 -2
  51. package/ui/OFL-Sixtyfour.txt +93 -0
  52. package/ui/app.css +35 -18
  53. package/ui/app.js +190 -76
  54. package/ui/index.html +28 -10
  55. package/ui/route.js +70 -31
package/ui/app.css CHANGED
@@ -9,6 +9,7 @@
9
9
  --orange:#f59e0b;--orange-soft:rgba(245,158,11,.14);--orange-ink:#fbbf24;
10
10
  --red:#ef4444;--red-soft:rgba(239,68,68,.14);--red-ink:#f87171;
11
11
  --violet:#8b5cf6;--violet-soft:rgba(139,92,246,.16);--violet-ink:#c4b5fd;
12
+ --brand-ink:#79b8ff; /* specpilot.dev's nav wordmark, dark (BL-PM-014) */
12
13
  --blue:#3b82f6;--blue-soft:rgba(59,130,246,.16);--blue-ink:#93c5fd;
13
14
  --hover:rgba(148,163,184,.08);--press:rgba(148,163,184,.14);--sel:rgba(96,165,250,.14);--sel-line:#60a5fa;
14
15
  --shadow:none;
@@ -28,6 +29,7 @@
28
29
  --orange:#d97706;--orange-soft:rgba(217,119,6,.12);--orange-ink:#b45309;
29
30
  --red:#dc2626;--red-soft:rgba(220,38,38,.12);--red-ink:#b91c1c;
30
31
  --violet:#7c3aed;--violet-soft:rgba(124,58,237,.12);--violet-ink:#6d28d9;
32
+ --brand-ink:#0058be;
31
33
  --blue:#2563eb;--blue-soft:rgba(37,99,235,.12);--blue-ink:#1d4ed8;
32
34
  --hover:rgba(15,23,42,.05);--press:rgba(15,23,42,.09);--sel:rgba(37,99,235,.12);--sel-line:#2563eb;
33
35
  color-scheme:light;
@@ -122,6 +124,8 @@ a{color:var(--accent);text-decoration:none}
122
124
  .gl .gh .cnt{color:var(--label-3);font-weight:500;font-variant-numeric:tabular-nums;text-transform:none;letter-spacing:0}
123
125
  .gl .gh .more{margin-left:auto;color:var(--green-ink);font-weight:500;font-size:12.5px;text-transform:none;letter-spacing:0}
124
126
  .gl .gh .more:hover{text-decoration:underline}
127
+ .gl .gh .more:disabled{opacity:.6;cursor:default;text-decoration:none}
128
+ #regenNote .note{margin:0 0 6px;overflow-wrap:anywhere}
125
129
  .gl .gh .disc{width:20px;height:20px;display:grid;place-items:center;color:var(--label-3);transition:transform .18s;transform-origin:center}
126
130
  .gl.closed .gh .disc{transform:rotate(-90deg)}
127
131
  .gl.closed .box{display:none}
@@ -233,6 +237,12 @@ input.txt{width:100%}
233
237
  .insp .row .v{color:var(--label)}
234
238
  .insp .desc{padding:10px 12px;color:var(--label-2);line-height:1.55;font-size:14px}
235
239
  .insp .actions{display:flex;gap:8px;flex-wrap:wrap;padding:2px}
240
+ /* Open in AI IDE (BL-PM-010): a small menu under its top-bar button */
241
+ .idewrap{position:relative;display:flex}
242
+ .idemenu{position:absolute;right:0;top:calc(100% + 6px);z-index:30;min-width:240px;max-width:calc(100vw - 32px);display:grid;padding:4px;background:var(--group);border:1px solid var(--sep-2);border-radius:6px;box-shadow:var(--shadow)}
243
+ .idemenu[hidden]{display:none}
244
+ .idemenu [role=menuitem]{display:block;width:100%;padding:8px 10px;border-radius:var(--rs);color:var(--label);font-size:13px;text-decoration:none}
245
+ .idemenu [role=menuitem]:hover,.idemenu [role=menuitem]:focus-visible{background:var(--hover)}
236
246
  .report li{display:flex;gap:10px;padding:9px 12px;border-top:1px solid var(--sep);font-size:13px;line-height:1.45}
237
247
  .report li:first-child{border-top:0}
238
248
  .report .f{font-family:var(--mono);font-size:12px;color:var(--green-ink);flex:none;min-width:150px;padding-top:2px}
@@ -324,17 +334,22 @@ input.txt{width:100%}
324
334
  .sheet .sh h2{margin:0;font-size:18px;font-weight:600;text-wrap:balance}
325
335
  .sheet .sh p{margin:2px 0 0;color:var(--label-3);font-size:13px}
326
336
  .sheet .sb{padding:12px 18px;display:flex;flex-direction:column;gap:14px;overflow:auto;overscroll-behavior:contain;min-height:0;margin:0}
327
- .sheet .sf{display:flex;gap:8px;justify-content:flex-end;padding:12px 18px 16px;border-top:1px solid var(--sep)}
328
- .sheet .sf .cloning{display:flex;align-items:center;gap:10px;margin-right:auto;min-width:0;color:var(--label-2);font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}
337
+ .sheet .sf{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;padding:12px 18px 16px;border-top:1px solid var(--sep)}
338
+ .sheet .sf .cloning{display:flex;align-items:center;gap:10px;margin-right:auto;color:var(--label-2);font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}
329
339
  .sheet .sf .cloning[hidden]{display:none}
330
340
  .cloning .bar{flex:none;width:96px;height:4px;border-radius:2px;background:var(--muted);overflow:hidden;position:relative}
331
341
  .cloning .bar::after{content:"";position:absolute;inset:0 60% 0 0;border-radius:2px;background:var(--accent);animation:cloning 1.2s ease-in-out infinite alternate}
332
342
  @keyframes cloning{from{transform:translateX(0)}to{transform:translateX(150%)}}
333
- @media (prefers-reduced-motion:reduce){.cloning .bar::after{animation:none}}
343
+ .cloning .bar.det::after{animation:none;inset:0 auto 0 0;width:var(--pct,0%);transition:width .2s ease-out}
344
+ @media (prefers-reduced-motion:reduce){.cloning .bar::after,.cloning .bar.det::after{animation:none;transition:none}}
334
345
  .field{display:flex;gap:8px;align-items:center;padding:6px 14px}
335
346
  .field .ico{color:var(--label-3);flex:none}
336
347
  .field input{flex:1;background:transparent;border:0;outline:0;font-family:var(--mono);font-size:13px;color:var(--label);min-width:0;padding:6px 0}
337
348
  .field input::placeholder{color:var(--label-3)}
349
+ .sheet.task{width:min(520px,100%)}
350
+ #taskIn{font-family:inherit;font-size:14px}
351
+ #taskSec{align-self:flex-start}
352
+ #taskErr{margin:0;font-size:12.5px;overflow-wrap:anywhere}
338
353
  .recent .row{padding-right:8px}
339
354
  .recent .row .body{cursor:pointer}
340
355
  .recent .btn{flex:none}
@@ -352,6 +367,9 @@ input.txt{width:100%}
352
367
  .chat .intro{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px;gap:22px;overflow:auto}
353
368
  .chat .intro .big{width:52px;height:52px;border-radius:14px}
354
369
  .chat .intro h2{font-size:28px;font-weight:700;margin:0;letter-spacing:-.02em;text-align:center;text-wrap:balance}
370
+ .chat .intro h2.para{max-width:640px;line-height:1.3;overflow-wrap:anywhere} /* guided setup: its paragraph is the heading (BL-PM-016) */
371
+ .chat .intro h2.para .mono{font-size:.8em}
372
+ .chat .intro .fine[hidden]{display:none}
355
373
  .chat .intro p{color:var(--label-2);max-width:540px;text-align:center;line-height:1.55;margin:8px 0 0;overflow-wrap:anywhere}
356
374
  .chat .intro p .mono{font-size:13px}
357
375
  .chat .intro .fine{font-size:12.5px;color:var(--label-3)}
@@ -379,6 +397,10 @@ input.txt{width:100%}
379
397
  .chat .me .ed{font-size:11px;color:var(--label-3);padding:3px 2px}
380
398
  .chat .me .mono{font-family:var(--mono);font-size:13px}
381
399
  .chat .me.skipped button.b{opacity:.75;font-style:italic}
400
+ .chat .det{display:inline-block;font-size:10.5px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--label-2);border:1px solid var(--sep);border-radius:6px;padding:0 5px;margin-right:4px;vertical-align:1px}
401
+ .chat .me.fixed{gap:3px}
402
+ .chat .me.fixed .b{max-width:82%;background:var(--group);color:var(--label);border:1px solid var(--sep);border-radius:14px 4px 14px 14px;padding:11px 15px;line-height:1.5;overflow-wrap:anywhere}
403
+ .chat .rc .l.fixed:hover{background:none}
382
404
  .chat .composer{border-top:1px solid var(--sep);background:var(--group);padding:14px 22px 16px;flex:none}
383
405
  .chat .composer .col{gap:10px}
384
406
  .chat .chips{display:flex;flex-wrap:wrap;gap:8px}
@@ -416,20 +438,6 @@ input.txt{width:100%}
416
438
  .chat .cbody{flex:1;display:flex;min-height:0;position:relative}
417
439
  .chat .cbody[hidden]{display:none}
418
440
  .chat .cmain{flex:1;display:flex;flex-direction:column;min-width:0;min-height:0}
419
- .chat .setups{width:232px;flex:none;border-right:1px solid var(--sep);background:var(--side);overflow-y:auto;padding:14px 10px}
420
- .chat .setups .sh{display:flex;justify-content:space-between;align-items:center;font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--label-3);padding:0 4px 10px}
421
- .chat .setups .note{font-size:12.5px;color:var(--label-3);padding:4px;margin:0}
422
- .chat .srow2{display:flex;align-items:stretch;gap:2px;border-radius:8px}
423
- .chat .srow2.cur{background:var(--hover)}
424
- .chat .srow2 .go{flex:1;min-width:0;display:flex;flex-direction:column;padding:7px 8px;border-radius:8px;color:var(--label)}
425
- .chat .srow2 .go:hover:not(:disabled){background:var(--hover)}
426
- .chat .srow2 .go:disabled{opacity:.6;cursor:default}
427
- .chat .srow2 .t{font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
428
- .chat .srow2 .d{font-size:11.5px;color:var(--label-3);overflow-wrap:anywhere}
429
- .chat .srow2 .rm{font-size:11.5px;color:var(--label-3);padding:0 6px;border-radius:6px}
430
- .chat .srow2 .rm:hover{color:var(--red-ink)}
431
- @media (min-width:721px){#chatSetups{display:none}}
432
- @media (max-width:720px){.chat .setups{display:none}.chat .cbody.lst .setups{display:block;position:absolute;z-index:5;inset:0 auto 0 0;max-width:85%;box-shadow:0 8px 24px rgba(0,0,0,.3)}}
433
441
  .chat .bot .cap{display:block;margin-top:4px;font-size:11.5px;color:var(--label-3)}
434
442
  .chat .cnote{font-size:12.5px;line-height:1.5;color:var(--label-2);background:var(--muted);border-radius:10px;padding:8px 12px;margin:6px 0 6px 36px}
435
443
  .chat .composer .cnote{margin:0}
@@ -465,7 +473,10 @@ input.txt{width:100%}
465
473
  .tile.home .logo{width:26px;height:26px;margin:0}
466
474
  #content:focus{outline:0}
467
475
  .content>.welcome{width:100%;max-width:560px;margin:0 auto;gap:22px;padding:clamp(28px,8vh,72px) 0 48px}
468
- .welcome .logo{width:56px;height:56px;border-radius:12px}
476
+ .welcome .logo{width:56px;height:56px;border-radius:12px;flex:none}
477
+ /* the wordmark as specpilot.dev's nav (32px logo, 20px text, 10px gap) scaled to the 56px logo; it shrinks first in a narrow window */
478
+ .welcome .brand{display:flex;align-items:center;gap:17.5px;min-width:0}
479
+ .welcome .wordmark{width:315px;height:35px;min-width:0;color:var(--brand-ink)}
469
480
  .welcome h1{font-size:clamp(26px,4vw,32px);font-weight:600;letter-spacing:-.02em;line-height:1.15;margin:0;text-wrap:balance}
470
481
  .welcome .lead{font-size:16px;line-height:1.55;color:var(--label-2);margin:0;max-width:52ch}
471
482
  .welcome .cta{display:flex;flex-direction:column;gap:10px}
@@ -479,5 +490,11 @@ input.txt{width:100%}
479
490
  .welcome .ic2 svg{width:15px;height:15px;stroke:var(--green-ink)}
480
491
  .welcome .recents .row{text-align:left}
481
492
  .welcome .recents .row .ttl{white-space:normal;overflow-wrap:anywhere}
493
+ .welcome .recents .hrow{padding:0 8px 0 0;gap:4px}
494
+ .welcome .recents .hrow:hover{background:var(--hover)}
495
+ .hrow>.act{display:flex;align-items:center;gap:12px;flex:1;min-width:0;align-self:stretch;padding:0 6px 0 14px;font:inherit;text-align:left;color:inherit}
496
+ .hrow>.act+[data-remove]{margin-left:34px} /* no link (folder not found): the chevron and Remove stay in line with the others */
497
+ .welcome .mcp{display:flex;align-items:center;gap:10px;padding:8px 8px 8px 14px;min-height:48px}
498
+ .welcome .mcp .v{font-family:var(--mono);font-size:12.5px;line-height:1.5;color:var(--label-2);flex:1;min-width:0;overflow-wrap:anywhere;user-select:all}
482
499
  .welcome .fine{display:flex;gap:8px;align-items:center;flex-wrap:wrap;color:var(--label-3);font-size:13px}
483
500
  .welcome .fine i{width:7px;height:7px;border-radius:50%;background:var(--green);flex:none}
package/ui/app.js CHANGED
@@ -47,7 +47,7 @@ function renderProject(){
47
47
  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
48
  $('#curGrp').textContent=name;$('#curGrp').title=p.root;
49
49
  $('#curBranch').textContent=p.branch||'';
50
- $('#subName').textContent=name;$('#subPath').textContent=where;
50
+ $('#subName').textContent=name;$('#subPath').textContent=where;$('#editorBtn').href=editorUrl(p.root);syncIde();
51
51
  $('#footAddr').textContent=$('#homeAddr').textContent=location.host;$('#footVer').textContent=$('#homeVer').textContent='v'+p.specpilotVersion;
52
52
  document.title=name+' · SpecPilot Local';
53
53
  }
@@ -78,8 +78,8 @@ function go(v,keep,sub){
78
78
  $$('.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
79
  syncNav();
80
80
  $('#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';
81
+ $('#chatSub').hidden=!(v==='new'||v==='setup');if(v!=='new'&&v!=='setup'){$('#chatRestart').hidden=$('#chatClose').hidden=true;chat=null;}
82
+ $('#modeSeg').hidden=v!=='board';$('#newTask').hidden=!(TOKEN&&v==='board');$('#editorBtn').hidden=NOPROJ.includes(v);syncIde();
83
83
  setNav(false);closeInsp();
84
84
  if(v!=='file'||sub!==fileNoteFor)clearFileNote();
85
85
  if(v==='home')loadRecent();
@@ -198,6 +198,7 @@ function openTask(col,i,quiet){
198
198
  insp.innerHTML=`<div class="ih">${col==='completed'?`<span class="id" translate="no">${esc(t.num)}</span>`:''}<span class="id" translate="no">${mdi(t.id)}</span><span class="pill ${col==='completed'?'green':col==='currentSprint'?'orange':'gray'}">${esc(COLS[col])}</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>
199
199
  <div class="ib2">
200
200
  <div class="gl"><div class="gh">Description <span class="cnt" translate="no">tasks.md · ## ${esc(COLS[col])}</span></div><div class="box"><div class="desc md">${md(t.description)}</div></div></div>
201
+ <div class="actions"><a class="btn sm" href="${esc(editorUrl(DATA.project.root+'/.specs/planning/tasks.md',t.line))}">Open tasks.md in VS Code</a></div>
201
202
  </div>`;
202
203
  openInsp(quiet);
203
204
  }
@@ -220,7 +221,9 @@ async function renderFile(path){
220
221
  if(src===null){$('#fmBox').innerHTML='';$('#fileBody').innerHTML=gone('.specs/'+path);return;}
221
222
  const isYaml=/\.ya?ml$/.test(path);
222
223
  const {fm,body}=isYaml?{fm:'',body:src}:splitFm(src);
223
- $('#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>`:'';
224
+ const ed=`<a class="more" href="${esc(editorUrl(DATA.project.root+'/.specs/'+path))}">Open in VS Code</a>`; // BL-PM-013
225
+ $('#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>`
226
+ :`<div class="gh"><span class="cnt" translate="no">.specs/${esc(path)}</span>${ed}</div>`;
224
227
  $('#fileBody').innerHTML=isYaml?`<pre translate="no">${esc(src)}</pre>`:md(body);
225
228
  }
226
229
  const gone=goneHtml; // one definition of the "no longer exists" markup: ui/route.js
@@ -258,12 +261,32 @@ function fileRows(list){
258
261
  return `<button type="button" class="row act" data-open="${esc(f.path)}"><span class="st hollow" aria-hidden="true"></span><div class="body"><div class="ttl"><span class="id" translate="no">${esc(f.path)}</span>${fm['argument-hint']!==undefined?`<span class="id" translate="no">${esc(fm['argument-hint'])}</span>`:''}</div>${fm.description!==undefined?`<div class="det">${esc(fm.description)}</div>`:''}</div><div class="trail">${fm['allowed-tools']!==undefined?`<span class="pill gray" translate="no">${esc(fm['allowed-tools'])}</span>`:''}${chev}</div></button>`;}).join('')
259
262
  :'<div class="empty">No files here.</div>';
260
263
  }
264
+ /* From SpecPilot / Yours (BL-PM-006): the server's `generated` flag decides; rows keep their full path. */
265
+ function fileGroup(list,box,cnt,ours){const l=list.filter(f=>!!f.generated===ours);$(box).innerHTML=fileRows(l);$(cnt).textContent=l.length;}
261
266
  function renderAgentFiles(){
262
- const N=DATA.nav;
263
- $('#cmdBox').innerHTML=fileRows(N.commands);$('#cmdCnt').textContent=N.commands.length;
264
- $('#prmBox').innerHTML=fileRows(N.prompts);$('#prmCnt').textContent=N.prompts.length;
265
- $('#sklBox').innerHTML=fileRows(N.skills);$('#sklCnt').textContent=N.skills.length;
266
- }
267
+ const N=DATA.nav,cmds=[...N.commands,...N.prompts];
268
+ fileGroup(cmds,'#cmdBox','#cmdSpCnt',true);fileGroup(cmds,'#cmdMine','#cmdYouCnt',false);
269
+ fileGroup(N.skills,'#sklBox','#sklSpCnt',true);fileGroup(N.skills,'#sklMine','#sklYouCnt',false);
270
+ }
271
+ /* Regenerate All (BL-PM-006): the server runs specpilot backfill's command step; its result lines are shown as sent,
272
+ until the next run or a project switch. */
273
+ function setRegenNote(lines){const n=$('#regenNote');n.innerHTML=lines.map(l=>`<p class="note" translate="no">${esc(l)}</p>`).join('');n.hidden=!lines.length;}
274
+ async function regenerate(){
275
+ const b=$('#cmdRegen'),p=PROJECT,had=document.activeElement===b;if(b.disabled)return;
276
+ b.disabled=true; // drops focus; given back below
277
+ let r,body={};
278
+ try{
279
+ r=await fetch('/api/commands/regenerate?'+pq(),{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN},body:'{}'});
280
+ body=await r.json().catch(()=>({}));
281
+ }catch(e){r=null;}
282
+ b.disabled=false;
283
+ if(p!==PROJECT)return;
284
+ if(!r)setRegenNote(['The server did not answer. Command files may have been partly written.']);
285
+ else if(r.status===200){await apply(body.specs,null);setRegenNote(body.message);}
286
+ else setRegenNote([(body.error||`Regenerate All did not run (HTTP ${r.status}).`)+(r.status===500?' Command files may have been partly written.':'')]);
287
+ if(had&&document.activeElement===document.body)b.focus();
288
+ }
289
+ $('#cmdRegen').onclick=regenerate;
267
290
  /* Inspector for a generated file: its front matter raw, its body rendered. */
268
291
  /* Is this generated file in the latest /api/specs listing? */
269
292
  function listed(path){const N=DATA.nav;return N.instructions.some(f=>f.exists&&f.path===path)||[N.commands,N.prompts,N.skills].some(l=>l.some(f=>f.path===path));}
@@ -276,11 +299,56 @@ async function openFile(path,quiet){
276
299
  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>`;
277
300
  if(src===null){insp.innerHTML=head+`<div class="ib2">${gone(path)}</div>`;openInsp(quiet);return;}
278
301
  const {fm,body}=splitFm(src);
279
- 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>`;
302
+ 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>`;
280
303
  openInsp(quiet);
281
304
  }
282
305
  document.addEventListener('click',e=>{const b=e.target.closest&&e.target.closest('[data-open]');if(b)openFile(b.dataset.open);});
283
306
 
307
+ /* Open in AI IDE (BL-PM-010): Cursor by its URL schemes when the project has SpecPilot's Cursor rules
308
+ file (`project.cursor`), and the onboarding prompt while development/onboarding.md exists. */
309
+ const ONB='development/onboarding.md',ideBtn=$('#ideBtn'),ideMenu=$('#ideMenu');
310
+ const hasOnb=()=>!!DATA&&ONB in DATA.files;
311
+ /* On every view switch and redraw: an open menu would hold another view's or project's items. */
312
+ function syncIde(){
313
+ closeIde(false);
314
+ $('#ideWrap').hidden=!DATA||NOPROJ.includes(curView)||!(DATA.project.cursor||hasOnb());
315
+ }
316
+ function closeIde(refocus){
317
+ if(ideMenu.hidden)return;
318
+ ideMenu.hidden=true;ideBtn.setAttribute('aria-expanded','false');
319
+ if(refocus)ideBtn.focus();
320
+ }
321
+ function copyPrompt(text,note){
322
+ const claude=DATA.nav.instructions.some(f=>f.path==='CLAUDE.md'&&f.exists);
323
+ (navigator.clipboard?navigator.clipboard.writeText(text):Promise.reject())
324
+ .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.')),
325
+ ()=>toast('Could not copy. Open development/onboarding.md and copy it.'));
326
+ }
327
+ async function openIde(){
328
+ const pj=PROJECT,cur=DATA.project.cursor;let prompt=null;
329
+ if(hasOnb())try{prompt=onboardingPrompt(await getText('.specs/'+ONB));}catch(e){toast(e.message);}
330
+ if(PROJECT!==pj||$('#ideWrap').hidden||!ideMenu.hidden)return; // switched away, or a second click opened it meanwhile
331
+ const item=(tag,attrs,label)=>`<${tag} role="menuitem" ${attrs}>${esc(label)}</${tag}>`;
332
+ const link=prompt!==null&&cur?cursorPromptUrl(prompt):null;
333
+ ideMenu.innerHTML=[
334
+ cur?item('a',`href="${esc(editorUrl(DATA.project.root,0,'cursor'))}"`,'Open in Cursor'):'',
335
+ 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')):'',
336
+ prompt!==null?item('button','type="button" data-copy="all"','Copy onboarding prompt'):'',
337
+ ].join('');
338
+ if(!ideMenu.children.length)return;
339
+ $$('[role=menuitem]',ideMenu).forEach(m=>m.onclick=()=>{
340
+ 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.':'');
341
+ closeIde(false);
342
+ });
343
+ ideMenu.hidden=false;ideBtn.setAttribute('aria-expanded','true');ideMenu.firstElementChild.focus();
344
+ }
345
+ ideBtn.onclick=()=>ideMenu.hidden?openIde():closeIde(true);
346
+ ideMenu.addEventListener('keydown',e=>{
347
+ const it=$$('[role=menuitem]',ideMenu),i=it.indexOf(document.activeElement);
348
+ if(e.key==='ArrowDown'||e.key==='ArrowUp'){e.preventDefault();it[(i+(e.key==='ArrowDown'?1:it.length-1))%it.length].focus();}
349
+ });
350
+ document.addEventListener('click',e=>{if(!ideMenu.hidden&&!e.target.closest('#ideWrap'))closeIde(false);});
351
+
284
352
  /* ---------------- palette + keys ---------------- */
285
353
  const palVeil=$('#palVeil'),palIn=$('#palIn'),palList=$('#palList');
286
354
  function items(q){q=q.toLowerCase();
@@ -300,8 +368,8 @@ document.addEventListener('keydown',e=>{
300
368
  const mod=e.metaKey||e.ctrlKey;const inField=/INPUT|SELECT|TEXTAREA/.test(e.target.tagName);
301
369
  if(mod&&e.key.toLowerCase()==='k'){e.preventDefault();palVeil.classList.contains('open')?closePal():openPal();return}
302
370
  if(mod&&/^[1-9]$/.test(e.key)){e.preventDefault();const n=NAV[+e.key-1];if(n)go(n[0],false,n[1]);return}
303
- if(e.key==='Escape'){hideTip();closeInsp();closePal();closeSheet();if(chat&&chat.st.editing&&!chatBusy){chat.st.editing=null;comp=null;drawChat();}setNav(false);return}
304
- if(inField||mod||e.altKey)return;
371
+ 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}
372
+ if(inField||mod||e.altKey||taskVeil.classList.contains('open'))return;
305
373
  if(e.key==='h'&&TOKEN&&!openVeil.classList.contains('open')){go('home');return;}
306
374
  if(/^[1-9]$/.test(e.key)){const n=NAV[+e.key-1];if(n)go(n[0],false,n[1]);}
307
375
  if((e.key==='j'||e.key==='k')&&curView==='board'){const rows=$$((mode==='board'?'#boardMode':'#listMode')+' .row[data-col]');if(!rows.length)return;let i=rows.findIndex(r=>r.dataset.col+':'+r.dataset.i===selected);i=e.key==='j'?Math.min(rows.length-1,i+1):Math.max(0,i-1);if(i<0)i=0;openTask(rows[i].dataset.col,+rows[i].dataset.i);rows[i].scrollIntoView({block:'nearest'});rows[i].focus();}
@@ -362,6 +430,47 @@ async function move(col,i,toSection,toIndex,isUndo){
362
430
  }else toast(body.error||`The move was not made (HTTP ${r.status}).`);
363
431
  }
364
432
 
433
+ /* ---------------- new task (BL-PM-005) ----------------
434
+ The server appends one row, `| <ID> | <description> |`, to the chosen section and picks the ID.
435
+ The description goes as typed; a refusal is shown in the form with what was typed kept. */
436
+ const taskVeil=$('#taskVeil'),taskIn=$('#taskIn');
437
+ let taskSection='backlog',adding=false;
438
+ function setTaskSection(s){taskSection=s;$$('#taskSec button').forEach(b=>{const on=b.dataset.s===s;b.classList.toggle('on',on);b.setAttribute('aria-pressed',on);});}
439
+ function taskError(m){const e=$('#taskErr');e.textContent=m||'';e.hidden=!m;}
440
+ function openNewTask(){if(!TOKEN||!DATA||!DATA.tasks)return;hideTip();taskIn.value='';taskError('');setTaskSection('backlog');taskVeil.classList.add('open');setTimeout(()=>taskIn.focus(),50);}
441
+ function closeNewTask(){if(!taskVeil.classList.contains('open')||adding)return;taskVeil.classList.remove('open');$('#newTask').focus();}
442
+ async function addTask(){
443
+ if(adding)return;
444
+ if(!taskIn.value.trim()){taskError('Type a description for the task.');taskIn.focus();return;}
445
+ const p=PROJECT,section=taskSection;
446
+ adding=true;$('#taskGo').disabled=true;taskError('');
447
+ let r,body={};
448
+ try{
449
+ r=await fetch('/api/tasks/new?'+pq(),{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN,'If-Match':DATA.tasks.sha256},body:JSON.stringify({description:taskIn.value,section})});
450
+ body=await r.json().catch(()=>({}));
451
+ }catch(e){r=null;}
452
+ adding=false;$('#taskGo').disabled=false;
453
+ if(!r){taskError('The server did not answer. Nothing was added.');return;}
454
+ if(p!==PROJECT)return;
455
+ if(r.status===200){
456
+ if(section==='backlog'&&body.index>=6)showAllBacklog=true;
457
+ taskVeil.classList.remove('open');
458
+ await apply(body.specs,['.specs/planning/tasks.md']);
459
+ $('#newTask').focus(); // what closing the inspector returns to
460
+ openTask(section,body.index);
461
+ const el=$(`${mode==='board'?'#boardMode':'#listMode'} .row[data-col="${section}"][data-i="${body.index}"]`);if(el)el.scrollIntoView({block:'nearest'});
462
+ toast(`${body.id} added to ## ${COLS[section]} in planning/tasks.md`);
463
+ return;
464
+ }
465
+ if(r.status===409&&body.specs)await apply(body.specs,null);
466
+ taskError(body.error||`The task was not added (HTTP ${r.status}).`);taskIn.focus();
467
+ }
468
+ $('#newTask').onclick=openNewTask;
469
+ $$('#taskSec button').forEach(b=>b.onclick=()=>setTaskSection(b.dataset.s));
470
+ $('#taskCancel').onclick=closeNewTask;
471
+ taskVeil.onclick=e=>{if(e.target===taskVeil)closeNewTask();};
472
+ $('#taskForm').onsubmit=e=>{e.preventDefault();addTask();};
473
+
365
474
  /* ---------------- setup chat (BL-055, BL-PM-004) ----------------
366
475
  The init.specpilot.dev chat over the CLI's own questions: for a new project (#new) and for a named
367
476
  folder with no .specs/ yet (its setup view). The questions, their chat lines, choices, steps and file
@@ -385,21 +494,17 @@ async function getQuestions(url){
385
494
  /* The page's own question of a new project; every other one is the server's or the chat core's. */
386
495
  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'};
387
496
  const CC=window.SpecPilotChat; // the chat core (BL-PM-004b): src/core/chatFlow.ts, served as /assets/chat-core.js
388
- /* Saved setups (BL-PM-004b): every setup the chat has started, kept in this browser under sp-setups. */
389
- let storeOk=true,setups=[];
390
- try{setups=setupsLoad(localStorage.getItem(SETUPS_KEY));}catch(e){storeOk=false;}
391
- function storeSetups(){try{localStorage.setItem(SETUPS_KEY,JSON.stringify(setups));}catch(e){storeOk=false;}}
392
- function saveSetup(st){if(!st.started)return;st.updatedAt=Date.now();setups=setupsPut(setups,setupRecord(st));storeSetups();}
393
- function dropSetup(id){setups=setupsRemove(setups,id);storeSetups();}
394
- 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});
395
- const restoreSetup=e=>({...JSON.parse(JSON.stringify(e)),editing:null});
497
+ /* Answers live in the page only: saved setups were removed on purpose (BL-PM-016); a key an older page left is removed once. */
498
+ try{localStorage.removeItem('sp-setups');}catch(e){}
499
+ // `seed`: what the detector filled in for guided setup (REQ-002.H.35), a normal answer the user can change
500
+ 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});
396
501
  const live={}; // the setups open in this page, by id
397
502
  let curNew=null; // the new-project setup #new shows
398
503
  let chat=null,chatBusy=false,comp=null;
399
504
  /* Shown by go(): the chat for a new project, or for the project without .specs/. */
400
505
  async function renderChat(isNew){
401
506
  const pj=PROJECT,note=$('#chatNote');
402
- $('#intro').hidden=$('#thread').hidden=$('#composer').hidden=note.hidden=true;$('#chatRestart').hidden=$('#chatClose').hidden=$('#chatSetups').hidden=true;$('#cbody').hidden=true;
507
+ $('#intro').hidden=$('#thread').hidden=$('#composer').hidden=note.hidden=true;$('#chatRestart').hidden=$('#chatClose').hidden=true;$('#cbody').hidden=true;
403
508
  chat=null;comp=null;
404
509
  if(!TOKEN){note.textContent='Started with --read-only, so nothing can be set up here.';note.hidden=false;return;}
405
510
  const q=await getQuestions(isNew?'/api/projects/new':'/api/setup?project='+pj);
@@ -408,11 +513,11 @@ async function renderChat(isNew){
408
513
  if(q.error){note.textContent=q.error;note.hidden=false;return;}
409
514
  let st;
410
515
  if(isNew){
411
- 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;}
516
+ if(!curNew||!live[curNew]){st=freshSetup('new');curNew=st.id;live[st.id]=st;}
412
517
  st=live[curNew];
413
518
  }else{
414
- const root=DATA.projects[pj].root,id='s:'+root,rec=setups.find(e=>e.id===id);
415
- st=live[id]||(live[id]=rec?restoreSetup(rec):freshSetup('setup',root));
519
+ const root=DATA.projects[pj].root,id='s:'+root;
520
+ st=live[id]||(live[id]=freshSetup('setup',root,id,seededAnswers(q.detected)));
416
521
  }
417
522
  chat={id:st.id,isNew,project:pj,q,st};
418
523
  $('#cbody').hidden=false;
@@ -428,27 +533,20 @@ function chatCtx(){
428
533
  const a=chat.st.answers,lq=chat.q.questions.find(x=>x.key==='language'),c=lq&&lq.choices.find(x=>x.value===a.language);
429
534
  return {name:chat.isNew?a.name:projectLabel(DATA.projects[chat.project]),language:c?c.name:(chat.q.detected?chat.q.detected.language:'')};
430
535
  }
431
- /* The list of saved setups beside the thread. */
432
- function drawSetups(){
433
- const el=$('#setupList');
434
- if(!storeOk){el.innerHTML='<p class="note">Setups cannot be saved in this browser.</p>';return;}
435
- const served=root=>DATA.projects.findIndex(p=>p.root===root);
436
- el.innerHTML=setups.length?setups.map(e=>{
437
- const off=e.kind==='setup'&&served(e.root)<0,t=setupTitle(e);
438
- 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>`;
439
- }).join(''):'<p class="note">No saved setups yet.</p>';
440
- }
536
+ /* What the detector filled in, for threadRows() and recapCards(): its rows, and the seeded answers not changed since. */
537
+ const chatDet=()=>chat.isNew?null:{rows:chat.q.detected?chat.q.detected.rows||[]:[],keys:detectedKeys(chat.st.seed,chat.st.answers)};
441
538
  function drawChat(){
442
539
  const st=chat.st,isNew=chat.isNew,ctx=chatCtx();
443
- $('#chatRestart').hidden=!st.started;$('#chatClose').hidden=!isNew;$('#chatSetups').hidden=false;
540
+ $('#chatRestart').hidden=!st.started;$('#chatClose').hidden=!isNew;
444
541
  $('#title').textContent=isNew?(st.answers.name||'New project'):projectLabel(DATA.projects[chat.project]);
445
- drawSetups();
446
542
  if(!st.started){ // the intro
447
543
  $('#intro').hidden=false;$('#thread').hidden=$('#composer').hidden=true;$('#chatSub').textContent='';$('#barI').style.width='0';$('#v-chat .bar').setAttribute('aria-valuenow','0');
448
544
  const mono=t=>`<span class="mono" translate="no">${esc(t)}</span>`;
449
- $('#introH').textContent=isNew?"Hey, I'm SpecPilot 👋":"Hey, I'm SpecPilot";
450
- $('#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.'
451
- :`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.`;
545
+ // guided setup opens with its paragraph as the heading and no fine print (BL-PM-016); the New Project intro is as before
546
+ 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.`;
547
+ $('#introH').innerHTML=isNew?"Hey, I'm SpecPilot 👋":setupLine;$('#introH').classList.toggle('para',!isNew);
548
+ $('#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.':'';
549
+ $('#introFine').hidden=!isNew;
452
550
  $('#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.`;
453
551
  const det=$('#introDetected');det.hidden=!(chat.q.detected);det.textContent=chat.q.detected?chat.q.detected.line:'';
454
552
  $('#nameLbl').hidden=$('#nameIn').parentElement.hidden=!isNew;$('#setupStart').hidden=isNew;$('#nameErr').textContent='';
@@ -458,17 +556,19 @@ function drawChat(){
458
556
  }
459
557
  $('#intro').hidden=true;$('#thread').hidden=$('#composer').hidden=false;
460
558
  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;
461
- if(st.finished!==!cur){st.finished=!cur;saveSetup(st);drawSetups();}
559
+ st.finished=!cur;
462
560
  const bar=$('#v-chat .bar'),pct=Math.round(done/list.length*100);$('#barI').style.width=pct+'%';bar.setAttribute('aria-valuenow',pct);
463
561
  $('#chatSub').textContent=cur?`Step ${steps.indexOf(cur.step)+1} of ${steps.length} · ${cur.step}`:'Review';
464
- let html=threadRows(chat.q,list,st.answers,cur,ctx,isNew).map(r=>
562
+ const det=chatDet(),detTag='<span class="det">detected</span>';
563
+ let html=threadRows(chat.q,list,st.answers,cur,ctx,isNew,det).map(r=>
465
564
  r.kind==='divider'?`<div class="divider"><span>${esc(r.text)}</span></div>`
466
565
  :r.kind==='note'?`<p class="cnote">${esc(r.text)}</p>`
467
566
  :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>`
468
- :`<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('');
567
+ :r.key===null?`<div class="me fixed"><span class="b">${esc(r.text)}</span>${detTag}</div>` // detected, not editable
568
+ :`<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('');
469
569
  if(!cur){
470
570
  const files=previewFiles(chat.q,st.answers),pv=st.preview,again=pv.done&&pv.changed;
471
- 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>`;
571
+ 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>`;
472
572
  }
473
573
  $('#msgs').innerHTML=html;
474
574
  const pvEl=$('#pv');if(pvEl)pvEl.addEventListener('toggle',()=>{if(pvEl.open)loadPreview();});
@@ -493,7 +593,7 @@ async function loadPreview(){
493
593
  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;}
494
594
  const kept=new Set(res.kept||[]);
495
595
  $('#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>`;
496
- if(c.st.preview.changed||!c.st.preview.done){c.st.preview={done:true,changed:false};saveSetup(c.st);}
596
+ if(c.st.preview.changed||!c.st.preview.done)c.st.preview={done:true,changed:false};
497
597
  const chg=$('#msgs .chg');if(chg)chg.remove();const sum=$('#pv summary');if(sum)sum.textContent=`Preview files (${res.files.length})`;
498
598
  }
499
599
 
@@ -560,7 +660,7 @@ function chatAnswer(cur,value){
560
660
  if(cur.seed!==undefined&&JSON.stringify(value)===JSON.stringify(cur.seed))st.seeded[cur.key]=value;else delete st.seeded[cur.key];
561
661
  const r=CC.reseed(chatAsk(),st.answers,st.seeded);st.answers=r.answers;st.seeded=r.seeded;
562
662
  if(st.preview.done)st.preview.changed=true;
563
- st.editing=null;comp=null;saveSetup(st);drawChat();
663
+ st.editing=null;comp=null;drawChat();
564
664
  }
565
665
  function chatEdit(key){
566
666
  if(chatBusy)return;
@@ -583,7 +683,7 @@ async function chatCreate(){
583
683
  if(chat!==c)return; // the view changed meanwhile
584
684
  btn.disabled=false;
585
685
  if(!r){err.textContent=c.isNew?'The server did not answer.':'The server did not answer. Nothing was set up.';return;}
586
- const done=()=>{dropSetup(c.st.id);delete live[c.st.id];if(curNew===c.st.id)curNew=null;};
686
+ const done=()=>{delete live[c.st.id];if(curNew===c.st.id)curNew=null;};
587
687
  if(c.isNew){
588
688
  const o=openOutcome(r.status,res,true);
589
689
  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;}
@@ -608,7 +708,7 @@ $('#introForm').onsubmit=e=>{
608
708
  if(problem){$('#nameErr').textContent=problem;$('#nameIn').focus();return;}
609
709
  chat.st.answers.name=v;
610
710
  }
611
- chat.st.started=true;chat.st.editing=null;saveSetup(chat.st);drawChat();
711
+ chat.st.started=true;chat.st.editing=null;drawChat();
612
712
  };
613
713
  $('#nameIn').addEventListener('input',()=>{$('#nameGo').disabled=!$('#nameIn').value.trim();$('#nameErr').textContent='';});
614
714
  $('#setupStart').onclick=()=>$('#introForm').requestSubmit();
@@ -660,24 +760,7 @@ $('#msgs').addEventListener('click',e=>{
660
760
  if(e.target.id==='chatCreate'){chatCreate();return;}
661
761
  const b=e.target.closest('[data-k]');if(b)chatEdit(b.dataset.k);
662
762
  });
663
- $('#setupList').addEventListener('click',e=>{
664
- if(chatBusy)return;
665
- const rm=e.target.closest('[data-rm-setup]');
666
- if(rm){
667
- if(!confirm('Remove this setup?'))return;
668
- const id=rm.dataset.rmSetup;dropSetup(id);delete live[id];
669
- if(chat&&chat.st.id===id){if(curNew===id)curNew=null;renderChat(chat.isNew);}else drawSetups();
670
- return;
671
- }
672
- const b=e.target.closest('[data-setup]');if(!b)return;
673
- const s=setups.find(x=>x.id===b.dataset.setup);if(!s)return;
674
- $('#cbody').classList.remove('lst');
675
- if(s.kind==='new'){curNew=s.id;if(curView==='new')renderChat(true);else go('new');return;}
676
- const i=DATA.projects.findIndex(p=>p.root===s.root);if(i>=0)location.hash='#'+i+'/board';
677
- });
678
- $('#setupNew').onclick=()=>{if(chatBusy)return;curNew=null;$('#cbody').classList.remove('lst');if(curView==='new')renderChat(true);else go('new');};
679
- $('#chatSetups').onclick=()=>$('#cbody').classList.toggle('lst');
680
- $('#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();};
763
+ $('#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();};
681
764
  $('#chatClose').onclick=()=>{if(!chatBusy)go('home');};
682
765
 
683
766
  /* ---------------- live reload (BL-052) ----------------
@@ -712,7 +795,7 @@ async function redraw(paths){
712
795
  if(p!==PROJECT)return; // switched projects meanwhile
713
796
  // The poller's echo of a move this page just made: same tasks.md hash, nothing to redraw.
714
797
  if(paths&&paths.length&&paths.every(p=>p==='.specs/planning/tasks.md')&&DATA&&DATA.tasks&&d.tasks&&d.tasks.sha256===DATA.tasks.sha256)return;
715
- await apply(d,paths);
798
+ await apply(d,paths);document.documentElement.dataset.rev=+(document.documentElement.dataset.rev||0)+1; // live reloads drawn: the browser tests wait on it
716
799
  }
717
800
  /* Draw a fresh /api/specs payload in place: same route, scroll, inspector, selection and focus. */
718
801
  async function apply(d,paths){
@@ -743,6 +826,7 @@ function listen(){
743
826
  if(!window.EventSource)return;
744
827
  if(es)es.close(); // one stream, for the shown project
745
828
  es=new EventSource('/api/events?'+pq());let dropped=false;
829
+ es.addEventListener('clone',e=>onCloneEvent(e.data));
746
830
  es.addEventListener('change',e=>{let paths=null;try{paths=JSON.parse(e.data).paths;}catch(_){}refresh(Array.isArray(paths)?paths:null);});
747
831
  es.onerror=()=>{dropped=true;}; // EventSource retries by itself
748
832
  es.onopen=()=>{if(dropped){dropped=false;refresh(null);}}; // catch up on anything missed
@@ -760,7 +844,7 @@ async function switchProject(n,keepRoute){
760
844
  /* Draw project PROJECT from payload d: the tail of a switch, also used with the payload an open returns (BL-067). */
761
845
  function showProject(d,keepRoute){
762
846
  Object.keys(fileCache).forEach(k=>{delete fileCache[k];});secShown.clear();
763
- DATA=d;selected=null;
847
+ DATA=d;selected=null;setRegenNote([]);
764
848
  renderProject();renderTasks();renderIde();renderAgentFiles();listen();
765
849
  if(keepRoute)route();else go('board');
766
850
  }
@@ -776,8 +860,21 @@ $('#projList').addEventListener('click',e=>{const b=e.target.closest('[data-proj
776
860
  file content; the strings are the ones REQ-002.H.21, H.24 and H.26 list. */
777
861
  const openVeil=$('#openVeil'),addBtn=$('#addBtn'),pathIn=$('#pathIn');
778
862
  const TABS=['folder','clone'],GO={folder:'Open',clone:'Clone Repository'};
779
- let openBusy=false,sheetFrom=addBtn,sheetTab='folder',cloneCtl=null,cloneNamed=false,cloneTick=null;
780
- if(TOKEN){addBtn.hidden=false;homeBtn.hidden=false;$('#rail>.logo').remove();} // the Home tile takes the logo's place (BL-PM-001)
863
+ let openBusy=false,sheetFrom=$('#homeOpen'),sheetTab='folder',cloneCtl=null,cloneNamed=false,cloneTick=null,cloneT0=0,cloneProg=null;
864
+ 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)
865
+ /* Connect Your AI IDE (BL-PM-007): the config line for this server's /mcp, only with --mcp. No status:
866
+ the page cannot know whether an IDE uses it. `env`: the token is SPECPILOT_MCP_TOKEN, so the line names it. */
867
+ const MCP=(document.querySelector('meta[name="specpilot-mcp"]')||{}).content||null;
868
+ if(TOKEN&&MCP){
869
+ const env=MCP==='env';
870
+ $('#mcpLine').textContent=mcpConfigLine(location.host,env?'${SPECPILOT_MCP_TOKEN}':TOKEN);
871
+ $('#mcpNote').textContent=env
872
+ ?'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.'
873
+ :'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.';
874
+ $('#homeMcp').hidden=false;
875
+ $('#mcpCopy').onclick=()=>(navigator.clipboard?navigator.clipboard.writeText($('#mcpLine').textContent):Promise.reject())
876
+ .then(()=>toast('Copied.'),()=>toast('Could not copy. Select the line and copy it.'));
877
+ }
781
878
  function openSheet(from,tab){
782
879
  hideTip();sheetFrom=from;openVeil.classList.add('open');
783
880
  $$('#openForm .field input').forEach(el=>{el.value='';});cloneNamed=false;
@@ -792,7 +889,7 @@ function setTab(t){
792
889
  }
793
890
  function closeSheet(){if(!openVeil.classList.contains('open'))return;if(cloneCtl)cloneCtl.abort();openVeil.classList.remove('open');sheetFrom.focus();}
794
891
  /* The registry as GET /api/projects sends it: in the sheet, or on Home (BL-PM-001), where a row opens
795
- its folder at once, has no Remove, and a served project also shows the branch the rail tooltip shows. */
892
+ its folder at once and a served project also shows the branch the rail tooltip shows. */
796
893
  function drawRecent(reg,home){
797
894
  $(home?'#homePath':'#recentPath').textContent=reg.path||'';
798
895
  $(home?'#homeBox':'#recentBox').innerHTML=recentHtml(reg,home,DATA?DATA.projects:[],chev);
@@ -834,11 +931,25 @@ function setCloning(ctl){
834
931
  cloneCtl=ctl;openBusy=!!ctl;
835
932
  $('#openGo').disabled=!!ctl;
836
933
  $$('#paneClone input, #openTabs button').forEach(el=>{el.disabled=!!ctl;});
837
- // An indeterminate bar and the time since the click: the page knows nothing else about a running clone.
838
- clearInterval(cloneTick);cloneTick=null;$('#cloneStatus').hidden=!ctl;
934
+ // The time since the click, and an indeterminate bar until git gives a percentage (BL-PM-009).
935
+ clearInterval(cloneTick);cloneTick=null;cloneProg=null;$('#cloneStatus').hidden=!ctl;
839
936
  if(!ctl)return;
840
- 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')}`;};
841
- tick();cloneTick=setInterval(tick,1000);
937
+ cloneT0=Date.now();drawCloning();cloneTick=setInterval(drawCloning,1000);
938
+ }
939
+ function drawCloning(){
940
+ const bar=$('#cloneStatus .bar'),p=cloneProg;
941
+ $('#cloneTime').textContent=cloneStatus(Math.floor((Date.now()-cloneT0)/1000),p);
942
+ bar.classList.toggle('det',!!p);
943
+ if(p){
944
+ bar.setAttribute('aria-valuemin','0');bar.setAttribute('aria-valuemax','100');bar.setAttribute('aria-valuenow',String(p.percent));
945
+ bar.setAttribute('aria-valuetext',`${CLONE_STAGES[p.stage]} ${p.percent}%`);bar.style.setProperty('--pct',p.percent+'%');
946
+ }else{['aria-valuemin','aria-valuemax','aria-valuenow','aria-valuetext'].forEach(a=>bar.removeAttribute(a));bar.style.removeProperty('--pct');}
947
+ }
948
+ /* A `clone` event from the stream: only while this page is cloning (not another tab's clone, not after the answer). */
949
+ function onCloneEvent(data){
950
+ const p=cloneProgress(data);
951
+ if(!cloneCtl||!p)return;
952
+ cloneProg=p;drawCloning();
842
953
  }
843
954
  async function cloneRepo(){
844
955
  if(openBusy)return;
@@ -858,7 +969,7 @@ async function removeRecent(path){
858
969
  try{out=await postPath(path,'/api/projects/remove');}catch(e){toast('The server did not answer.');return;}
859
970
  if(out.r.status===200){drawRecent(out.res);if(curView==='home')drawRecent(out.res,true);}else toast(out.res.error||`Nothing was removed (HTTP ${out.r.status}).`);
860
971
  }
861
- addBtn.onclick=()=>openSheet(addBtn);
972
+ addBtn.onclick=()=>{go('home');$('#homeOpen').focus();}; // every new project starts from Home (BL-PM-014); only Home's buttons open the sheet
862
973
  homeBtn.onclick=()=>go('home');
863
974
  $('#homeOpen').onclick=e=>openSheet(e.currentTarget);
864
975
  $('#homeNew').onclick=()=>go('new');
@@ -872,7 +983,10 @@ $('#openTabs').addEventListener('keydown',e=>{
872
983
  e.preventDefault();const n=TABS.length,i=TABS.indexOf(sheetTab),t=TABS[e.key==='Home'?0:e.key==='End'?n-1:(i+(e.key==='ArrowLeft'?n-1:1))%n];
873
984
  setTab(t);$(`#openTabs [data-t="${t}"]`).focus();
874
985
  });
875
- $('#homeBox').addEventListener('click',e=>{const row=e.target.closest('[data-path]');if(row)openPath(row.dataset.path);});
986
+ $('#homeBox').addEventListener('click',e=>{
987
+ const rm=e.target.closest('[data-remove]');if(rm){removeRecent(rm.dataset.remove);return;}
988
+ const row=e.target.closest('[data-path]');if(row)openPath(row.dataset.path);
989
+ });
876
990
  $('#openCancel').onclick=closeSheet;
877
991
  openVeil.onclick=e=>{if(e.target===openVeil)closeSheet();};
878
992
  $('#openForm').onsubmit=e=>{e.preventDefault();if(sheetTab==='clone')cloneRepo();else openPath(pathIn.value.trim());};