specpilot 2.19.0 → 2.21.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.
- package/README.md +38 -15
- package/dist/cli.js +6 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/add-specs.d.ts +1 -0
- package/dist/commands/add-specs.d.ts.map +1 -1
- package/dist/commands/add-specs.js +13 -7
- package/dist/commands/add-specs.js.map +1 -1
- package/dist/commands/archive.d.ts +5 -0
- package/dist/commands/archive.d.ts.map +1 -1
- package/dist/commands/archive.js +15 -10
- package/dist/commands/archive.js.map +1 -1
- package/dist/commands/backfill.js +8 -9
- package/dist/commands/backfill.js.map +1 -1
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +12 -39
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/migrate.js +1 -1
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/refine.d.ts.map +1 -1
- package/dist/commands/refine.js +21 -9
- package/dist/commands/refine.js.map +1 -1
- package/dist/commands/serve.d.ts +13 -1
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +38 -12
- package/dist/commands/serve.js.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +7 -3
- package/dist/commands/validate.js.map +1 -1
- package/dist/core/agentConfig.js +6 -2
- package/dist/core/agentConfig.js.map +1 -1
- package/dist/core/chatFlow.d.ts +15 -1
- package/dist/core/chatFlow.d.ts.map +1 -1
- package/dist/core/chatFlow.js +45 -4
- package/dist/core/chatFlow.js.map +1 -1
- package/dist/core/ideConfig.d.ts +0 -1
- package/dist/core/ideConfig.d.ts.map +1 -1
- package/dist/core/ideConfig.js +1 -2
- package/dist/core/ideConfig.js.map +1 -1
- package/dist/core/render.d.ts +2 -0
- package/dist/core/render.d.ts.map +1 -1
- package/dist/core/render.js +1 -0
- package/dist/core/render.js.map +1 -1
- package/dist/core/slashCommands.js +7 -7
- package/dist/core/specFiles.d.ts.map +1 -1
- package/dist/core/specFiles.js +12 -9
- package/dist/core/specFiles.js.map +1 -1
- package/dist/core/templateEngine.d.ts +12 -0
- package/dist/core/templateEngine.d.ts.map +1 -1
- package/dist/core/templateEngine.js +44 -9
- package/dist/core/templateEngine.js.map +1 -1
- package/dist/utils/addSpecsQuestions.d.ts +7 -0
- package/dist/utils/addSpecsQuestions.d.ts.map +1 -1
- package/dist/utils/addSpecsQuestions.js +7 -1
- package/dist/utils/addSpecsQuestions.js.map +1 -1
- package/dist/utils/codeAnalyzer.d.ts +5 -0
- package/dist/utils/codeAnalyzer.d.ts.map +1 -1
- package/dist/utils/codeAnalyzer.js +52 -22
- package/dist/utils/codeAnalyzer.js.map +1 -1
- package/dist/utils/folderPicker.d.ts.map +1 -1
- package/dist/utils/folderPicker.js +5 -2
- package/dist/utils/folderPicker.js.map +1 -1
- package/dist/utils/gitClone.js +2 -2
- package/dist/utils/gitClone.js.map +1 -1
- package/dist/utils/ideConfigGenerator.d.ts +3 -8
- package/dist/utils/ideConfigGenerator.d.ts.map +1 -1
- package/dist/utils/ideConfigGenerator.js +9 -15
- package/dist/utils/ideConfigGenerator.js.map +1 -1
- package/dist/utils/logger.d.ts +5 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +18 -11
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/mcpLocal.d.ts +2 -0
- package/dist/utils/mcpLocal.d.ts.map +1 -1
- package/dist/utils/mcpLocal.js +5 -5
- package/dist/utils/mcpLocal.js.map +1 -1
- package/dist/utils/nodeCheck.d.ts +20 -0
- package/dist/utils/nodeCheck.d.ts.map +1 -0
- package/dist/utils/nodeCheck.js +50 -0
- package/dist/utils/nodeCheck.js.map +1 -0
- package/dist/utils/projectDetector.d.ts +5 -0
- package/dist/utils/projectDetector.d.ts.map +1 -1
- package/dist/utils/projectDetector.js +16 -12
- package/dist/utils/projectDetector.js.map +1 -1
- package/dist/utils/projectRegistry.d.ts +4 -0
- package/dist/utils/projectRegistry.d.ts.map +1 -1
- package/dist/utils/projectRegistry.js +8 -1
- package/dist/utils/projectRegistry.js.map +1 -1
- package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
- package/dist/utils/slashCommandGenerator.js +20 -67
- package/dist/utils/slashCommandGenerator.js.map +1 -1
- package/dist/utils/specArchiver.d.ts +22 -4
- package/dist/utils/specArchiver.d.ts.map +1 -1
- package/dist/utils/specArchiver.js +52 -16
- package/dist/utils/specArchiver.js.map +1 -1
- package/dist/utils/specBackfiller.d.ts +19 -12
- package/dist/utils/specBackfiller.d.ts.map +1 -1
- package/dist/utils/specBackfiller.js +81 -64
- package/dist/utils/specBackfiller.js.map +1 -1
- package/dist/utils/specGenerator.d.ts.map +1 -1
- package/dist/utils/specGenerator.js +15 -3
- package/dist/utils/specGenerator.js.map +1 -1
- package/dist/utils/specPaths.d.ts +30 -0
- package/dist/utils/specPaths.d.ts.map +1 -1
- package/dist/utils/specPaths.js +145 -2
- package/dist/utils/specPaths.js.map +1 -1
- package/dist/utils/specReader.d.ts +9 -0
- package/dist/utils/specReader.d.ts.map +1 -1
- package/dist/utils/specReader.js +50 -1
- package/dist/utils/specReader.js.map +1 -1
- package/dist/utils/specServer.d.ts +24 -0
- package/dist/utils/specServer.d.ts.map +1 -1
- package/dist/utils/specServer.js +252 -106
- package/dist/utils/specServer.js.map +1 -1
- package/dist/utils/specSetup.d.ts.map +1 -1
- package/dist/utils/specSetup.js +7 -16
- package/dist/utils/specSetup.js.map +1 -1
- package/dist/utils/specValidator.d.ts +6 -0
- package/dist/utils/specValidator.d.ts.map +1 -1
- package/dist/utils/specValidator.js +215 -29
- package/dist/utils/specValidator.js.map +1 -1
- package/dist/utils/taskMover.d.ts +9 -3
- package/dist/utils/taskMover.d.ts.map +1 -1
- package/dist/utils/taskMover.js +61 -54
- package/dist/utils/taskMover.js.map +1 -1
- package/package.json +3 -3
- package/ui/app.css +107 -11
- package/ui/app.js +333 -48
- package/ui/index.html +41 -23
- package/ui/md.js +13 -11
- package/ui/route.js +42 -13
package/ui/app.js
CHANGED
|
@@ -11,9 +11,16 @@ const toast=(m,action)=>{
|
|
|
11
11
|
const x=document.createElement('button');x.type='button';x.className='tx';x.setAttribute('aria-label','Dismiss');x.innerHTML='<svg class="ico" aria-hidden="true" focusable="false"><use href="#i-x"/></svg>';x.onclick=()=>{toastEl.classList.remove('show');clearTimeout(toastT);};toastEl.appendChild(x);
|
|
12
12
|
toastEl.classList.add('show');clearTimeout(toastT);toastT=setTimeout(()=>toastEl.classList.remove('show'),8000);}; // every toast stays 8 s (D13; 2.6 s for a plain one until 2026-10-21), the × ends it early (BL-UI-03)
|
|
13
13
|
/* Task moves (BL-053) are on only when the server put a token in the page (not with --read-only). */
|
|
14
|
-
|
|
14
|
+
/* A service worker in control is an earlier program's on this origin (BL-142): the token is not used, every
|
|
15
|
+
registration goes, and a page that was served a token reloads once, uncontrolled; a flag stops a second try. */
|
|
16
|
+
const SW=navigator.serviceWorker,CONTROLLED=!!(SW&&SW.controller);
|
|
17
|
+
const SERVED=(document.querySelector('meta[name="specpilot-token"]')||{}).content||null;
|
|
18
|
+
let swReload=false;
|
|
19
|
+
try{if(!CONTROLLED)sessionStorage.removeItem('sp-sw-reload');else if(SERVED&&!sessionStorage.getItem('sp-sw-reload')){sessionStorage.setItem('sp-sw-reload','1');swReload=true;}}catch(e){}
|
|
20
|
+
if(CONTROLLED)SW.getRegistrations().then(rs=>Promise.all(rs.map(r=>r.unregister()))).then(()=>{if(swReload)location.reload();},()=>{});
|
|
21
|
+
const TOKEN=CONTROLLED?null:SERVED;
|
|
15
22
|
/* /mcp is on (BL-PM-007), and whose token it takes: `page` or `env` (SPECPILOT_MCP_TOKEN). */
|
|
16
|
-
const MCP=(document.querySelector('meta[name="specpilot-mcp"]')||{}).content||null;
|
|
23
|
+
const MCP=TOKEN&&(document.querySelector('meta[name="specpilot-mcp"]')||{}).content||null;
|
|
17
24
|
const ADDABLE={backlog:true,currentSprint:true}; // the sections POST /api/tasks/new writes to (REQ-002.H.29); which lanes move comes from the payload's table (BL-TB-11)
|
|
18
25
|
const chev='<svg class="ico chev" aria-hidden="true" focusable="false"><use href="#i-chev"/></svg>';
|
|
19
26
|
|
|
@@ -21,12 +28,13 @@ const chev='<svg class="ico chev" aria-hidden="true" focusable="false"><use href
|
|
|
21
28
|
let theme=null;try{theme=localStorage.getItem('sp-theme');}catch(e){}
|
|
22
29
|
function setMeta(light){const m=document.querySelector('meta[name=theme-color]');if(m)m.content=light?'#f8fafc':'#0f172a';}
|
|
23
30
|
if(theme==='light'){document.documentElement.setAttribute('data-theme','light');setMeta(true);}
|
|
24
|
-
$('#themeBtn').onclick=()=>{const light=document.documentElement.getAttribute('data-theme')==='light';if(light)document.documentElement.removeAttribute('data-theme');else document.documentElement.setAttribute('data-theme','light');setMeta(!light);try{light?localStorage.removeItem('sp-theme'):localStorage.setItem('sp-theme','light');}catch(e){}toast('Appearance: '+(light?'dark':'light'));};
|
|
31
|
+
$('#themeBtn').onclick=()=>{closeSet(true);const light=document.documentElement.getAttribute('data-theme')==='light';if(light)document.documentElement.removeAttribute('data-theme');else document.documentElement.setAttribute('data-theme','light');setMeta(!light);try{light?localStorage.removeItem('sp-theme'):localStorage.setItem('sp-theme','light');}catch(e){}toast('Appearance: '+(light?'dark':'light'));};
|
|
25
32
|
/* Quit (BL-098): the route `specpilot serve --stop` uses; the server then stops as on Ctrl+C. This page
|
|
26
33
|
closes its stream and says so; other open pages see a dropped stream, as before. */
|
|
27
34
|
let stopped=false;
|
|
28
35
|
if(TOKEN)$('#quitBtn').hidden=false;
|
|
29
36
|
$('#quitBtn').onclick=async()=>{
|
|
37
|
+
closeSet(true);
|
|
30
38
|
if(!confirm('Quit SpecPilot? Open pages stop updating.'))return;
|
|
31
39
|
let r;
|
|
32
40
|
try{r=await fetch('/api/quit',{method:'POST',cache:'no-store',headers:{'Content-Type':'application/json','X-SpecPilot-Token':TOKEN},body:'{}'});}
|
|
@@ -37,6 +45,35 @@ $('#quitBtn').onclick=async()=>{
|
|
|
37
45
|
document.querySelector('main.pane').replaceChildren(p);
|
|
38
46
|
};
|
|
39
47
|
|
|
48
|
+
/* Settings (BL-UI-02, REQ-002.H.72): the rail's cog opens a menu holding the theme item and Quit. It sits outside
|
|
49
|
+
the rail (position: fixed), since the rail scrolls and would clip it; keys as the card menu's. */
|
|
50
|
+
const setBtn=$('#setBtn'),setMenu=$('#setMenu');
|
|
51
|
+
function openSet(){
|
|
52
|
+
hideTip();
|
|
53
|
+
$('#themeBtn').textContent=document.documentElement.getAttribute('data-theme')==='light'?'Dark appearance':'Light appearance';
|
|
54
|
+
setMenu.hidden=false;setBtn.setAttribute('aria-expanded','true');
|
|
55
|
+
const r=setBtn.getBoundingClientRect(),w=setMenu.offsetWidth,h=setMenu.offsetHeight,m=8;
|
|
56
|
+
setMenu.style.left=Math.max(m,Math.min(r.right+6,innerWidth-w-m))+'px';
|
|
57
|
+
setMenu.style.top=Math.max(m,Math.min(r.bottom-h,innerHeight-h-m))+'px';
|
|
58
|
+
$('[role=menuitem]:not([hidden])',setMenu).focus();
|
|
59
|
+
}
|
|
60
|
+
function closeSet(refocus){
|
|
61
|
+
if(setMenu.hidden)return;
|
|
62
|
+
setMenu.hidden=true;setBtn.setAttribute('aria-expanded','false');
|
|
63
|
+
if(setMenu.contains(document.activeElement))document.activeElement.blur();
|
|
64
|
+
if(refocus)setBtn.focus();
|
|
65
|
+
}
|
|
66
|
+
setBtn.onclick=()=>setMenu.hidden?openSet():closeSet(true);
|
|
67
|
+
setMenu.addEventListener('keydown',e=>{
|
|
68
|
+
const it=$$('[role=menuitem]:not([hidden])',setMenu),i=it.indexOf(document.activeElement);
|
|
69
|
+
if(e.key==='ArrowDown'||e.key==='ArrowUp'){e.preventDefault();it[(i+(e.key==='ArrowDown'?1:it.length-1))%it.length].focus();}
|
|
70
|
+
else if(e.key==='Home'||e.key==='End'){e.preventDefault();it[e.key==='Home'?0:it.length-1].focus();}
|
|
71
|
+
else if(e.key==='Escape'){e.preventDefault();e.stopPropagation();closeSet(true);}
|
|
72
|
+
});
|
|
73
|
+
setMenu.addEventListener('mousedown',e=>e.preventDefault()); // a press inside keeps focus in the menu, as the card menu's
|
|
74
|
+
setMenu.addEventListener('focusout',e=>{if(!setMenu.contains(e.relatedTarget)&&e.relatedTarget!==setBtn)closeSet(false);});
|
|
75
|
+
document.addEventListener('click',e=>{if(!setMenu.hidden&&!(e.target.closest&&e.target.closest('#setMenu,#setBtn')))closeSet(false);});
|
|
76
|
+
|
|
40
77
|
/* ---------------- data: fetched, never embedded ---------------- */
|
|
41
78
|
let DATA=null;
|
|
42
79
|
/* The shown project: its index on the serve command line (BL-054); every /api/ call names it. */
|
|
@@ -59,30 +96,43 @@ function initials(n){const w=String(n).split(/[^A-Za-z0-9]+/).filter(Boolean);
|
|
|
59
96
|
if(!w.length)return '??';
|
|
60
97
|
if(w.length>1)return (w[0][0]+w[1][0]).toUpperCase();
|
|
61
98
|
return w[0].slice(0,2).toUpperCase();}
|
|
99
|
+
/* BL-190 (REQ-002.H.78): the banner for a server Node.js outside engines.node; its words and versions from the payload, set as text. */
|
|
100
|
+
const orList=xs=>xs.length>1?xs.slice(0,-1).join(', ')+' or '+xs[xs.length-1]:xs.join('');
|
|
101
|
+
function drawNodeBar(){
|
|
102
|
+
const n=DATA&&DATA.node,bar=$('#nodeBar');
|
|
103
|
+
let gone=false;try{gone=!!n&&sessionStorage.getItem('sp-node-dismissed')===n.version;}catch(e){}
|
|
104
|
+
if(!n||n.ok!==false||gone){bar.hidden=true;return;}
|
|
105
|
+
$('#nodeLong').textContent='Node.js '+n.version+' on this server has known security vulnerabilities, including TLS certificate bypass, memory disclosure and denial of service (Node.js security releases, '+n.release+'). Update to '+orList(n.patched)+' or later.';
|
|
106
|
+
$('#nodeShort').textContent='Node.js '+n.version+' has known security vulnerabilities. Update to '+orList(n.patched)+'+.';
|
|
107
|
+
$('#nodeLink').href='https://nodejs.org/en/blog/vulnerability'; // set here: index.html carries no external src or href (the page-shell test in specServer.test.ts); a link loads nothing (SEC-004.39)
|
|
108
|
+
bar.hidden=false;}
|
|
109
|
+
$('#nodeX').addEventListener('click',()=>{try{sessionStorage.setItem('sp-node-dismissed',DATA.node.version);}catch(e){}$('#nodeBar').hidden=true;});
|
|
62
110
|
function renderProject(){
|
|
111
|
+
drawNodeBar();
|
|
63
112
|
$('#footAddr').textContent=$('#homeAddr').textContent=location.host;$('#footVer').textContent=$('#homeVer').textContent='v'+DATA.specpilotVersion;
|
|
64
113
|
const p=DATA.project;
|
|
65
114
|
if(!p){ // no project served (BL-080): an empty rail and top bar; Home is the view
|
|
66
115
|
$('#projList').innerHTML='';$('#curGrp').textContent='';$('#curGrp').title='';$('#curBranch').textContent='';
|
|
67
|
-
$('#subName').textContent='';$('#subPath').textContent='';document.title='SpecPilot
|
|
116
|
+
$('#subName').textContent='';$('#subPath').textContent='';document.title='SpecPilot';return;}
|
|
68
117
|
const name=projectLabel(p), where=p.root+(p.branch?' · '+p.branch:'');
|
|
69
|
-
$('#projList').innerHTML=DATA.projects.map((q,i)=>{
|
|
118
|
+
$('#projList').innerHTML=DATA.projects.map((q,i)=>{if(q.closed)return ''; // BL-166: a closed project keeps its slot, no tile
|
|
119
|
+
const n=projectLabel(q),cur=i===PROJECT&&!NOPROJ.includes(curView);
|
|
70
120
|
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('');
|
|
71
121
|
$('#curGrp').textContent=name;$('#curGrp').title=p.root;
|
|
72
122
|
$('#curBranch').textContent=p.branch||'';
|
|
73
123
|
$('#subName').textContent=name;$('#subPath').textContent=where;$('#editorBtn').href=editorUrl(p.root);syncIde();
|
|
74
|
-
document.title=name+' · SpecPilot
|
|
124
|
+
document.title=name+' · SpecPilot';
|
|
75
125
|
}
|
|
76
126
|
/* Everything a payload draws; with no project served (BL-080) only the rail, bar and footer. */
|
|
77
|
-
function renderAll(){renderProject();if(!DATA.project)return;renderTasks();renderIde();renderAgentFiles();}
|
|
127
|
+
function renderAll(){drawMcp();renderProject();if(!DATA.project)return;renderTasks();renderIde();renderAgentFiles();}
|
|
78
128
|
|
|
79
129
|
/* ---------------- views ---------------- */
|
|
80
130
|
const homeBtn=$('#homeBtn');
|
|
81
|
-
const VIEWS={board:'Tasks',explorer:'Explorer',security:'Security',instructions:'Instructions',commands:'Commands',skills:'Skills',setup:'',home:'',new:''};
|
|
131
|
+
const VIEWS={overview:'Overview',board:'Tasks',explorer:'Explorer',security:'Security',instructions:'Instructions',commands:'Commands',skills:'Skills',setup:'',home:'',new:''};
|
|
82
132
|
const NOPROJ=['home','new']; // views that belong to no project (BL-PM-001, BL-PM-004)
|
|
83
133
|
const TITLES={'planning/roadmap.md':'Roadmap','project/requirements.md':'Requirements','architecture/architecture.md':'Architecture','quality/tests.md':'Tests'};
|
|
84
134
|
const NAV=[['board'],['file','planning/roadmap.md'],['file','project/requirements.md'],['explorer'],['file','architecture/architecture.md'],['file','quality/tests.md'],['security'],['instructions'],['commands'],['skills']];
|
|
85
|
-
let curView='
|
|
135
|
+
let curView='overview',curFile='';
|
|
86
136
|
function syncNav(){
|
|
87
137
|
$$('.src .srow').forEach(b=>{
|
|
88
138
|
const on=b.dataset.v==='file'?(curView==='file'&&b.dataset.f===curFile):(b.dataset.v===curView);
|
|
@@ -93,9 +143,9 @@ function syncNav(){
|
|
|
93
143
|
t.classList.toggle('cur',cur);if(cur)t.setAttribute('aria-current','true');else t.removeAttribute('aria-current');});
|
|
94
144
|
}
|
|
95
145
|
function go(v,sub){
|
|
96
|
-
if(v==='file'){if(!DATA||!sub)v='
|
|
97
|
-
else if(NOPROJ.includes(v)){if(!TOKEN)v='
|
|
98
|
-
else if(!VIEWS[v]||v==='setup')v='
|
|
146
|
+
if(v==='file'){if(!DATA||!sub)v='overview';else curFile=sub;} // Overview is the landing (BL-171)
|
|
147
|
+
else if(NOPROJ.includes(v)){if(!TOKEN)v='overview';} // no Home and no #new with --read-only
|
|
148
|
+
else if(!VIEWS[v]||v==='setup')v='overview';
|
|
99
149
|
if(!NOPROJ.includes(v)&&DATA&&!DATA.project)v='home'; // no project served: Home is the only view (BL-080)
|
|
100
150
|
else if(!NOPROJ.includes(v)&&DATA&&DATA.project.specs===false)v='setup'; // no .specs/ yet: every route of the project shows the setup view (BL-055)
|
|
101
151
|
curView=v;
|
|
@@ -111,6 +161,7 @@ function go(v,sub){
|
|
|
111
161
|
if(v==='file')renderFile(sub);
|
|
112
162
|
if(v==='explorer')renderExplorer();
|
|
113
163
|
if(v==='security')renderSecurity();
|
|
164
|
+
if(v==='overview')renderOverview();
|
|
114
165
|
setHash(v,v==='file'?sub:null);
|
|
115
166
|
$('#content').scrollTop=0;
|
|
116
167
|
}
|
|
@@ -118,16 +169,34 @@ function go(v,sub){
|
|
|
118
169
|
let urlOk=true,memHash='';
|
|
119
170
|
try{history.replaceState(null,'',location.href);}catch(e){urlOk=false;}
|
|
120
171
|
try{memHash=location.hash;}catch(e){memHash='';}
|
|
172
|
+
/* The indices of closed projects (BL-166): their slots stay in DATA.projects as {closed: true}. */
|
|
173
|
+
function closedProjects(){return DATA&&DATA.projects?DATA.projects.flatMap((q,i)=>q.closed?[i]:[]):[];}
|
|
174
|
+
/* Project n closed (BL-166): the rail redrawn from `projects`; if it was the shown one, Home and a toast naming it. */
|
|
175
|
+
function projectClosed(n,projects){
|
|
176
|
+
const q=DATA.projects[n];if(!q||q.closed)return;
|
|
177
|
+
DATA.projects=projects||DATA.projects.map((x,i)=>i===n?{closed:true}:x);renderProject();
|
|
178
|
+
toast(`${projectLabel(q)} was closed.`);
|
|
179
|
+
if(n!==PROJECT)return;
|
|
180
|
+
if(es){es.close();es=null;}
|
|
181
|
+
replacing(()=>go('home')); // the page's own move: no history entry (BL-192)
|
|
182
|
+
// behind Home, the first open project's data (or the no-project state), so no view shows the closed one's
|
|
183
|
+
// the index from the server's list, not this page's: a close this page did not hear of may have moved the first open one
|
|
184
|
+
fetch('/api/specs',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(d=>{if(d&&PROJECT===n){PROJECT=d.project?d.projects.findIndex(q=>!q.closed):0;showProject(d,true);}}).catch(()=>{});
|
|
185
|
+
}
|
|
121
186
|
function curHash(){if(!urlOk)return memHash;try{return location.hash;}catch(e){return memHash;}}
|
|
187
|
+
/* BL-192 (REQ-002.H.77): a section the person opens adds a history entry, so Back and Forward walk them; what the page does
|
|
188
|
+
on its own (route() resolving a hash, the go-Home when the shown project closes, a forced view on live reload) replaces it. */
|
|
189
|
+
let navReplace=false;
|
|
190
|
+
function replacing(fn){const was=navReplace;navReplace=true;try{return fn();}finally{navReplace=was;}}
|
|
122
191
|
function setHash(v,sub){const h='#'+(PROJECT&&!NOPROJ.includes(v)?PROJECT+'/':'')+v+(sub?'/'+sub:'');if(curHash()===h)return;memHash=h;
|
|
123
192
|
if(!urlOk)return;
|
|
124
|
-
try{history
|
|
125
|
-
function route(){
|
|
126
|
-
const r=resolveRoute(curHash(),DATA?DATA.files:{},DATA?DATA.projects.length:1,!!TOKEN);
|
|
193
|
+
try{history[navReplace?'replaceState':'pushState'](null,'',h);}catch(e){urlOk=false;}}
|
|
194
|
+
function route(){replacing(()=>{ // inside route() itself, so showProject()'s re-entry after a project's fetch replaces too
|
|
195
|
+
const r=resolveRoute(curHash(),DATA?DATA.files:{},DATA?DATA.projects.length:1,!!TOKEN,closedProjects());
|
|
127
196
|
if(NOPROJ.includes(r.view)){go(r.view);return;} // Home and #new belong to no project: the shown one stays loaded behind them
|
|
128
197
|
if(r.project!==PROJECT){switchProject(r.project,true);return;}
|
|
129
198
|
go(r.view,r.sub);
|
|
130
|
-
}
|
|
199
|
+
});}
|
|
131
200
|
if(urlOk)window.addEventListener('hashchange',route);
|
|
132
201
|
$$('.src .srow[data-v]').forEach(b=>b.onclick=()=>go(b.dataset.v,b.dataset.f));
|
|
133
202
|
function setNav(on){const w=$('#win');w.classList.toggle('nav',on);$('#scrim').hidden=!on;$('#menuBtn').setAttribute('aria-expanded',on?'true':'false');}
|
|
@@ -319,16 +388,165 @@ function openTask(col,i,quiet){
|
|
|
319
388
|
const foot=col==='review'&&TOKEN?`<div class="if" id="inspFoot">${done}<div class="fb">${t.approved?'':'<button type="button" class="btn pri" id="rvApprove">Approve</button>'}<button type="button" class="btn" id="rvSend">Send back</button></div>
|
|
320
389
|
<form id="rvForm" autocomplete="off" hidden><label for="rvNote">What needs fixing? (optional)</label><textarea id="rvNote" name="review-note" rows="3" maxlength="200" aria-describedby="rvCount rvErr"></textarea><div class="fc" id="rvCount" aria-live="polite">0/200</div><div class="fb"><button type="submit" class="btn pri" id="rvGo">Send back to Current Sprint</button><button type="button" class="btn" id="rvCancel">Cancel</button></div></form>
|
|
321
390
|
<p class="err" id="rvErr" role="alert" hidden></p></div>`:'';
|
|
391
|
+
const editable=col==='backlog'&&!!TOKEN; // BL-TB-08: a Backlog row's description, with a token
|
|
322
392
|
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 ${PILL[col]}">${esc(COLS[col])}</span>${col==='review'&&t.approved?'<span class="pill green">Approved</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>
|
|
323
393
|
<div class="ib2">
|
|
324
|
-
<div class="gl"><div class="gh">Description <span class="cnt" translate="no">tasks.md · ## ${esc(COLS[col])}</span
|
|
394
|
+
<div class="gl"><div class="gh">Description <span class="cnt" translate="no">tasks.md · ## ${esc(COLS[col])}</span>${editable?'<button type="button" class="btn sm" id="edBtn">Edit</button>':''}</div><div class="box"${editable?' id="edBox"':''}><div class="desc md">${md(t.description)}</div></div>${editable?editForm():''}</div>
|
|
325
395
|
${fieldsBlock(col,t)}${reason}${hist}
|
|
326
396
|
<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>
|
|
327
397
|
</div>${foot}`;
|
|
328
398
|
if(foot)bindReview(col,i);
|
|
399
|
+
if(editable)bindEdit(col,i);
|
|
329
400
|
bindRadios(insp,(key,btn)=>chooseField(col,i,key,btn));
|
|
330
401
|
openInsp(quiet);
|
|
331
402
|
}
|
|
403
|
+
/* ---------------- Edit a Backlog description (BL-TB-08, REQ-002.H.73) ----------------
|
|
404
|
+
The cell's text in a one-line form; Save writes through POST /api/tasks/fields by New Task's rules. A redraw while
|
|
405
|
+
the form is open keeps it open with the typed text (apply); a closed panel or another card drops it. */
|
|
406
|
+
const editForm=()=>`<form id="edForm" autocomplete="off" hidden><textarea id="edText" name="task-description" rows="4" maxlength="4000" aria-label="Description" aria-describedby="edCount edErr"></textarea><div class="fc" id="edCount" aria-live="polite">0/4000</div><div class="fb"><button type="submit" class="btn pri" id="edSave">Save</button><button type="button" class="btn" id="edCancel">Cancel</button></div><p class="err" id="edErr" role="alert" hidden></p></form>`;
|
|
407
|
+
function edError(m){const e=$('#edErr');if(!e)return;e.textContent=m||'';e.hidden=!m;}
|
|
408
|
+
function edCount(){const n=$('#edText'),c=$('#edCount');if(n&&c)c.textContent=[...n.value].length+'/4000';}
|
|
409
|
+
function openEdit(text,err){
|
|
410
|
+
const f=$('#edForm');if(!f)return;f.hidden=false;$('#edBox').hidden=true;$('#edBtn').hidden=true;
|
|
411
|
+
const n=$('#edText');n.value=text;edCount();edError(err||'');n.focus();n.setSelectionRange(n.value.length,n.value.length);
|
|
412
|
+
}
|
|
413
|
+
function closeEdit(refocus){
|
|
414
|
+
const f=$('#edForm');if(!f||f.hidden)return;f.hidden=true;$('#edBox').hidden=false;$('#edBtn').hidden=false;edError('');
|
|
415
|
+
if(refocus)$('#edBtn').focus();
|
|
416
|
+
}
|
|
417
|
+
function bindEdit(col,i){
|
|
418
|
+
$('#edBtn').onclick=()=>openEdit(DATA.tasks[col][i].description);
|
|
419
|
+
$('#edCancel').onclick=()=>closeEdit(true);
|
|
420
|
+
$('#edText').oninput=edCount;
|
|
421
|
+
$('#edText').onkeydown=e=>{
|
|
422
|
+
if(e.key==='Escape'){e.preventDefault();e.stopPropagation();closeEdit(true);}
|
|
423
|
+
else if(e.key==='Enter'&&!e.isComposing){e.preventDefault();if(!e.shiftKey)$('#edForm').requestSubmit();} // one line: Enter never breaks it
|
|
424
|
+
};
|
|
425
|
+
$('#edForm').onsubmit=e=>{e.preventDefault();saveEdit(col,i);};
|
|
426
|
+
}
|
|
427
|
+
let editingDesc=false;
|
|
428
|
+
async function saveEdit(col,i){
|
|
429
|
+
const t=DATA.tasks[col]&&DATA.tasks[col][i],p=PROJECT;if(!t||editingDesc)return;
|
|
430
|
+
const typed=$('#edText').value;
|
|
431
|
+
editingDesc=true;$('#edForm').setAttribute('aria-busy','true');$('#edSave').disabled=true;
|
|
432
|
+
let r,body={};
|
|
433
|
+
try{
|
|
434
|
+
r=await fetch('/api/tasks/fields?'+pq(),{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,description:typed})});
|
|
435
|
+
body=await r.json().catch(()=>({}));
|
|
436
|
+
}catch(e){r=null;}
|
|
437
|
+
editingDesc=false;
|
|
438
|
+
if(p!==PROJECT)return;
|
|
439
|
+
const f=$('#edForm');if(f){f.removeAttribute('aria-busy');$('#edSave').disabled=false;}
|
|
440
|
+
if(r&&r.status===200){
|
|
441
|
+
closeEdit(false); // before the redraw, which would keep an open form open
|
|
442
|
+
wrote(['.specs/planning/tasks.md'],body.specs);await apply(body.specs,['.specs/planning/tasks.md']);
|
|
443
|
+
const b=$('#edBtn');if(b)b.focus();toast('Description saved.');return;
|
|
444
|
+
}
|
|
445
|
+
if(r&&r.status===409&&body.specs)await apply(body.specs,null); // still in Backlog: the redraw keeps the form and the typed text
|
|
446
|
+
const msg=!r?'The server did not answer. Nothing was changed.':body.error||`Nothing was changed (HTTP ${r.status}).`;
|
|
447
|
+
if($('#edForm')&&!$('#edForm').hidden&&inspOpen&&inspOpen.id===t.id){edError(msg);return;}
|
|
448
|
+
// the row left Backlog: the panel on its new lane, with no Edit; gone, the panel is closed. The typed text is dropped.
|
|
449
|
+
const c=Object.keys(COLS).find(k=>Array.isArray(DATA.tasks[k])&&DATA.tasks[k].some(x=>x.id===t.id));
|
|
450
|
+
if(c){openTask(c,findRow(c,t.id,0),true);$('#inspX').focus();}
|
|
451
|
+
toast(msg);
|
|
452
|
+
}
|
|
453
|
+
/* ---------------- Overview (BL-171, REQ-002.H.76) ----------------
|
|
454
|
+
The landing: cards from the payload (and roadmap.md's text), every text the files' own; a card with nothing to show is left
|
|
455
|
+
out. Counts are of rows or files another view lists, and each opens that view (REQ-002.H.5's Overview exception). */
|
|
456
|
+
const OV_TYPES=['feat','bug','chore'],OV_PRIS=['P1','P2','P3'];
|
|
457
|
+
/* BL-191 redesign (REQ-002.H.76): a top band, two columns that stack on their own, Spec files last; every card the same parts. */
|
|
458
|
+
const ovIco=id=>`<svg class="ico" aria-hidden="true" focusable="false"><use href="#${id}"/></svg>`;
|
|
459
|
+
function ovCard(key,icon,title,src,body,o={}){
|
|
460
|
+
return body?`<section class="ovcard${o.flag?' flag':''}" data-card="${key}"><div class="ovch">${ovIco(icon)}<h3>${esc(title)}</h3>${o.count!==undefined?`<span class="ovcount">${o.count}</span>`:''}${src?`<span class="ovsrc" translate="no">${esc(src)}</span>`:''}</div><div class="ovcb">${body}</div>${o.foot?`<div class="ovcf">${o.foot}</div>`:''}</section>`:'';
|
|
461
|
+
}
|
|
462
|
+
function ovLink(go,label,f){return `<button type="button" class="ovlink" data-go="${go}"${f?` data-f="${esc(f)}"`:''}>${esc(label)}${ovIco('i-chev')}</button>`;}
|
|
463
|
+
function ovRow(col,i,t){return `<button type="button" class="ovrow" data-task="${col}:${i}"><span class="id" translate="no">${mdi(t.id)}</span><span class="d">${mdi(t.description)}</span><span class="ovchips">${chips(t)}</span></button>`;}
|
|
464
|
+
const OV_LINKLESS=['claude-code','codex','windsurf','antigravity']; // IDEs the page has no open link for (README: Windsurf has none yet)
|
|
465
|
+
function ovIdeBtn(){
|
|
466
|
+
const p=DATA.project;
|
|
467
|
+
if(p.cursor)return `<a class="btn" href="${esc(editorUrl(p.root,0,'cursor'))}">${ovIco('i-ext')}Open in Cursor</a>`;
|
|
468
|
+
if(OV_LINKLESS.includes((p.uses||[])[0]))return `<button type="button" class="btn" data-copypath>${ovIco('i-copy')}Copy folder path</button>`;
|
|
469
|
+
return `<a class="btn" href="${esc(editorUrl(p.root))}">${ovIco('i-ext')}Open in VS Code</a>`;
|
|
470
|
+
}
|
|
471
|
+
function renderOverview(){
|
|
472
|
+
const box=$('#ovBox');if(!box||!DATA||!DATA.project)return;
|
|
473
|
+
const O=DATA.overview||{project:{},commits:[],prompts:[]},P=O.project||{},T=DATA.tasks,N=DATA.nav,F=DATA.files||{};
|
|
474
|
+
const label=projectLabel(DATA.project),pm=F['project/project.yaml']||{},has=v=>v!==null&&v!==undefined;
|
|
475
|
+
const facts=[has(P.version)?`version ${P.version}`:null,has(P.language)?String(P.language):null,has(P.framework)?String(P.framework):null,has(P.license)?String(P.license):null,has(pm.lastUpdated)?`lastUpdated ${pm.lastUpdated}`:null].filter(x=>x!==null);
|
|
476
|
+
let lanes='',mixes='',review='',sprint='';
|
|
477
|
+
if(T){
|
|
478
|
+
lanes=`<div class="ovlanes">${['backlog','currentSprint','review','completed'].map(c=>`<button type="button" class="ovlane" data-go="board"><span class="n">${(T[c]||[]).length}</span><span class="l"><span class="st ${DOT[c]}" aria-hidden="true"></span>${esc(COLS[c])}</span></button>`).join('')}</div>`;
|
|
479
|
+
const open=[...(T.backlog||[]),...(T.currentSprint||[]),...(T.review||[])];
|
|
480
|
+
const line=(key,label,cls,vals)=>{const parts=vals.map(v=>[v,open.filter(t=>t[key]===v).length]).filter(([,n])=>n);
|
|
481
|
+
return parts.length?`<button type="button" class="ovmix" data-go="board" data-mix="${key}"><span class="k">${label}</span>${parts.map(([v,n])=>`<span class="pill chip ${cls}${tone(v)}" translate="no">${esc(v)} ${n}</span>`).join('')}</button>`:'';};
|
|
482
|
+
const ty=line('type','Type','ty',OV_TYPES),pr=line('priority','Priority','pri',OV_PRIS);
|
|
483
|
+
mixes=ty||pr?`<div class="ovmixes">${ty}${pr}</div>`:'';
|
|
484
|
+
const rv=T.review||[],cs=T.currentSprint||[];
|
|
485
|
+
review=ovCard('review','i-check','Review','## Review',rv.length?`<div class="ovrows">${rv.map((t,i)=>ovRow('review',i,t)).join('')}</div>`:`<div class="ovempty">${ovIco('i-check')}<span>Nothing waiting for you. Agents move finished work here.</span></div>`,{count:rv.length,foot:ovLink('board','Open Review in Tasks')});
|
|
486
|
+
sprint=cs.length?ovCard('sprint','i-arrow','Current Sprint','## Current Sprint',`<div class="ovrows">${cs.slice(0,5).map((t,i)=>ovRow('currentSprint',i,t)).join('')}</div>`,{count:cs.length,foot:ovLink('board',`All ${cs.length} in Tasks`)}):'';
|
|
487
|
+
}
|
|
488
|
+
const hero=`<section class="ovcard ovhero" data-card="project"><div class="ovident"><div class="ovbig" aria-hidden="true">${esc(initials(label))}</div><div class="ovtxt"><h2 class="ovname">${esc(label)}</h2>${has(P.description)?`<p class="ovdesc">${esc(String(P.description))}</p>`:''}${facts.length?`<div class="ovfacts">${facts.map(f=>`<span class="ovfact" translate="no">${esc(f)}</span>`).join('')}</div>`:''}</div>`
|
|
489
|
+
+`<div class="ovacts"><button type="button" class="btn pri" data-go="board">${ovIco('i-board')}Open Tasks</button>${ovIdeBtn()}</div></div>${lanes}${mixes}</section>`;
|
|
490
|
+
const commits=(O.commits||[]).map(c=>`<div class="ovrow ovcommit"><span class="id" translate="no">${esc(c.hash)}</span><span class="d">${esc(c.message)}</span><span class="when">${esc(when(c.date))}</span></div>`).join('');
|
|
491
|
+
const prompts=(O.prompts||[]).map(p=>`<button type="button" class="ovrow ovprompt" data-go="file" data-f="development/prompts.md"><span class="d">${esc(p)}</span></button>`).join('');
|
|
492
|
+
const done=T?(T.completed||[]).slice().sort((a,b)=>Number(b.num)-Number(a.num)).slice(0,3).map(t=>`<button type="button" class="ovrow ovdone" data-go="board"><span class="id" translate="no">#${esc(t.num)} ${mdi(t.id)}</span><span class="d">${mdi(t.description)}</span></button>`).join(''):'';
|
|
493
|
+
const group=(icon,title,rows)=>rows?`<div class="ovsub">${ovIco(icon)}${title}</div><div class="ovrows">${rows}</div>`:'';
|
|
494
|
+
const recent=ovCard('recent','i-git','Recent activity',[commits?'.git/logs/HEAD':'',prompts?'prompts.md':'',done?'## Completed':''].filter(Boolean).join(' · '),group('i-git','Commits',commits)+group('i-file','Prompt log',prompts)+group('i-check','Completed',done));
|
|
495
|
+
const secFiles=['security/threat-model.md','security/security-decisions.md'].filter(p=>p in F);
|
|
496
|
+
const security=secFiles.length?ovCard('security','i-shield','Security','security/',`<div class="ovsecs">${secFiles.map(p=>{const m=metaLine(F[p]);return `<button type="button" class="ovfile" data-go="security"><span class="p" translate="no">${esc(p)}</span>${m?`<span class="m" translate="no">${esc(m)}</span>`:''}</button>`;}).join('')}</div>`
|
|
497
|
+
+('security/security-decisions.md' in F?`<div class="ovtiles"><button type="button" class="ovtile wide" data-go="security" id="ovDec" hidden><span class="k">Decisions</span><span class="v"></span></button></div>`:''),{foot:ovLink('security','Open Security')}):'';
|
|
498
|
+
const I=N.instructions,gen=a=>a.filter(f=>f.generated).length,cmds=[...N.commands,...N.prompts],S=N.skills;
|
|
499
|
+
const tile=(go,k,v,small,wide)=>`<button type="button" class="ovtile${wide?' wide':''}" data-go="${go}"><span class="k">${esc(k)}</span><span class="v">${esc(v)}</span>${small?`<small translate="no">${esc(small)}</small>`:''}</button>`;
|
|
500
|
+
const guide=ovCard('guide','i-bot','Agent Guidance','',`<div class="ovtiles">`+tile('instructions','Instructions',`${I.filter(f=>f.exists).length} of ${I.length}`,I.filter(f=>f.exists).map(f=>f.path).join(' · '),true)
|
|
501
|
+
+tile('commands','Commands',String(cmds.length),`From SpecPilot ${gen(cmds)} · Yours ${cmds.length-gen(cmds)}`)
|
|
502
|
+
+tile('skills','Skills',String(S.length),[`From SpecPilot ${gen(S)} · Yours ${S.length-gen(S)}`,...S.map(f=>f.path.split('/').slice(-2,-1)[0])].join(' · '))+`</div>`);
|
|
503
|
+
const specs=N.specs.slice().sort((a,b)=>{const x=(F[a]||{}).lastUpdated,y=(F[b]||{}).lastUpdated;
|
|
504
|
+
if(x&&y&&x!==y)return x<y?1:-1;if(!x!==!y)return x?-1:1;return a<b?-1:a>b?1:0;});
|
|
505
|
+
const files=specs.length?ovCard('files','i-file','Spec files','newest first',`<div class="ovfiles">${specs.slice(0,8).map(p=>{const m=metaLine(F[p]);return `<button type="button" class="ovfile" data-go="file" data-f="${esc(p)}"><span class="p" translate="no">${esc(p)}</span>${m?`<span class="m" translate="no">${esc(m)}</span>`:''}</button>`;}).join('')}</div>`,{count:specs.length,foot:ovLink('explorer',`All ${specs.length} in Explorer`)}):'';
|
|
506
|
+
box.innerHTML=`<div id="ovFlag"></div>`+hero+`<div class="ovcols"><div class="ovcol">${review}${sprint}${recent}</div><div class="ovcol"><div id="ovRoad"></div>${security}${guide}</div></div>`+files;
|
|
507
|
+
ovRoadmap();ovDecisions();
|
|
508
|
+
}
|
|
509
|
+
/* Roadmap, always (BL-191): the last ### under ## Timeline and its first five lines, or the board's Warning box saying what to fix. */
|
|
510
|
+
const OV_ROAD={
|
|
511
|
+
norel:['## Timeline in planning/roadmap.md has no ### release','The card shows the last ### heading under ## Timeline and its first lines, and there is none.','add a ### heading for the next release under ## Timeline, with its first lines'],
|
|
512
|
+
notl:['planning/roadmap.md has no ## Timeline','The card shows the last ### release under ## Timeline, and the file has no such section.','add a ## Timeline section with a ### heading for the next release'],
|
|
513
|
+
nofile:['No planning/roadmap.md in .specs/','Every project needs a roadmap; the card shows its latest release.','create planning/roadmap.md with a ## Timeline section and a ### heading for the next release']};
|
|
514
|
+
function ovRoadCard(body,flag){return ovCard('roadmap','i-map','Roadmap','planning/roadmap.md',body,flag?{flag:true}:{foot:ovLink('file','Open Roadmap','planning/roadmap.md')});}
|
|
515
|
+
function ovRoadFlag(kind){
|
|
516
|
+
const [title,what,fix]=OV_ROAD[kind];
|
|
517
|
+
const prompt=kind==='nofile'?'Create .specs/planning/roadmap.md with a ## Timeline section and a ### heading for the next release, so SpecPilot’s Overview shows it.':`In .specs/planning/roadmap.md, ${fix}, so SpecPilot’s Overview shows the next release.`;
|
|
518
|
+
return ovRoadCard(`<div class="msg warn">${ovIco('i-warn')}<div class="mb"><div class="mt"><span class="mw">Warning</span> ${esc(title)}</div><p>${esc(what)}</p><p>Fix: ${esc(fix)}, best done by your AI IDE.</p>`
|
|
519
|
+
+`<div class="actions"><button type="button" class="btn sm" data-prompt="${esc(prompt)}">Copy prompt</button>${kind==='nofile'?'':`<button type="button" class="btn sm" data-go="file" data-f="planning/roadmap.md">Open Roadmap</button>`}</div></div></div>`,true);
|
|
520
|
+
}
|
|
521
|
+
async function ovRoadmap(){
|
|
522
|
+
const pj=PROJECT,place=(card,flagged)=>{const slot=$('#ovRoad');if(PROJECT!==pj||curView!=='overview'||!slot)return;slot.outerHTML=card;
|
|
523
|
+
const f=$('#ovFlag');if(f)f.innerHTML=flagged?`<div class="msg warn ovbanner">${ovIco('i-warn')}<div class="mb"><div class="mt">This project’s roadmap has no release to show. The Roadmap card says what to fix.</div></div></div>`:'';};
|
|
524
|
+
if(!('planning/roadmap.md' in (DATA.files||{})))return place(ovRoadFlag('nofile'),true);
|
|
525
|
+
let src;try{src=await getText('.specs/planning/roadmap.md');}catch(e){return place(ovRoadFlag('nofile'),true);}
|
|
526
|
+
const lines=src.split('\n');
|
|
527
|
+
const t=lines.findIndex(l=>/^## Timeline\b/.test(l.trim()));if(t<0)return place(ovRoadFlag('notl'),true);
|
|
528
|
+
let end=lines.findIndex((l,i)=>i>t&&/^## /.test(l.trim()));if(end<0)end=lines.length;
|
|
529
|
+
let h=-1;for(let i=t+1;i<end;i++)if(/^### /.test(lines[i].trim()))h=i;
|
|
530
|
+
if(h<0)return place(ovRoadFlag('norel'),true);
|
|
531
|
+
let stop=lines.findIndex((l,i)=>i>h&&/^#{1,3} /.test(l.trim()));if(stop<0||stop>end)stop=end;
|
|
532
|
+
const body=lines.slice(h+1,stop).filter(l=>l.trim()).slice(0,5);
|
|
533
|
+
place(ovRoadCard(`<div class="ovroad md">${md([lines[h],...body].join('\n'))}</div>`,false),false);
|
|
534
|
+
}
|
|
535
|
+
/* Decisions <n>: the ### heading lines outside code fences in security-decisions.md, the headings the Security view renders. */
|
|
536
|
+
async function ovDecisions(){
|
|
537
|
+
const pj=PROJECT;if(!('security/security-decisions.md' in (DATA.files||{})))return;
|
|
538
|
+
let src;try{src=await getText('.specs/security/security-decisions.md');}catch(e){return;}
|
|
539
|
+
let fence=false,n=0;for(const l of src.split('\n')){if(/^\s*(```|~~~)/.test(l))fence=!fence;else if(!fence&&/^### /.test(l))n++;}
|
|
540
|
+
const t=$('#ovDec');if(PROJECT!==pj||curView!=='overview'||!t)return;t.querySelector('.v').textContent=String(n);t.hidden=false;
|
|
541
|
+
}
|
|
542
|
+
$('#ovBox').addEventListener('click',e=>{
|
|
543
|
+
const t=e.target.closest('[data-task]');
|
|
544
|
+
if(t){const [col,i]=t.dataset.task.split(':');go('board');openTask(col,+i);return;}
|
|
545
|
+
const p=e.target.closest('[data-prompt]');if(p){copyText(p.getAttribute('data-prompt'));return;}
|
|
546
|
+
if(e.target.closest('[data-copypath]')){copyText(DATA.project.root);return;}
|
|
547
|
+
const g=e.target.closest('[data-go]');if(g)go(g.dataset.go,g.dataset.f);
|
|
548
|
+
});
|
|
549
|
+
|
|
332
550
|
/* ---------------- Type and Priority (BL-125) ----------------
|
|
333
551
|
A row of a typed Backlog, Current Sprint or Review table carries a Type and a Priority: chips on the card's bottom
|
|
334
552
|
line, two radio groups in the detail panel that write through POST /api/tasks/fields on choice, the same two in
|
|
@@ -443,7 +661,42 @@ async function review(col,i,action,extra,isUndo){
|
|
|
443
661
|
else if($('#inspFoot'))rvError(msg);
|
|
444
662
|
else toast(msg);
|
|
445
663
|
}
|
|
446
|
-
|
|
664
|
+
/* Resize the details panel (BL-TB-02, REQ-002.H.74): a handle on its left edge; the chosen width is kept per browser
|
|
665
|
+
in sp-insp-width and applied clamped to the pane on each open and window resize, a clamp never rewriting it. */
|
|
666
|
+
const grip=$('#inspGrip'),INSP_W=400,INSP_MIN=320,INSP_GAP=160;
|
|
667
|
+
let inspW=INSP_W;try{const v=parseInt(localStorage.getItem('sp-insp-width'),10);if(v>0)inspW=v;}catch(e){}
|
|
668
|
+
function sizeInsp(){
|
|
669
|
+
const max=insp.parentElement.clientWidth-INSP_GAP,narrow=max<INSP_MIN,w=narrow?INSP_W:Math.max(INSP_MIN,Math.min(inspW,max));
|
|
670
|
+
grip.classList.toggle('off',narrow); // a narrow pane: min(400px, 100%) as before, no handle
|
|
671
|
+
insp.parentElement.style.setProperty('--insp-w',w+'px');
|
|
672
|
+
grip.setAttribute('aria-valuemin',INSP_MIN);grip.setAttribute('aria-valuemax',Math.max(INSP_MIN,max));grip.setAttribute('aria-valuenow',w);
|
|
673
|
+
return w;
|
|
674
|
+
}
|
|
675
|
+
const setInsp=w=>{inspW=w;inspW=sizeInsp();};
|
|
676
|
+
const keepInsp=()=>{try{localStorage.setItem('sp-insp-width',String(inspW));}catch(e){}};
|
|
677
|
+
grip.addEventListener('pointerdown',e=>{
|
|
678
|
+
if(e.button!==0)return;e.preventDefault();grip.focus();grip.setPointerCapture(e.pointerId);
|
|
679
|
+
const x0=e.clientX,w0=sizeInsp();let done=false;
|
|
680
|
+
const move=ev=>setInsp(w0+x0-ev.clientX); // the handle is on the left edge: left widens
|
|
681
|
+
const end=keep=>{
|
|
682
|
+
if(done)return;done=true;
|
|
683
|
+
grip.removeEventListener('pointermove',move);grip.removeEventListener('pointerup',up);grip.removeEventListener('lostpointercapture',up);document.removeEventListener('keydown',esc,true);
|
|
684
|
+
insp.classList.remove('drag');grip.classList.remove('drag');document.body.classList.remove('resizing');
|
|
685
|
+
if(keep)keepInsp();else setInsp(w0);
|
|
686
|
+
};
|
|
687
|
+
const up=()=>end(true);
|
|
688
|
+
const esc=ev=>{if(ev.key==='Escape'){ev.preventDefault();ev.stopPropagation();end(false);}}; // capture: before the page's Escape, which closes the panel
|
|
689
|
+
insp.classList.add('drag');grip.classList.add('drag');document.body.classList.add('resizing');
|
|
690
|
+
grip.addEventListener('pointermove',move);grip.addEventListener('pointerup',up);grip.addEventListener('lostpointercapture',up);document.addEventListener('keydown',esc,true);
|
|
691
|
+
});
|
|
692
|
+
grip.addEventListener('keydown',e=>{
|
|
693
|
+
const cur=+grip.getAttribute('aria-valuenow'),to={ArrowLeft:cur+16,ArrowRight:cur-16,Home:INSP_MIN,End:Infinity}[e.key];
|
|
694
|
+
if(to===undefined)return;e.preventDefault();e.stopPropagation();setInsp(to);keepInsp();
|
|
695
|
+
});
|
|
696
|
+
grip.addEventListener('dblclick',()=>{inspW=INSP_W;sizeInsp();try{localStorage.removeItem('sp-insp-width');}catch(e){}});
|
|
697
|
+
window.addEventListener('resize',()=>sizeInsp());
|
|
698
|
+
sizeInsp();
|
|
699
|
+
function openInsp(quiet){sizeInsp();insp.classList.add('open');insp.setAttribute('aria-hidden','false');$('#inspX').onclick=closeInsp;if(!quiet)setTimeout(()=>{if(insp.classList.contains('open')&&!insp.contains(document.activeElement))$('#inspX').focus();},60);} // the close button takes focus unless the panel closed meanwhile or something in it already has focus (the Send back box, BL-113)
|
|
447
700
|
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;}}
|
|
448
701
|
function bind(){
|
|
449
702
|
$$('#v-board .row[data-col]').forEach(r=>{const col=r.dataset.col,i=+r.dataset.i;
|
|
@@ -495,11 +748,19 @@ async function renderSecurity(){
|
|
|
495
748
|
}
|
|
496
749
|
|
|
497
750
|
/* ---------------- automation: generated files, read as they are ---------------- */
|
|
751
|
+
/* An absent file says why (BL-161, REQ-002.H.69): missing for an IDE the project uses, else not needed, else
|
|
752
|
+
(no IDE known) not in this repo. The server decides which IDEs; the page only names them. */
|
|
753
|
+
function absentTrail(f,uses){
|
|
754
|
+
const names=a=>a.map(v=>IDE_NAME[v]||v).join(', ');
|
|
755
|
+
if(!uses.length)return {pill:'<span class="pill gray">not in this repo</span>',det:''};
|
|
756
|
+
return f.ides.length?{pill:'<span class="pill orange">missing</span>',det:`SpecPilot writes it for ${esc(names(f.ides))}.`}
|
|
757
|
+
:{pill:'<span class="pill gray">not needed</span>',det:`This project uses ${esc(names(uses))}.`};
|
|
758
|
+
}
|
|
498
759
|
function renderIde(){
|
|
499
|
-
const I=DATA.nav.instructions;
|
|
760
|
+
const I=DATA.nav.instructions,uses=DATA.project&&DATA.project.uses||[];
|
|
500
761
|
$('#insBox').innerHTML=I.map(f=>f.exists
|
|
501
762
|
?`<button type="button" class="row act" data-open="${esc(f.path)}"><span class="st green" aria-hidden="true"></span><div class="body"><div class="ttl"><span class="id" translate="no">${esc(f.path)}</span></div><div class="det">${f.bytes} bytes</div></div><div class="trail">${chev}</div></button>`
|
|
502
|
-
|
|
763
|
+
:(a=>`<div class="row"><span class="st hollow" aria-hidden="true"></span><div class="body"><div class="ttl"><span class="id" translate="no">${esc(f.path)}</span></div>${a.det?`<div class="det">${a.det}</div>`:''}</div><div class="trail">${a.pill}</div></div>`)(absentTrail(f,uses))).join('');
|
|
503
764
|
$('#insMeta').textContent=I.filter(f=>f.exists).length+' of '+I.length;
|
|
504
765
|
}
|
|
505
766
|
function fileRows(list){
|
|
@@ -666,6 +927,7 @@ const palVeil=$('#palVeil'),palIn=$('#palIn'),palList=$('#palList');
|
|
|
666
927
|
function items(q){q=q.toLowerCase();
|
|
667
928
|
const T=DATA?DATA.tasks:null;
|
|
668
929
|
const it=[
|
|
930
|
+
{l:'Overview',k:'view',go:()=>go('overview')}, // BL-171: first, with no digit key, so NAV and 1 to 9 stay
|
|
669
931
|
...NAV.map(n=>n[0]==='file'?{l:'.specs/'+n[1],k:'file',go:()=>go('file',n[1])}:{l:VIEWS[n[0]],k:'view',go:()=>go(n[0])}),
|
|
670
932
|
...(DATA?DATA.nav.specs:[]).filter(p=>!NAV.some(n=>n[1]===p)).map(p=>({l:'.specs/'+p,k:'file',go:()=>go('file',p)})),
|
|
671
933
|
...(T?['currentSprint','review','backlog','completed','wontDo'].flatMap(c=>(T[c]||[]).map((t,i)=>({l:t.id+' '+t.description,k:'task',go:()=>{go('board');openTask(c,i)}}))):[])
|
|
@@ -680,8 +942,8 @@ document.addEventListener('keydown',e=>{
|
|
|
680
942
|
const mod=e.metaKey||e.ctrlKey;const inField=/INPUT|SELECT|TEXTAREA/.test(e.target.tagName);
|
|
681
943
|
if(mod&&e.key.toLowerCase()==='k'){e.preventDefault();palVeil.classList.contains('open')?closePal():openPal();return}
|
|
682
944
|
if(mod&&/^[1-9]$/.test(e.key)){e.preventDefault();const n=NAV[+e.key-1];if(n)go(n[0],n[1]);return}
|
|
683
|
-
if(e.key==='Escape'){if(busyVeil.classList.contains('open')){closeBusy();return}if(!ideMenu.hidden){closeIde(true);return}if(!cardMenu.hidden){closeCardMenu(true);return}hideTip();closeInsp();closePal();closeSheet();closeNewTask();closeArchive();setNav(false);return}
|
|
684
|
-
if(inField||mod||e.altKey||!cardMenu.hidden||taskVeil.classList.contains('open')||archVeil.classList.contains('open')||busyVeil.classList.contains('open'))return;
|
|
945
|
+
if(e.key==='Escape'){if(busyVeil.classList.contains('open')){closeBusy();return}if(!ideMenu.hidden){closeIde(true);return}if(!cardMenu.hidden){closeCardMenu(true);return}if(!setMenu.hidden){closeSet(true);return}hideTip();closeInsp();closePal();closeSheet();closeNewTask();closeArchive();setNav(false);return}
|
|
946
|
+
if(inField||mod||e.altKey||!cardMenu.hidden||!setMenu.hidden||taskVeil.classList.contains('open')||archVeil.classList.contains('open')||busyVeil.classList.contains('open'))return;
|
|
685
947
|
if(e.key==='h'&&TOKEN&&!openVeil.classList.contains('open')){go('home');return;}
|
|
686
948
|
if(/^[1-9]$/.test(e.key)){const n=NAV[+e.key-1];if(n)go(n[0],n[1]);}
|
|
687
949
|
if((e.key==='j'||e.key==='k')&&curView==='board'){const rows=$$('#v-board .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();}
|
|
@@ -851,7 +1113,7 @@ $('#taskForm').onsubmit=e=>{e.preventDefault();addTask();};
|
|
|
851
1113
|
/* ---------------- archive Completed (BL-TB-06, D8) ----------------
|
|
852
1114
|
The Completed step of `specpilot archive`, run by the server with the same plan and block as the CLI. The
|
|
853
1115
|
dialog says what the action does and lists the gates from the latest payload: the CLI's branch guard and the
|
|
854
|
-
|
|
1116
|
+
line limit (its numbers from tasks.archive, BL-123), each with a box to tick when it warns; a section within the limit is archived with {force:true}
|
|
855
1117
|
once the user ticks that box. Every other answer than 200 is shown in the dialog, as New Task does. */
|
|
856
1118
|
const archVeil=$('#archVeil');
|
|
857
1119
|
let archiving=false;
|
|
@@ -860,9 +1122,9 @@ function archGates(){
|
|
|
860
1122
|
if(!b)out.push({key:'branch',text:'No git branch.'});
|
|
861
1123
|
else if(b==='main'||b==='master')out.push({key:'branch',text:`On ${b}.`});
|
|
862
1124
|
else out.push({key:'branch:'+b,warn:true,text:`On branch ${b}. Archive is recommended only on the default branch after merging. ${branchRisk('The archive')} Archive on this branch anyway.`});
|
|
863
|
-
if(!a.rows)out.push({key:'none',off:true,text:`Nothing to archive: ## Completed has ${n} ${n===1?'row':'rows'}, and an archive keeps the newest
|
|
864
|
-
else if(a.lines>
|
|
865
|
-
else out.push({key:'force',warn:true,text:`## Completed is ${a.lines} lines, within its
|
|
1125
|
+
if(!a.rows)out.push({key:'none',off:true,text:`Nothing to archive: ## Completed has ${n} ${n===1?'row':'rows'}, and an archive keeps the newest ${a.keep}.`});
|
|
1126
|
+
else if(a.lines>a.limit)out.push({key:'limit',text:`## Completed is ${a.lines} lines, over its ${a.limit}-line limit: ${a.rows} rows move, the newest ${n-a.rows} stay.`});
|
|
1127
|
+
else out.push({key:'force',warn:true,text:`## Completed is ${a.lines} lines, within its ${a.limit}-line limit. Archive ${a.rows} rows anyway; the newest ${n-a.rows} stay.`});
|
|
866
1128
|
const act=recentActivity();
|
|
867
1129
|
if(act)out.push({key:'activity',warn:true,text:`${act}: an agent or editor may still be working on the specs. If it saves planning/tasks.md from a copy it read before the archive, the archive is lost; if it edits after, its edit can fail or land on the wrong row because the rows moved under it. Archive anyway.`});
|
|
868
1130
|
return out;
|
|
@@ -974,14 +1236,13 @@ function renderSetup(){
|
|
|
974
1236
|
$('#suOff').hidden=MCP_ON;
|
|
975
1237
|
$$('#v-setup .step').forEach(el=>{el.classList.toggle('off',!MCP_ON);el.inert=!MCP_ON;});
|
|
976
1238
|
$('#suConfigBox').hidden=!MCP_ON;
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
else $('#suMcpNote').textContent='';
|
|
1239
|
+
$('#suIde').hidden=!MCP_ON;
|
|
1240
|
+
if(MCP_ON)drawMcp();else $('#suMcpNote').textContent='';
|
|
980
1241
|
$('#suFoot').innerHTML=`Prefer the terminal? ${mono(isNew?'specpilot init':'specpilot add-specs')} in that folder asks the same questions one by one.`;
|
|
981
1242
|
suStatus();suPrompt();drawProgress();
|
|
982
1243
|
}
|
|
983
1244
|
function copyText(text){(navigator.clipboard?navigator.clipboard.writeText(text):Promise.reject()).then(()=>toast('Copied.'),()=>toast('Could not copy. Select the line and copy it.'));}
|
|
984
|
-
$('#suConfigCopy').onclick=()=>copyText($('#suConfig').
|
|
1245
|
+
$('#suConfigCopy').onclick=()=>copyText($('#suConfig').textContent);
|
|
985
1246
|
$('#suPromptCopy').onclick=()=>copyText($('#suPrompt').textContent);
|
|
986
1247
|
/* #new: when the name passes init's rule and a parent is typed, register <parent>/<name> as the one pending path. */
|
|
987
1248
|
async function registerPending(){
|
|
@@ -1053,17 +1314,19 @@ async function apply(d,paths){
|
|
|
1053
1314
|
const scroll=$('#content').scrollTop,ib0=insp.querySelector('.ib2'),inspScroll=ib0?ib0.scrollTop:0;
|
|
1054
1315
|
const lanes=$$('#boardMode .gl[data-col] .box').map(b=>[b.closest('.gl').dataset.col,b.scrollTop]); // BL-TB-03: each lane's own scroll
|
|
1055
1316
|
const was=inspOpen;
|
|
1317
|
+
const edF=$('#edForm'),edTyped=edF&&!edF.hidden?$('#edText').value:null; // BL-TB-08: an open edit survives a redraw
|
|
1056
1318
|
const hadSpecs=!(DATA&&DATA.project&&DATA.project.specs===false);
|
|
1057
1319
|
DATA=d;
|
|
1058
1320
|
renderAll();
|
|
1059
1321
|
const to=reloadView(curView,hadSpecs,!d.project||d.project.specs!==false); // .specs/ gone: offer setup; appeared another way: Tasks; Home stays
|
|
1060
|
-
if(to){go(to);return;}
|
|
1322
|
+
if(to){replacing(()=>go(to));return;} // a forced view replaces the entry (BL-192)
|
|
1061
1323
|
if(curView==='file')await renderFile(curFile);
|
|
1062
1324
|
if(curView==='explorer')renderExplorer();
|
|
1325
|
+
if(curView==='overview')renderOverview();
|
|
1063
1326
|
if(curView==='security')await renderSecurity();
|
|
1064
1327
|
if(was&&was.kind==='task'){
|
|
1065
1328
|
const i=findRow(was.col,was.id,was.i);
|
|
1066
|
-
if(i>=0){openTask(was.col,i,true);$$(`#v-board .row[data-col="${was.col}"][data-i="${i}"]`).forEach(r=>r.classList.add('sel'));}
|
|
1329
|
+
if(i>=0){openTask(was.col,i,true);$$(`#v-board .row[data-col="${was.col}"][data-i="${i}"]`).forEach(r=>r.classList.add('sel'));if(edTyped!==null)openEdit(edTyped);}
|
|
1067
1330
|
else{insp.classList.remove('open');insp.setAttribute('aria-hidden','true');selected=null;inspOpen=null;}
|
|
1068
1331
|
}
|
|
1069
1332
|
if(was&&was.kind==='file'&&(!paths||paths.includes(was.path)))await openFile(was.path,true);
|
|
@@ -1073,15 +1336,17 @@ async function apply(d,paths){
|
|
|
1073
1336
|
refocus(key);
|
|
1074
1337
|
}
|
|
1075
1338
|
let es=null;
|
|
1076
|
-
function listen(){
|
|
1339
|
+
function listen(missed){
|
|
1077
1340
|
if(stopped||!window.EventSource)return;
|
|
1078
1341
|
if(es)es.close(); // one stream, for the shown project
|
|
1079
|
-
es=new EventSource(DATA&&!DATA.project?'/api/events':'/api/events?'+pq());let dropped
|
|
1342
|
+
es=new EventSource(DATA&&!DATA.project?'/api/events':'/api/events?'+pq());let dropped=!!missed; // no project served: the server-level stream (BL-080)
|
|
1080
1343
|
es.addEventListener('clone',e=>onCloneEvent(e.data));
|
|
1081
1344
|
es.addEventListener('setup',e=>onSetupEvent(e.data));
|
|
1082
1345
|
es.addEventListener('mcp',e=>{let d=null;try{d=JSON.parse(e.data);}catch(_){}if(d&&DATA){DATA.mcp=d;if(curView==='setup'||curView==='new')suStatus();}});
|
|
1346
|
+
es.addEventListener('closed',()=>projectClosed(PROJECT)); // this project was closed from another page (BL-166)
|
|
1083
1347
|
es.addEventListener('change',e=>{let paths=null;try{paths=JSON.parse(e.data).paths;}catch(_){}refresh(Array.isArray(paths)?paths:null);});
|
|
1084
|
-
es
|
|
1348
|
+
const mine=es; // a refusal or a 503 closes it for good: reopen it in 5 s unless it was replaced meanwhile (BL-144)
|
|
1349
|
+
es.onerror=()=>{dropped=true;if(mine.readyState===2)setTimeout(()=>{if(es===mine)listen(true);},5000);}; // otherwise EventSource retries by itself
|
|
1085
1350
|
es.onopen=()=>{if(dropped){dropped=false;refresh(null);}}; // catch up on anything missed
|
|
1086
1351
|
}
|
|
1087
1352
|
|
|
@@ -1100,10 +1365,10 @@ function showProject(d,keepRoute){
|
|
|
1100
1365
|
Object.keys(fileCache).forEach(k=>{delete fileCache[k];});secShown.clear();
|
|
1101
1366
|
DATA=d;selected=null;setRegenNote([]);
|
|
1102
1367
|
renderAll();listen();
|
|
1103
|
-
if(keepRoute)route();else go('
|
|
1368
|
+
if(keepRoute)route();else go('overview');
|
|
1104
1369
|
}
|
|
1105
1370
|
$('#projList').addEventListener('click',e=>{const b=e.target.closest('[data-project]');if(!b)return;
|
|
1106
|
-
if(+b.dataset.project!==PROJECT)switchProject(+b.dataset.project);else if(NOPROJ.includes(curView))go('
|
|
1371
|
+
if(+b.dataset.project!==PROJECT)switchProject(+b.dataset.project);else if(NOPROJ.includes(curView))go('overview');});
|
|
1107
1372
|
|
|
1108
1373
|
/* ---------------- open a project (BL-067) ----------------
|
|
1109
1374
|
The + tile opens the mockup's sheet on its Folder tab. The list is GET /api/projects; opening is
|
|
@@ -1116,17 +1381,37 @@ const openVeil=$('#openVeil'),addBtn=$('#addBtn'),pathIn=$('#pathIn');
|
|
|
1116
1381
|
const TABS=['folder','clone'],GO={folder:'Open',clone:'Clone Repository'};
|
|
1117
1382
|
let openBusy=false,sheetFrom=$('#homeOpen'),sheetTab='folder',cloneCtl=null,browseCtl=null,browseBtn=null,cloneNamed=false,cloneTick=null,cloneT0=0,cloneProg=null;
|
|
1118
1383
|
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)
|
|
1119
|
-
/* Connect Your AI IDE (BL-PM-007): the config
|
|
1120
|
-
the page cannot know whether an IDE uses it.
|
|
1384
|
+
/* Connect Your AI IDE (BL-PM-007): the config for this server's /mcp, unless --no-mcp (BL-105). No status here:
|
|
1385
|
+
the page cannot know whether an IDE uses it. Per IDE since BL-157 (REQ-002.H.68), one choice for Home and the Setup
|
|
1386
|
+
view: kept in the browser, else the first IDE the project's project.yaml lists (BL-158, REQ-002.A.13), else
|
|
1387
|
+
without a list the IDE of the first instruction file the project in front has, else Claude Code; nothing labels
|
|
1388
|
+
that guess. `env`: the token is SPECPILOT_MCP_TOKEN, whose value the page never holds. */
|
|
1389
|
+
const IDE_NAME={'claude-code':'Claude Code',cursor:'Cursor',vscode:'VS Code',windsurf:'Windsurf',codex:'Codex',antigravity:'Antigravity'};
|
|
1390
|
+
const IDE_OF={'CLAUDE.md':'Claude Code','AGENTS.md':'Codex','.github/copilot-instructions.md':'VS Code','.cursor/rules/specpilot.mdc':'Cursor','.windsurfrules':'Windsurf','.antigravity/rules.md':'Antigravity','CODEX_INSTRUCTIONS.md':'Codex'};
|
|
1391
|
+
let mcpIde=null;try{const v=localStorage.getItem('sp-mcp-ide');if(MCP_IDES.includes(v))mcpIde=v;}catch(e){}
|
|
1392
|
+
function mcpChoice(){
|
|
1393
|
+
if(mcpIde)return mcpIde;
|
|
1394
|
+
const ides=DATA&&DATA.project?DATA.project.ides:null;
|
|
1395
|
+
if(ides)return IDE_NAME[ides[0]]||'Claude Code';
|
|
1396
|
+
const f=DATA&&DATA.nav?DATA.nav.instructions.find(i=>i.exists):null;
|
|
1397
|
+
return f&&IDE_OF[f.path]||'Claude Code';
|
|
1398
|
+
}
|
|
1399
|
+
function drawMcp(){
|
|
1400
|
+
if(!TOKEN||!MCP)return;
|
|
1401
|
+
const ide=mcpChoice(),c=mcpConfig(ide,location.host,MCP==='env'?null:TOKEN);
|
|
1402
|
+
const a=document.activeElement,fg=a&&a.closest?a.closest('#mcpIde,#suIde'):null,fv=fg&&a.dataset.v; // a redraw keeps focus (live reload, a choice)
|
|
1403
|
+
for(const [g,box] of [['#mcpIde','#homeMcp'],['#suIde','#suConnect']]){
|
|
1404
|
+
$(g).innerHTML=MCP_IDES.map(v=>`<button type="button" role="radio" data-v="${v}" aria-checked="${v===ide}" tabindex="${v===ide?0:-1}" class="${v===ide?'on':''}">${v}</button>`).join('');
|
|
1405
|
+
bindRadios($(box),(key,b)=>{mcpIde=b.dataset.v;try{localStorage.setItem('sp-mcp-ide',mcpIde);}catch(e){}drawMcp();});
|
|
1406
|
+
}
|
|
1407
|
+
if(fg)$(`#${fg.id} [data-v="${fv}"]`).focus();
|
|
1408
|
+
$('#mcpLine').textContent=c.text;$('#mcpNote').textContent=c.note;
|
|
1409
|
+
$('#suConfig').textContent=c.text;$('#suMcpNote').textContent=c.note;
|
|
1410
|
+
}
|
|
1121
1411
|
if(TOKEN&&MCP){
|
|
1122
|
-
|
|
1123
|
-
$('#mcpLine').textContent=mcpConfigLine(location.host,env?'${SPECPILOT_MCP_TOKEN}':TOKEN);
|
|
1124
|
-
$('#mcpNote').textContent=env
|
|
1125
|
-
?'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.'
|
|
1126
|
-
:'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.';
|
|
1412
|
+
drawMcp();
|
|
1127
1413
|
$('#homeMcp').hidden=false;
|
|
1128
|
-
$('#mcpCopy').onclick=()=>(
|
|
1129
|
-
.then(()=>toast('Copied.'),()=>toast('Could not copy. Select the line and copy it.'));
|
|
1414
|
+
$('#mcpCopy').onclick=()=>copyText($('#mcpLine').textContent);
|
|
1130
1415
|
}
|
|
1131
1416
|
function openSheet(from,tab){
|
|
1132
1417
|
hideTip();sheetFrom=from;openVeil.classList.add('open');
|
|
@@ -1175,7 +1460,7 @@ async function showOutcome(o){
|
|
|
1175
1460
|
closeSheet();
|
|
1176
1461
|
if(o.specs){PROJECT=o.project;showProject(o.specs,false);}
|
|
1177
1462
|
else if(o.project!==PROJECT)await switchProject(o.project);
|
|
1178
|
-
else if(wasHome)go('
|
|
1463
|
+
else if(wasHome)go('overview');
|
|
1179
1464
|
toast(o.toast);
|
|
1180
1465
|
if(wasHome)$('#content').focus(); // Home is gone from the screen: focus goes to the project's view, not to a hidden control
|
|
1181
1466
|
}
|
|
@@ -1244,7 +1529,7 @@ async function browseFolder(btn,field,pick){
|
|
|
1244
1529
|
async function removeRecent(path){
|
|
1245
1530
|
let out;
|
|
1246
1531
|
try{out=await postPath(path,'/api/projects/remove');}catch(e){toast('The server did not answer.');return;}
|
|
1247
|
-
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}).`);
|
|
1532
|
+
if(out.r.status===200){if(out.res.closed!=null)projectClosed(out.res.closed,out.res.projects);drawRecent(out.res);if(curView==='home')drawRecent(out.res,true);}else toast(out.res.error||`Nothing was removed (HTTP ${out.r.status}).`);
|
|
1248
1533
|
}
|
|
1249
1534
|
addBtn.onclick=()=>{go('home');$('#homeOpen').focus();}; // every new project starts from Home (BL-PM-014); only Home's buttons open the sheet
|
|
1250
1535
|
homeBtn.onclick=()=>go('home');
|