specpilot 2.10.0 → 2.11.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/dist/__tests__/fixtures/allFields.d.ts +3 -0
- package/dist/__tests__/fixtures/allFields.d.ts.map +1 -0
- package/dist/__tests__/fixtures/allFields.js +31 -0
- package/dist/__tests__/fixtures/allFields.js.map +1 -0
- package/dist/core/chatFlow.d.ts +420 -0
- package/dist/core/chatFlow.d.ts.map +1 -0
- package/dist/core/chatFlow.js +1107 -0
- package/dist/core/chatFlow.js.map +1 -0
- package/dist/core/specFiles.js +21 -21
- package/dist/core/templateEngine.d.ts.map +1 -1
- package/dist/core/templateEngine.js +15 -4
- package/dist/core/templateEngine.js.map +1 -1
- package/dist/utils/addSpecsQuestions.d.ts +2 -1
- package/dist/utils/addSpecsQuestions.d.ts.map +1 -1
- package/dist/utils/addSpecsQuestions.js +2 -1
- package/dist/utils/addSpecsQuestions.js.map +1 -1
- package/dist/utils/initQuestions.d.ts +2 -1
- package/dist/utils/initQuestions.d.ts.map +1 -1
- package/dist/utils/initQuestions.js +2 -1
- package/dist/utils/initQuestions.js.map +1 -1
- package/dist/utils/specServer.d.ts +5 -1
- package/dist/utils/specServer.d.ts.map +1 -1
- package/dist/utils/specServer.js +46 -11
- package/dist/utils/specServer.js.map +1 -1
- package/dist/utils/specSetup.d.ts +21 -4
- package/dist/utils/specSetup.d.ts.map +1 -1
- package/dist/utils/specSetup.js +113 -20
- package/dist/utils/specSetup.js.map +1 -1
- package/package.json +1 -1
- package/ui/app.css +43 -2
- package/ui/app.js +201 -45
- package/ui/index.html +11 -2
- package/ui/route.js +54 -5
package/ui/route.js
CHANGED
|
@@ -116,6 +116,7 @@ function flowValue(qu,answers){
|
|
|
116
116
|
/* Whether a question has been answered: its key is there and, for a choice, the answer is one of the
|
|
117
117
|
choices now offered (a framework kept from another language is asked again). An empty optional answer counts. */
|
|
118
118
|
function answered(qu,answers){
|
|
119
|
+
if(typeof qu.answered==='boolean')return qu.answered; // a question from the chat core (BL-PM-004b) knows
|
|
119
120
|
if(!(qu.key in answers))return false;
|
|
120
121
|
return !qu.choices||qu.choices.some(c=>c.value===answers[qu.key]);
|
|
121
122
|
}
|
|
@@ -161,22 +162,29 @@ function chatText(qu,ctx){return String(qu.chat||'').replace(/\{name\}/g,ctx.nam
|
|
|
161
162
|
/* The answer as a bubble or a recap row shows it: the choice's own text up to its " — " part (the chips
|
|
162
163
|
keep the whole), the typed text, or Skipped. */
|
|
163
164
|
function answerText(qu,answers){
|
|
165
|
+
if(typeof qu.text==='string')return qu.text; // the chat core's own (BL-PM-004b)
|
|
164
166
|
const v=answers[qu.key];
|
|
165
167
|
if(qu.choices){const c=qu.choices.find(x=>x.value===v);return c?c.name.split(' — ')[0]:'';}
|
|
166
168
|
return String(v===undefined?'':v).trim()||'Skipped';
|
|
167
169
|
}
|
|
168
170
|
|
|
169
171
|
/* The thread up to the current question: the name bubble (a new project only: `named`), a divider per step,
|
|
170
|
-
|
|
172
|
+
the skip notes before a question (BL-PM-004b), a bot row per asked question (with its file caption) and an
|
|
173
|
+
answer row per answered one, then the note after it; after the last answer a Review divider. */
|
|
171
174
|
function threadRows(q,list,answers,cur,ctx,named){
|
|
172
175
|
const steps=[...new Set(list.map(x=>x.step))],rows=[];
|
|
173
176
|
if(named)rows.push({kind:'user',key:'name',text:ctx.name,mono:true,skipped:false});
|
|
174
177
|
let last=null;
|
|
175
178
|
for(const qu of list){
|
|
176
179
|
if(qu.step!==last){rows.push({kind:'divider',text:`Step ${steps.indexOf(qu.step)+1} · ${qu.step}`});last=qu.step;}
|
|
177
|
-
rows.push({kind:'
|
|
180
|
+
for(const n of qu.notesBefore||[])rows.push({kind:'note',text:n});
|
|
181
|
+
rows.push({kind:'bot',key:qu.key,text:chatText(qu,ctx),cli:qu.message,caption:qu.caption||''});
|
|
178
182
|
if(cur&&qu.key===cur.key)break;
|
|
179
|
-
if(answered(qu,answers))
|
|
183
|
+
if(answered(qu,answers)){
|
|
184
|
+
const text=answerText(qu,answers);
|
|
185
|
+
rows.push({kind:'user',key:qu.key,text,mono:qu.key==='parent'||qu.key==='handle',skipped:text==='Skipped'||text==='None'&&!qu.choices});
|
|
186
|
+
if(qu.noteAfter)rows.push({kind:'note',text:qu.noteAfter});
|
|
187
|
+
}
|
|
180
188
|
}
|
|
181
189
|
if(!cur)rows.push({kind:'divider',text:'Review'});
|
|
182
190
|
return rows;
|
|
@@ -203,7 +211,48 @@ function previewFiles(q,answers){
|
|
|
203
211
|
return [...(q.files.specs[pick('apiParadigm')]||[]),...(q.files.outside[ide]||[])].map(path=>({path,kept:keep.includes(path)}));
|
|
204
212
|
}
|
|
205
213
|
|
|
206
|
-
|
|
207
|
-
|
|
214
|
+
/* ---- the full chat (BL-PM-004b): one renderer for every option, tabs, and the saved setups ---- */
|
|
215
|
+
|
|
216
|
+
/* One option as a chip, or a card when it has a description: emoji, label, a Recommended or Check this badge,
|
|
217
|
+
the description and a warning line. `pressed` is its state; `data-v` its value. */
|
|
218
|
+
function optionHtml(o,pressed){
|
|
219
|
+
const badge=o.badge==='recommended'?'<span class="bdg">Recommended</span>':o.badge==='flagged'?'<span class="bdg fl">Check this</span>':'';
|
|
220
|
+
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>`;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/* A tab strip: `tabs` as [{id, label, count}], the active one selected. */
|
|
224
|
+
function tabsHtml(tabs,active){
|
|
225
|
+
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>`;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* A CLI question's choices as options: the text up to " — " as the label, the rest as the description,
|
|
229
|
+
with the chat core's badges. */
|
|
230
|
+
function choiceOptions(qu){
|
|
231
|
+
return (qu.choices||[]).map(c=>{const [label,description]=c.name.split(' — ');return {id:c.value,label,description,badge:qu.badges&&qu.badges[c.value]};});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* Saved setups (REQ-002.H.28), kept by the page in localStorage under sp-setups: the list as stored, newest first. */
|
|
235
|
+
const SETUPS_KEY='sp-setups',MAX_SETUPS=50;
|
|
236
|
+
function setupsLoad(raw){
|
|
237
|
+
let v;try{v=JSON.parse(raw||'[]');}catch(e){return [];}
|
|
238
|
+
if(!Array.isArray(v))return [];
|
|
239
|
+
return v.filter(e=>e&&typeof e==='object'&&typeof e.id==='string'&&(e.kind==='new'||e.kind==='setup')&&e.answers&&typeof e.answers==='object')
|
|
240
|
+
.sort((a,b)=>(b.updatedAt||0)-(a.updatedAt||0));
|
|
241
|
+
}
|
|
242
|
+
/* The list with `entry` saved (replaced by id, else added), newest first, at most 50. */
|
|
243
|
+
function setupsPut(list,entry){return [entry,...list.filter(e=>e.id!==entry.id)].sort((a,b)=>(b.updatedAt||0)-(a.updatedAt||0)).slice(0,MAX_SETUPS);}
|
|
244
|
+
function setupsRemove(list,id){return list.filter(e=>e.id!==id);}
|
|
245
|
+
/* What is stored for a setup: never the token, only what the chat needs to resume. */
|
|
246
|
+
function setupRecord(st){
|
|
247
|
+
return {id:st.id,kind:st.kind,root:st.root,name:st.kind==='new'?String(st.answers.name||''):st.name||'',answers:st.answers,editing:null,started:!!st.started,
|
|
248
|
+
seeded:st.seeded||{},updatedAt:st.updatedAt||0,finished:!!st.finished,preview:st.preview||{done:false,changed:false}};
|
|
249
|
+
}
|
|
250
|
+
/* A row of the list: its title, `In progress` or `Ready to create`. */
|
|
251
|
+
function setupTitle(e){return e.kind==='setup'?(e.name||String(e.root||'').split(/[/\\]/).filter(Boolean).pop()||'Untitled setup'):(e.name||'Untitled setup');}
|
|
252
|
+
function setupStatus(e){return e.finished?'Ready to create':'In progress';}
|
|
253
|
+
|
|
254
|
+
const api={resolveRoute,goneHtml,when,recentHtml,openOutcome,reloadView,repoNameFromUrl,projectLabel,
|
|
255
|
+
projectNameError,handleError,HANDLE_PATTERN,flowValue,answered,flowQuestions,nextQuestion,answerError,chatText,answerText,threadRows,recapCards,flowBody,previewFiles,
|
|
256
|
+
optionHtml,tabsHtml,choiceOptions,SETUPS_KEY,setupsLoad,setupsPut,setupsRemove,setupRecord,setupTitle,setupStatus};
|
|
208
257
|
if(typeof module==='object'&&module.exports)module.exports=api;else Object.assign(root,api);
|
|
209
258
|
})(this);
|