specpilot 2.3.0 → 2.5.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 (44) hide show
  1. package/README.md +8 -6
  2. package/dist/cli.js +2 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/archive.d.ts.map +1 -1
  5. package/dist/commands/archive.js +5 -1
  6. package/dist/commands/archive.js.map +1 -1
  7. package/dist/commands/backfill.js +20 -7
  8. package/dist/commands/backfill.js.map +1 -1
  9. package/dist/commands/serve.d.ts +1 -0
  10. package/dist/commands/serve.d.ts.map +1 -1
  11. package/dist/commands/serve.js +5 -3
  12. package/dist/commands/serve.js.map +1 -1
  13. package/dist/utils/slashCommandGenerator.d.ts +28 -4
  14. package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
  15. package/dist/utils/slashCommandGenerator.js +363 -37
  16. package/dist/utils/slashCommandGenerator.js.map +1 -1
  17. package/dist/utils/specArchiver.d.ts +22 -0
  18. package/dist/utils/specArchiver.d.ts.map +1 -1
  19. package/dist/utils/specArchiver.js +121 -26
  20. package/dist/utils/specArchiver.js.map +1 -1
  21. package/dist/utils/specBackfiller.d.ts +4 -4
  22. package/dist/utils/specBackfiller.d.ts.map +1 -1
  23. package/dist/utils/specBackfiller.js +4 -4
  24. package/dist/utils/specBackfiller.js.map +1 -1
  25. package/dist/utils/specReader.d.ts +21 -0
  26. package/dist/utils/specReader.d.ts.map +1 -1
  27. package/dist/utils/specReader.js +26 -3
  28. package/dist/utils/specReader.js.map +1 -1
  29. package/dist/utils/specServer.d.ts +5 -0
  30. package/dist/utils/specServer.d.ts.map +1 -1
  31. package/dist/utils/specServer.js +89 -3
  32. package/dist/utils/specServer.js.map +1 -1
  33. package/dist/utils/specValidator.d.ts +3 -1
  34. package/dist/utils/specValidator.d.ts.map +1 -1
  35. package/dist/utils/specValidator.js +44 -11
  36. package/dist/utils/specValidator.js.map +1 -1
  37. package/dist/utils/taskMover.d.ts +50 -0
  38. package/dist/utils/taskMover.d.ts.map +1 -0
  39. package/dist/utils/taskMover.js +131 -0
  40. package/dist/utils/taskMover.js.map +1 -0
  41. package/package.json +1 -1
  42. package/ui/app.css +7 -0
  43. package/ui/app.js +70 -2
  44. package/ui/index.html +1 -0
package/ui/app.js CHANGED
@@ -4,7 +4,13 @@
4
4
  (function(){
5
5
  const $=(s,r=document)=>r.querySelector(s), $$=(s,r=document)=>[...r.querySelectorAll(s)];
6
6
  const toastEl=$('#toast');let toastT;
7
- const toast=m=>{toastEl.textContent=m;toastEl.classList.add('show');clearTimeout(toastT);toastT=setTimeout(()=>toastEl.classList.remove('show'),2600);};
7
+ const toast=(m,action)=>{
8
+ toastEl.textContent=m;toastEl.classList.toggle('has-action',!!action);
9
+ if(action){const b=document.createElement('button');b.type='button';b.className='tact';b.textContent=action.label;b.onclick=()=>{toastEl.classList.remove('show');action.fn();};toastEl.appendChild(b);}
10
+ toastEl.classList.add('show');clearTimeout(toastT);toastT=setTimeout(()=>toastEl.classList.remove('show'),action?8000:2600);};
11
+ /* Task moves (BL-053) are on only when the server put a token in the page (not with --read-only). */
12
+ const TOKEN=(document.querySelector('meta[name="specpilot-token"]')||{}).content||null;
13
+ const MOVABLE={backlog:true,currentSprint:true};
8
14
  const chev='<svg class="ico chev" aria-hidden="true" focusable="false"><use href="#i-chev"/></svg>';
9
15
 
10
16
  /* theme: dark by default, light is a per-viewer toggle */
@@ -128,7 +134,8 @@ function rowsOf(col){
128
134
  return col==='completed'?items.reverse():items;
129
135
  }
130
136
  function taskRow({t,i},col){
131
- return `<button type="button" class="row act" data-col="${col}" data-i="${i}">
137
+ const mv=TOKEN&&MOVABLE[col];
138
+ return `<button type="button" class="row act" data-col="${col}" data-i="${i}"${mv?' draggable="true" aria-keyshortcuts="Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight"':''}>
132
139
  <span class="st ${DOT[col]}" aria-hidden="true"></span>
133
140
  <div class="body"><div class="ttl clamp">${col==='completed'?`<span class="num" translate="no">${esc(t.num)}</span>`:''}<span class="id" translate="no">${mdi(t.id)}</span>${mdi(t.description)}</div></div>
134
141
  <div class="trail">${chev}</div>
@@ -175,6 +182,7 @@ function openInsp(quiet){insp.classList.add('open');insp.setAttribute('aria-hidd
175
182
  function closeInsp(){const was=insp.classList.contains('open');insp.classList.remove('open');insp.setAttribute('aria-hidden','true');selected=null;inspOpen=null;$$('.row.sel').forEach(r=>r.classList.remove('sel'));if(was&&lastFocus&&lastFocus.focus){lastFocus.focus();lastFocus=null;}}
176
183
  function bind(){
177
184
  $$('#v-board .row[data-col]').forEach(r=>r.onclick=()=>openTask(r.dataset.col,+r.dataset.i));
185
+ if(TOKEN)bindMoves();
178
186
  $$('[data-more]').forEach(b=>b.onclick=e=>{e.stopPropagation();if(b.dataset.more==='completed')showAllDone=true;else showAllBacklog=true;renderTasks();});
179
187
  $$('[data-disc]').forEach(b=>b.onclick=e=>{e.stopPropagation();const g=$('#gDone');g.classList.toggle('closed');b.setAttribute('aria-expanded',!g.classList.contains('closed'));});
180
188
  }
@@ -274,6 +282,60 @@ document.addEventListener('keydown',e=>{
274
282
  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();}
275
283
  });
276
284
 
285
+ /* ---------------- task moves (BL-053) ----------------
286
+ A move is one line of planning/tasks.md cut and pasted unchanged; the server does it and
287
+ answers with the new file hash and the fresh payload. Completed rows never move. */
288
+ let dragging=null,moving=false;
289
+ function bindMoves(){
290
+ $$('#v-board .row[draggable="true"]').forEach(r=>{
291
+ r.ondragstart=e=>{dragging={col:r.dataset.col,i:+r.dataset.i};e.dataTransfer.setData('text/plain',DATA.tasks[dragging.col][dragging.i].id);e.dataTransfer.effectAllowed='move';r.classList.add('drag');};
292
+ r.ondragend=()=>{r.classList.remove('drag');dragging=null;$$('.gl.drop').forEach(g=>g.classList.remove('drop'));};
293
+ r.onkeydown=e=>{
294
+ if(!e.altKey||e.metaKey||e.ctrlKey)return;
295
+ const col=r.dataset.col,i=+r.dataset.i,n=DATA.tasks[col].length;
296
+ const go2={ArrowUp:i>0&&[col,i-1],ArrowDown:i<n-1&&[col,i+1],ArrowRight:col==='backlog'&&['currentSprint',DATA.tasks.currentSprint.length],ArrowLeft:col==='currentSprint'&&['backlog',DATA.tasks.backlog.length]}[e.key];
297
+ if(go2===undefined)return;
298
+ e.preventDefault();
299
+ if(go2)move(col,i,go2[0],go2[1]);
300
+ };
301
+ });
302
+ $$('#v-board .gl[data-col="backlog"],#v-board .gl[data-col="currentSprint"]').forEach(g=>{
303
+ g.ondragover=e=>{if(!dragging)return;e.preventDefault();e.dataTransfer.dropEffect='move';g.classList.add('drop');};
304
+ g.ondragleave=e=>{if(!g.contains(e.relatedTarget))g.classList.remove('drop');};
305
+ g.ondrop=e=>{
306
+ if(!dragging)return;e.preventDefault();g.classList.remove('drop');
307
+ const to=g.dataset.col,src=dragging;dragging=null;
308
+ // Position among the target's rows once the dragged row is out of the way.
309
+ const others=DATA.tasks[to].map((_,j)=>j).filter(j=>!(to===src.col&&j===src.i));
310
+ const over=e.target.closest&&e.target.closest('.row[data-col]');
311
+ let at=others.length;
312
+ if(over&&over.dataset.col===to){const j=+over.dataset.i,k=others.indexOf(j);if(k>=0){const b=over.getBoundingClientRect();at=k+(e.clientY>b.top+b.height/2?1:0);}}
313
+ move(src.col,src.i,to,at);
314
+ };
315
+ });
316
+ }
317
+ async function move(col,i,toSection,toIndex,isUndo){
318
+ const t=DATA.tasks[col][i];if(!t||moving)return;
319
+ moving=true;
320
+ let r,body={};
321
+ try{
322
+ r=await fetch('/api/tasks/move',{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN,'If-Match':DATA.tasks.sha256},body:JSON.stringify({id:t.id,toSection,toIndex})});
323
+ body=await r.json().catch(()=>({}));
324
+ }catch(e){moving=false;toast('The server did not answer. Nothing was moved.');return;}
325
+ moving=false;
326
+ if(r.status===200){
327
+ if(toSection==='backlog'&&toIndex>=6)showAllBacklog=true;
328
+ await apply(body.specs,['.specs/planning/tasks.md']);
329
+ const j=DATA.tasks[toSection].findIndex(x=>x.id===t.id);
330
+ const el=$(`${mode==='board'?'#boardMode':'#listMode'} .row[data-col="${toSection}"][data-i="${j}"]`);if(el)el.focus();
331
+ const msg=col===toSection?`${t.id} moved within ## ${COLS[col]} in planning/tasks.md`:`${t.id} moved from ## ${COLS[col]} to ## ${COLS[toSection]} in planning/tasks.md`;
332
+ toast(msg,isUndo?null:{label:'Undo',fn:()=>{const k=DATA.tasks[toSection].findIndex(x=>x.id===t.id);if(k>=0)move(toSection,k,body.from,body.fromIndex,true);}});
333
+ }else if(r.status===409){
334
+ if(body.specs)await apply(body.specs,null);
335
+ toast(body.error||'planning/tasks.md changed on disk since this page loaded. The move was not made.');
336
+ }else toast(body.error||`The move was not made (HTTP ${r.status}).`);
337
+ }
338
+
277
339
  /* ---------------- live reload (BL-052) ----------------
278
340
  On a change event: re-fetch, redraw in place. Route, scroll, open inspector, selected row
279
341
  and focus stay where they were. If the server is gone, the last content stays on screen. */
@@ -303,6 +365,12 @@ function refresh(paths){refreshing=refreshing.then(()=>redraw(paths)).catch(()=>
303
365
  async function redraw(paths){
304
366
  let d;
305
367
  try{const r=await fetch('/api/specs',{cache:'no-store'});if(!r.ok)return;d=await r.json();}catch(e){return;} // server gone: keep what is shown
368
+ // The poller's echo of a move this page just made: same tasks.md hash, nothing to redraw.
369
+ if(paths&&paths.length&&paths.every(p=>p==='.specs/planning/tasks.md')&&DATA&&DATA.tasks&&d.tasks&&d.tasks.sha256===DATA.tasks.sha256)return;
370
+ await apply(d,paths);
371
+ }
372
+ /* Draw a fresh /api/specs payload in place: same route, scroll, inspector, selection and focus. */
373
+ async function apply(d,paths){
306
374
  (paths||Object.keys(fileCache)).forEach(p=>{delete fileCache[p];});
307
375
  const key=focusKey(document.activeElement);
308
376
  const scroll=$('#content').scrollTop,ib0=insp.querySelector('.ib2'),inspScroll=ib0?ib0.scrollTop:0;
package/ui/index.html CHANGED
@@ -5,6 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <title>SpecPilot Local</title>
7
7
  <meta name="theme-color" content="#0f172a">
8
+ <!-- specpilot-token -->
8
9
  <link rel="icon" href="/assets/favicon.svg" type="image/svg+xml">
9
10
  <link rel="stylesheet" href="/assets/app.css">
10
11
  <script src="/assets/md.js" defer></script>