specpilot 2.2.3 → 2.3.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 +51 -0
  2. package/dist/cli.js +9 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/serve.d.ts +8 -0
  5. package/dist/commands/serve.d.ts.map +1 -0
  6. package/dist/commands/serve.js +66 -0
  7. package/dist/commands/serve.js.map +1 -0
  8. package/dist/utils/markdownSections.d.ts +13 -0
  9. package/dist/utils/markdownSections.d.ts.map +1 -0
  10. package/dist/utils/markdownSections.js +16 -0
  11. package/dist/utils/markdownSections.js.map +1 -0
  12. package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
  13. package/dist/utils/slashCommandGenerator.js +43 -23
  14. package/dist/utils/slashCommandGenerator.js.map +1 -1
  15. package/dist/utils/specArchiver.d.ts +13 -0
  16. package/dist/utils/specArchiver.d.ts.map +1 -1
  17. package/dist/utils/specArchiver.js +57 -33
  18. package/dist/utils/specArchiver.js.map +1 -1
  19. package/dist/utils/specPaths.d.ts +26 -0
  20. package/dist/utils/specPaths.d.ts.map +1 -0
  21. package/dist/utils/specPaths.js +92 -0
  22. package/dist/utils/specPaths.js.map +1 -0
  23. package/dist/utils/specPoller.d.ts +22 -0
  24. package/dist/utils/specPoller.d.ts.map +1 -0
  25. package/dist/utils/specPoller.js +119 -0
  26. package/dist/utils/specPoller.js.map +1 -0
  27. package/dist/utils/specReader.d.ts +30 -0
  28. package/dist/utils/specReader.d.ts.map +1 -0
  29. package/dist/utils/specReader.js +120 -0
  30. package/dist/utils/specReader.js.map +1 -0
  31. package/dist/utils/specServer.d.ts +60 -0
  32. package/dist/utils/specServer.d.ts.map +1 -0
  33. package/dist/utils/specServer.js +259 -0
  34. package/dist/utils/specServer.js.map +1 -0
  35. package/dist/utils/specValidator.d.ts.map +1 -1
  36. package/dist/utils/specValidator.js +5 -13
  37. package/dist/utils/specValidator.js.map +1 -1
  38. package/package.json +11 -4
  39. package/ui/app.css +299 -0
  40. package/ui/app.js +340 -0
  41. package/ui/favicon.svg +25 -0
  42. package/ui/index.html +171 -0
  43. package/ui/md.js +81 -0
  44. package/ui/route.js +25 -0
package/ui/md.js ADDED
@@ -0,0 +1,81 @@
1
+ /* Markdown renderer, ported from the approved mockup. Renders the file as written: no
2
+ summarising, no reordering, no text substitution beyond escaping and inline emphasis.
3
+ Every piece of file text passes through esc() before any tag is added, so raw HTML in
4
+ a spec file is shown as text, never parsed. Loaded as /assets/md.js in the browser and
5
+ required directly by the Jest tests. */
6
+ (function (root) {
7
+ const esc=s=>String(s).replace(/[&<>"]/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c]));
8
+ const ANCHOR=/\[((?:REQ|ARCH|TASKS|ROADMAP|TESTS|SEC|CTX|PROMPT|API|PROJ|FIX|ADR|BL|CS|CD)-[A-Za-z0-9.\-]+)\]/g;
9
+ function inline(t){
10
+ let h=esc(t);
11
+ h=h.replace(/`([^`]+)`/g,(m,c)=>'<code translate="no">'+c+'</code>');
12
+ h=h.replace(/\*\*([^*]+)\*\*/g,'<strong>$1</strong>');
13
+ h=h.replace(/(^|[^*\w])\*([^*\n]+)\*(?=[^*\w]|$)/g,'$1<em>$2</em>');
14
+ h=h.replace(/\[([^\]\[]+)\]\((https?:[^)\s]+|[^)\s]+\.md[^)\s]*)\)/g,'<span class="lk">$1</span>');
15
+ h=h.replace(ANCHOR,m=>'<span class="ref" translate="no">'+m+'</span>');
16
+ return h;
17
+ }
18
+ /* Split a table row into n cells on the first n-1 pipes only; the last cell keeps the rest,
19
+ so a `|` inside backticks in a description survives (same rule as specReader.ts). */
20
+ function cells(line,n){
21
+ let rest=line.trim().replace(/^\|/,'').replace(/\|$/,'');
22
+ if(!n)return rest.split('|').map(c=>c.trim());
23
+ const out=[];
24
+ for(let k=0;k<n-1;k++){const p=rest.indexOf('|');if(p<0)break;out.push(rest.slice(0,p).trim());rest=rest.slice(p+1);}
25
+ out.push(rest.trim());
26
+ return out;
27
+ }
28
+ function md(src){
29
+ const L=String(src).replace(/\r/g,'').split('\n');
30
+ const o=[];let i=0;
31
+ const close=()=>{while(st.length)o.push(st.pop());};
32
+ let st=[];
33
+ while(i<L.length){
34
+ let l=L[i];
35
+ if(/^\s*$/.test(l)){close();i++;continue;}
36
+ let m;
37
+ if(m=l.match(/^(#{1,6})\s+(.*)$/)){close();const n=Math.min(6,m[1].length+1);o.push('<h'+n+'>'+inline(m[2])+'</h'+n+'>');i++;continue;}
38
+ if(/^\s*(---|\*\*\*|___)\s*$/.test(l)){close();o.push('<hr>');i++;continue;}
39
+ if(/^```/.test(l)){close();i++;const b=[];while(i<L.length&&!/^```/.test(L[i])){b.push(L[i]);i++;}i++;o.push('<pre translate="no">'+esc(b.join('\n'))+'</pre>');continue;}
40
+ if(/^>\s?/.test(l)){close();const b=[];while(i<L.length&&/^>\s?/.test(L[i])){b.push(L[i].replace(/^>\s?/,''));i++;}o.push('<blockquote>'+md(b.join('\n'))+'</blockquote>');continue;}
41
+ if(/^\s*\|/.test(l)&&i+1<L.length&&/^\s*\|[\s:|-]+\|?\s*$/.test(L[i+1])){
42
+ close();const head=cells(l);i+=2;const rows=[];
43
+ while(i<L.length&&/^\s*\|/.test(L[i])){rows.push(cells(L[i],head.length));i++;}
44
+ o.push('<div class="tw"><table><thead><tr>'+head.map(c=>'<th>'+inline(c)+'</th>').join('')+'</tr></thead><tbody>'+
45
+ rows.map(r=>'<tr>'+r.map(c=>'<td>'+inline(c)+'</td>').join('')+'</tr>').join('')+'</tbody></table></div>');
46
+ continue;}
47
+ if(m=l.match(/^(\s*)([-*+])\s+(.*)$/)){
48
+ close();const items=[];
49
+ while(i<L.length){
50
+ const mm=L[i].match(/^(\s*)([-*+])\s+(.*)$/);
51
+ if(!mm) {if(/^\s+\S/.test(L[i])&&items.length){items[items.length-1]+=' '+L[i].trim();i++;continue;} break;}
52
+ items.push(mm[3]);i++;
53
+ }
54
+ o.push('<ul>'+items.map(t=>{
55
+ const cb=t.match(/^\[([ xX])\]\s*(.*)$/);
56
+ if(cb)return '<li class="cb '+(cb[1]===' '?'off':'on')+'">'+inline(cb[2])+'</li>';
57
+ return '<li>'+inline(t)+'</li>';}).join('')+'</ul>');
58
+ continue;}
59
+ if(m=l.match(/^(\s*)(\d+)\.\s+(.*)$/)){
60
+ close();const items=[];const start=m[2];
61
+ /* Each item keeps the number written in the file (value=), so gaps and repeats show as written. */
62
+ while(i<L.length){const mm=L[i].match(/^(\s*)(\d+)\.\s+(.*)$/);if(!mm)break;items.push([mm[2],mm[3]]);i++;}
63
+ o.push('<ol start="'+start+'">'+items.map(([n,t])=>'<li value="'+n+'">'+inline(t)+'</li>').join('')+'</ol>');
64
+ continue;}
65
+ {const b=[];while(i<L.length&&!/^\s*$/.test(L[i])&&!/^(#{1,6}\s|\s*\||>\s?|```|\s*[-*+]\s|\s*\d+\.\s)/.test(L[i])){b.push(L[i]);i++;}
66
+ if(b.length)o.push('<p>'+inline(b.join(' '))+'</p>');else i++;}
67
+ }
68
+ close();
69
+ return o.join('');
70
+ }
71
+ /* Front matter is metadata, not prose: split it off so a view can show it as a table. */
72
+ function splitFm(src){
73
+ const t=String(src).replace(/\r/g,'');
74
+ if(!t.startsWith('---\n'))return {fm:'',body:t};
75
+ const e=t.indexOf('\n---\n',3);
76
+ if(e<0)return {fm:'',body:t};
77
+ return {fm:t.slice(4,e),body:t.slice(e+5)};
78
+ }
79
+ const api={md,splitFm,esc};
80
+ if(typeof module==='object'&&module.exports)module.exports=api;else Object.assign(root,api);
81
+ })(this);
package/ui/route.js ADDED
@@ -0,0 +1,25 @@
1
+ /* Hash routing for the serve UI, kept free of the DOM so Jest can require it.
2
+ Loaded as /assets/route.js in the browser. */
3
+ (function (root) {
4
+ const VIEWS=['board','explorer','security','instructions','commands','skills'];
5
+ const esc=s=>String(s).replace(/[&<>"]/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c]));
6
+
7
+ /* "#file/quality/tests.md" → {view:'file', sub:'quality/tests.md', missing:false}.
8
+ A file the latest /api/specs does not list stays on the file view with missing:true,
9
+ so the page can say it no longer exists instead of silently showing something else. */
10
+ function resolveRoute(hash,files){
11
+ const h=String(hash||'').replace(/^#/,''),ix=h.indexOf('/');
12
+ const view=ix<0?h:h.slice(0,ix);
13
+ let sub=ix<0?'':h.slice(ix+1);
14
+ try{sub=decodeURIComponent(sub);}catch(e){}
15
+ if(view==='file'&&sub)return {view:'file',sub,missing:!Object.prototype.hasOwnProperty.call(files||{},sub)};
16
+ if(VIEWS.includes(view))return {view,sub,missing:false};
17
+ return {view:'board',sub:'',missing:false};
18
+ }
19
+
20
+ /* The whole content of a view whose file is gone: its path, and that it no longer exists. */
21
+ function goneHtml(path){return `<p class="note"><span class="mono" translate="no">${esc(path)}</span> no longer exists.</p>`;}
22
+
23
+ const api={resolveRoute,goneHtml};
24
+ if(typeof module==='object'&&module.exports)module.exports=api;else Object.assign(root,api);
25
+ })(this);