fix(ui): check step names drop the repeated gate

This commit is contained in:
sam committed 2026-10-18 13:20:52 +11:00
1 parent a9cc2c07de
commit 369d33e251
2 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -127,7 +127,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Qq(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(qq(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=Zq(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(qq(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Yq(t.key)&&!qq(t.sep,`newline`)){let e=Zq(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):qq(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!qq(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Qq(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||qq(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.ite Line truncated
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=Zq(Xq(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=Zq(Xq(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function tJ(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Kq||null,prettyErrors:t}}function nJ(e,t={}){let{lineCounter:n,prettyErrors:r}=tJ(t),i=new eJ(n?.addNewLine),a=new Mq(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new JK(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(XK(e,n)),o.warnings.forEach(XK(e,n))),o}function rJ(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=nJ(e,n);if(!i)return null;if(i.warnings.forEach(e=>EG(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function iJ(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return xW(e)&&!r?e.toString(n):new GK(e,r,n).toString(n)}var aJ=e=>typeof e==`object`&&!!e&&!Array.isArray(e),oJ=e=>aJ(e)?Object.entries(e).map(([e,t])=>[e,Array.isArray(t)?t:[]]):[];function sJ(e){if(aJ(e)){if(aJ(e.parallel))return{kind:`parallel`,base:[`parallel`],branches:oJ(e.parallel)};if(aJ(e.switch))return{kind:`switch`,base:[`switch`,`cases`],on:typeof e.switch.on==`string`?e.switch.on:``,branches:oJ(e.switch.cases)}}}function cJ(e){return e.slice(2).includes(`parallel`)}function lJ(e,t){let n=nJ(e).getIn(t,!0);if(SW(n))return n.toJSON()}function uJ(e,t,n){let r=nJ(e);return r.setIn(t,r.createNode(xJ(n))),r.toString()}function dJ(e,t,n){let r=nJ(e),i=t.slice(0,-1),a=cJ(i);if(a&&![`agent.run`,`workflow.call`].includes(n))throw Error(`Branches allow only read-only agents and workflow calls.`);let o=r.getIn(i,!0);if(TW(o)||(r.setIn(i,r.createNode([])),o=r.getIn(i,!0)),!TW(o))return{source:e,path:[]};let s=Math.min(Math.max(Number(t.at(-1))+1,0),o.items.length),c=n===`parallel`?{parallel:{"branch-1":[],"branch-2":[]}}:n===`switch`?{switch:{on:``,cases:{true:[],default:[]}}}:{type:n,...a&&n===`agent.run`?{settings:{read_only:!0}}:{}};return o.items.splice(s,0,r.createNode(c)),{source:r.toString(),path:[...i,s]}}function fJ(e,t){if(t===`switch`){if(!e||e.includes(`/`))throw Error(`A case is the value it matches, without a slash.`)}else if(!/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(e))throw Error(`Use a lowercase branch name with letters, digits, dots or dashes.`)}function pJ(e,t){let n=e.getIn(t,!0),r=sJ(SW(n)?n.toJSON():void 0),i=r?e.getIn([...t,...r.base],!0):void 0;if(!r||!SW(i))throw Error(`This step has no branches.`);return{kind:r.kind,branches:i}}function mJ(e,t,n){let r=nJ(e),{kind:i,branches:a}=pJ(r,t);if(fJ(n,i),a.has(n))throw Error(`Branch ${n} already exists.`);return a.set(n,r.createNode([])),r.toString()}function hJ(e,t,n,r){let i=nJ(e),{kind:a,branches:o}=pJ(i,t);if(fJ(r,a),n!==r&&o.has(r))throw Error(`Branch ${r} already exists.`);let s=o.items.find(e=>wW(e.key)&&e.key.value===n);if(!s||!wW(s.key))throw Error(`Branch ${n} does not exist.`);return s.key.value=r,i.toString()}function gJ(e,t,n){let r=nJ(e),{kind:i,branches:a}=pJ(r,t);if(i===`parallel`&&a.items.length<=2)throw Error(`Parallel needs at least two branches.`);if(a.items.length<=1)throw Error(`A switch needs at least one case.`);return Line truncated
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=Zq(Xq(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=Zq(Xq(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function tJ(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Kq||null,prettyErrors:t}}function nJ(e,t={}){let{lineCounter:n,prettyErrors:r}=tJ(t),i=new eJ(n?.addNewLine),a=new Mq(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new JK(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(XK(e,n)),o.warnings.forEach(XK(e,n))),o}function rJ(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=nJ(e,n);if(!i)return null;if(i.warnings.forEach(e=>EG(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function iJ(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return xW(e)&&!r?e.toString(n):new GK(e,r,n).toString(n)}var aJ=e=>typeof e==`object`&&!!e&&!Array.isArray(e),oJ=e=>aJ(e)?Object.entries(e).map(([e,t])=>[e,Array.isArray(t)?t:[]]):[];function sJ(e){if(aJ(e)){if(aJ(e.parallel))return{kind:`parallel`,base:[`parallel`],branches:oJ(e.parallel)};if(aJ(e.switch))return{kind:`switch`,base:[`switch`,`cases`],on:typeof e.switch.on==`string`?e.switch.on:``,branches:oJ(e.switch.cases)}}}function cJ(e){return e.slice(2).includes(`parallel`)}function lJ(e,t){let n=nJ(e).getIn(t,!0);if(SW(n))return n.toJSON()}function uJ(e,t,n){let r=nJ(e);return r.setIn(t,r.createNode(xJ(n))),r.toString()}function dJ(e,t,n){let r=nJ(e),i=t.slice(0,-1),a=cJ(i);if(a&&![`agent.run`,`workflow.call`].includes(n))throw Error(`Branches allow only read-only agents and workflow calls.`);let o=r.getIn(i,!0);if(TW(o)||(r.setIn(i,r.createNode([])),o=r.getIn(i,!0)),!TW(o))return{source:e,path:[]};let s=Math.min(Math.max(Number(t.at(-1))+1,0),o.items.length),c=n===`parallel`?{parallel:{"branch-1":[],"branch-2":[]}}:n===`switch`?{switch:{on:``,cases:{true:[],default:[]}}}:{type:n,...a&&n===`agent.run`?{settings:{read_only:!0}}:{}};return o.items.splice(s,0,r.createNode(c)),{source:r.toString(),path:[...i,s]}}function fJ(e,t){if(t===`switch`){if(!e||e.includes(`/`))throw Error(`A case is the value it matches, without a slash.`)}else if(!/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(e))throw Error(`Use a lowercase branch name with letters, digits, dots or dashes.`)}function pJ(e,t){let n=e.getIn(t,!0),r=sJ(SW(n)?n.toJSON():void 0),i=r?e.getIn([...t,...r.base],!0):void 0;if(!r||!SW(i))throw Error(`This step has no branches.`);return{kind:r.kind,branches:i}}function mJ(e,t,n){let r=nJ(e),{kind:i,branches:a}=pJ(r,t);if(fJ(n,i),a.has(n))throw Error(`Branch ${n} already exists.`);return a.set(n,r.createNode([])),r.toString()}function hJ(e,t,n,r){let i=nJ(e),{kind:a,branches:o}=pJ(i,t);if(fJ(r,a),n!==r&&o.has(r))throw Error(`Branch ${r} already exists.`);let s=o.items.find(e=>wW(e.key)&&e.key.value===n);if(!s||!wW(s.key))throw Error(`Branch ${n} does not exist.`);return s.key.value=r,i.toString()}function gJ(e,t,n){let r=nJ(e),{kind:i,branches:a}=pJ(r,t);if(i===`parallel`&&a.items.length<=2)throw Error(`Parallel needs at least two branches.`);if(a.items.length<=1)throw Error(`A switch needs at least one case.`);return Line truncated
`).find(e=>e.trim())?.trim()}}function IJ(e,t){let n=JSON.stringify(e??{})+` `+(typeof t==`string`?`{{ ${t.replace(/^!/,``)} }}`:``);return[...new Set([...n.matchAll(MJ)].map(e=>e[1]))]}function LJ(e){let t=nJ(e).toJS(),n=NJ(t)&&Array.isArray(t.steps)?t.steps:[],r=[],i=[],a=new Map,o=[],s=new Set,c=`start`;r.push({id:c,type:`step`,position:{x:0,y:0},data:{kind:`start`,key:`start`,title:`Starts when`,type:``,detail:``}});let l=[c],u=1,d=new Map,f=e=>{let t=d.get(e)??0;return d.set(e,t+1),t},p=(e,t,n,i,s,c,l,u)=>{let d=NJ(e)?e:{},p=sJ(d),m=p?.kind??(typeof d.type==`string`?d.type:``),h=NJ(d.settings)?d.settings:{},g=typeof d.id==`string`?d.id:``,_=`step-${t}`,v=s?`${s}/${g||m}`:g||m;r.push({id:_,type:`step`,position:{x:n,y:i},data:{kind:`step`,key:g||t,name:g||void 0,title:g||jJ(m),type:m,step:l?.length===2?String(Number(l[1])+1).padStart(2,`0`):void 0,detail:p?.on?`on ${p.on.replace(/^steps\./,``)}`:PJ(m,h),summary:FJ(h),when:typeof d.when==`string`?d.when:void 0,retry:NJ(d.retry)&&typeof d.retry.attempts==`number`?d.retry.attempts:void 0,continues:d.on_failure===`continue`,branch:s,lane:u,path:l,stage:v,occurrence:f(v),...c?{resume:c}:{}}}),g&&a.set(g,_);let y=p?.on?`{{ ${p.on} }}`:``;for(let e of IJ([d.settings,y],d.when))o.push({from:e,to:_});return _},m=(e,t,n)=>{e.forEach((r,a)=>i.push({id:`flow-${r}-${t}`,source:r,target:t,kind:`flow`,...s.has(r)?{otherwise:!0}:{},insertAfter:a===e.length-1?n:void 0}))};for(let[e,t]of n.entries()){let n=sJ(t);if(n){let{kind:i,base:a,branches:o}=n,c=p(t,String(e+1),0,u*OJ,void 0,void 0,[`steps`,e]);m(l,c,[`steps`,e-1]),u++;let d=NJ(t)&&typeof t.id==`string`?t.id:i,f=i===`switch`&&!o.some(([e])=>e==="default"),h=o.length+ +!!f,g=[],_=0;o.forEach(([t,n],o)=>{let s=(o-(h-1)/2)*kJ,l=[c],f=[`steps`,e,...a,t];n.forEach((n,r)=>{let a=p(n,`${e+1}-${t}-${r+1}`,s,(u+r)*OJ,t,d,[...f,r],i);m(l,a,[...f,r-1]),l=[a]}),_=Math.max(_,n.length);let v=`add-${e}-${t}`;r.push({id:v,type:`add`,position:{x:s+104,y:(u+n.length)*OJ},data:{kind:`step`,key:v,title:``,type:``,detail:``,branch:t,lane:i,insertAfter:[...f,n.length-1]}}),m(l,v),g.push(v)});let v=(Math.max(_,1)+1)*OJ-24;o.forEach(([t],n)=>{let a=(n-(h-1)/2)*kJ;r.push({id:`lane-${e}-${t}`,type:`lane`,position:{x:a-12,y:u*OJ-40},style:{width:`264px`,height:`${v}px`},zIndex:-1,data:{kind:`step`,key:t,title:t,type:``,detail:``,lane:i}})}),f&&(g.push(c),s.add(c)),l=g,u+=Math.max(_,1)+1;continue}let i=p(t,String(e+1),0,u*OJ,void 0,void 0,[`steps`,e]);m(l,i,[`steps`,e-1]),l=[i],u++}r.push({id:`add-end`,type:`add`,position:{x:104,y:u*OJ-24},data:{kind:`step`,key:`add`,title:``,type:``,detail:``,insertAfter:[`steps`,n.length-1]}}),m(l,`add-end`);for(let{from:e,to:t}of o){let n=a.get(e);n&&(i.some(e=>e.kind===`flow`&&e.source===n&&e.target===t)||i.push({id:`data-${n}-${t}`,source:n,target:t,kind:`data`,label:e,offset:24+14*i.filter(e=>e.kind===`data`).length,sourceHandle:`data-out`,targetHandle:`data-in`}))}return{nodes:r,edges:i}}var RJ=`\0`,zJ=k({inheritAttrs:!1,__name:`OptionSelect`,props:{modelValue:{},options:{},placeholder:{},disabled:{type:Boolean},size:{},class:{}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=t;return(t,r)=>(R(),K(z(Dl),{"model-value":e.modelValue===``&&e.options.some(e=>e.value===``)?RJ:e.modelValue||void 0,disabled:e.disabled,"onUpdate:modelValue":r[0]||=e=>n(`update:modelValue`,e===RJ?``:String(e))},{default:j(()=>[M(z(Pl),H({size:e.size??`sm`,class:t.$props.class},t.$attrs),{default:j(()=>[M(z(Fl),{placeholder:e.placeholder},null,8,[`placeholder`])]),_:1},16,[`size`,`class`]),M(z(Ol),null,{default:j(()=>[(R(!0),W(V,null,G(e.options,e=>(R(),K(z(jl),{key:e.value,value:e.value===``?RJ:e.value,disabled:e.disabled},{default:j(()=>[A(B(e.label),1)]),_:2},1032,[`value`,`disabled`]))),128))]),_:1})]),_:1},8,[`model-value`,`disabled`]))}}),BJ=k({__name:`WorkflowPicker`,props:{value:{},workflows:{},label:{}},emits:[`pick`],setup(e,{emit:t}){let n=t;return(t,r)=>(R(),K(z(Dl),{"model-value":e.value||void 0,"onUpdate:modelValue":r[0]||=e=>n(`pick`,String(e))},{default:j(()=>[M(z(Pl),{"aria-label":e.label},{default:j(()=>[M(z(Fl),{placeholder:`Choose workflow`})]),_:1},8,[`aria-label`]),M(z(Ol),null,{default:j(()=>[e.value&&!e.workflows.some(t=>t.id===e.value)?(R(),K(z(jl),{key:0,value:e.value,disabled:``},{default:j(()=>[A(B(e.value)+` (unavailable)`,1)]),_:1},8,[`value`])):L(``,!0),(R(!0),W(V,null,G(e.workflows,e=>(R(),K(z(jl),{key:e.id,value:e.id},{default:j(()=>[A(B(e.id),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`model-value`]))}});function VJ(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function HJ(e,t=[]){let n=nJ(e),r=n.errors[0];if(r)return{ok:!1,message:rY(r.message),line:r.linePos?.[0]?.line};let i=n.toJS();if(!iY(i))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let a=typeof i.id==`string`?i.id.trim():``;if(!a)return{ok:!1,message:`workflow id is required`};let o=i.steps;if(o==null||o===``)return{ok:!1,message:`workflow ${a} has no steps`};if(!Array.isAr Line truncated
`).map((e,t)=>({number:t+1,text:e,tokens:$J(e)}))}var ZJ=/^(\s*)(-\s+)?/,QJ=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function $J(e){let{code:t,comment:n}=eY(e),r=tY(t);return n&&r.push({text:n,kind:`comment`}),r}function eY(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(t)r===t&&(t=``);else if(r===`"`||r===`'`)t=r;else if(r===`#`&&(n===0||/\s/.test(e[n-1]??``)))return{code:e.slice(0,n),comment:e.slice(n)}}return{code:e,comment:``}}function tY(e){if(!e)return[];let t=[],n=ZJ.exec(e);n?.[1]&&t.push({text:n[1],kind:`plain`}),n?.[2]&&t.push({text:n[2],kind:`punct`});let r=e.slice(n?.[0].length??0);if(!r)return t;let i=QJ.exec(r);return i?(t.push({text:i[1]??``,kind:`key`}),t.push({text:i[2]??`:`,kind:`punct`}),i[3]&&t.push({text:i[3],kind:`plain`}),[...t,...nY(i[4]??``)]):[...t,...nY(r)]}function nY(e){if(!e)return[];let t=/^("[^"]*"?|'[^']*'?)([\s\S]*)$/.exec(e);if(!t)return[{text:e,kind:`plain`}];let n=[{text:t[1]??``,kind:`string`}];return t[2]&&n.push({text:t[2],kind:`plain`}),n}function rY(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function iY(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function aY(e){return typeof e==`string`&&e.trim()!==``}var oY={class:`space-y-4 px-3 py-3`},sY={key:0,class:`rounded-md bg-danger/10 px-2.5 py-1.5 text-xs text-danger`,role:`alert`},cY={key:1,class:`space-y-3`},lY={key:0,class:`block space-y-1.5`},uY=[`id`],dY=[`value`],fY={class:`text-xs font-medium text-muted-foreground`},pY={class:`flex items-center gap-2`},mY={key:1,role:`alert`,class:`text-xs text-danger`},hY={key:2,class:`space-y-1.5`},gY=[`title`],_Y={key:4,class:`flex flex-wrap items-center gap-1 pt-0.5`},vY={key:0,class:`divide-y divide-border rounded-md border border-border`},yY=[`title`],bY={key:0,class:`space-y-3`},xY={class:`text-[13px]`},SY={key:0,class:`text-danger`},CY={class:`ml-2 text-xs text-fg-subtle`},wY={key:1,class:`space-y-3`},TY={class:`text-[13px]`},EY={class:`ml-2 text-xs text-fg-subtle`},DY=[`title`],OY={key:0,class:`text-xs text-danger`},kY={class:`space-y-1.5`},AY={key:0,role:`alert`,class:`text-xs text-danger`},jY={class:`divide-y divide-border rounded-md border border-border`},MY={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},NY={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},PY={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},FY={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},IY=[`for`],LY=k({__name:`StepEditor`,props:{yaml:{},path:{},vocabulary:{},workflows:{},modelAliases:{}},emits:[`update:yaml`],setup(e,{emit:t}){let n=We(),r=e,i=t,a=I(()=>lJ(r.yaml,r.path)??{}),o=I(()=>sJ(a.value)),s=I(()=>o.value?.kind??(typeof a.value.type==`string`?a.value.type:``)),c=I(()=>o.value?.branches.map(([e])=>e)??[]),l=I(()=>s.value===`parallel`?2:1);function u(e){i(`update:yaml`,uJ(r.yaml,r.path,{...a.value,switch:{...a.value.switch,on:e}}))}let d=q(``),f=q(``);function p(e,t,n=``){try{let a=e===`add`?mJ(r.yaml,r.path,t):e===`rename`?hJ(r.yaml,r.path,t,n):gJ(r.yaml,r.path,t);i(`update:yaml`,a),d.value=``,f.value=``}catch(e){f.value=String(e.message)}}let m=I(()=>r.vocabulary.find(e=>e.name===s.value)),h=I(()=>typeof a.value.settings==`object`&&a.value.settings!==null?a.value.settings:{}),g=I(()=>bJ(r.yaml,r.path)),_=I(()=>KJ(a.value)),v=I(()=>m.value?.settings&&a.value.settings?JJ(a.value.settings,m.value.settings,`settings`):``),y=[`mission`,`workflow`,`message`,`body`,`plan`,`then`,`status`,`detail`,`run`,`rules`],x=/mission|body|detail|plan|rules/;function S(e,t){return[`workflow.call`,`workflow.handoff`].includes(s.value)&&e===`workflow`||s.value===`human.approve`&&e===`then`?`workflow`:s.value===`agent.run`&&e===`model`?`select`:t.type===`string`?t.enum?`select`:x.test(e)?`text`:`line`:t.type===`boolean`?`boolean`:t.type===`integer`||t.type===`number`?`number`:t.type===`array`&&t.items?.type===`string`?`lines`:`yaml`}let C=I(()=>{let e=Object.entries(m.value?.settings?.properties??{}).filter(([e])=>s.value!==`workflow.call`||![`inputs`,`outputs`].includes(e)).map(([e,t])=>({key:e,schema:t,kind:S(e,t),options:s.value===`agent.run`&&e===`model`?r.modelAliases:t.enum??[]})),t=e.filter(e=>y.includes(e.key)&&e.kind!==`boolean`).sort((e,t)=>y.indexOf(e.key)-y.indexOf(t.key))[0],n=e.filter(e=>e!==t);return{lead:t,compact:n.filter(e=>[`workflow`,`select`,`line`,`number`,`boolean`].includes(e.kind)),long:n.filter(e=>[`text`,`lines`,`yaml`].includes(e.kind))}}),w=q(!C.value.lead&&!o.value),ee=e=>[{value:``,label:`Default`},...e.map(e=>({value:e,label:e}))];function te(e){let{id:t,type:n,...a}=e;i(`update:yaml`,uJ(r.yaml,r.path,{id:t,type:n,...a}))}function T(e,t){te({...a.value,[e]:t})}function E(e){let t={...a.value.retry,...e};T(`retry`,t.attempts===void 0&&!t.backoff?void 0:{...t,attempts:t.attempts??1})}function ne(e,t){let n={...h.value,[e]:t};s.value===`workflow.call`&&e===`wait`&&t!==!0&&delete n.outputs,te({...a.value,settings:n})}function re(e,t){let n={...h.value,[e]:t};s.value===`workflow.call`&&t!==h.value[e]&&(delete n.inputs,delete n.outputs),te({...a.value,settings:n})}let ie=I(()=>r.workflows.find(e=>e.id===h.value.workflow)),ae=I(()=>Object.entries(SJ(ie.value?.yaml??``,`inputs`)??{})),D=I(()=>Object.entries(SJ(ie.value?.yaml??``,`outputs`)??{})),oe=I(()=>Object.entries(SJ(r.yaml,`inputs`)??{})),se=I(()=>Object.entries(SJ(r.yaml,`outputs`)??{})),ce=I(()=>h.value.inputs??{}),O=I(()=>h.value.outputs??{}),le=e=>typeof e==`string`&&e.startsWith(`inputs.`),ue=e=>[`object`,`array`].includes(e.type??``),de=e=>ce.value[e]===void 0?``:String(ce.value[e]);function fe(e,t,n){ne(`inputs`,{...ce.value,[e]:t===``?void 0:le(t)?t:Gv(t,n??`string`)})}let pe=(e,t,n)=>e.filter(([,e])=>e.type===t.type||e.type===`any`||t.type===`any`).map(([e])=>({value:`${n}.${e}`,label:e})),me=q(null);function he(e,t){let n=me.value??C.value.lead?.key;if(!n)return;let r=typeof h.value[n]==`string`?h.value[n]:``,i=`{{ steps.${e}.${t} }}`;ne(n,r?`${r.trimEnd()} ${i}`:i)}let ge=q({});function _e(e,t){try{ne(e,t.trim()?rJ(t):void 0),ge.value={...ge.value,[e]:``}}catch(t){ge.value={...ge.value,[ Line truncated
+3 -3
View File
@@ -154,9 +154,9 @@ const TYPE_TITLES: Record<string, string> = {
"repo.prepare": "Prepare worktree",
"repo.commit": "Commit",
"repo.open-pr": "Open pull request",
"gate.repository": "Repository gate",
"gate.diff-size": "Diff size gate",
"gate.diff-rules": "Diff rules gate",
"gate.repository": "Repository",
"gate.diff-size": "Diff size",
"gate.diff-rules": "Diff rules",
"forge.comment": "Comment",
"forge.close-issue": "Close issue",
"human.approve": "Human approval",