specpilot 2.14.0 → 2.16.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 (41) hide show
  1. package/README.md +19 -19
  2. package/dist/cli.js +3 -3
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/add-specs.d.ts +1 -2
  5. package/dist/commands/add-specs.d.ts.map +1 -1
  6. package/dist/commands/add-specs.js +1 -1
  7. package/dist/commands/add-specs.js.map +1 -1
  8. package/dist/commands/init.d.ts.map +1 -1
  9. package/dist/commands/init.js +27 -33
  10. package/dist/commands/init.js.map +1 -1
  11. package/dist/commands/serve.d.ts.map +1 -1
  12. package/dist/commands/serve.js +6 -4
  13. package/dist/commands/serve.js.map +1 -1
  14. package/dist/core/chatFlow.js +2 -2
  15. package/dist/core/chatFlow.js.map +1 -1
  16. package/dist/core/slashCommands.d.ts.map +1 -1
  17. package/dist/core/slashCommands.js +0 -1
  18. package/dist/core/slashCommands.js.map +1 -1
  19. package/dist/utils/mcpLocal.d.ts +10 -0
  20. package/dist/utils/mcpLocal.d.ts.map +1 -1
  21. package/dist/utils/mcpLocal.js +61 -2
  22. package/dist/utils/mcpLocal.js.map +1 -1
  23. package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
  24. package/dist/utils/slashCommandGenerator.js +6 -0
  25. package/dist/utils/slashCommandGenerator.js.map +1 -1
  26. package/dist/utils/specServer.d.ts +4 -4
  27. package/dist/utils/specServer.d.ts.map +1 -1
  28. package/dist/utils/specServer.js +187 -115
  29. package/dist/utils/specServer.js.map +1 -1
  30. package/dist/utils/specSetup.d.ts +21 -23
  31. package/dist/utils/specSetup.d.ts.map +1 -1
  32. package/dist/utils/specSetup.js +63 -56
  33. package/dist/utils/specSetup.js.map +1 -1
  34. package/dist/utils/specValidator.d.ts.map +1 -1
  35. package/dist/utils/specValidator.js +5 -2
  36. package/dist/utils/specValidator.js.map +1 -1
  37. package/package.json +1 -1
  38. package/ui/app.css +40 -110
  39. package/ui/app.js +113 -304
  40. package/ui/index.html +21 -27
  41. package/ui/route.js +3 -101
package/ui/index.html CHANGED
@@ -11,7 +11,6 @@
11
11
  <link rel="stylesheet" href="/assets/app.css">
12
12
  <script src="/assets/md.js" defer></script>
13
13
  <script src="/assets/route.js" defer></script>
14
- <script src="/assets/chat-core.js" defer></script>
15
14
  <script src="/assets/app.js" defer></script>
16
15
  </head>
17
16
  <body>
@@ -115,13 +114,12 @@
115
114
  <main class="pane">
116
115
  <div class="tb">
117
116
  <button class="ib menu" id="menuBtn" aria-label="Show sidebar"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-menu"/></svg></button>
118
- <div><h1 id="title">Tasks</h1><div class="sub"><span id="subName" translate="no"></span><span class="mono" id="subPath" translate="no"></span><span id="chatSub" aria-live="polite" hidden></span></div></div>
117
+ <div><h1 id="title">Tasks</h1><div class="sub"><span id="subName" translate="no"></span><span class="mono" id="subPath" translate="no"></span><span class="mono" id="crumb" translate="no" hidden></span></div></div>
119
118
  <div class="right">
120
119
  <div class="seg" id="modeSeg"><button class="on" data-m="list">List</button><button data-m="board">Board</button></div>
121
120
  <a class="ib" id="editorBtn" hidden aria-label="Open in VS Code" title="Open in VS Code"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-ext"/></svg></a>
122
121
  <div class="idewrap" id="ideWrap" hidden><button type="button" class="ib" id="ideBtn" aria-haspopup="menu" aria-expanded="false" aria-controls="ideMenu" aria-label="Open in AI IDE" title="Open in AI IDE"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-spark"/></svg></button><div class="idemenu" id="ideMenu" role="menu" aria-label="Open in AI IDE" hidden></div></div>
123
122
  <button type="button" class="btn line sm" id="newTask" hidden><svg class="ico ico-13" aria-hidden="true" focusable="false"><use href="#i-plus"/></svg>New Task</button>
124
- <button type="button" class="btn" id="chatRestart" hidden>Start over</button><button type="button" class="btn" id="chatClose" hidden>Close</button>
125
123
  </div>
126
124
  </div>
127
125
  <div class="content" id="content" tabindex="-1">
@@ -137,10 +135,10 @@
137
135
  </div>
138
136
  <div class="gl benefits"><div class="box">
139
137
  <div class="row"><span class="ic2"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-folder"/></svg></span><div class="body"><div class="ttl">Files are the truth</div><div class="det">Every view is read from <span class="mono" translate="no">.specs/</span> and git. Every action writes a file you could have edited by hand.</div></div></div>
140
- <div class="row"><span class="ic2"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-shield"/></svg></span><div class="body"><div class="ttl">Nothing leaves this machine</div><div class="det">Runs on localhost, no account, no telemetry. No <span class="mono" translate="no">.specs/</span> yet? The guided setup writes one for you.</div></div></div>
138
+ <div class="row"><span class="ic2"><svg class="ico" aria-hidden="true" focusable="false"><use href="#i-shield"/></svg></span><div class="body"><div class="ttl">Nothing leaves this machine</div><div class="det">Runs on localhost, no account, no telemetry. No <span class="mono" translate="no">.specs/</span> yet? Your AI IDE writes one for you.</div></div></div>
141
139
  </div></div>
142
140
  <div class="gl recents"><div class="gh">Recent projects <span class="cnt" id="homePath" translate="no"></span></div><div class="box" id="homeBox"></div></div>
143
- <!-- BL-PM-007: only with specpilot serve --mcp -->
141
+ <!-- BL-PM-007: unless specpilot serve --no-mcp (BL-105) -->
144
142
  <div class="gl" id="homeMcp" hidden><div class="gh">Connect Your AI IDE <span class="cnt">optional, one line</span></div><div class="box"><div class="mcp"><code class="v" id="mcpLine" translate="no"></code><button type="button" class="btn sm" id="mcpCopy">Copy</button></div></div><p class="note" id="mcpNote"></p></div>
145
143
  <div class="fine"><i aria-hidden="true"></i><span>Server running on <span class="mono" id="homeAddr" translate="no"></span> · <span id="homeVer" translate="no"></span></span></div>
146
144
  </section>
@@ -168,33 +166,29 @@
168
166
  <div id="secBody"></div>
169
167
  </section>
170
168
 
171
- <!-- SETUP CHAT (BL-PM-004): the init.specpilot.dev chat over the CLI's own questions; shown for a new project
172
- (#new) and for a named folder with no .specs/ yet (BL-055). The questions, their chat lines and choices come from the server -->
173
- <section class="view chat" id="v-chat">
174
- <div class="bar" role="progressbar" aria-label="Setup progress" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><i id="barI"></i></div>
175
- <p class="note" id="chatNote" hidden></p>
176
- <div class="cbody" id="cbody" hidden>
177
- <div class="cmain">
178
- <section class="intro" id="intro" hidden>
179
- <svg class="big" aria-hidden="true" focusable="false"><use href="#logo"/></svg>
180
- <div><h2 id="introH">Hey, I'm SpecPilot</h2><p id="introText"></p><p id="introText2" hidden></p><p class="note" id="introDetected" hidden translate="no"></p></div>
181
- <div class="fine" id="introFine">Runs on this machine. Nothing leaves it.</div>
182
- <form class="start" id="introForm" autocomplete="off">
183
- <div class="lbl" id="nameLbl">Name your project to start</div>
184
- <div class="row"><input class="cfield mono" id="nameIn" name="project-name" type="text" placeholder="e.g. parcel-track" spellcheck="false" maxlength="214" aria-labelledby="nameLbl" aria-describedby="nameErr"><button type="submit" class="send" id="nameGo" aria-label="Start">→</button></div>
185
- <div class="err" id="nameErr" role="alert"></div>
186
- <button type="button" class="btn pri" id="setupStart" hidden>Start Guided Setup</button>
187
- </form>
188
- </section>
189
- <section class="thread" id="thread" hidden><div class="col" id="msgs"></div></section>
190
- <section class="composer" id="composer" hidden><form class="col" id="comp" autocomplete="off"></form></section>
191
- </div>
169
+ <!-- SETUP (BL-103): a project without .specs/ (Open, Clone, a folder named on the command line) and #new.
170
+ The user's AI IDE does the setup over MCP; this view says how, and nothing on it writes a spec. -->
171
+ <section class="view setupv" id="v-setup">
172
+ <p class="lead" id="suLead"></p>
173
+ <p class="note" id="suNote" hidden></p>
174
+ <div class="gl" id="suNew" hidden>
175
+ <div class="fields">
176
+ <div class="f"><label for="suName">Project name</label><input id="suName" name="project-name" type="text" spellcheck="false" maxlength="214" placeholder="my-project" aria-describedby="suErr"></div>
177
+ <div class="f"><label for="suParent">Parent folder</label><div class="in"><input id="suParent" name="parent-folder" type="text" spellcheck="false" maxlength="4096" placeholder="~/dev" aria-describedby="suErr"><button type="button" class="btn" id="suBrowse">Browse…</button></div></div>
178
+ </div>
179
+ <p class="err" id="suErr" role="alert"></p>
180
+ <p class="note">Nothing is created yet. The folder is made by your IDE in step 3, only at this path.</p>
192
181
  </div>
182
+ <div class="warnbox" id="suOff" hidden><span aria-hidden="true">!</span><span>This server was started with <span class="mono" translate="no">--no-mcp</span>, so your IDE cannot reach it. Restart with <span class="mono" translate="no">specpilot serve</span> and come back here.</span></div>
183
+ <div class="gl step" id="suConnect"><div class="gh"><span class="n">1</span>Connect your AI IDE<span class="st" id="suStatus" role="status"></span></div><div class="box pre" id="suConfigBox"><pre id="suConfig" translate="no"></pre><button type="button" class="btn sm" id="suConfigCopy">Copy</button></div><p class="note" id="suMcpNote"></p></div>
184
+ <div class="gl step" id="suTell"><div class="gh"><span class="n">2</span>Tell it what to do</div><div class="box line"><code id="suPrompt" translate="no"></code><button type="button" class="btn sm" id="suPromptCopy">Copy</button></div></div>
185
+ <div class="gl step" id="suProgress"><div class="gh"><span class="n">3</span>Progress</div><p class="note">Updates by itself as your IDE calls the server. Nothing here to click.</p>
186
+ <ol class="steps"><li class="wait"><i aria-hidden="true"></i>Read the code</li><li class="wait"><i aria-hidden="true"></i>Answer the questions</li><li class="wait"><i aria-hidden="true"></i>Write the files</li><li class="wait"><i aria-hidden="true"></i>Validate</li></ol></div>
187
+ <p class="note sufoot" id="suFoot"></p>
193
188
  </section>
194
189
 
195
190
  <!-- FILE: any .specs/ file, rendered as written -->
196
191
  <section class="view" id="v-file">
197
- <div class="gl" id="fileNote" hidden></div>
198
192
  <div class="gl" id="fmBox"></div>
199
193
  <div class="md doc" id="fileBody"></div>
200
194
  </section>
package/ui/route.js CHANGED
@@ -127,7 +127,8 @@ function cloneProgress(data){
127
127
  segment of its root), never the whole path, which stays in the tooltip and the sub-line. */
128
128
  function projectLabel(p){return p.name!==null&&p.name!==undefined?p.name:String(p.root).split(/[/\\]/).filter(Boolean).pop()||p.root;}
129
129
 
130
- /* ---- the setup chat (BL-PM-004): one question at a time over GET /api/setup or /api/projects/new ---- */
130
+ /* ---- the question rules: the name and handle rules (init, the server, the Setup view), and the CLI's question
131
+ list as the chat core takes it (BL-PM-004; since BL-103 read on the server, for the setup tools of BL-104) ---- */
131
132
 
132
133
  /* What is wrong with a project name, in `specpilot init`'s words (`hint` is the terminal's extra line), or
133
134
  null. The one copy of the rule: init and the server load it from here, the page checks with it. */
@@ -180,71 +181,6 @@ function flowQuestions(q,answers,first){
180
181
  return out.sort((a,b)=>(a.order??-1)-(b.order??-1));
181
182
  }
182
183
 
183
- /* The question the composer shows: the one being edited, else the first asked question without an answer,
184
- else null, which means the recap. */
185
- function nextQuestion(list,answers,editing){
186
- if(editing){const qu=list.find(x=>x.key===editing);if(qu)return qu;}
187
- return list.find(x=>!answered(x,answers))||null;
188
- }
189
-
190
- /* What Continue shows under the answer, or null: a required text left empty, a project name or a handle
191
- the server would refuse (its own message; never the terminal's hint). */
192
- function answerError(qu,value){
193
- const v=String(value).trim();
194
- if(qu.choices)return null;
195
- if(!v)return qu.required?'This one is required.':null;
196
- if(qu.key==='name'){const e=projectNameError(v);return e?e.message+'.':null;}
197
- return qu.key==='handle'?handleError(v):null;
198
- }
199
-
200
- /* The bot bubble's line: `chat` with `{name}` and `{language}` filled. `ctx` is {name, language}: the project
201
- name (the folder's label in guided setup) and the language choice's text, or the detected language. */
202
- function chatText(qu,ctx){return String(qu.chat||'').replace(/\{name\}/g,ctx.name||'').replace(/\{language\}/g,ctx.language||'');}
203
-
204
- /* The answer as a bubble or a recap row shows it: the choice's own text up to its " — " part (the chips
205
- keep the whole), the typed text, or Skipped. */
206
- function answerText(qu,answers){
207
- if(typeof qu.text==='string')return qu.text; // the chat core's own (BL-PM-004b)
208
- const v=answers[qu.key];
209
- if(qu.choices){const c=qu.choices.find(x=>x.value===v);return c?c.name.split(' — ')[0]:'';}
210
- return String(v===undefined?'':v).trim()||'Skipped';
211
- }
212
-
213
- /* The thread up to the current question: the name bubble (a new project only: `named`), a divider per step,
214
- the skip notes before a question (BL-PM-004b), a bot row per asked question (with its file caption) and an
215
- answer row per answered one, then the note after it; after the last answer a Review divider. */
216
- function threadRows(q,list,answers,cur,ctx,named,det){
217
- const facts=step=>det&&det.rows?det.rows.filter(f=>f.step===step):[],marked=k=>!!det&&(det.keys||[]).includes(k);
218
- const steps=[...new Set(list.map(x=>x.step))],rows=[];
219
- if(named)rows.push({kind:'user',key:'name',text:ctx.name,mono:true,skipped:false});
220
- let last=null;
221
- for(const qu of list){
222
- if(qu.step!==last){
223
- rows.push({kind:'divider',text:`Step ${steps.indexOf(qu.step)+1} · ${qu.step}`});last=qu.step;
224
- // what the detector found for this step: answered, never asked, not editable (BL-PM-016)
225
- for(const f of facts(qu.step))rows.push({kind:'user',key:null,text:`${f.label}: ${f.value}`,mono:false,skipped:false,detected:true});
226
- }
227
- for(const n of qu.notesBefore||[])rows.push({kind:'note',text:n});
228
- rows.push({kind:'bot',key:qu.key,text:chatText(qu,ctx),cli:qu.message,caption:qu.caption||''});
229
- if(cur&&qu.key===cur.key)break;
230
- if(answered(qu,answers)){
231
- const text=answerText(qu,answers);
232
- rows.push({kind:'user',key:qu.key,text,mono:qu.key==='parent'||qu.key==='handle',skipped:text==='Skipped'||text==='None'&&!qu.choices,...(marked(qu.key)?{detected:true}:{})});
233
- if(qu.noteAfter)rows.push({kind:'note',text:qu.noteAfter});
234
- }
235
- }
236
- if(!cur)rows.push({kind:'divider',text:'Review'});
237
- return rows;
238
- }
239
-
240
- /* The recap: one card per step in use, the detector's rows first (no key: not editable), then one row per asked question. */
241
- function recapCards(list,answers,det){
242
- const steps=[...new Set(list.map(x=>x.step))],keys=det&&det.keys||[];
243
- return steps.map(step=>({title:step,rows:[
244
- ...(det&&det.rows||[]).filter(f=>f.step===step).map(f=>({key:null,label:f.label,value:f.value,detected:true})),
245
- ...list.filter(x=>x.step===step).map(qu=>({key:qu.key,label:qu.label,value:answerText(qu,answers),...(keys.includes(qu.key)?{detected:true}:{})}))]}));
246
- }
247
-
248
184
  /* The POST body: the answer of every question asked, text trimmed. */
249
185
  function flowBody(list,answers){
250
186
  const body={};
@@ -252,46 +188,12 @@ function flowBody(list,answers){
252
188
  return body;
253
189
  }
254
190
 
255
- /* The files that will be written for the answers so far: .specs/ for the API paradigm, then the files
256
- outside it for the IDE; `kept` marks one that is already in the folder (guided setup's `keep`). */
257
- function previewFiles(q,answers){
258
- const pick=k=>{const x=q.questions.find(y=>y.key===k);return x?flowValue(x,answers):undefined;};
259
- const ide=pick('ide'),keep=q.keep&&q.keep[ide]||[];
260
- return [...(q.files.specs[pick('apiParadigm')]||[]),...(q.files.outside[ide]||[])].map(path=>({path,kept:keep.includes(path)}));
261
- }
262
-
263
- /* ---- the full chat (BL-PM-004b): one renderer for every option, and tabs ---- */
264
-
265
- /* One option as a chip, or a card when it has a description: emoji, label, a Recommended or Check this badge,
266
- the description and a warning line. `pressed` is its state; `data-v` its value. */
267
- function optionHtml(o,pressed){
268
- const badge=o.badge==='recommended'?'<span class="bdg">Recommended</span>':o.badge==='flagged'?'<span class="bdg fl">Check this</span>':'';
269
- return `<button type="button" class="chip${o.description?' card':''}${o.todo?' todo':''}" aria-pressed="${!!pressed}" data-v="${esc(o.id)}"><b>${o.emoji?`<span class="em" aria-hidden="true">${esc(o.emoji)}</span>`:''}${esc(o.label)}${badge}</b>${o.description?`<small>${esc(o.description)}</small>`:''}${o.warning?`<small class="wn">⚠ ${esc(o.warning)}</small>`:''}</button>`;
270
- }
271
-
272
- /* A tab strip: `tabs` as [{id, label, count}], the active one selected. */
273
- function tabsHtml(tabs,active){
274
- return `<div class="ctabs" role="tablist">${tabs.map(t=>`<button type="button" role="tab" class="tab" aria-selected="${t.id===active}" data-tab="${esc(t.id)}">${esc(t.label)}${t.count?` <span class="cnt">${t.count}</span>`:''}</button>`).join('')}</div>`;
275
- }
276
-
277
- /* A CLI question's choices as options: the text up to " — " as the label, the rest as the description,
278
- with the chat core's badges. */
279
- function choiceOptions(qu){
280
- return (qu.choices||[]).map(c=>{const [label,description]=c.name.split(' — ');return {id:c.value,label,description,badge:qu.badges&&qu.badges[c.value]};});
281
- }
282
-
283
- /* Guided setup's answers the detector fills in (REQ-002.H.35): the platforms, from direct evidence only. */
284
- function seededAnswers(detected){return detected&&detected.platform?{platforms:[detected.platform]}:{};}
285
- /* The keys whose answer is still the one the detector filled in: they show `detected`. */
286
- function detectedKeys(seed,answers){return Object.keys(seed||{}).filter(k=>JSON.stringify(answers[k])===JSON.stringify(seed[k]));}
287
-
288
191
  /* The one line an IDE's MCP settings take (BL-PM-007); serve.ts prints the same line. */
289
192
  function mcpConfigLine(host,token){
290
193
  return JSON.stringify({mcpServers:{'specpilot-local':{type:'http',url:`http://${host}/mcp`,headers:{'X-SpecPilot-Token':token}}}});
291
194
  }
292
195
 
293
196
  const api={mcpConfigLine,resolveRoute,goneHtml,when,editorUrl,cursorPromptUrl,onboardingPrompt,recentHtml,openOutcome,reloadView,repoNameFromUrl,CLONE_STAGES,cloneStatus,cloneProgress,projectLabel,
294
- projectNameError,handleError,HANDLE_PATTERN,flowValue,answered,flowQuestions,nextQuestion,answerError,chatText,answerText,threadRows,recapCards,flowBody,previewFiles,
295
- optionHtml,tabsHtml,choiceOptions,seededAnswers,detectedKeys};
197
+ projectNameError,handleError,HANDLE_PATTERN,flowValue,answered,flowQuestions,flowBody};
296
198
  if(typeof module==='object'&&module.exports)module.exports=api;else Object.assign(root,api);
297
199
  })(this);