specpilot 2.2.4 → 2.4.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 (48) hide show
  1. package/README.md +25 -0
  2. package/dist/cli.js +10 -0
  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/serve.d.ts +9 -0
  8. package/dist/commands/serve.d.ts.map +1 -0
  9. package/dist/commands/serve.js +68 -0
  10. package/dist/commands/serve.js.map +1 -0
  11. package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
  12. package/dist/utils/slashCommandGenerator.js +117 -26
  13. package/dist/utils/slashCommandGenerator.js.map +1 -1
  14. package/dist/utils/specArchiver.d.ts +22 -0
  15. package/dist/utils/specArchiver.d.ts.map +1 -1
  16. package/dist/utils/specArchiver.js +121 -26
  17. package/dist/utils/specArchiver.js.map +1 -1
  18. package/dist/utils/specPaths.d.ts +26 -0
  19. package/dist/utils/specPaths.d.ts.map +1 -0
  20. package/dist/utils/specPaths.js +92 -0
  21. package/dist/utils/specPaths.js.map +1 -0
  22. package/dist/utils/specPoller.d.ts +22 -0
  23. package/dist/utils/specPoller.d.ts.map +1 -0
  24. package/dist/utils/specPoller.js +119 -0
  25. package/dist/utils/specPoller.js.map +1 -0
  26. package/dist/utils/specReader.d.ts +21 -0
  27. package/dist/utils/specReader.d.ts.map +1 -1
  28. package/dist/utils/specReader.js +26 -3
  29. package/dist/utils/specReader.js.map +1 -1
  30. package/dist/utils/specServer.d.ts +65 -0
  31. package/dist/utils/specServer.d.ts.map +1 -0
  32. package/dist/utils/specServer.js +345 -0
  33. package/dist/utils/specServer.js.map +1 -0
  34. package/dist/utils/specValidator.d.ts +3 -1
  35. package/dist/utils/specValidator.d.ts.map +1 -1
  36. package/dist/utils/specValidator.js +44 -11
  37. package/dist/utils/specValidator.js.map +1 -1
  38. package/dist/utils/taskMover.d.ts +50 -0
  39. package/dist/utils/taskMover.d.ts.map +1 -0
  40. package/dist/utils/taskMover.js +131 -0
  41. package/dist/utils/taskMover.js.map +1 -0
  42. package/package.json +2 -3
  43. package/ui/app.css +306 -0
  44. package/ui/app.js +408 -0
  45. package/ui/favicon.svg +25 -0
  46. package/ui/index.html +172 -0
  47. package/ui/md.js +81 -0
  48. package/ui/route.js +25 -0
package/ui/index.html ADDED
@@ -0,0 +1,172 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>SpecPilot Local</title>
7
+ <meta name="theme-color" content="#0f172a">
8
+ <!-- specpilot-token -->
9
+ <link rel="icon" href="/assets/favicon.svg" type="image/svg+xml">
10
+ <link rel="stylesheet" href="/assets/app.css">
11
+ <script src="/assets/md.js" defer></script>
12
+ <script src="/assets/route.js" defer></script>
13
+ <script src="/assets/app.js" defer></script>
14
+ </head>
15
+ <body>
16
+ <svg class="sprite" width="0" height="0" aria-hidden="true" focusable="false"><defs>
17
+ <symbol id="logo" viewBox="0 0 300 300" fill="none">
18
+ <rect width="300" height="300" rx="60" fill="url(#paint0_linear_18_9)"/>
19
+ <g filter="url(#filter0_d_18_9)">
20
+ <rect x="46.5" y="73.5" width="207.888" height="153" rx="76.5" stroke="white" stroke-width="41"/>
21
+ <circle cx="116.376" cy="150" r="16.561" fill="#FFFEFE"/>
22
+ <circle cx="116.376" cy="150" r="16.561" stroke="black"/>
23
+ <path d="M184.985 133.439C194.131 133.439 201.546 140.853 201.546 150C201.546 159.146 194.131 166.561 184.985 166.561C175.839 166.561 168.424 159.146 168.424 150C168.425 140.854 175.839 133.439 184.985 133.439Z" fill="white"/>
24
+ <path d="M184.985 133.439C194.131 133.439 201.546 140.853 201.546 150C201.546 159.146 194.131 166.561 184.985 166.561C175.839 166.561 168.424 159.146 168.424 150C168.425 140.854 175.839 133.439 184.985 133.439Z" stroke="black"/>
25
+ </g>
26
+ <defs>
27
+ <filter id="filter0_d_18_9" x="24" y="52" width="252.888" height="198" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
28
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
29
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
30
+ <feOffset dy="1"/>
31
+ <feGaussianBlur stdDeviation="1"/>
32
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0"/>
33
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_18_9"/>
34
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_18_9" result="shape"/>
35
+ </filter>
36
+ <linearGradient id="paint0_linear_18_9" x1="150" y1="0" x2="150" y2="300" gradientUnits="userSpaceOnUse">
37
+ <stop stop-color="#1481FC"/>
38
+ <stop offset="1" stop-color="#0077FF"/>
39
+ </linearGradient>
40
+ <symbol id="i-term" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M7 10l3 2.5-3 2.5M13 15h4"/></symbol>
41
+ <symbol id="i-spark" viewBox="0 0 24 24"><path d="M12 3l1.7 4.8L18.5 9.5l-4.8 1.7L12 16l-1.7-4.8L5.5 9.5l4.8-1.7z"/><path d="M18 15.5l.8 2.2 2.2.8-2.2.8-.8 2.2-.8-2.2-2.2-.8 2.2-.8z"/></symbol>
42
+ </defs>
43
+ </symbol>
44
+ <symbol id="i-board" viewBox="0 0 24 24"><rect x="3" y="4" width="5" height="16" rx="1"/><rect x="10" y="4" width="5" height="10" rx="1"/><rect x="17" y="4" width="4" height="13" rx="1"/></symbol>
45
+ <symbol id="i-map" viewBox="0 0 24 24"><path d="M3 6l6-2 6 2 6-2v14l-6 2-6-2-6 2z"/><path d="M9 4v14M15 6v14"/></symbol>
46
+ <symbol id="i-req" viewBox="0 0 24 24"><path d="M9 6h11M9 12h11M9 18h11"/><path d="M4 6l1 1 2-2M4 12l1 1 2-2M4 18l1 1 2-2"/></symbol>
47
+ <symbol id="i-folder" viewBox="0 0 24 24"><path d="M3 7a2 2 0 012-2h4l2 2h8a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2z"/></symbol>
48
+ <symbol id="i-arch" viewBox="0 0 24 24"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="8.5" y="14" width="7" height="7" rx="1"/><path d="M6.5 10v2h11v-2M12 12v2"/></symbol>
49
+ <symbol id="i-test" viewBox="0 0 24 24"><path d="M9 3h6M10 3v6l-5.5 9a2 2 0 001.7 3h11.6a2 2 0 001.7-3L14 9V3"/><path d="M7 15h10"/></symbol>
50
+ <symbol id="i-shield" viewBox="0 0 24 24"><path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z"/><path d="M9 12l2 2 4-4"/></symbol>
51
+ <symbol id="i-bot" viewBox="0 0 24 24"><rect x="4" y="8" width="16" height="12" rx="2"/><path d="M12 8V4M8 4h8"/><circle cx="9" cy="14" r="1"/><circle cx="15" cy="14" r="1"/></symbol>
52
+ <symbol id="i-plus" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></symbol>
53
+ <symbol id="i-gear" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 00.3 1.8l.1.1a2 2 0 11-2.8 2.8l-.1-.1a1.7 1.7 0 00-1.8-.3 1.7 1.7 0 00-1 1.5V21a2 2 0 11-4 0v-.1a1.7 1.7 0 00-1.1-1.5 1.7 1.7 0 00-1.8.3l-.1.1a2 2 0 11-2.8-2.8l.1-.1a1.7 1.7 0 00.3-1.8 1.7 1.7 0 00-1.5-1H3a2 2 0 110-4h.1a1.7 1.7 0 001.5-1.1 1.7 1.7 0 00-.3-1.8l-.1-.1a2 2 0 112.8-2.8l.1.1a1.7 1.7 0 001.8.3H9a1.7 1.7 0 001-1.5V3a2 2 0 114 0v.1a1.7 1.7 0 001 1.5 1.7 1.7 0 001.8-.3l.1-.1a2 2 0 112.8 2.8l-.1.1a1.7 1.7 0 00-.3 1.8V9a1.7 1.7 0 001.5 1H21a2 2 0 110 4h-.1a1.7 1.7 0 00-1.5 1z"/></symbol>
54
+ <symbol id="i-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></symbol>
55
+ <symbol id="i-x" viewBox="0 0 24 24"><path d="M6 6l12 12M18 6L6 18"/></symbol>
56
+ <symbol id="i-file" viewBox="0 0 24 24"><path d="M6 3h8l4 4v14H6z"/><path d="M14 3v4h4"/></symbol>
57
+ <symbol id="i-play" viewBox="0 0 24 24"><path d="M7 5l12 7-12 7z"/></symbol>
58
+ <symbol id="i-git" viewBox="0 0 24 24"><circle cx="6" cy="6" r="2.5"/><circle cx="6" cy="18" r="2.5"/><circle cx="18" cy="8" r="2.5"/><path d="M6 8.5v7M18 10.5c0 4-12 2-12 5"/></symbol>
59
+ <symbol id="i-menu" viewBox="0 0 24 24"><path d="M4 7h16M4 12h16M4 17h16"/></symbol>
60
+ <symbol id="i-hd" viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 12h18M7 16h2"/></symbol>
61
+ <symbol id="i-search" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="M20 20l-3.5-3.5"/></symbol>
62
+ <symbol id="i-ext" viewBox="0 0 24 24"><path d="M14 4h6v6M20 4l-9 9"/><path d="M19 14v5a1 1 0 01-1 1H5a1 1 0 01-1-1V6a1 1 0 011-1h5"/></symbol>
63
+ <symbol id="i-chev" viewBox="0 0 24 24"><path d="M9 6l6 6-6 6"/></symbol>
64
+ <symbol id="i-arrow" viewBox="0 0 24 24"><path d="M5 12h14M13 6l6 6-6 6"/></symbol>
65
+ <symbol id="i-check" viewBox="0 0 24 24"><path d="M5 12l5 5L20 7"/></symbol>
66
+ </defs></svg>
67
+
68
+ <a class="skip" href="#content">Skip to Content</a>
69
+ <div class="win" id="win">
70
+ <nav class="rail" id="rail" aria-label="Projects">
71
+ <svg class="logo" aria-hidden="true" focusable="false"><use href="#logo"/></svg>
72
+ <div class="rsep" aria-hidden="true"></div>
73
+ <div class="rlist" id="projList" role="group" aria-label="Open projects"></div>
74
+ <div class="rfoot">
75
+ <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>
76
+ </div>
77
+ </nav>
78
+ <aside class="src" id="src">
79
+ <div class="top"><b id="curGrp" translate="no"></b><span class="br mono" id="curBranch" translate="no"></span></div>
80
+ <button class="search" id="palBtn"><svg class="ico ico-13" aria-hidden="true" focusable="false"><use href="#i-search"/></svg>Search<kbd>&#8984;K</kbd></button>
81
+ <div class="snav">
82
+ <div class="grp" id="gPlan">Plan</div>
83
+ <div role="group" aria-labelledby="gPlan">
84
+ <button class="srow on" data-v="board"><svg aria-hidden="true" focusable="false"><use href="#i-board"/></svg><span class="t">Tasks</span><span class="meta" translate="no">tasks.md</span></button>
85
+ <button class="srow" data-v="file" data-f="planning/roadmap.md"><svg aria-hidden="true" focusable="false"><use href="#i-map"/></svg><span class="t">Roadmap</span><span class="meta" translate="no">roadmap.md</span></button>
86
+ <button class="srow" data-v="file" data-f="project/requirements.md"><svg aria-hidden="true" focusable="false"><use href="#i-req"/></svg><span class="t">Requirements</span><span class="meta" translate="no">requirements.md</span></button>
87
+ </div>
88
+ <div class="grp" id="gSpecs">Specs</div>
89
+ <div role="group" aria-labelledby="gSpecs">
90
+ <button class="srow" data-v="explorer"><svg aria-hidden="true" focusable="false"><use href="#i-folder"/></svg><span class="t">Explorer</span><span class="meta" translate="no">.specs/</span></button>
91
+ <button class="srow" data-v="file" data-f="architecture/architecture.md"><svg aria-hidden="true" focusable="false"><use href="#i-arch"/></svg><span class="t">Architecture</span><span class="meta" translate="no">architecture/</span></button>
92
+ <button class="srow" data-v="file" data-f="quality/tests.md"><svg aria-hidden="true" focusable="false"><use href="#i-test"/></svg><span class="t">Tests</span><span class="meta" translate="no">quality/</span></button>
93
+ <button class="srow" data-v="security"><svg aria-hidden="true" focusable="false"><use href="#i-shield"/></svg><span class="t">Security</span><span class="meta" translate="no">security/</span></button>
94
+ </div>
95
+ <div class="grp" id="gAuto">Automation</div>
96
+ <div role="group" aria-labelledby="gAuto">
97
+ <button class="srow" data-v="instructions"><svg aria-hidden="true" focusable="false"><use href="#i-file"/></svg><span class="t">Instructions</span><span class="meta" id="insMeta" translate="no"></span></button>
98
+ <button class="srow" data-v="commands"><svg aria-hidden="true" focusable="false"><use href="#i-term"/></svg><span class="t">Commands</span><span class="meta" id="cmdMeta" translate="no">.claude/commands/</span></button>
99
+ <button class="srow" data-v="skills"><svg aria-hidden="true" focusable="false"><use href="#i-spark"/></svg><span class="t">Skills</span><span class="meta" id="sklMeta" translate="no">.claude/skills/</span></button>
100
+ </div>
101
+ </div>
102
+ <div class="foot"><span class="v" id="footAddr" title="Local server, read-only" translate="no"></span><span class="v ml-auto" id="footVer" translate="no"></span></div>
103
+ </aside>
104
+ <div class="scrim" id="scrim" hidden></div>
105
+
106
+ <main class="pane">
107
+ <div class="tb">
108
+ <button class="ib menu" id="menuBtn" aria-label="Show sidebar"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-menu"/></svg></button>
109
+ <div><h1 id="title">Tasks</h1><div class="sub"><span id="subName" translate="no"></span><span class="mono" id="subPath" translate="no"></span></div></div>
110
+ <div class="right">
111
+ <div class="seg" id="modeSeg"><button class="on" data-m="list">List</button><button data-m="board">Board</button></div>
112
+ </div>
113
+ </div>
114
+ <div class="content" id="content">
115
+ <p class="note" id="loadErr" hidden></p>
116
+
117
+ <!-- TASKS: the rows of planning/tasks.md, from readSpecs() -->
118
+ <section class="view on" id="v-board">
119
+ <div id="listMode">
120
+ <div class="gl" id="gSprint" data-col="currentSprint"></div>
121
+ <div class="gl mt18" id="gBacklog" data-col="backlog"></div>
122
+ <div class="gl mt18" id="gDone" data-col="completed"></div>
123
+ </div>
124
+ <div id="boardMode" class="board" hidden></div>
125
+ <div class="gl" id="gRaw" hidden></div>
126
+ <div class="gl" id="gConv"></div>
127
+ </section>
128
+
129
+ <!-- EXPLORER: the .specs/ folder -->
130
+ <section class="view" id="v-explorer">
131
+ <div id="exBody"></div>
132
+ <p class="note" id="exNote"></p>
133
+ </section>
134
+
135
+ <!-- SECURITY: both files in security/, each as written -->
136
+ <section class="view" id="v-security">
137
+ <div id="secBody"></div>
138
+ </section>
139
+
140
+ <!-- FILE: any .specs/ file, rendered as written -->
141
+ <section class="view" id="v-file">
142
+ <div class="gl" id="fmBox"></div>
143
+ <div class="md doc" id="fileBody"></div>
144
+ </section>
145
+
146
+ <!-- INSTRUCTIONS -->
147
+ <section class="view" id="v-instructions">
148
+ <div class="gl"><div class="gh">Instruction Files</div><div class="box" id="insBox"></div></div>
149
+ </section>
150
+
151
+ <!-- COMMANDS -->
152
+ <section class="view" id="v-commands">
153
+ <div class="gl"><div class="gh"><span translate="no">.claude/commands/</span> <span class="cnt" id="cmdCnt"></span></div><div class="box" id="cmdBox"></div></div>
154
+ <div class="gl"><div class="gh"><span translate="no">.github/prompts/</span> <span class="cnt" id="prmCnt"></span></div><div class="box" id="prmBox"></div></div>
155
+ </section>
156
+
157
+ <!-- SKILLS -->
158
+ <section class="view" id="v-skills">
159
+ <div class="gl"><div class="gh"><span translate="no">.claude/skills/</span> <span class="cnt" id="sklCnt"></span></div><div class="box" id="sklBox"></div></div>
160
+ </section>
161
+
162
+ </div>
163
+
164
+ <aside class="insp" id="insp" aria-label="Details"></aside>
165
+ </main>
166
+ </div>
167
+
168
+ <!-- PALETTE -->
169
+ <div class="veil pal-veil" id="palVeil"><div class="pal"><input id="palIn" type="search" name="q" aria-label="Search views, spec files and tasks" placeholder="Jump to a view, spec file or task…" autocomplete="off" spellcheck="false"><ul id="palList"></ul></div></div>
170
+ <div class="toast" id="toast" role="status" aria-live="polite"></div>
171
+ </body>
172
+ </html>
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);