specpilot 2.6.0 → 2.7.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 (45) hide show
  1. package/README.md +7 -5
  2. package/dist/cli.js +2 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/add-specs.d.ts.map +1 -1
  5. package/dist/commands/add-specs.js +17 -46
  6. package/dist/commands/add-specs.js.map +1 -1
  7. package/dist/commands/init.d.ts.map +1 -1
  8. package/dist/commands/init.js +3 -0
  9. package/dist/commands/init.js.map +1 -1
  10. package/dist/commands/serve.d.ts +5 -1
  11. package/dist/commands/serve.d.ts.map +1 -1
  12. package/dist/commands/serve.js +21 -8
  13. package/dist/commands/serve.js.map +1 -1
  14. package/dist/utils/addSpecsQuestions.d.ts +34 -0
  15. package/dist/utils/addSpecsQuestions.d.ts.map +1 -0
  16. package/dist/utils/addSpecsQuestions.js +55 -0
  17. package/dist/utils/addSpecsQuestions.js.map +1 -0
  18. package/dist/utils/agentConfigGenerator.d.ts +2 -0
  19. package/dist/utils/agentConfigGenerator.d.ts.map +1 -1
  20. package/dist/utils/agentConfigGenerator.js +23 -14
  21. package/dist/utils/agentConfigGenerator.js.map +1 -1
  22. package/dist/utils/ideConfigGenerator.d.ts +5 -3
  23. package/dist/utils/ideConfigGenerator.d.ts.map +1 -1
  24. package/dist/utils/ideConfigGenerator.js +37 -36
  25. package/dist/utils/ideConfigGenerator.js.map +1 -1
  26. package/dist/utils/slashCommandGenerator.d.ts +7 -0
  27. package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
  28. package/dist/utils/slashCommandGenerator.js +16 -6
  29. package/dist/utils/slashCommandGenerator.js.map +1 -1
  30. package/dist/utils/specGenerator.d.ts +6 -0
  31. package/dist/utils/specGenerator.d.ts.map +1 -1
  32. package/dist/utils/specGenerator.js +14 -0
  33. package/dist/utils/specGenerator.js.map +1 -1
  34. package/dist/utils/specServer.d.ts +5 -2
  35. package/dist/utils/specServer.d.ts.map +1 -1
  36. package/dist/utils/specServer.js +78 -13
  37. package/dist/utils/specServer.js.map +1 -1
  38. package/dist/utils/specSetup.d.ts +59 -0
  39. package/dist/utils/specSetup.d.ts.map +1 -0
  40. package/dist/utils/specSetup.js +288 -0
  41. package/dist/utils/specSetup.js.map +1 -0
  42. package/package.json +1 -1
  43. package/ui/app.css +10 -0
  44. package/ui/app.js +70 -3
  45. package/ui/index.html +9 -0
package/ui/app.js CHANGED
@@ -53,7 +53,7 @@ function renderProject(){
53
53
  }
54
54
 
55
55
  /* ---------------- views ---------------- */
56
- const VIEWS={board:'Tasks',explorer:'Explorer',security:'Security',instructions:'Instructions',commands:'Commands',skills:'Skills'};
56
+ const VIEWS={board:'Tasks',explorer:'Explorer',security:'Security',instructions:'Instructions',commands:'Commands',skills:'Skills',setup:''};
57
57
  const TITLES={'planning/roadmap.md':'Roadmap','project/requirements.md':'Requirements','architecture/architecture.md':'Architecture','quality/tests.md':'Tests'};
58
58
  const NAV=[['board'],['file','planning/roadmap.md'],['file','project/requirements.md'],['explorer'],['file','architecture/architecture.md'],['file','quality/tests.md'],['security'],['instructions'],['commands'],['skills']];
59
59
  let curView='board',curFile='';
@@ -64,13 +64,16 @@ function syncNav(){
64
64
  }
65
65
  function go(v,keep,sub){
66
66
  if(v==='file'){if(!DATA||!sub)v='board';else curFile=sub;}
67
- else if(!VIEWS[v])v='board';
67
+ else if(!VIEWS[v]||v==='setup')v='board';
68
+ if(DATA&&DATA.project.specs===false)v='setup'; // no .specs/ yet: every route shows the setup view (BL-055)
68
69
  curView=v;
69
70
  $$('.content>.view').forEach(e=>e.classList.toggle('on',e.id==='v-'+v));
70
71
  syncNav();
71
- $('#title').textContent=v==='file'?(TITLES[sub]||sub):VIEWS[v];
72
+ $('#title').textContent=v==='file'?(TITLES[sub]||sub):v==='setup'?'No .specs/ folder in '+DATA.projects[PROJECT].root:VIEWS[v];
72
73
  $('#modeSeg').hidden=v!=='board';
73
74
  setNav(false);closeInsp();
75
+ if(v!=='file'||sub!==fileNoteFor)clearFileNote();
76
+ if(v==='setup')renderSetup();
74
77
  if(v==='file')renderFile(sub);
75
78
  if(v==='explorer')renderExplorer();
76
79
  if(v==='security')renderSecurity();
@@ -346,6 +349,67 @@ async function move(col,i,toSection,toIndex,isUndo){
346
349
  }else toast(body.error||`The move was not made (HTTP ${r.status}).`);
347
350
  }
348
351
 
352
+ /* ---------------- guided setup (BL-055) ----------------
353
+ A named folder with no .specs/ yet. The questions, their choices and the detected line come from
354
+ GET /api/setup, which serves the CLI's own text; the page adds only the strings REQ-002.H.17 lists. */
355
+ let setupQ=null,setupBusy=false,fileNoteFor=null;
356
+ function clearFileNote(){const n=$('#fileNote');n.hidden=true;n.innerHTML='';fileNoteFor=null;}
357
+ function setFileNote(path,lines){const n=$('#fileNote');n.innerHTML=lines.map(l=>`<p class="note" translate="no">${esc(l)}</p>`).join('');n.hidden=false;fileNoteFor=path;}
358
+ async function renderSetup(){
359
+ const pj=PROJECT,intro=$('#setupIntro'),det=$('#setupDetected'),form=$('#setupForm'),note=$('#setupNote');
360
+ intro.hidden=det.hidden=form.hidden=note.hidden=true;form.innerHTML='';
361
+ if(!TOKEN){note.textContent='Started with --read-only, so nothing can be set up here.';note.hidden=false;return;}
362
+ let r,q=null;
363
+ try{r=await fetch('/api/setup?'+pq(),{cache:'no-store'});if(r.ok)q=await r.json();else if(r.status!==404)q={error:(await r.json().catch(()=>({}))).error||'HTTP '+r.status};}
364
+ catch(e){q={error:'The server did not answer.'};}
365
+ if(PROJECT!==pj||curView!=='setup')return;
366
+ if(!q)return; // 404: not a folder named on the command line, so no form
367
+ if(q.error){note.textContent=q.error;note.hidden=false;return;}
368
+ setupQ=q;intro.hidden=false;
369
+ if(q.detected){det.textContent=q.detected.line;det.hidden=false;}
370
+ form.innerHTML=q.questions.map(qu=>{
371
+ const body=qu.key==='handle'
372
+ ?`<input type="text" name="handle" aria-label="handle" maxlength="39">`
373
+ :qu.choices?qu.choices.map((c,i)=>`<label><input type="radio" name="${esc(qu.key)}" value="${esc(c.value)}"${i===0?' checked':''}>${esc(c.name)}</label>`).join('')
374
+ :'';
375
+ return `<fieldset data-key="${esc(qu.key)}"><legend>${esc(qu.message)}</legend><div class="opts">${body}</div>${qu.key==='ide'?'<div class="keep" id="setupKeep" hidden translate="no"></div>':''}</fieldset>`;
376
+ }).join('')+'<button type="submit" class="go">Create .specs/</button>';
377
+ form.hidden=false;
378
+ const sync=()=>{
379
+ const lang=form.language?form.language.value:null,fw=form.querySelector('fieldset[data-key="framework"]');
380
+ if(fw&&q.frameworks){const list=lang&&q.frameworks[lang]||[];fw.hidden=!list.length;
381
+ fw.querySelector('.opts').innerHTML=list.map((v,i)=>`<label><input type="radio" name="framework" value="${esc(v)}"${i===0?' checked':''}>${esc(v)}</label>`).join('');}
382
+ const ide=form.ide.value,keep=(q.keep&&q.keep[ide])||[],k=$('#setupKeep');
383
+ k.hidden=!keep.length;k.textContent=keep.length?'Already here, will be kept: '+keep.join(', '):'';
384
+ };
385
+ form.onchange=sync;sync();
386
+ form.onsubmit=e=>{e.preventDefault();submitSetup(form);};
387
+ }
388
+ async function submitSetup(form){
389
+ if(setupBusy)return;setupBusy=true;
390
+ const p=PROJECT,root=DATA.projects[PROJECT].root,btn=form.querySelector('button.go');btn.disabled=true;
391
+ const body={};$$('fieldset[data-key]',form).forEach(f=>{if(f.hidden)return;const k=f.dataset.key;const el=form[k];if(el)body[k]=el.value;});
392
+ let r,res={};
393
+ try{
394
+ r=await fetch('/api/setup?'+pq(),{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN},body:JSON.stringify(body)});
395
+ res=await r.json().catch(()=>({}));
396
+ }catch(e){setupBusy=false;btn.disabled=false;toast('The server did not answer. Nothing was set up.');return;}
397
+ setupBusy=false;btn.disabled=false;
398
+ if(p!==PROJECT)return;
399
+ if(r.status===200){
400
+ await apply(res.specs,null);
401
+ toast('.specs/ created in '+root);
402
+ go('file',false,'development/onboarding.md');
403
+ const lines=[];
404
+ if(res.kept&&res.kept.length)lines.push('Kept as they were: '+res.kept.join(', ')+'. Run specpilot backfill there to add missing SpecPilot sections to the instruction and command files.');
405
+ if(res.notice)lines.push(res.notice);
406
+ if(lines.length)setFileNote('development/onboarding.md',lines);
407
+ }else{
408
+ if(r.status===409&&res.specs)await apply(res.specs,null);
409
+ toast(res.error||`Nothing was set up (HTTP ${r.status}).`);
410
+ }
411
+ }
412
+
349
413
  /* ---------------- live reload (BL-052) ----------------
350
414
  On a change event: re-fetch, redraw in place. Route, scroll, open inspector, selected row
351
415
  and focus stay where they were. If the server is gone, the last content stays on screen. */
@@ -386,8 +450,11 @@ async function apply(d,paths){
386
450
  const key=focusKey(document.activeElement);
387
451
  const scroll=$('#content').scrollTop,ib0=insp.querySelector('.ib2'),inspScroll=ib0?ib0.scrollTop:0;
388
452
  const was=inspOpen;
453
+ const hadSpecs=DATA&&DATA.project.specs!==false;
389
454
  DATA=d;
390
455
  renderProject();renderTasks();renderIde();renderAgentFiles();
456
+ if(d.project.specs===false&&curView!=='setup'){go('setup');return;} // .specs/ gone: offer setup
457
+ if(hadSpecs===false&&d.project.specs!==false&&curView==='setup'){go('board');return;} // .specs/ appeared another way
391
458
  if(curView==='file')await renderFile(curFile);
392
459
  if(curView==='explorer')renderExplorer();
393
460
  if(curView==='security')await renderSecurity();
package/ui/index.html CHANGED
@@ -137,8 +137,17 @@
137
137
  <div id="secBody"></div>
138
138
  </section>
139
139
 
140
+ <!-- SETUP (BL-055): a named folder with no .specs/ yet; the questions are the CLI's own -->
141
+ <section class="view" id="v-setup">
142
+ <p class="note" id="setupIntro" hidden>Runs what specpilot add-specs runs in this folder. Existing files are never changed.</p>
143
+ <p class="note" id="setupDetected" hidden translate="no"></p>
144
+ <form class="setup" id="setupForm" hidden autocomplete="off"></form>
145
+ <p class="note" id="setupNote" hidden></p>
146
+ </section>
147
+
140
148
  <!-- FILE: any .specs/ file, rendered as written -->
141
149
  <section class="view" id="v-file">
150
+ <div class="gl" id="fileNote" hidden></div>
142
151
  <div class="gl" id="fmBox"></div>
143
152
  <div class="md doc" id="fileBody"></div>
144
153
  </section>