@code-partner/codepipe 0.13.1-dev.256.gc0bb4c3 → 0.13.1-dev.265.g11b4c39
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/index.js +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var lb=Object.defineProperty;var x=(t,e)=>()=>(t&&(e=t(t=0)),e);var ze=(t,e)=>{for(var r in e)lb(t,r,{get:e[r],enumerable:!0})};var Ve,mt,zs=x(()=>{"use strict";Ve="0.13.1-dev.
|
|
2
|
+
var lb=Object.defineProperty;var x=(t,e)=>()=>(t&&(e=t(t=0)),e);var ze=(t,e)=>{for(var r in e)lb(t,r,{get:e[r],enumerable:!0})};var Ve,mt,zs=x(()=>{"use strict";Ve="0.13.1-dev.265.g11b4c39",mt="https://hub.dev.codepipe.dev"});function Vn(t){return typeof t!="number"||!Number.isFinite(t)?!1:t>=xu&&t<=ht}var ht,xu,Su=x(()=>{"use strict";zs();ht=4,xu=4});var Eu=x(()=>{"use strict";zs()});function Xn(t=6){return`# CodePipe Context Repo format version.
|
|
3
3
|
# Bumped by the scaffold / the format-migration PR \u2014 do not edit by hand.
|
|
4
4
|
template_version: ${t}
|
|
5
5
|
`}function Xs(t){if(!t)return 0;let e=/^\s*template_version:\s*(\d+)\s*$/m.exec(t),r=e?parseInt(e[1]??"",10):NaN;return Number.isFinite(r)&&r>=0?r:0}function Js(t,e=Vs){let r=[];for(let n of e)if(!(n.version<=t))for(let o of n.addedPaths)r.includes(o)||r.push(o);return r}function Zs(t,e=Vs){return e.filter(r=>r.version>t)}var Tu,gt,Kr,Vs,Ru=x(()=>{"use strict";Tu=6,gt=".codepipe-context.yaml",Kr=".devpipe-context.yaml",Vs=[{version:1,summary:"ADR section: adr/ scaffold (README, template, derived INDEX) + the format-version stamp itself",addedPaths:["adr/README.md","adr/0000-template.md","adr/INDEX.md",gt]},{version:2,summary:"Rename the format-version stamp .devpipe-context.yaml \u2192 .codepipe-context.yaml (drop the devpipe-brand leftover)",addedPaths:[gt]},{version:3,summary:"Custom project actions (the RUN tab): actions/ scaffold with the format README",addedPaths:["actions/README.md"]},{version:4,summary:"Project map: model/ scaffold with the format README (facts/ vs derived/ layout)",addedPaths:["model/README.md"]},{version:5,summary:"Roles: roles/ scaffold with the format README (override a bundled critic by name, or add your own)",addedPaths:["roles/README.md"]},{version:6,summary:"Skills: skills/ scaffold with the format README (procedures the agent invokes instead of improvising)",addedPaths:["skills/README.md"]}]});function Zn(t){return`model/facts/identity/${t}.yaml`}function gr(t){return`model/facts/events/${t}.yaml`}function ta(t){return`model/facts/annotations/${t}.md`}function ra(t){return`model/derived/correlates/${t}.yaml`}function na(t){return`model/derived/touched/${t}.yaml`}function Iu(t){return t===""?"root":t.replace(/\//g,"-")}function oa(t,e){return`model/derived/structure/${t}/${Iu(e)}.yaml`}function ei(t){return typeof t=="string"&&Pu.test(t)}function re(t){if(typeof t!="string")return null;let e=t.indexOf(":");if(e<=0)return null;let r=t.indexOf(":",e+1);if(r<0)return null;let n=t.slice(0,e);if(!Cu.includes(n))return null;let o=t.slice(e+1,r),i=t.slice(r+1);return o===""&&!mb.includes(n)||i===""?null:{level:n,repo:o,path:i}}function xe(t){return`task::${t}`}function ye(t,e,r){return`${t}:${e}:${r}`}function Qn(t){let e=[];return vt(t)?(ri(t.modelFormatVersion)||e.push("modelFormatVersion: missing or not a positive integer"),typeof t.repo!="string"&&e.push("repo: missing (empty string = cross-repo)"),typeof t.builtFromCommit!="string"&&e.push("builtFromCommit: missing"),Array.isArray(t.edges)?t.edges.forEach((r,n)=>{if(!vt(r)){e.push(`edges[${n}]: not an object`);return}ia.includes(r.kind)||e.push(`edges[${n}].kind: unknown "${String(r.kind)}"`),re(r.from)||e.push(`edges[${n}].from: malformed nodeKey`),re(r.to)||e.push(`edges[${n}].to: malformed nodeKey`),r.weight!==void 0&&!(typeof r.weight=="number"&&Number.isFinite(r.weight))&&e.push(`edges[${n}].weight: not a finite number`)}):e.push("edges: not an array"),e.length?{ok:!1,errors:e}:{ok:!0,value:t}):{ok:!1,errors:["edge sheet: not an object"]}}function Au(t){return{...t,edges:Hr(t.edges,e=>`${e.kind} ${e.from} ${e.to}`)}}function yr(t){return kr(Au(t))}function vt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ri(t){return typeof t=="number"&&Number.isInteger(t)&&t>0}function yt(t){return typeof t=="string"&&t.length>0}function gb(t){return t.modelFormatVersion!==2}function jt(t){let e=[];if(!vt(t))return{ok:!1,errors:["shard: not an object"]};ri(t.modelFormatVersion)||e.push("modelFormatVersion: missing or not a positive integer"),yt(t.repo)||e.push("repo: missing or empty"),yt(t.builtFromCommit)||e.push("builtFromCommit: missing or empty");let r=typeof t.repo=="string"?t.repo:"",n=new Set;return Array.isArray(t.nodes)?t.nodes.forEach((o,i)=>{if(!vt(o)){e.push(`nodes[${i}]: not an object`);return}let s=re(o.key);if(!s){e.push(`nodes[${i}].key: malformed nodeKey (${JSON.stringify(o.key??null)})`);return}o.level!==s.level&&e.push(`nodes[${i}]: level "${String(o.level)}" does not match key prefix "${s.level}"`),r&&s.repo!==r&&e.push(`nodes[${i}].key: repo "${s.repo}" mixed into shard of repo "${r}"`);let a=o.key;n.has(a)&&e.push(`nodes[${i}].key: duplicate "${a}"`),n.add(a),o.entityId!==void 0&&!ei(o.entityId)&&e.push(`nodes[${i}].entityId: malformed (${JSON.stringify(o.entityId)})`)}):e.push("nodes: not an array"),Array.isArray(t.edges)?t.edges.forEach((o,i)=>{if(!vt(o)){e.push(`edges[${i}]: not an object`);return}ia.includes(o.kind)||e.push(`edges[${i}].kind: unknown "${String(o.kind)}"`),(!yt(o.to)||!re(o.to))&&e.push(`edges[${i}].to: malformed nodeKey`),(!yt(o.from)||!n.has(o.from))&&e.push(`edges[${i}].from: "${String(o.from)}" is not a node of this shard`),o.weight!==void 0&&!(typeof o.weight=="number"&&Number.isFinite(o.weight))&&e.push(`edges[${i}].weight: not a finite number`)}):e.push("edges: not an array"),e.length?{ok:!1,errors:e}:{ok:!0,value:t}}function eo(t){let e=[];if(!vt(t))return{ok:!1,errors:["identity: not an object"]};if(ri(t.modelFormatVersion)||e.push("modelFormatVersion: missing or not a positive integer"),yt(t.repo)||e.push("repo: missing or empty"),t.builtFromCommit!==void 0&&!yt(t.builtFromCommit)&&e.push("builtFromCommit: not a non-empty string"),!Array.isArray(t.entities))e.push("entities: not an array");else{let r=new Set;t.entities.forEach((n,o)=>{if(!vt(n)){e.push(`entities[${o}]: not an object`);return}ei(n.entityId)?r.has(n.entityId)?e.push(`entities[${o}].entityId: duplicate "${n.entityId}"`):r.add(n.entityId):e.push(`entities[${o}].entityId: malformed (${JSON.stringify(n.entityId??null)})`),re(n.currentKey)||e.push(`entities[${o}].currentKey: malformed nodeKey`),n.status!=="active"&&n.status!=="orphaned"&&e.push(`entities[${o}].status: expected active|orphaned`),yt(n.firstSeen)||e.push(`entities[${o}].firstSeen: missing`),yt(n.lastSeen)||e.push(`entities[${o}].lastSeen: missing`),n.aliases!==void 0&&(Array.isArray(n.aliases)?n.aliases.forEach((i,s)=>{(!vt(i)||!re(i.key)||!yt(i.until))&&e.push(`entities[${o}].aliases[${s}]: malformed`)}):e.push(`entities[${o}].aliases: not an array`))})}return e.length?{ok:!1,errors:e}:{ok:!0,value:t}}function Nt(t){let e=[];return vt(t)?(ri(t.modelFormatVersion)||e.push("modelFormatVersion: missing or not a positive integer"),yt(t.taskKey)||e.push("taskKey: missing or empty"),t.origin!=="bootstrap"&&t.origin!=="pipeline"&&e.push("origin: expected bootstrap|pipeline"),t.date!==void 0&&!(typeof t.date=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t.date))&&e.push("date: expected YYYY-MM-DD"),(!Array.isArray(t.commits)||t.commits.some(r=>!yt(r)))&&e.push("commits: not an array of non-empty strings"),Array.isArray(t.files)?t.files.forEach((r,n)=>{if(!vt(r)||!re(r.key)){e.push(`files[${n}].key: malformed nodeKey`);return}r.entityId!==void 0&&!ei(r.entityId)&&e.push(`files[${n}].entityId: malformed`),r.churn!==void 0&&!(typeof r.churn=="number"&&r.churn>=0)&&e.push(`files[${n}].churn: not a non-negative number`)}):e.push("files: not an array"),e.length?{ok:!1,errors:e}:{ok:!0,value:t}):{ok:!1,errors:["event: not an object"]}}function Hr(t,e){return[...t].sort((r,n)=>e(r)<e(n)?-1:e(r)>e(n)?1:0)}function _u(t){return{...t,nodes:Hr(t.nodes,e=>e.key),edges:Hr(t.edges,e=>`${e.kind}\0${e.from}\0${e.to}`)}}function ju(t){return{...t,entities:Hr(t.entities,e=>e.entityId).map(e=>e.aliases?{...e,aliases:Hr(e.aliases,r=>`${r.key}\0${r.until}`)}:e)}}function Nu(t){let e=t.links?{...t.links,...t.links.adr?{adr:[...t.links.adr].sort()}:{},...t.links.tasks?{tasks:[...t.links.tasks].sort()}:{}}:void 0;return{...t,commits:[...t.commits].sort(),files:Hr(t.files,r=>r.key),...e?{links:e}:{}}}function Jn(t){return yb.test(t)?t:JSON.stringify(t)}function Ou(t){if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="number"){if(!Number.isFinite(t))throw new Error(`model yaml: non-finite number ${t}`);return JSON.stringify(t)}if(typeof t=="string")return JSON.stringify(t);throw new Error(`model yaml: unsupported scalar ${typeof t}`)}function Lu(t){return t===null||["boolean","number","string"].includes(typeof t)}function Qs(t){return Object.entries(t).filter(([,e])=>e!==void 0).sort(([e],[r])=>e<r?-1:e>r?1:0)}function Mu(t,e,r){if(Array.isArray(t)){for(let n of t)if(Lu(n))r.push(`${e}- ${Ou(n)}`);else{if(Array.isArray(n))throw new Error("model yaml: nested arrays are not part of the model schema");{let o=Qs(n);if(o.length===0){r.push(`${e}- {}`);continue}o.forEach(([i,s],a)=>{let c=a===0?`${e}- `:`${e} `;ea(i,s,c,`${e} `,r)})}}return}for(let[n,o]of Qs(t))ea(n,o,e,e,r)}function ea(t,e,r,n,o){if(Lu(e))o.push(`${r}${Jn(t)}: ${Ou(e)}`);else if(Array.isArray(e))e.length===0?o.push(`${r}${Jn(t)}: []`):(o.push(`${r}${Jn(t)}:`),Mu(e,`${n} `,o));else{let i=Qs(e);if(i.length===0)o.push(`${r}${Jn(t)}: {}`);else{o.push(`${r}${Jn(t)}:`);for(let[s,a]of i)ea(s,a,`${n} `,`${n} `,o)}}}function kr(t){let e=[];return Mu(t,"",e),e.join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`}function ua(t){return kr(_u(t))}function da(t){return kr(ju(t))}function Wr(t){return kr(Nu(t))}var Oe,ub,db,pb,fb,Qo,hr,Cu,ia,Pu,mb,nt,sa,aa,ca,ti,hb,la,wr,yb,pa=x(()=>{"use strict";Oe=2,ub="model",db="model/README.md",pb="model/facts",fb="model/derived",Qo="model/derived/INDEX.yaml",hr="model/derived/relates.yaml";Cu=["system","container","component","code","task","adr"],ia=["contains","touched_by","correlates","relates","references","depends_on"],Pu=/^e_[0-9a-f]{8}$/;mb=["system","task","adr"];nt={windowCommits:1e3,commitFileCap:30,supportMin:5,jaccardMinPct:25,halfLifeDays:270,topK:8};sa=2,aa=5,ca=50,ti=2e3,hb=5e4,la={touched_by:.8,references:.7,relates:.6,correlates:.4,contains:.3,depends_on:.5},wr={budgetTokens:4e3,activationCutoff:.05,topKPerNode:8,nodeCap:200};yb=/^[A-Za-z0-9_][A-Za-z0-9_.-]*$/});function wb(t){return t==="DONE"}function kb(t){return t==="AWAITING_EXTERNAL_FIX"?!1:fa.indexOf(t)>=fa.indexOf("IMPLEMENTING")}var fa,Du=x(()=>{"use strict";fa=["BACKLOG","QUEUED","INTAKE","AWAITING_APPROVAL","ANALYZING","ESTIMATING","AWAITING_ANSWER","REVIEW","READY","IMPLEMENTING","BUILD","CODE_REVIEW","TESTING","AWAITING_EXTERNAL_FIX","READY_TO_APPLY","APPLYING","AWAITING_CLUSTER","TRACKING","NEEDS_MANUAL","DONE"]});function $b(t){for(let e of ma)if(e.phases.includes(t))return e.id;return null}function vb(t){for(let e of Uu)if(e.phases.includes(t))return e.id;return null}var ma,bb,Uu,Bu=x(()=>{"use strict";ma=[{id:"intake",label:"Intake",phases:["INTAKE"]},{id:"analysis",label:"Analysis",phases:["ANALYZING","ESTIMATING"]},{id:"ready",label:"Ready",phases:["READY"]},{id:"implementation",label:"Implementation",phases:["IMPLEMENTING","BUILD"]},{id:"delivery",label:"Delivery",phases:["READY_TO_APPLY","APPLYING","AWAITING_CLUSTER"]}],bb=ma.flatMap(t=>t.phases),Uu=[{id:"review",label:"Review / tracking",phases:["CODE_REVIEW","TESTING","TRACKING"]},{id:"attention",label:"Need your attention",phases:["NEEDS_MANUAL","AWAITING_APPROVAL","AWAITING_EXTERNAL_FIX","AWAITING_ANSWER","REVIEW"]},{id:"backlog",label:"Backlog / queue",phases:["BACKLOG","QUEUED"]}]});function xb(t){return Fu.includes(t)?"planning":"implementation"}function Ht(){return{inputTokens:0,outputTokens:0,cacheReadInputTokens:0,cacheCreationInputTokens:0,totalCostUsd:0,model:"",numTurns:0,durationMs:0}}var ha,Fu,Sb,ga=x(()=>{"use strict";ha=["estimate","analyze","implement","resolve-conflict","rework","draft","build","code-review","index","backfill","analysis","chat","observer","council","testing"],Fu=["draft","analysis","chat","observer","council"];Sb=1});function Gu(t,e){return e.toLowerCase().includes(t.toLowerCase())}function ka(t){let e=t.filter(o=>o&&typeof o.id=="string"&&o.id.trim().length>0);if(e.length===0||Yu.every(o=>e.some(i=>Gu(o,i.id))))return null;let n=[...e].sort((o,i)=>{let s=o.createdAt??"",a=i.createdAt??"";return s!==a?s<a?1:-1:o.id<i.id?1:-1});for(let o of qu){let i=n.find(s=>Gu(o,s.id));if(i)return i.id}return n[0].id}function qr(){return{default:null,roles:{}}}function Eb(t,e){let r=t?.roles?.[e];return typeof r=="string"&&r.trim().length>0?r.trim():t?.default&&t.default.trim().length>0?t.default.trim():ro[e]??Wu}function Tb(t){let e=t?.provider;return typeof e=="string"&&e.trim().length>0?e.trim():Xe}function Rb(t){let e=qr();if(!t||typeof t!="object")return e;let r=t.llm;if(!r||typeof r!="object")return e;let n=r.provider;typeof n=="string"&&n.trim().length>0&&(e.provider=n.trim());let o=r.models;if(!o||typeof o!="object")return e;for(let[i,s]of Object.entries(o))typeof s!="string"||s.trim().length===0||(i==="default"?e.default=s.trim():e.roles[i]=s.trim());return e}function Ib(t){let e=typeof t.provider=="string"&&t.provider.trim().length>0&&t.provider.trim()!==Xe;if(t.default===null&&Object.keys(t.roles).length===0&&!e)return null;let{provider:r,...n}=t;return JSON.stringify(e?{provider:r.trim(),...n}:n)}function Cb(t){if(!t)return qr();try{let e=JSON.parse(t);if(!e||typeof e!="object")return qr();let r=e,n=qr();typeof r.provider=="string"&&r.provider.trim().length>0&&(n.provider=r.provider.trim()),typeof r.default=="string"&&(n.default=r.default);let o=r.roles;if(o&&typeof o=="object")for(let[i,s]of Object.entries(o))typeof s=="string"&&(n.roles[i]=s);return n}catch{return qr()}}var Xe,ya,Pe,to,ni,oi,Ku,Hu,wa,ro,Wu,qu,Yu,ba=x(()=>{"use strict";ga();Xe="claude",ya=[Xe],Pe="opus",to="sonnet",ni="haiku",oi=[Pe,to,ni],Ku="build-discovery",Hu=[Ku],wa=[...ha,...Hu],ro={analyze:Pe,implement:Pe,"resolve-conflict":Pe,rework:Pe,estimate:to,build:ni,"build-discovery":Pe,"code-review":Pe,draft:to,index:Pe,backfill:Pe,analysis:Pe,chat:Pe,observer:Pe,council:Pe,testing:Pe},Wu=Pe,qu=[Pe,to,ni],Yu=Array.from(new Set(Object.values(ro)))});function Ot(t){return Pb.has(t)?!0:Ab.some(e=>t.startsWith(e))}function ii(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function br(t,e){if(t!=null){if(typeof t!="string")throw new Error(`${e} must be a string`);return t}}function va(t,e){if(t!=null){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} must be a number`);return t}}function Sa(t,e){let r=ii(e,"action definition"),n=t.replace(/\.(yml|yaml)$/i,""),o=br(r.id,"id")??n;if(!$a.test(o))throw new Error(`id must match ${$a} (got "${o}")`);if(o!==n)throw new Error(`id "${o}" must match the file name ("${n}")`);let i=br(r.title,"title")?.trim()||o,s;if(r.env!==void 0&&r.env!==null){let p=ii(r.env,"env");s={};for(let[d,m]of Object.entries(p)){if(!Je.test(d))throw new Error(`env name "${d}" must match ${Je}`);if(typeof m!="string"&&typeof m!="number"&&typeof m!="boolean")throw new Error(`env.${d} must be a scalar`);s[d]=String(m)}}let a,c=r.params;if(c!=null){if(!Array.isArray(c))throw new Error("params must be a list");if(c.length>zu)throw new Error(`too many params (max ${zu})`);let p=new Set;a=c.map((d,m)=>_b(d,m,p))}let l=r.steps;if(!Array.isArray(l)||l.length===0)throw new Error("steps must be a non-empty list");if(l.length>Vu)throw new Error(`too many steps (max ${Vu})`);let u=l.map((p,d)=>{let m=ii(p,`steps[${d}]`),f=br(m.run,`steps[${d}].run`);if(!f||f.trim().length===0)throw new Error(`steps[${d}].run is required`);let g=br(m.name,`steps[${d}].name`),k=va(m.timeout_sec,`steps[${d}].timeout_sec`);if(k!==void 0&&(!Number.isInteger(k)||k<=0))throw new Error(`steps[${d}].timeout_sec must be a positive integer`);return{run:f,...g?{name:g}:{},...k!==void 0?{timeout_sec:k}:{}}});return{id:o,title:i,...s?{env:s}:{},...a?{params:a}:{},steps:u}}function _b(t,e,r){let n=ii(t,`params[${e}]`),o=br(n.name,`params[${e}].name`);if(!o||!Je.test(o))throw new Error(`params[${e}].name must match ${Je}`);if(r.has(o))throw new Error(`duplicate param "${o}"`);r.add(o);let i=n.type;if(i!=="string"&&i!=="enum"&&i!=="number"&&i!=="boolean")throw new Error(`params[${e}].type must be string | enum | number | boolean`);let s;if(i==="enum"){let m=n.enum;if(!Array.isArray(m)||m.length===0||!m.every(f=>typeof f=="string"))throw new Error(`params[${e}].enum must be a non-empty string list`);s=m}let a=br(n.label,`params[${e}].label`),c=br(n.help,`params[${e}].help`),l=n.required===!0,u=va(n.min,`params[${e}].min`),p=va(n.max,`params[${e}].max`),d=n.default;if(d!=null&&typeof d!="string"&&typeof d!="number"&&typeof d!="boolean")throw new Error(`params[${e}].default must be a scalar`);return{name:o,type:i,...a?{label:a}:{},...c?{help:c}:{},...l?{required:!0}:{},...s?{enum:s}:{},...u!==void 0?{min:u}:{},...p!==void 0?{max:p}:{},...d!=null?{default:d}:{}}}function Ea(t,e){let r=t.params??[],n=new Map(r.map(i=>[i.name,i]));for(let i of Object.keys(e))if(!n.has(i))return{ok:!1,error:`unknown param: ${i}`};let o={};for(let i of r){let s=e[i.name];if(s==null||typeof s=="string"&&s.trim()==="")if(i.default!==void 0)s=i.default;else{if(i.required)return{ok:!1,error:`${i.name} is required`};continue}switch(i.type){case"string":{if(typeof s!="string")return{ok:!1,error:`${i.name} must be a string`};o[i.name]=s;break}case"enum":{if(typeof s!="string"||!(i.enum??[]).includes(s))return{ok:!1,error:`${i.name} must be one of: ${(i.enum??[]).join(", ")}`};o[i.name]=s;break}case"number":{let a=typeof s=="number"?s:typeof s=="string"?Number(s):NaN;if(!Number.isFinite(a))return{ok:!1,error:`${i.name} must be a number`};if(i.min!==void 0&&a<i.min)return{ok:!1,error:`${i.name} must be \u2265 ${i.min}`};if(i.max!==void 0&&a>i.max)return{ok:!1,error:`${i.name} must be \u2264 ${i.max}`};o[i.name]=a;break}case"boolean":{let a=typeof s=="boolean"?s:s==="true"?!0:s==="false"?!1:null;if(a===null)return{ok:!1,error:`${i.name} must be a boolean`};o[i.name]=a;break}}}return{ok:!0,values:o}}var Je,Pb,Ab,xa,$a,zu,Vu,Ta=x(()=>{"use strict";Je=/^[A-Z][A-Z0-9_]*$/,Pb=new Set(["GH_TOKEN","GITHUB_TOKEN","GITLAB_TOKEN"]),Ab=["BITBUCKET_","YOUTRACK_","CLAUDE_","INPUT_"];xa=600,$a=/^[a-z0-9-]+$/,zu=32,Vu=64});function Xu(){return{primary:$e,context:$e,tasks:$e,docs:$e,code_comments:$e,chat:$e,code_review:$e}}function Ju(t){return!t||t.trim().length===0||t.trim().toLowerCase()===$e}function jb(t){if(typeof t!="string")return $e;let e=t.trim().replace(/\s+/g," ");return e.length===0||e.length>40||e.toLowerCase()===$e?$e:e}function Nb(t){let e=Xu();if(!t||typeof t!="object")return e;let r=t.language;if(!r||typeof r!="object"||Array.isArray(r))return e;let n=r;for(let o of no)e[o]=jb(n[o]);return e}function Ob(t){return no.every(e=>Ju(t[e]))}var $e,no,Yr,oo,Ra=x(()=>{"use strict";$e="auto",no=["primary","context","tasks","docs","code_comments","chat","code_review"],Yr=["English","Russian","German","Spanish","French","Portuguese","Italian","Chinese","Japanese","Korean"],oo=40});function Aa(t=Zu){let e=[];for(let r of t)e.push(...r.fields),r.groups&&e.push(...Aa(r.groups));return e}function Qu(t,e){let r=JSON.stringify(e);return Aa().find(n=>n.file===t&&JSON.stringify(n.path)===r)}function _a(t){let e=Qu(t.file,t.path);if(!e)return{ok:!1,error:`unknown setting path: ${t.file}:${t.path.join(".")}`};let r=t.value,n=e.type==="model"||e.type==="enum"||e.type==="string";if(r===null||n&&typeof r=="string"&&r.trim().length===0)return e.nullable?{ok:!0,field:e,value:null}:{ok:!1,error:`${e.id} cannot be cleared`};switch(e.type){case"model":case"string":{if(typeof r!="string")return{ok:!1,error:`${e.id} must be a string`};let i=r.trim();return e.type==="string"&&e.mustContain&&!i.includes(e.mustContain)?{ok:!1,error:`${e.id} must contain "${e.mustContain}"`}:e.maxLength!==void 0&&i.length>e.maxLength?{ok:!1,error:`${e.id} must be \u2264 ${e.maxLength} chars`}:{ok:!0,field:e,value:i}}case"enum":{if(typeof r!="string")return{ok:!1,error:`${e.id} must be a string`};let i=r.trim();return e.suggestions?.includes(i)?{ok:!0,field:e,value:i}:{ok:!1,error:`${e.id} must be one of: ${(e.suggestions??[]).join(", ")}`}}case"number":return typeof r!="number"||!Number.isFinite(r)||!Number.isInteger(r)?{ok:!1,error:`${e.id} must be an integer`}:e.min!==void 0&&r<e.min?{ok:!1,error:`${e.id} must be \u2265 ${e.min}`}:e.max!==void 0&&r>e.max?{ok:!1,error:`${e.id} must be \u2264 ${e.max}`}:{ok:!0,field:e,value:r};case"boolean":return typeof r!="boolean"?{ok:!1,error:`${e.id} must be a boolean`}:{ok:!0,field:e,value:r};case"string_list":{if(!Array.isArray(r))return{ok:!1,error:`${e.id} must be a list`};let i=r.map(s=>typeof s=="string"?s.trim():"").filter(s=>s.length>0);return i.length===0?e.nullable?{ok:!0,field:e,value:null}:{ok:!1,error:`${e.id} must be a non-empty list`}:{ok:!0,field:e,value:i}}case"string_map":{if(typeof r!="object"||r===null||Array.isArray(r))return{ok:!1,error:`${e.id} must be a name\u2192value map`};let i=Object.entries(r);if(i.length===0)return e.nullable?{ok:!0,field:e,value:null}:{ok:!1,error:`${e.id} must be a non-empty map`};if(i.length>Ia)return{ok:!1,error:`${e.id} must have \u2264 ${Ia} entries`};let s={};for(let[a,c]of i){if(!Je.test(a))return{ok:!1,error:`${e.id}: name "${a}" must match ${Je}`};if(Ot(a))return{ok:!1,error:`${e.id}: name "${a}" is reserved`};if(typeof c!="string")return{ok:!1,error:`${e.id}: value of "${a}" must be a string`};if(c.length>Ca)return{ok:!1,error:`${e.id}: value of "${a}" must be \u2264 ${Ca} chars`};s[a]=c}return{ok:!0,field:e,value:s}}}}var Lb,Mb,Ia,Ca,Pa,Zu,ed=x(()=>{"use strict";Ta();ba();pa();Ra();Lb={primary:"Primary language",context:"Context documents",tasks:"Tracker issues",docs:"Repo documentation",code_comments:"Code comments",chat:"Agent chat",code_review:"Code review comments"},Mb={primary:"The project's main language (agent status notes ride it). Empty \u21D2 auto.",context:"Knowledge, ADRs and task artifacts in the Context Repo. Empty \u21D2 auto.",tasks:"Issue titles/bodies the agent drafts. Empty \u21D2 auto.",docs:"Documentation changes in the project repos. Empty \u21D2 auto.",code_comments:"New code comments the agent writes. Empty \u21D2 auto.",chat:"The interactive task-drafting chat. Empty/auto \u21D2 mirror the user's messages.",code_review:"Review findings and PR comments. Empty \u21D2 follows the tracker-issues language."},Ia=64,Ca=2e3,Pa=2e3,Zu=[{id:"branch",label:"Branch",help:"Task-branch naming.",fields:[{id:"branch.pattern",file:"project.yaml",path:["branch","pattern"],type:"string",label:"Task-branch pattern",nullable:!0,mustContain:"<TASK_ID>",help:"Template for the per-task branch name. Must contain the <TASK_ID> placeholder. Empty \u21D2 default codepipe/<TASK_ID>."}]},{id:"llm",label:"LLM",fields:[{id:"llm.provider",file:"regimen.yaml",path:["llm","provider"],type:"enum",label:"Provider",nullable:!1,suggestions:[...ya],help:"LLM backend for this project. Currently only claude is available."}],groups:[{id:"llm.models",label:"Models by role",help:"Model per pipeline stage. Empty \u21D2 the role's recommended default applies.",fields:[{id:"llm.models.default",file:"regimen.yaml",path:["llm","models","default"],type:"model",label:"default (catch-all)",nullable:!0,suggestions:[...oi],help:"Overrides the recommended defaults for every role not listed below."},...wa.map(t=>({id:`llm.models.${t}`,file:"regimen.yaml",path:["llm","models",t],type:"model",label:t,nullable:!0,suggestions:[...oi],help:`recommended: ${ro[t]}`}))]}]},{id:"apply.style",label:"Commits & PRs",help:"Instructions for the AI agent on how to write commit messages and PR descriptions. Empty \u21D2 built-in templates.",fields:[{id:"apply.commit_style",file:"project.yaml",path:["apply","commit_style"],type:"string",label:"Commit message style",nullable:!0,multiline:!0,maxLength:Pa,help:'e.g. "English, imperative mood, first line \u2264 72 chars, start with the issue key". Empty \u21D2 "<KEY>: <task title>".'},{id:"apply.pr_style",file:"project.yaml",path:["apply","pr_style"],type:"string",label:"PR description style",nullable:!0,multiline:!0,maxLength:Pa,help:`e.g. "implementation details, bullet list of what was done, in the tracker's language". Empty \u21D2 the default PR body.`}]},{id:"apply.delivery",label:"Delivery & merge",help:"How a finished change reaches the repository: with or without a pull request, and who merges it.",fields:[{id:"apply.pull_request",file:"project.yaml",path:["apply","pull_request"],type:"boolean",label:"Open a pull request",nullable:!1,help:"On (default): the task branch is pushed and a pull request is opened \u2014 the change is reviewable in the git host and keeps a history of review comments. Off: no PR at all; the branch is merged into the default branch directly, and the agent's review remarks live only in the dashboard and the Context Repo."},{id:"apply.done",file:"project.yaml",path:["apply","done"],type:"enum",label:"Task is done when",nullable:!1,suggestions:["merge","branch"],help:"merge (default): the task is finished only once its change lands in the default branch. branch: the task ends at the pushed branch (plus the PR, if enabled) and nothing is merged for you."},{id:"apply.auto_merge",file:"project.yaml",path:["apply","auto_merge"],type:"enum",label:"Auto-merge pull requests",nullable:!1,suggestions:["off","on_ci_green"],help:"Applies to the pull-request path only. off (default): the merge waits for you (Approve on the task card). on_ci_green: as soon as the PR is open, conflict-free and its CI is green, CodePipe merges it \u2014 changes reach the default branch with no further review from you. Requires full automation; branch protection on the host still applies (a refused merge parks the task). Without pull requests, full automation merges the branch itself and this switch does not apply."}]},{id:"variables",label:"Variables",help:"Non-secret env vars for custom actions (RUN tab). Secrets go via the sealed Secrets form on the Tokens section instead.",fields:[{id:"variables",file:"project.yaml",path:["variables"],type:"string_map",label:"Variables",nullable:!0,help:"NAME=value pairs, one per line. Names are env-style (A-Z, 0-9, _); reserved credential names are refused."}]},{id:"testing",label:"Testing",help:"An optional phase after code review: writes the test plan you run in the morning and reports what it could verify.",fields:[{id:"testing.enabled",file:"regimen.yaml",path:["testing","enabled"],type:"boolean",nullable:!1,label:"Run the testing phase",help:"Off by default. When on, a task passing code review goes through a test pass before the PR: it derives TESTPLAN.md from the plan's requirements and reports per requirement what it could verify. A requirement it finds broken sends the change back for a fix (bounded below)."},{id:"testing.max_iterations",file:"regimen.yaml",path:["testing","max_iterations"],type:"number",nullable:!0,min:1,max:10,label:"Fix rounds before stopping",help:"How many times a failed test pass may send the change back before the task waits for you. Empty \u21D2 2."}]},{id:"skills",label:"Skills",help:"Reusable procedures the agent can invoke instead of improvising. Only their names and one-line descriptions sit in the prompt; the steps load when a skill is used.",fields:[{id:"skills.from_bundled",file:"regimen.yaml",path:["skills","from_bundled"],type:"boolean",nullable:!1,label:"Use the skills shipped with CodePipe",help:"On by default. General procedures maintained with the product."},{id:"skills.from_context_repo",file:"regimen.yaml",path:["skills","from_context_repo"],type:"boolean",nullable:!1,label:"Use this project's skills",help:"On by default. Skills the team writes in the context repository under `skills/<name>/SKILL.md`. These override a bundled skill of the same name."},{id:"skills.from_project_repo",file:"regimen.yaml",path:["skills","from_project_repo"],type:"boolean",nullable:!1,label:"Use the code repository's skills",help:"On by default. `.claude/skills/` inside the project repositories \u2014 the skills your developers already use locally. These win over both other sources."}]},{id:"gates",label:"Gates",help:"Approval gate before the pipeline starts (on by default; orthogonal to automation).",fields:[{id:"gates.require_approval",file:"regimen.yaml",path:["gates","require_approval"],type:"boolean",label:"Require approval before start",nullable:!1,help:"When on (default), a task taken from Develop waits in the QUEUE for a single Confirm before the pipeline starts \u2014 the Confirm pulls in dependency closure and topologically orders the queue. Off \u21D2 conveyor: the task starts the pipeline immediately."}]},{id:"automation",label:"Automation",help:"How far the pipeline advances the G1\u2013G4 gates without a manual Run/Approve. Independent of the approval gate above.",fields:[{id:"automation.level",file:"regimen.yaml",path:["automation","level"],type:"enum",label:"Automation level",nullable:!1,suggestions:["assisted","full"],help:"assisted \u21D2 manual Run/Approve at each of G1\u2013G4; full \u21D2 gates auto-pass."}]},{id:"language",label:"Language",help:"Languages the agent writes in, per area. Empty \u21D2 auto: mirror the language of the user's material.",fields:no.map(t=>({id:`language.${t}`,file:"project.yaml",path:["language",t],type:"string",label:Lb[t],nullable:!0,maxLength:40,suggestions:t==="chat"?[$e,...Yr]:[...Yr],help:Mb[t]}))},{id:"context.model",label:"Project map",help:"Parameters of the project map (built from git history by the CLI). Empty fields keep the defaults.",fields:[{id:"context.model.enabled",file:"regimen.yaml",path:["context","model","enabled"],type:"boolean",label:"Enable in the pipeline",nullable:!1,help:"When on, agents are asked to record intent annotations and (once available) receive an assembled context pack. Off \u21D2 the pipeline ignores the map entirely."},{id:"context.model.prompt.pack",file:"regimen.yaml",path:["context","model","prompt","pack"],type:"boolean",nullable:!1,label:"Give agents the context pack",help:"On by default. The assembled pack costs up to ~4000 tokens on every task of the analyze / estimate / implement / rework roles. Turning it off keeps the map building and stops the spend \u2014 the way to see what the pack is actually worth on this project."},{id:"context.model.prompt.annotations",file:"regimen.yaml",path:["context","model","prompt","annotations"],type:"boolean",nullable:!1,label:"Ask agents for intent annotations",help:"On by default. Adds the annotations block to the implement and rework prompts \u2014 the layer that records WHY the code is shaped this way. Cheap, and worth accumulating even while the pack is off."},{id:"context.index.hub",file:"regimen.yaml",path:["context","index","hub"],type:"enum",label:"Search index on the server",nullable:!0,suggestions:["off","metadata"],help:"off (default): search runs on your machine, nothing is uploaded. metadata: paths, labels and task texts (never code) are mirrored to the server so search and structure stay available while your machine is offline. Switching back to off deletes the mirrored rows."},{id:"context.model.issue_key_pattern",file:"regimen.yaml",path:["context","model","issue_key_pattern"],type:"string",label:"Issue-key pattern (regex)",nullable:!0,maxLength:200,help:"Regex that finds tracker issue keys in commit subjects when mining task events from history. Empty \u21D2 derived from the tracker project key (e.g. DEV-\\d+)."},{id:"context.model.cochange.window_commits",file:"regimen.yaml",path:["context","model","cochange","window_commits"],type:"number",label:"History window (commits)",nullable:!0,min:50,max:5e4,help:`How many commits back from the build commit are mined. Default ${nt.windowCommits}.`},{id:"context.model.cochange.commit_file_cap",file:"regimen.yaml",path:["context","model","cochange","commit_file_cap"],type:"number",label:"Commit size cap (files)",nullable:!0,min:2,max:500,help:`Commits touching more files are ignored as noise. Default ${nt.commitFileCap}.`},{id:"context.model.cochange.support_min",file:"regimen.yaml",path:["context","model","cochange","support_min"],type:"number",label:"Minimum co-occurrences",nullable:!0,min:1,max:100,help:`A pair of files must change together at least this many times. Default ${nt.supportMin}.`},{id:"context.model.cochange.jaccard_min_pct",file:"regimen.yaml",path:["context","model","cochange","jaccard_min_pct"],type:"number",label:"Minimum Jaccard (%)",nullable:!0,min:0,max:100,help:`Overlap threshold: |A\u2229B| / |A\u222AB| of the files' commit sets, in percent. Default ${nt.jaccardMinPct}.`},{id:"context.model.cochange.half_life_days",file:"regimen.yaml",path:["context","model","cochange","half_life_days"],type:"number",label:"Time-decay half-life (days)",nullable:!0,min:1,max:3650,help:`A commit this old counts half as much. Default ${nt.halfLifeDays} (~9 months).`},{id:"context.model.cochange.top_k",file:"regimen.yaml",path:["context","model","cochange","top_k"],type:"number",label:"Edges per file (top-k)",nullable:!0,min:1,max:64,help:`Only the k strongest co-change edges of a file survive \u2014 bounds graph density whatever the thresholds. Default ${nt.topK}.`}]},{id:"context.job_logs",label:"Job transcripts",help:"Whether the raw agent transcript of each job is kept in the Context Repo.",fields:[{id:"context.job_logs.enabled",file:"regimen.yaml",path:["context","job_logs","enabled"],type:"boolean",label:"Keep transcripts in the Context Repo",nullable:!1,help:"Off (default): the transcript is discarded after the run \u2014 nothing lands in the Context Repo. On: each job's raw transcript is committed as tasks/<KEY>/logs/job-<id>.jsonl for post-mortem debugging."}]}]});function td(t){if(t==null)return[];if(!Array.isArray(t))return null;let e=[];for(let r of t){if(typeof r!="string"||r.trim().length===0)return null;e.push(r.trim())}return e}function Na(t){let{name:e,body:r,origin:n}=t;if(!ja.test(e))return{ok:!1,error:`role name must match ${ja} (got "${e}")`};if(r.trim().length===0)return{ok:!1,error:"role body is empty \u2014 the body IS the role's prompt"};let o=t.frontmatter;if(o==null||typeof o!="object"||Array.isArray(o))return{ok:!1,error:"missing or malformed frontmatter block"};let i=o,s=i.description;if(typeof s!="string"||s.trim().length===0)return{ok:!1,error:"description is required (one line: what this role looks for)"};if(s.length>300)return{ok:!1,error:"description must be \u2264 300 characters"};let a=td(i.refs);if(a===null)return{ok:!1,error:"refs must be a list of non-empty paths"};if(a.length>10)return{ok:!1,error:"refs must list at most 10 files \u2014 a role is a narrow view"};for(let d of a)if(d.startsWith("/")||d.includes(".."))return{ok:!1,error:`ref "${d}" must be a path inside the Context Repo`};let c=td(i.scenarios);if(c===null)return{ok:!1,error:"scenarios must be a list"};let l=[];for(let d of c){if(!si.includes(d))return{ok:!1,error:`unknown scenario "${d}" \u2014 one of: ${si.join(", ")}`};l.includes(d)||l.push(d)}if(l.length===0)return{ok:!1,error:`scenarios must name at least one of: ${si.join(", ")}`};let u=i.model;if(u!==void 0&&(typeof u!="string"||u.trim().length===0))return{ok:!1,error:"model must be a non-empty string when set"};let p=i.enabled;return p!==void 0&&typeof p!="boolean"?{ok:!1,error:"enabled must be true or false"}:{ok:!0,role:{name:e,description:s.trim(),...typeof u=="string"?{model:u.trim()}:{},refs:a,scenarios:l,enabled:p!==!1,body:r.trim(),origin:n}}}function Oa(t,e){let r=new Map;for(let n of t)r.set(n.name,n);for(let n of e)r.set(n.name,n);return[...r.values()].sort((n,o)=>n.name<o.name?-1:n.name>o.name?1:0)}function La(t,e){return t.filter(r=>r.enabled&&r.scenarios.includes(e))}var si,ja,CA,PA,rd=x(()=>{"use strict";si=["plan_review","code_review","council"],ja=/^[a-z][a-z0-9-]{1,39}$/,CA=10,PA=300});function Ma(t){return nd.includes(t)}function Da(t){return`prompts/${t}.md`}var nd,od=x(()=>{"use strict";nd=["analysis","analyze","backfill","build","chat","code-review","code-review-external","code-review-fix","council","draft","estimate","implement","index","observer","resolve-conflict","review-comment","rework","testing"]});function Ba(t){if(!Ua.test(t.name))return{ok:!1,error:`skill directory name must match ${Ua}`};if(t.body.trim().length===0)return{ok:!1,error:"SKILL.md has no body \u2014 the body IS the procedure"};let e=t.frontmatter;if(!e||typeof e!="object"||Array.isArray(e))return{ok:!1,error:"SKILL.md has no frontmatter block"};let r=e.description;return typeof r!="string"||r.trim().length===0?{ok:!1,error:"description is required \u2014 it is what decides when the skill fires"}:r.length>300?{ok:!1,error:"description must be \u2264 300 characters"}:{ok:!0,skill:{name:t.name,description:r.trim()}}}function Fa(t,e,r){let n=new Map;for(let o of[...t,...e,...r])n.set(o.name,o);return[...n.values()].sort((o,i)=>o.name<i.name?-1:o.name>i.name?1:0)}function sd(t){let e=t.trim(),r=e.lastIndexOf("@"),n=r===-1?e:e.slice(0,r),o=r===-1?"":e.slice(r+1).trim();if(!Db.test(n))return{ok:!1,error:`"${t}": expected <owner>/<repo>[@<40-hex sha>]`};let i=id.find(s=>s.repo.toLowerCase()===n.toLowerCase());return o&&!Ub.test(o)?{ok:!1,error:`"${t}": pin to a full 40-character commit sha \u2014 a branch or tag can change under you`}:!i&&!o?{ok:!1,error:`"${t}": a third-party marketplace must be pinned to a commit (<owner>/<repo>@<sha>). Its skills run beside your code with the agent's token.`}:{ok:!0,source:{repo:n,sha:o,name:i?.name??n.replace("/","-").toLowerCase(),official:!!i}}}function Bb(t){let e=[],r=[],n=new Set;for(let o of t){if(!o.trim())continue;let i=sd(o);if(!i.ok){r.push(i.error);continue}n.has(i.source.name)||(n.add(i.source.name),e.push(i.source))}return{sources:e,errors:r}}function Gb(t,e){let r=new Set(e.map(i=>i.name)),n={},o=[];for(let i of t){let s=i.trim();if(s){if(!Fb.test(s)||!r.has(s.slice(s.indexOf("@")+1))){o.push(s);continue}n[s]=!0}}return{enabled:n,unknown:o}}var Ua,jA,id,Db,Ub,Fb,ad=x(()=>{"use strict";Ua=/^[a-z][a-z0-9-]{1,39}$/,jA=300;id=[{repo:"anthropics/skills",name:"anthropic-agent-skills"},{repo:"anthropics/claude-plugins-official",name:"claude-plugins-official"}],Db=/^[A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*$/,Ub=/^[0-9a-f]{40}$/;Fb=/^[A-Za-z0-9][\w.-]*@[A-Za-z0-9][\w.-]*$/});function cd(t,e){if(t==null)return[];if(!Array.isArray(t)||t.length>e)return null;let r=[];for(let n of t){if(typeof n!="string"||n.trim().length===0)return null;r.push(n.trim())}return r}function Kb(t,e){if(!t||typeof t!="object"||Array.isArray(t))return{ok:!1,error:"queue plan must be a JSON object"};let r=new Set(e),n=t,o=cd(n.order,e.length);if(o===null)return{ok:!1,error:"order must be a list of task keys"};for(let f of o)if(!r.has(f))return{ok:!1,error:`order names ${f}, which is not in this batch`};if(new Set(o).size!==o.length)return{ok:!1,error:"order repeats a task key"};let i=e.filter(f=>!o.includes(f));if(o.length>0&&i.length>0)return{ok:!1,error:`order omits ${i.join(", ")}`};let s=n.tasks,a=[];if(s!=null){if(!Array.isArray(s))return{ok:!1,error:"tasks must be a list"};for(let f of s){if(!f||typeof f!="object")return{ok:!1,error:"each task entry must be an object"};let g=f,k=typeof g.taskKey=="string"?g.taskKey.trim():"";if(!r.has(k))return{ok:!1,error:`tasks names ${k||"(empty)"}, which is not in this batch`};let h=cd(g.after,e.length);if(h===null)return{ok:!1,error:`${k}: after must be a list of task keys`};for(let $ of h){if(!r.has($))return{ok:!1,error:`${k}: after names ${$}, not in this batch`};if($===k)return{ok:!1,error:`${k}: cannot come after itself`}}let w=typeof g.decisions=="string"?g.decisions.trim():"";a.push({taskKey:k,decisions:w.slice(0,4e3),after:h})}}let c=[],l=n.conflicts;if(Array.isArray(l))for(let f of l){if(!f||typeof f!="object")continue;let g=f,k=typeof g.taskKey=="string"?g.taskKey.trim():"",h=typeof g.adr=="string"?g.adr.trim():"",w=typeof g.detail=="string"?g.detail.trim():"";!r.has(k)||!w||c.push({taskKey:k,adr:h,detail:w.slice(0,4e3)})}let u=[],p=n.related;if(Array.isArray(p))for(let f of p){if(!f||typeof f!="object")continue;let g=f,k=typeof g.taskKey=="string"?g.taskKey.trim():"",h=typeof g.detail=="string"?g.detail.trim():"";!k||!h||u.push({taskKey:k,detail:h.slice(0,4e3)})}let d=typeof n.summary=="string"?n.summary.trim().slice(0,4e3):"",m=n.deferBehind===!0;return{ok:!0,plan:{order:o,tasks:a,conflicts:c,related:u,summary:d,deferBehind:m}}}var OA,LA,ld=x(()=>{"use strict";OA=4e3,LA=4e3});function Hb(t,e){if(!t||typeof t!="object"||Array.isArray(t))return{ok:!1,error:"council verdict must be a JSON object"};let r=t,n=r.unresolved===!0,o=typeof r.fork=="string"?r.fork.trim().slice(0,4e3):"";if(n)return o?{ok:!0,verdict:{answers:[],unresolved:!0,fork:o}}:{ok:!1,error:"an unresolved verdict must describe the fork"};let i=r.answers;if(!Array.isArray(i))return{ok:!1,error:"answers must be a list"};if(i.length!==e.length)return{ok:!1,error:`expected ${e.length} answer(s), got ${i.length}`};let s=[];for(let[a,c]of i.entries()){if(!c||typeof c!="object")return{ok:!1,error:`answer ${a+1} must be an object`};let l=c,u=typeof l.answer=="string"?l.answer.trim():"";if(!u)return{ok:!1,error:`answer ${a+1} is empty`};s.push({question:typeof l.question=="string"?l.question.trim():e[a],answer:u.slice(0,4e3),rationale:typeof l.rationale=="string"?l.rationale.trim().slice(0,4e3):""})}return{ok:!0,verdict:{answers:s,unresolved:!1,fork:""}}}var DA,ud=x(()=>{"use strict";DA=4e3});function Yb(t){let e=t.replace(/^#+\s*/,"").trim();for(let r of Wb)if(r.re.test(e))return{kind:r.kind,letter:r.letter};return null}function Ga(t){let e=[],r=new Map,n="",o=null,i=null;for(let a of t.split(`
|
|
7
|
+
`}function ua(t){return kr(_u(t))}function da(t){return kr(ju(t))}function Wr(t){return kr(Nu(t))}var Oe,ub,db,pb,fb,Qo,hr,Cu,ia,Pu,mb,nt,sa,aa,ca,ti,hb,la,wr,yb,pa=x(()=>{"use strict";Oe=2,ub="model",db="model/README.md",pb="model/facts",fb="model/derived",Qo="model/derived/INDEX.yaml",hr="model/derived/relates.yaml";Cu=["system","container","component","code","task","adr"],ia=["contains","touched_by","correlates","relates","references","depends_on"],Pu=/^e_[0-9a-f]{8}$/;mb=["system","task","adr"];nt={windowCommits:1e3,commitFileCap:30,supportMin:5,jaccardMinPct:25,halfLifeDays:270,topK:8};sa=2,aa=5,ca=50,ti=2e3,hb=5e4,la={touched_by:.8,references:.7,relates:.6,correlates:.4,contains:.3,depends_on:.5},wr={budgetTokens:4e3,activationCutoff:.05,topKPerNode:8,nodeCap:200};yb=/^[A-Za-z0-9_][A-Za-z0-9_.-]*$/});function wb(t){return t==="DONE"}function kb(t){return t==="AWAITING_EXTERNAL_FIX"?!1:fa.indexOf(t)>=fa.indexOf("IMPLEMENTING")}var fa,Du=x(()=>{"use strict";fa=["BACKLOG","QUEUED","INTAKE","AWAITING_APPROVAL","ANALYZING","ESTIMATING","AWAITING_ANSWER","REVIEW","READY","IMPLEMENTING","BUILD","CODE_REVIEW","TESTING","AWAITING_EXTERNAL_FIX","READY_TO_APPLY","APPLYING","AWAITING_CLUSTER","TRACKING","NEEDS_MANUAL","DONE"]});function $b(t){for(let e of ma)if(e.phases.includes(t))return e.id;return null}function vb(t){for(let e of Uu)if(e.phases.includes(t))return e.id;return null}var ma,bb,Uu,Bu=x(()=>{"use strict";ma=[{id:"intake",label:"Intake",phases:["INTAKE"]},{id:"analysis",label:"Analysis",phases:["ANALYZING","ESTIMATING"]},{id:"ready",label:"Ready",phases:["READY"]},{id:"implementation",label:"Implementation",phases:["IMPLEMENTING","BUILD"]},{id:"delivery",label:"Delivery",phases:["READY_TO_APPLY","APPLYING","AWAITING_CLUSTER"]}],bb=ma.flatMap(t=>t.phases),Uu=[{id:"review",label:"Review / tracking",phases:["CODE_REVIEW","TESTING","TRACKING"]},{id:"attention",label:"Need your attention",phases:["NEEDS_MANUAL","AWAITING_APPROVAL","AWAITING_EXTERNAL_FIX","AWAITING_ANSWER","REVIEW"]},{id:"backlog",label:"Backlog / queue",phases:["BACKLOG","QUEUED"]}]});function xb(t){return Fu.includes(t)?"planning":"implementation"}function Ht(){return{inputTokens:0,outputTokens:0,cacheReadInputTokens:0,cacheCreationInputTokens:0,totalCostUsd:0,model:"",numTurns:0,durationMs:0}}var ha,Fu,Sb,ga=x(()=>{"use strict";ha=["estimate","analyze","implement","resolve-conflict","rework","draft","build","code-review","index","backfill","analysis","chat","observer","council","testing"],Fu=["draft","analysis","chat","observer","council"];Sb=1});function Gu(t,e){return e.toLowerCase().includes(t.toLowerCase())}function ka(t){let e=t.filter(o=>o&&typeof o.id=="string"&&o.id.trim().length>0);if(e.length===0||Yu.every(o=>e.some(i=>Gu(o,i.id))))return null;let n=[...e].sort((o,i)=>{let s=o.createdAt??"",a=i.createdAt??"";return s!==a?s<a?1:-1:o.id<i.id?1:-1});for(let o of qu){let i=n.find(s=>Gu(o,s.id));if(i)return i.id}return n[0].id}function qr(){return{default:null,roles:{}}}function Eb(t,e){let r=t?.roles?.[e];return typeof r=="string"&&r.trim().length>0?r.trim():t?.default&&t.default.trim().length>0?t.default.trim():ro[e]??Wu}function Tb(t){let e=t?.provider;return typeof e=="string"&&e.trim().length>0?e.trim():Xe}function Rb(t){let e=qr();if(!t||typeof t!="object")return e;let r=t.llm;if(!r||typeof r!="object")return e;let n=r.provider;typeof n=="string"&&n.trim().length>0&&(e.provider=n.trim());let o=r.models;if(!o||typeof o!="object")return e;for(let[i,s]of Object.entries(o))typeof s!="string"||s.trim().length===0||(i==="default"?e.default=s.trim():e.roles[i]=s.trim());return e}function Ib(t){let e=typeof t.provider=="string"&&t.provider.trim().length>0&&t.provider.trim()!==Xe;if(t.default===null&&Object.keys(t.roles).length===0&&!e)return null;let{provider:r,...n}=t;return JSON.stringify(e?{provider:r.trim(),...n}:n)}function Cb(t){if(!t)return qr();try{let e=JSON.parse(t);if(!e||typeof e!="object")return qr();let r=e,n=qr();typeof r.provider=="string"&&r.provider.trim().length>0&&(n.provider=r.provider.trim()),typeof r.default=="string"&&(n.default=r.default);let o=r.roles;if(o&&typeof o=="object")for(let[i,s]of Object.entries(o))typeof s=="string"&&(n.roles[i]=s);return n}catch{return qr()}}var Xe,ya,Pe,to,ni,oi,Ku,Hu,wa,ro,Wu,qu,Yu,ba=x(()=>{"use strict";ga();Xe="claude",ya=[Xe],Pe="opus",to="sonnet",ni="haiku",oi=[Pe,to,ni],Ku="build-discovery",Hu=[Ku],wa=[...ha,...Hu],ro={analyze:Pe,implement:Pe,"resolve-conflict":Pe,rework:Pe,estimate:to,build:ni,"build-discovery":Pe,"code-review":Pe,draft:to,index:Pe,backfill:Pe,analysis:Pe,chat:Pe,observer:Pe,council:Pe,testing:Pe},Wu=Pe,qu=[Pe,to,ni],Yu=Array.from(new Set(Object.values(ro)))});function Ot(t){return Pb.has(t)?!0:Ab.some(e=>t.startsWith(e))}function ii(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function br(t,e){if(t!=null){if(typeof t!="string")throw new Error(`${e} must be a string`);return t}}function va(t,e){if(t!=null){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} must be a number`);return t}}function Sa(t,e){let r=ii(e,"action definition"),n=t.replace(/\.(yml|yaml)$/i,""),o=br(r.id,"id")??n;if(!$a.test(o))throw new Error(`id must match ${$a} (got "${o}")`);if(o!==n)throw new Error(`id "${o}" must match the file name ("${n}")`);let i=br(r.title,"title")?.trim()||o,s;if(r.env!==void 0&&r.env!==null){let p=ii(r.env,"env");s={};for(let[d,m]of Object.entries(p)){if(!Je.test(d))throw new Error(`env name "${d}" must match ${Je}`);if(typeof m!="string"&&typeof m!="number"&&typeof m!="boolean")throw new Error(`env.${d} must be a scalar`);s[d]=String(m)}}let a,c=r.params;if(c!=null){if(!Array.isArray(c))throw new Error("params must be a list");if(c.length>zu)throw new Error(`too many params (max ${zu})`);let p=new Set;a=c.map((d,m)=>_b(d,m,p))}let l=r.steps;if(!Array.isArray(l)||l.length===0)throw new Error("steps must be a non-empty list");if(l.length>Vu)throw new Error(`too many steps (max ${Vu})`);let u=l.map((p,d)=>{let m=ii(p,`steps[${d}]`),f=br(m.run,`steps[${d}].run`);if(!f||f.trim().length===0)throw new Error(`steps[${d}].run is required`);let g=br(m.name,`steps[${d}].name`),k=va(m.timeout_sec,`steps[${d}].timeout_sec`);if(k!==void 0&&(!Number.isInteger(k)||k<=0))throw new Error(`steps[${d}].timeout_sec must be a positive integer`);return{run:f,...g?{name:g}:{},...k!==void 0?{timeout_sec:k}:{}}});return{id:o,title:i,...s?{env:s}:{},...a?{params:a}:{},steps:u}}function _b(t,e,r){let n=ii(t,`params[${e}]`),o=br(n.name,`params[${e}].name`);if(!o||!Je.test(o))throw new Error(`params[${e}].name must match ${Je}`);if(r.has(o))throw new Error(`duplicate param "${o}"`);r.add(o);let i=n.type;if(i!=="string"&&i!=="enum"&&i!=="number"&&i!=="boolean")throw new Error(`params[${e}].type must be string | enum | number | boolean`);let s;if(i==="enum"){let m=n.enum;if(!Array.isArray(m)||m.length===0||!m.every(f=>typeof f=="string"))throw new Error(`params[${e}].enum must be a non-empty string list`);s=m}let a=br(n.label,`params[${e}].label`),c=br(n.help,`params[${e}].help`),l=n.required===!0,u=va(n.min,`params[${e}].min`),p=va(n.max,`params[${e}].max`),d=n.default;if(d!=null&&typeof d!="string"&&typeof d!="number"&&typeof d!="boolean")throw new Error(`params[${e}].default must be a scalar`);return{name:o,type:i,...a?{label:a}:{},...c?{help:c}:{},...l?{required:!0}:{},...s?{enum:s}:{},...u!==void 0?{min:u}:{},...p!==void 0?{max:p}:{},...d!=null?{default:d}:{}}}function Ea(t,e){let r=t.params??[],n=new Map(r.map(i=>[i.name,i]));for(let i of Object.keys(e))if(!n.has(i))return{ok:!1,error:`unknown param: ${i}`};let o={};for(let i of r){let s=e[i.name];if(s==null||typeof s=="string"&&s.trim()==="")if(i.default!==void 0)s=i.default;else{if(i.required)return{ok:!1,error:`${i.name} is required`};continue}switch(i.type){case"string":{if(typeof s!="string")return{ok:!1,error:`${i.name} must be a string`};o[i.name]=s;break}case"enum":{if(typeof s!="string"||!(i.enum??[]).includes(s))return{ok:!1,error:`${i.name} must be one of: ${(i.enum??[]).join(", ")}`};o[i.name]=s;break}case"number":{let a=typeof s=="number"?s:typeof s=="string"?Number(s):NaN;if(!Number.isFinite(a))return{ok:!1,error:`${i.name} must be a number`};if(i.min!==void 0&&a<i.min)return{ok:!1,error:`${i.name} must be \u2265 ${i.min}`};if(i.max!==void 0&&a>i.max)return{ok:!1,error:`${i.name} must be \u2264 ${i.max}`};o[i.name]=a;break}case"boolean":{let a=typeof s=="boolean"?s:s==="true"?!0:s==="false"?!1:null;if(a===null)return{ok:!1,error:`${i.name} must be a boolean`};o[i.name]=a;break}}}return{ok:!0,values:o}}var Je,Pb,Ab,xa,$a,zu,Vu,Ta=x(()=>{"use strict";Je=/^[A-Z][A-Z0-9_]*$/,Pb=new Set(["GH_TOKEN","GITHUB_TOKEN","GITLAB_TOKEN"]),Ab=["BITBUCKET_","YOUTRACK_","CLAUDE_","INPUT_"];xa=600,$a=/^[a-z0-9-]+$/,zu=32,Vu=64});function Xu(){return{primary:$e,context:$e,tasks:$e,docs:$e,code_comments:$e,chat:$e,code_review:$e}}function Ju(t){return!t||t.trim().length===0||t.trim().toLowerCase()===$e}function jb(t){if(typeof t!="string")return $e;let e=t.trim().replace(/\s+/g," ");return e.length===0||e.length>40||e.toLowerCase()===$e?$e:e}function Nb(t){let e=Xu();if(!t||typeof t!="object")return e;let r=t.language;if(!r||typeof r!="object"||Array.isArray(r))return e;let n=r;for(let o of no)e[o]=jb(n[o]);return e}function Ob(t){return no.every(e=>Ju(t[e]))}var $e,no,Yr,oo,Ra=x(()=>{"use strict";$e="auto",no=["primary","context","tasks","docs","code_comments","chat","code_review"],Yr=["English","Russian","German","Spanish","French","Portuguese","Italian","Chinese","Japanese","Korean"],oo=40});function Aa(t=Zu){let e=[];for(let r of t)e.push(...r.fields),r.groups&&e.push(...Aa(r.groups));return e}function Qu(t,e){let r=JSON.stringify(e);return Aa().find(n=>n.file===t&&JSON.stringify(n.path)===r)}function _a(t){let e=Qu(t.file,t.path);if(!e)return{ok:!1,error:`unknown setting path: ${t.file}:${t.path.join(".")}`};let r=t.value,n=e.type==="model"||e.type==="enum"||e.type==="string";if(r===null||n&&typeof r=="string"&&r.trim().length===0)return e.nullable?{ok:!0,field:e,value:null}:{ok:!1,error:`${e.id} cannot be cleared`};switch(e.type){case"model":case"string":{if(typeof r!="string")return{ok:!1,error:`${e.id} must be a string`};let i=r.trim();return e.type==="string"&&e.mustContain&&!i.includes(e.mustContain)?{ok:!1,error:`${e.id} must contain "${e.mustContain}"`}:e.maxLength!==void 0&&i.length>e.maxLength?{ok:!1,error:`${e.id} must be \u2264 ${e.maxLength} chars`}:{ok:!0,field:e,value:i}}case"enum":{if(typeof r!="string")return{ok:!1,error:`${e.id} must be a string`};let i=r.trim();return e.suggestions?.includes(i)?{ok:!0,field:e,value:i}:{ok:!1,error:`${e.id} must be one of: ${(e.suggestions??[]).join(", ")}`}}case"number":return typeof r!="number"||!Number.isFinite(r)?{ok:!1,error:`${e.id} must be a number`}:!e.float&&!Number.isInteger(r)?{ok:!1,error:`${e.id} must be an integer`}:e.min!==void 0&&r<e.min?{ok:!1,error:`${e.id} must be \u2265 ${e.min}`}:e.max!==void 0&&r>e.max?{ok:!1,error:`${e.id} must be \u2264 ${e.max}`}:{ok:!0,field:e,value:r};case"boolean":return typeof r!="boolean"?{ok:!1,error:`${e.id} must be a boolean`}:{ok:!0,field:e,value:r};case"string_list":{if(!Array.isArray(r))return{ok:!1,error:`${e.id} must be a list`};let i=r.map(s=>typeof s=="string"?s.trim():"").filter(s=>s.length>0);return i.length===0?e.nullable?{ok:!0,field:e,value:null}:{ok:!1,error:`${e.id} must be a non-empty list`}:{ok:!0,field:e,value:i}}case"string_map":{if(typeof r!="object"||r===null||Array.isArray(r))return{ok:!1,error:`${e.id} must be a name\u2192value map`};let i=Object.entries(r);if(i.length===0)return e.nullable?{ok:!0,field:e,value:null}:{ok:!1,error:`${e.id} must be a non-empty map`};if(i.length>Ia)return{ok:!1,error:`${e.id} must have \u2264 ${Ia} entries`};let s={};for(let[a,c]of i){if(!Je.test(a))return{ok:!1,error:`${e.id}: name "${a}" must match ${Je}`};if(Ot(a))return{ok:!1,error:`${e.id}: name "${a}" is reserved`};if(typeof c!="string")return{ok:!1,error:`${e.id}: value of "${a}" must be a string`};if(c.length>Ca)return{ok:!1,error:`${e.id}: value of "${a}" must be \u2264 ${Ca} chars`};s[a]=c}return{ok:!0,field:e,value:s}}}}var Lb,Mb,Ia,Ca,Pa,Zu,ed=x(()=>{"use strict";Ta();ba();pa();Ra();Lb={primary:"Primary language",context:"Context documents",tasks:"Tracker issues",docs:"Repo documentation",code_comments:"Code comments",chat:"Agent chat",code_review:"Code review comments"},Mb={primary:"The project's main language (agent status notes ride it). Empty \u21D2 auto.",context:"Knowledge, ADRs and task artifacts in the Context Repo. Empty \u21D2 auto.",tasks:"Issue titles/bodies the agent drafts. Empty \u21D2 auto.",docs:"Documentation changes in the project repos. Empty \u21D2 auto.",code_comments:"New code comments the agent writes. Empty \u21D2 auto.",chat:"The interactive task-drafting chat. Empty/auto \u21D2 mirror the user's messages.",code_review:"Review findings and PR comments. Empty \u21D2 follows the tracker-issues language."},Ia=64,Ca=2e3,Pa=2e3,Zu=[{id:"branch",label:"Branch",help:"Task-branch naming.",fields:[{id:"branch.pattern",file:"project.yaml",path:["branch","pattern"],type:"string",label:"Task-branch pattern",nullable:!0,mustContain:"<TASK_ID>",help:"Template for the per-task branch name. Must contain the <TASK_ID> placeholder. Empty \u21D2 default codepipe/<TASK_ID>."}]},{id:"llm",label:"LLM",fields:[{id:"llm.provider",file:"regimen.yaml",path:["llm","provider"],type:"enum",label:"Provider",nullable:!1,suggestions:[...ya],help:"LLM backend for this project. Currently only claude is available."}],groups:[{id:"llm.models",label:"Models by role",help:"Model per pipeline stage. Empty \u21D2 the role's recommended default applies.",fields:[{id:"llm.models.default",file:"regimen.yaml",path:["llm","models","default"],type:"model",label:"default (catch-all)",nullable:!0,suggestions:[...oi],help:"Overrides the recommended defaults for every role not listed below."},...wa.map(t=>({id:`llm.models.${t}`,file:"regimen.yaml",path:["llm","models",t],type:"model",label:t,nullable:!0,suggestions:[...oi],help:`recommended: ${ro[t]}`}))]}]},{id:"apply.style",label:"Commits & PRs",help:"Instructions for the AI agent on how to write commit messages and PR descriptions. Empty \u21D2 built-in templates.",fields:[{id:"apply.commit_style",file:"project.yaml",path:["apply","commit_style"],type:"string",label:"Commit message style",nullable:!0,multiline:!0,maxLength:Pa,help:'e.g. "English, imperative mood, first line \u2264 72 chars, start with the issue key". Empty \u21D2 "<KEY>: <task title>".'},{id:"apply.pr_style",file:"project.yaml",path:["apply","pr_style"],type:"string",label:"PR description style",nullable:!0,multiline:!0,maxLength:Pa,help:`e.g. "implementation details, bullet list of what was done, in the tracker's language". Empty \u21D2 the default PR body.`}]},{id:"apply.delivery",label:"Delivery & merge",help:"How a finished change reaches the repository: with or without a pull request, and who merges it.",fields:[{id:"apply.pull_request",file:"project.yaml",path:["apply","pull_request"],type:"boolean",label:"Open a pull request",nullable:!1,help:"On (default): the task branch is pushed and a pull request is opened \u2014 the change is reviewable in the git host and keeps a history of review comments. Off: no PR at all; the branch is merged into the default branch directly, and the agent's review remarks live only in the dashboard and the Context Repo."},{id:"apply.done",file:"project.yaml",path:["apply","done"],type:"enum",label:"Task is done when",nullable:!1,suggestions:["merge","branch"],help:"merge (default): the task is finished only once its change lands in the default branch. branch: the task ends at the pushed branch (plus the PR, if enabled) and nothing is merged for you."},{id:"apply.auto_merge",file:"project.yaml",path:["apply","auto_merge"],type:"enum",label:"Auto-merge pull requests",nullable:!1,suggestions:["off","on_ci_green"],help:"Applies to the pull-request path only. off (default): the merge waits for you (Approve on the task card). on_ci_green: as soon as the PR is open, conflict-free and its CI is green, CodePipe merges it \u2014 changes reach the default branch with no further review from you. Requires full automation; branch protection on the host still applies (a refused merge parks the task). Without pull requests, full automation merges the branch itself and this switch does not apply."}]},{id:"variables",label:"Variables",help:"Non-secret env vars for custom actions (RUN tab). Secrets go via the sealed Secrets form on the Tokens section instead.",fields:[{id:"variables",file:"project.yaml",path:["variables"],type:"string_map",label:"Variables",nullable:!0,help:"NAME=value pairs, one per line. Names are env-style (A-Z, 0-9, _); reserved credential names are refused."}]},{id:"testing",label:"Testing",help:"An optional phase after code review: writes the test plan you run in the morning and reports what it could verify.",fields:[{id:"testing.enabled",file:"regimen.yaml",path:["testing","enabled"],type:"boolean",nullable:!1,label:"Run the testing phase",help:"Off by default. When on, a task passing code review goes through a test pass before the PR: it derives TESTPLAN.md from the plan's requirements and reports per requirement what it could verify. A requirement it finds broken sends the change back for a fix (bounded below)."},{id:"testing.max_iterations",file:"regimen.yaml",path:["testing","max_iterations"],type:"number",nullable:!0,min:1,max:10,label:"Fix rounds before stopping",help:"How many times a failed test pass may send the change back before the task waits for you. Empty \u21D2 2."}]},{id:"code_review",label:"Code review",help:"The review of a developer's branch, triggered by moving the tracker issue into the review column.",fields:[{id:"code_review.external.verification",file:"regimen.yaml",path:["code_review","external","verification"],type:"boolean",nullable:!1,label:"Verification round (second reviewer)",help:"Off by default. When on, the first review verdict is checked by a second independent pass that confirms, refutes or re-grades the findings before anything reaches the card or the PR. Roughly doubles the review cost."}]},{id:"skills",label:"Skills",help:"Reusable procedures the agent can invoke instead of improvising. Only their names and one-line descriptions sit in the prompt; the steps load when a skill is used.",fields:[{id:"skills.from_bundled",file:"regimen.yaml",path:["skills","from_bundled"],type:"boolean",nullable:!1,label:"Use the skills shipped with CodePipe",help:"On by default. General procedures maintained with the product."},{id:"skills.from_context_repo",file:"regimen.yaml",path:["skills","from_context_repo"],type:"boolean",nullable:!1,label:"Use this project's skills",help:"On by default. Skills the team writes in the context repository under `skills/<name>/SKILL.md`. These override a bundled skill of the same name."},{id:"skills.from_project_repo",file:"regimen.yaml",path:["skills","from_project_repo"],type:"boolean",nullable:!1,label:"Use the code repository's skills",help:"On by default. `.claude/skills/` inside the project repositories \u2014 the skills your developers already use locally. These win over both other sources."}]},{id:"gates",label:"Gates",help:"Approval gate before the pipeline starts (on by default; orthogonal to automation).",fields:[{id:"gates.require_approval",file:"regimen.yaml",path:["gates","require_approval"],type:"boolean",label:"Require approval before start",nullable:!1,help:"When on (default), a task taken from Develop waits in the QUEUE for a single Confirm before the pipeline starts \u2014 the Confirm pulls in dependency closure and topologically orders the queue. Off \u21D2 conveyor: the task starts the pipeline immediately."}]},{id:"automation",label:"Automation",help:"How far the pipeline advances the G1\u2013G4 gates without a manual Run/Approve. Independent of the approval gate above.",fields:[{id:"automation.level",file:"regimen.yaml",path:["automation","level"],type:"enum",label:"Automation level",nullable:!1,suggestions:["assisted","full"],help:"assisted \u21D2 manual Run/Approve at each of G1\u2013G4; full \u21D2 gates auto-pass."}]},{id:"language",label:"Language",help:"Languages the agent writes in, per area. Empty \u21D2 auto: mirror the language of the user's material.",fields:no.map(t=>({id:`language.${t}`,file:"project.yaml",path:["language",t],type:"string",label:Lb[t],nullable:!0,maxLength:40,suggestions:t==="chat"?[$e,...Yr]:[...Yr],help:Mb[t]}))},{id:"context.model",label:"Project map",help:"Parameters of the project map (built from git history by the CLI). Empty fields keep the defaults.",fields:[{id:"context.model.enabled",file:"regimen.yaml",path:["context","model","enabled"],type:"boolean",label:"Enable in the pipeline",nullable:!1,help:"When on, agents are asked to record intent annotations and (once available) receive an assembled context pack. Off \u21D2 the pipeline ignores the map entirely."},{id:"context.model.prompt.pack",file:"regimen.yaml",path:["context","model","prompt","pack"],type:"boolean",nullable:!1,label:"Give agents the context pack",help:"On by default. The assembled pack costs up to ~4000 tokens on every task of the analyze / estimate / implement / rework roles. Turning it off keeps the map building and stops the spend \u2014 the way to see what the pack is actually worth on this project."},{id:"context.model.prompt.annotations",file:"regimen.yaml",path:["context","model","prompt","annotations"],type:"boolean",nullable:!1,label:"Ask agents for intent annotations",help:"On by default. Adds the annotations block to the implement and rework prompts \u2014 the layer that records WHY the code is shaped this way. Cheap, and worth accumulating even while the pack is off."},{id:"context.index.hub",file:"regimen.yaml",path:["context","index","hub"],type:"enum",label:"Search index on the server",nullable:!0,suggestions:["off","metadata"],help:"off (default): search runs on your machine, nothing is uploaded. metadata: paths, labels and task texts (never code) are mirrored to the server so search and structure stay available while your machine is offline. Switching back to off deletes the mirrored rows."},{id:"context.model.issue_key_pattern",file:"regimen.yaml",path:["context","model","issue_key_pattern"],type:"string",label:"Issue-key pattern (regex)",nullable:!0,maxLength:200,help:"Regex that finds tracker issue keys in commit subjects when mining task events from history. Empty \u21D2 derived from the tracker project key (e.g. DEV-\\d+)."},{id:"context.model.cochange.window_commits",file:"regimen.yaml",path:["context","model","cochange","window_commits"],type:"number",label:"History window (commits)",nullable:!0,min:50,max:5e4,help:`How many commits back from the build commit are mined. Default ${nt.windowCommits}.`},{id:"context.model.cochange.commit_file_cap",file:"regimen.yaml",path:["context","model","cochange","commit_file_cap"],type:"number",label:"Commit size cap (files)",nullable:!0,min:2,max:500,help:`Commits touching more files are ignored as noise. Default ${nt.commitFileCap}.`},{id:"context.model.cochange.support_min",file:"regimen.yaml",path:["context","model","cochange","support_min"],type:"number",label:"Minimum co-occurrences",nullable:!0,min:1,max:100,help:`A pair of files must change together at least this many times. Default ${nt.supportMin}.`},{id:"context.model.cochange.jaccard_min_pct",file:"regimen.yaml",path:["context","model","cochange","jaccard_min_pct"],type:"number",label:"Minimum Jaccard (%)",nullable:!0,min:0,max:100,help:`Overlap threshold: |A\u2229B| / |A\u222AB| of the files' commit sets, in percent. Default ${nt.jaccardMinPct}.`},{id:"context.model.cochange.half_life_days",file:"regimen.yaml",path:["context","model","cochange","half_life_days"],type:"number",label:"Time-decay half-life (days)",nullable:!0,min:1,max:3650,help:`A commit this old counts half as much. Default ${nt.halfLifeDays} (~9 months).`},{id:"context.model.cochange.top_k",file:"regimen.yaml",path:["context","model","cochange","top_k"],type:"number",label:"Edges per file (top-k)",nullable:!0,min:1,max:64,help:`Only the k strongest co-change edges of a file survive \u2014 bounds graph density whatever the thresholds. Default ${nt.topK}.`}]},{id:"rate_limit",label:"Rate limit",help:"Automatic project pause as the LLM usage window fills up.",fields:[{id:"rate_limit.auto_pause.enabled",file:"project.yaml",path:["rate_limit","auto_pause","enabled"],type:"boolean",nullable:!1,label:"Pause the project near the limit",help:"On (default): when window utilization reaches the threshold, the project is paused (same pause as the manual one) and you get an email \u2014 the remaining window stays available for your own work. Off: agents keep working until the provider actually runs out."},{id:"rate_limit.auto_pause.threshold",file:"project.yaml",path:["rate_limit","auto_pause","threshold"],type:"number",float:!0,nullable:!0,min:.05,max:1,label:"Pause threshold (share of the window)",help:"Fraction of the usage window at which the pause fires; the rest (1 \u2212 threshold) is your manual-work reserve. Empty \u21D2 0.75."}]},{id:"context.job_logs",label:"Job transcripts",help:"Whether the raw agent transcript of each job is kept in the Context Repo.",fields:[{id:"context.job_logs.enabled",file:"regimen.yaml",path:["context","job_logs","enabled"],type:"boolean",label:"Keep transcripts in the Context Repo",nullable:!1,help:"Off (default): the transcript is discarded after the run \u2014 nothing lands in the Context Repo. On: each job's raw transcript is committed as tasks/<KEY>/logs/job-<id>.jsonl for post-mortem debugging."}]}]});function td(t){if(t==null)return[];if(!Array.isArray(t))return null;let e=[];for(let r of t){if(typeof r!="string"||r.trim().length===0)return null;e.push(r.trim())}return e}function Na(t){let{name:e,body:r,origin:n}=t;if(!ja.test(e))return{ok:!1,error:`role name must match ${ja} (got "${e}")`};if(r.trim().length===0)return{ok:!1,error:"role body is empty \u2014 the body IS the role's prompt"};let o=t.frontmatter;if(o==null||typeof o!="object"||Array.isArray(o))return{ok:!1,error:"missing or malformed frontmatter block"};let i=o,s=i.description;if(typeof s!="string"||s.trim().length===0)return{ok:!1,error:"description is required (one line: what this role looks for)"};if(s.length>300)return{ok:!1,error:"description must be \u2264 300 characters"};let a=td(i.refs);if(a===null)return{ok:!1,error:"refs must be a list of non-empty paths"};if(a.length>10)return{ok:!1,error:"refs must list at most 10 files \u2014 a role is a narrow view"};for(let d of a)if(d.startsWith("/")||d.includes(".."))return{ok:!1,error:`ref "${d}" must be a path inside the Context Repo`};let c=td(i.scenarios);if(c===null)return{ok:!1,error:"scenarios must be a list"};let l=[];for(let d of c){if(!si.includes(d))return{ok:!1,error:`unknown scenario "${d}" \u2014 one of: ${si.join(", ")}`};l.includes(d)||l.push(d)}if(l.length===0)return{ok:!1,error:`scenarios must name at least one of: ${si.join(", ")}`};let u=i.model;if(u!==void 0&&(typeof u!="string"||u.trim().length===0))return{ok:!1,error:"model must be a non-empty string when set"};let p=i.enabled;return p!==void 0&&typeof p!="boolean"?{ok:!1,error:"enabled must be true or false"}:{ok:!0,role:{name:e,description:s.trim(),...typeof u=="string"?{model:u.trim()}:{},refs:a,scenarios:l,enabled:p!==!1,body:r.trim(),origin:n}}}function Oa(t,e){let r=new Map;for(let n of t)r.set(n.name,n);for(let n of e)r.set(n.name,n);return[...r.values()].sort((n,o)=>n.name<o.name?-1:n.name>o.name?1:0)}function La(t,e){return t.filter(r=>r.enabled&&r.scenarios.includes(e))}var si,ja,CA,PA,rd=x(()=>{"use strict";si=["plan_review","code_review","council"],ja=/^[a-z][a-z0-9-]{1,39}$/,CA=10,PA=300});function Ma(t){return nd.includes(t)}function Da(t){return`prompts/${t}.md`}var nd,od=x(()=>{"use strict";nd=["analysis","analyze","backfill","build","chat","code-review","code-review-external","code-review-fix","code-review-verify","council","draft","estimate","implement","index","observer","resolve-conflict","review-comment","rework","testing"]});function Ba(t){if(!Ua.test(t.name))return{ok:!1,error:`skill directory name must match ${Ua}`};if(t.body.trim().length===0)return{ok:!1,error:"SKILL.md has no body \u2014 the body IS the procedure"};let e=t.frontmatter;if(!e||typeof e!="object"||Array.isArray(e))return{ok:!1,error:"SKILL.md has no frontmatter block"};let r=e.description;return typeof r!="string"||r.trim().length===0?{ok:!1,error:"description is required \u2014 it is what decides when the skill fires"}:r.length>300?{ok:!1,error:"description must be \u2264 300 characters"}:{ok:!0,skill:{name:t.name,description:r.trim()}}}function Fa(t,e,r){let n=new Map;for(let o of[...t,...e,...r])n.set(o.name,o);return[...n.values()].sort((o,i)=>o.name<i.name?-1:o.name>i.name?1:0)}function sd(t){let e=t.trim(),r=e.lastIndexOf("@"),n=r===-1?e:e.slice(0,r),o=r===-1?"":e.slice(r+1).trim();if(!Db.test(n))return{ok:!1,error:`"${t}": expected <owner>/<repo>[@<40-hex sha>]`};let i=id.find(s=>s.repo.toLowerCase()===n.toLowerCase());return o&&!Ub.test(o)?{ok:!1,error:`"${t}": pin to a full 40-character commit sha \u2014 a branch or tag can change under you`}:!i&&!o?{ok:!1,error:`"${t}": a third-party marketplace must be pinned to a commit (<owner>/<repo>@<sha>). Its skills run beside your code with the agent's token.`}:{ok:!0,source:{repo:n,sha:o,name:i?.name??n.replace("/","-").toLowerCase(),official:!!i}}}function Bb(t){let e=[],r=[],n=new Set;for(let o of t){if(!o.trim())continue;let i=sd(o);if(!i.ok){r.push(i.error);continue}n.has(i.source.name)||(n.add(i.source.name),e.push(i.source))}return{sources:e,errors:r}}function Gb(t,e){let r=new Set(e.map(i=>i.name)),n={},o=[];for(let i of t){let s=i.trim();if(s){if(!Fb.test(s)||!r.has(s.slice(s.indexOf("@")+1))){o.push(s);continue}n[s]=!0}}return{enabled:n,unknown:o}}var Ua,jA,id,Db,Ub,Fb,ad=x(()=>{"use strict";Ua=/^[a-z][a-z0-9-]{1,39}$/,jA=300;id=[{repo:"anthropics/skills",name:"anthropic-agent-skills"},{repo:"anthropics/claude-plugins-official",name:"claude-plugins-official"}],Db=/^[A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*$/,Ub=/^[0-9a-f]{40}$/;Fb=/^[A-Za-z0-9][\w.-]*@[A-Za-z0-9][\w.-]*$/});function cd(t,e){if(t==null)return[];if(!Array.isArray(t)||t.length>e)return null;let r=[];for(let n of t){if(typeof n!="string"||n.trim().length===0)return null;r.push(n.trim())}return r}function Kb(t,e){if(!t||typeof t!="object"||Array.isArray(t))return{ok:!1,error:"queue plan must be a JSON object"};let r=new Set(e),n=t,o=cd(n.order,e.length);if(o===null)return{ok:!1,error:"order must be a list of task keys"};for(let f of o)if(!r.has(f))return{ok:!1,error:`order names ${f}, which is not in this batch`};if(new Set(o).size!==o.length)return{ok:!1,error:"order repeats a task key"};let i=e.filter(f=>!o.includes(f));if(o.length>0&&i.length>0)return{ok:!1,error:`order omits ${i.join(", ")}`};let s=n.tasks,a=[];if(s!=null){if(!Array.isArray(s))return{ok:!1,error:"tasks must be a list"};for(let f of s){if(!f||typeof f!="object")return{ok:!1,error:"each task entry must be an object"};let g=f,k=typeof g.taskKey=="string"?g.taskKey.trim():"";if(!r.has(k))return{ok:!1,error:`tasks names ${k||"(empty)"}, which is not in this batch`};let h=cd(g.after,e.length);if(h===null)return{ok:!1,error:`${k}: after must be a list of task keys`};for(let $ of h){if(!r.has($))return{ok:!1,error:`${k}: after names ${$}, not in this batch`};if($===k)return{ok:!1,error:`${k}: cannot come after itself`}}let w=typeof g.decisions=="string"?g.decisions.trim():"";a.push({taskKey:k,decisions:w.slice(0,4e3),after:h})}}let c=[],l=n.conflicts;if(Array.isArray(l))for(let f of l){if(!f||typeof f!="object")continue;let g=f,k=typeof g.taskKey=="string"?g.taskKey.trim():"",h=typeof g.adr=="string"?g.adr.trim():"",w=typeof g.detail=="string"?g.detail.trim():"";!r.has(k)||!w||c.push({taskKey:k,adr:h,detail:w.slice(0,4e3)})}let u=[],p=n.related;if(Array.isArray(p))for(let f of p){if(!f||typeof f!="object")continue;let g=f,k=typeof g.taskKey=="string"?g.taskKey.trim():"",h=typeof g.detail=="string"?g.detail.trim():"";!k||!h||u.push({taskKey:k,detail:h.slice(0,4e3)})}let d=typeof n.summary=="string"?n.summary.trim().slice(0,4e3):"",m=n.deferBehind===!0;return{ok:!0,plan:{order:o,tasks:a,conflicts:c,related:u,summary:d,deferBehind:m}}}var OA,LA,ld=x(()=>{"use strict";OA=4e3,LA=4e3});function Hb(t,e){if(!t||typeof t!="object"||Array.isArray(t))return{ok:!1,error:"council verdict must be a JSON object"};let r=t,n=r.unresolved===!0,o=typeof r.fork=="string"?r.fork.trim().slice(0,4e3):"";if(n)return o?{ok:!0,verdict:{answers:[],unresolved:!0,fork:o}}:{ok:!1,error:"an unresolved verdict must describe the fork"};let i=r.answers;if(!Array.isArray(i))return{ok:!1,error:"answers must be a list"};if(i.length!==e.length)return{ok:!1,error:`expected ${e.length} answer(s), got ${i.length}`};let s=[];for(let[a,c]of i.entries()){if(!c||typeof c!="object")return{ok:!1,error:`answer ${a+1} must be an object`};let l=c,u=typeof l.answer=="string"?l.answer.trim():"";if(!u)return{ok:!1,error:`answer ${a+1} is empty`};s.push({question:typeof l.question=="string"?l.question.trim():e[a],answer:u.slice(0,4e3),rationale:typeof l.rationale=="string"?l.rationale.trim().slice(0,4e3):""})}return{ok:!0,verdict:{answers:s,unresolved:!1,fork:""}}}var DA,ud=x(()=>{"use strict";DA=4e3});function Yb(t){let e=t.replace(/^#+\s*/,"").trim();for(let r of Wb)if(r.re.test(e))return{kind:r.kind,letter:r.letter};return null}function Ga(t){let e=[],r=new Map,n="",o=null,i=null;for(let a of t.split(`
|
|
8
8
|
`)){let c=/^#{1,6}\s+(.*)$/.exec(a);if(c){n=c[1].trim(),o=Yb(n),i=null;continue}let l=qb.exec(a);if(l&&o){let u=l[1];r.set(u,(r.get(u)??0)+1),i={id:u,kind:o.kind,text:l[2].trim(),section:n},e.push(i);continue}if(i&&a.trim()&&!/^#{1,6}\s/.test(a)&&!/^\s*[-*]\s/.test(a)){i.text=`${i.text}
|
|
9
9
|
${a.trim()}`.trim();continue}a.trim()||(i=null)}let s=[...r.entries()].filter(([,a])=>a>1).map(([a])=>a);return{items:e,structured:e.length>=2&&s.length===0,duplicateIds:s}}function zb(t){let e={decision:"D",change:"C",assumption:"A",out_of_scope:"O",test:"T",procedure:"P"};return t.items.filter(r=>!r.id.startsWith(e[r.kind]))}function Vb(t,e){let r=new Map(t.items.map(s=>[s.id,s])),n=e.filter(s=>!s.approved),o=e.filter(s=>s.approved).map(s=>s.id);if(n.length===0)return"";let i=["Rejected plan items:",""];for(let s of n){let a=r.get(s.id),c=a?`${s.id} \u2014 ${a.text.split(`
|
|
10
10
|
`)[0]}`:s.id;i.push(`- **${c}**`),s.remark?.trim()&&i.push(` ${s.remark.trim()}`)}return o.length>0&&i.push("",`Approved and settled: ${o.join(", ")}. Do not revisit these unless a`,"rejected item forces it \u2014 and say so explicitly if it does."),i.join(`
|
|
11
11
|
`)}function Ka(t){let e=new Set;for(let r of t.items)if(r.kind==="procedure")for(let n of r.text.matchAll(Xb))e.add(n[1]);return[...e]}var Wb,qb,Xb,dd=x(()=>{"use strict";Wb=[{re:/^decisions?$/i,kind:"decision",letter:"D"},{re:/^changes?$/i,kind:"change",letter:"C"},{re:/^assumptions?$/i,kind:"assumption",letter:"A"},{re:/^out of scope$/i,kind:"out_of_scope",letter:"O"},{re:/^test strategy$/i,kind:"test",letter:"T"},{re:/^procedures?$/i,kind:"procedure",letter:"P"}],qb=/^\s*[-*]\s+(?:\*\*)?\[([A-Z][0-9]+)\](?:\*\*)?\s*(.*)$/;Xb=/`([a-z][a-z0-9-]{1,39})`/g});function Qb(t){let e=[],r=null;for(let o of t.split(`
|
|
12
12
|
`)){let i=Zb.exec(o);if(i){r={id:i[1],status:i[2].toLowerCase(),text:i[3].trim()},e.push(r);continue}if(/^#{1,6}\s/.test(o)||/^\s*[-*]\s/.test(o)||!o.trim()){r=null;continue}r&&(r.text=`${r.text}
|
|
13
|
-
${o.trim()}`.trim())}let n={};for(let o of e)n[o.id]=o;return{items:e,byId:n}}function e$(t,e){let r=new Set(t);return{unreported:t.filter(n=>!(n in e.byId)),unknown:e.items.filter(n=>!r.has(n.id)).map(n=>n.id),notDone:e.items.filter(n=>n.status!=="done")}}var Jb,Zb,pd=x(()=>{"use strict";Jb=["done","deviated","partial","dropped"],Zb=/^\s*[-*]\s+(?:\*\*)?\[([A-Z][0-9]+)\](?:\*\*)?\s*[—:-]?\s*(done|deviated|partial|dropped)\b\s*[—:-]?\s*(.*)$/i});var fd=x(()=>{"use strict"});var md=x(()=>{"use strict"});var hd=x(()=>{"use strict"});function Ha(t){return`codepipe-host-${t}`}function t$(t){let e=t.filter(r=>r!=="self-hosted");return`runs-on: [self-hosted${e.length?", "+e.join(", "):""}]`}var gd=x(()=>{"use strict"});function r$(t,e){return(t&&t.includes("<TASK_ID>")?t:yd).replace(/<TASK_ID>/g,e.toLowerCase())}function n$(t,e){if(t)return`${t.replace(/\/+$/,"")}/issue/${encodeURIComponent(e)}`}function io(t){return!(!t||t.length>250||!/^[A-Za-z0-9._/-]+$/.test(t)||/^[-/.]/.test(t)||/[/.]$/.test(t)||t.endsWith(".lock")||t.includes("..")||t.includes("//")||t.includes("/."))}function Wa(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.owner=="string"?e.owner.trim():"",n=typeof e.repo=="string"?e.repo.trim():typeof e.repoName=="string"?e.repoName.trim():"",o=typeof e.host=="string"?e.host.trim():"";return!r||!n||o!=="github"&&o!=="gitlab"&&o!=="bitbucket"?null:{host:o,owner:r,repoName:n}}function qa(t){if(!t.mirror)return t;let{mirror:e,...r}=t;return{...r,host:e.host,owner:e.owner,repoName:e.repoName}}function xt(t){return`${t}${wd}`}var yd,Wt,wd,kd=x(()=>{"use strict";yd="codepipe/<TASK_ID>";Wt=/^[a-z][a-z0-9-]{1,30}$/,wd="-codepipe-ctx"});function o$(t,e){return`${t}:${e}`}var bd=x(()=>{"use strict"});function $d(t){let e=(t??"").trim();return/^pr_closed_without_merge\b/.test(e)?"blocked":/^(merge_failed|close_failed)\b/.test(e)||/^chain_base_changed\b/.test(e)?"conflict":/^(build_failed|ci_failed)\b/.test(e)?"loop_exhausted":"error"}function i$(t){for(let e=t.length-1;e>=0;e--){let r=t[e];if(r.to==="NEEDS_MANUAL")return r}return null}function s$(t,e){if(t==="AWAITING_ANSWER")return{kind:"question"};if(t==="NEEDS_MANUAL"){let n=i$(e)?.reason,o={kind:$d(n)};return n&&(o.reason=n),o}}var vd=x(()=>{"use strict"});function $r(t){for(let e of xd){let r=t.match(e.pattern);if(r)return{name:e.name,args:(r[1]??"").trim()}}return null}var xd,Sd=x(()=>{"use strict";xd=[{name:"rework",pattern:/^@(?:codepipe|devpipe)\s+rework:\s*(.+)$/im,description:"Send the task back to ANALYZING with a new instruction.",hasArg:!0},{name:"approve",pattern:/^@(?:codepipe|devpipe)\s+approve\s*$/im,description:"Merge every PR for this task (TRACKING only)."},{name:"reject",pattern:/^@(?:codepipe|devpipe)\s+reject(?::\s*(.+))?\s*$/im,description:"Abandon this task: close any open PR(s) and move it to DONE (reason rejected_and_closed). Valid from any non-terminal phase; from early phases it just skips the task.",hasArg:!0},{name:"merge",pattern:/^@(?:codepipe|devpipe)\s+merge\s*$/im,description:"Merge the task branch into the default branch without a PR (direct apply path, apply.pull_request=false; TRACKING only)."},{name:"rebase",pattern:/^@(?:codepipe|devpipe)\s+rebase\s*$/im,description:"Re-apply the patch on top of the latest base branch and force-push. Use after a PR merge conflict or APPLYING failure."},{name:"update",pattern:/^@(?:codepipe|devpipe)\s+update(?::\s*(.+))?\s*$/im,description:"Update a conflicting PR: resolve conflicts against the current base branch (TRACKING only). Optional `: <instruction>` is forwarded to the agent.",hasArg:!0},{name:"apply",pattern:/^@(?:codepipe|devpipe)\s+apply:\s*(local|auto)\s*$/im,description:"Override apply mode for this task: local (you apply by hand) or auto.",hasArg:!0},{name:"fix",pattern:/^@(?:codepipe|devpipe)\s+fix\s*$/im,description:"Fix the external review remarks on the developer's branch (waiting-for-fix state only)."}]});var Ed=x(()=>{"use strict"});function Td(t){let e=Math.max(1,Math.round(t));if(e<60)return`${e}s`;let r=Math.round(e/60);if(r<60)return`${r}m`;let n=Math.round(r/60);return n<24?`${n}h`:`${Math.round(n/24)}d`}function a$(t,e=Date.now()){return`${Td((e-t)/1e3)} ago`}function c$(t){let e=Math.floor(t/86400),r=Math.floor(t%86400/3600),n=Math.floor(t%3600/60);return e>0?`${e}d ${r}h`:r>0?`${r}h ${n}m`:`${n}m`}var Rd=x(()=>{"use strict"});var Id=x(()=>{"use strict"});function Cd(t){return t.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/^[^A-Z]+/,"").slice(0,10)}function za(t){let e=t.split(/[^A-Za-z0-9]+/).filter(Boolean),r=Cd(e.length>=2?e.map(o=>o[0]).join(""):(e[0]??"").slice(0,4));if(vr.test(r))return r;let n=Cd(t);return vr.test(n)?n:ai}function Va(t,e){let r=new Set([...e].map(n=>n.toUpperCase()));if(!r.has(t.toUpperCase()))return t;for(let n=1;n<1e4;n++){let o=String(n),i=t.slice(0,10-o.length)+o;if(!r.has(i.toUpperCase()))return i}return t}function Vr(t){return`tasks/${t}/issue.yaml`}var Ya,so,ai,vr,ci,l$,ao,zr,Pd=x(()=>{"use strict";Ya=["bug","feature","epic"],so="feature",ai="TASK",vr=/^[A-Z][A-Z0-9]{1,9}$/;ci={backlog:"Backlog",source:["To Do"],inProgress:"In Progress",review:"Review",done:["Done"],rejected:["Rejected"],statusColumns:["Backlog","To Do","In Progress","Review","Done","Rejected"]},l$=ci.backlog,ao="tracker/config.yaml",zr="tracker/counter"});function co(t){let e=t.split(`
|
|
13
|
+
${o.trim()}`.trim())}let n={};for(let o of e)n[o.id]=o;return{items:e,byId:n}}function e$(t,e){let r=new Set(t);return{unreported:t.filter(n=>!(n in e.byId)),unknown:e.items.filter(n=>!r.has(n.id)).map(n=>n.id),notDone:e.items.filter(n=>n.status!=="done")}}var Jb,Zb,pd=x(()=>{"use strict";Jb=["done","deviated","partial","dropped"],Zb=/^\s*[-*]\s+(?:\*\*)?\[([A-Z][0-9]+)\](?:\*\*)?\s*[—:-]?\s*(done|deviated|partial|dropped)\b\s*[—:-]?\s*(.*)$/i});var fd=x(()=>{"use strict"});var md=x(()=>{"use strict"});var hd=x(()=>{"use strict"});function Ha(t){return`codepipe-host-${t}`}function t$(t){let e=t.filter(r=>r!=="self-hosted");return`runs-on: [self-hosted${e.length?", "+e.join(", "):""}]`}var gd=x(()=>{"use strict"});function r$(t,e){return(t&&t.includes("<TASK_ID>")?t:yd).replace(/<TASK_ID>/g,e.toLowerCase())}function n$(t,e){if(t)return`${t.replace(/\/+$/,"")}/issue/${encodeURIComponent(e)}`}function io(t){return!(!t||t.length>250||!/^[A-Za-z0-9._/-]+$/.test(t)||/^[-/.]/.test(t)||/[/.]$/.test(t)||t.endsWith(".lock")||t.includes("..")||t.includes("//")||t.includes("/."))}function Wa(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.owner=="string"?e.owner.trim():"",n=typeof e.repo=="string"?e.repo.trim():typeof e.repoName=="string"?e.repoName.trim():"",o=typeof e.host=="string"?e.host.trim():"";return!r||!n||o!=="github"&&o!=="gitlab"&&o!=="bitbucket"?null:{host:o,owner:r,repoName:n}}function qa(t){if(!t.mirror)return t;let{mirror:e,...r}=t;return{...r,host:e.host,owner:e.owner,repoName:e.repoName}}function xt(t){return`${t}${wd}`}var yd,Wt,wd,kd=x(()=>{"use strict";yd="codepipe/<TASK_ID>";Wt=/^[a-z][a-z0-9-]{1,30}$/,wd="-codepipe-ctx"});function o$(t,e){return`${t}:${e}`}var bd=x(()=>{"use strict"});function $d(t){let e=(t??"").trim();return/^pr_closed_without_merge\b/.test(e)?"blocked":/^(merge_failed|close_failed)\b/.test(e)||/^chain_base_changed\b/.test(e)||/^write action apply_delivery failed: .*hit conflicts/.test(e)?"conflict":/^(build_failed|ci_failed)\b/.test(e)?"loop_exhausted":"error"}function i$(t){for(let e=t.length-1;e>=0;e--){let r=t[e];if(r.to==="NEEDS_MANUAL")return r}return null}function s$(t,e){if(t==="AWAITING_ANSWER")return{kind:"question"};if(t==="NEEDS_MANUAL"){let n=i$(e)?.reason,o={kind:$d(n)};return n&&(o.reason=n),o}}var vd=x(()=>{"use strict"});function $r(t){for(let e of xd){let r=t.match(e.pattern);if(r)return{name:e.name,args:(r[1]??"").trim()}}return null}var xd,Sd=x(()=>{"use strict";xd=[{name:"rework",pattern:/^@(?:codepipe|devpipe)\s+rework:\s*(.+)$/im,description:"Send the task back to ANALYZING with a new instruction.",hasArg:!0},{name:"approve",pattern:/^@(?:codepipe|devpipe)\s+approve\s*$/im,description:"Merge every PR for this task (TRACKING only)."},{name:"reject",pattern:/^@(?:codepipe|devpipe)\s+reject(?::\s*(.+))?\s*$/im,description:"Abandon this task: close any open PR(s) and move it to DONE (reason rejected_and_closed). Valid from any non-terminal phase; from early phases it just skips the task.",hasArg:!0},{name:"merge",pattern:/^@(?:codepipe|devpipe)\s+merge\s*$/im,description:"Merge the task branch into the default branch without a PR (direct apply path, apply.pull_request=false; TRACKING only)."},{name:"rebase",pattern:/^@(?:codepipe|devpipe)\s+rebase\s*$/im,description:"Re-apply the patch on top of the latest base branch and force-push. Use after a PR merge conflict or APPLYING failure."},{name:"update",pattern:/^@(?:codepipe|devpipe)\s+update(?::\s*(.+))?\s*$/im,description:"Update a conflicting PR: resolve conflicts against the current base branch (TRACKING only). Optional `: <instruction>` is forwarded to the agent.",hasArg:!0},{name:"apply",pattern:/^@(?:codepipe|devpipe)\s+apply:\s*(local|auto)\s*$/im,description:"Override apply mode for this task: local (you apply by hand) or auto.",hasArg:!0},{name:"fix",pattern:/^@(?:codepipe|devpipe)\s+fix\s*$/im,description:"Fix the external review remarks on the developer's branch (waiting-for-fix state only)."}]});var Ed=x(()=>{"use strict"});function Td(t){let e=Math.max(1,Math.round(t));if(e<60)return`${e}s`;let r=Math.round(e/60);if(r<60)return`${r}m`;let n=Math.round(r/60);return n<24?`${n}h`:`${Math.round(n/24)}d`}function a$(t,e=Date.now()){return`${Td((e-t)/1e3)} ago`}function c$(t){let e=Math.floor(t/86400),r=Math.floor(t%86400/3600),n=Math.floor(t%3600/60);return e>0?`${e}d ${r}h`:r>0?`${r}h ${n}m`:`${n}m`}var Rd=x(()=>{"use strict"});var Id=x(()=>{"use strict"});function Cd(t){return t.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/^[^A-Z]+/,"").slice(0,10)}function za(t){let e=t.split(/[^A-Za-z0-9]+/).filter(Boolean),r=Cd(e.length>=2?e.map(o=>o[0]).join(""):(e[0]??"").slice(0,4));if(vr.test(r))return r;let n=Cd(t);return vr.test(n)?n:ai}function Va(t,e){let r=new Set([...e].map(n=>n.toUpperCase()));if(!r.has(t.toUpperCase()))return t;for(let n=1;n<1e4;n++){let o=String(n),i=t.slice(0,10-o.length)+o;if(!r.has(i.toUpperCase()))return i}return t}function Vr(t){return`tasks/${t}/issue.yaml`}var Ya,so,ai,vr,ci,l$,ao,zr,Pd=x(()=>{"use strict";Ya=["bug","feature","epic"],so="feature",ai="TASK",vr=/^[A-Z][A-Z0-9]{1,9}$/;ci={backlog:"Backlog",source:["To Do"],inProgress:"In Progress",review:"Review",done:["Done"],rejected:["Rejected"],statusColumns:["Backlog","To Do","In Progress","Review","Done","Rejected"]},l$=ci.backlog,ao="tracker/config.yaml",zr="tracker/counter"});function co(t){let e=t.split(`
|
|
14
14
|
`),r=e.indexOf("---");if(r<0)return;let n=e.slice(r+1),o=n.lastIndexOf("## Attachments");o>=0&&n.slice(o+1).every(c=>c.trim()===""||/^- \[[^\]]*\]\(attachments\/[^)]*\)$/.test(c.trim()))&&(n=n.slice(0,o));let i=n.join(`
|
|
15
15
|
`).trim();if(!(!i||i==="_(no description)_"))return i}function u$(t){return`{{ancestorExcerpt:${t}}}`}var li,Ad=x(()=>{"use strict";li=/\{\{ancestorExcerpt:([^}]+)\}\}/g});var d$,_d=x(()=>{"use strict";d$="youtrack"});function xr(t){let e=t.match(/^git@([^:/]+):/);if(e)return e[1]??null;let r=t.match(/^ssh:\/\/(?:[^@/]+@)?([^/:]+)/);if(r)return r[1]??null;let n=t.match(/^https?:\/\/(?:[^@/]+@)?([^/:]+)/);return n?n[1]??null:null}function lo(t){switch(t){case Xr.gitlab:return"oauth2";case Xr.bitbucket:return"x-token-auth";default:return"x-access-token"}}var Xr,Lt,jd=x(()=>{"use strict";Xr={github:"github.com",gitlab:"gitlab.com",bitbucket:"bitbucket.org"};Lt="x-bitbucket-api-token-auth"});var Nd=x(()=>{"use strict"});var Od=x(()=>{"use strict";_d();jd();Nd()});var Ld={};ze(Ld,{ACTION_ID_RE:()=>$a,ACTION_STEP_DEFAULT_TIMEOUT_SEC:()=>xa,ALL_JOB_ROLES:()=>ha,ALL_MODEL_ROLE_KEYS:()=>wa,ANALYSIS_MAX_DRAFTS:()=>Xa,ANCESTOR_EXCERPT_RE:()=>li,ANCESTOR_EXCERPT_TOKEN:()=>u$,ANNOTATION_MAX_PER_TASK:()=>aa,BACKFILL_MAX_DRAFTS:()=>p$,BITBUCKET_API_TOKEN_GIT_USER:()=>Lt,BUILD_DISCOVERY:()=>Ku,COCHANGE_DEFAULTS:()=>nt,CODEPIPE_COMMANDS:()=>xd,COMMIT_STYLE_MAX_LENGTH:()=>Pa,CONTEXT_PACK_DECAY:()=>la,CONTEXT_PACK_DEFAULTS:()=>wr,CONTEXT_REPO_SUFFIX:()=>wd,CONTEXT_STAMP_FILE:()=>gt,CONTEXT_TEMPLATE_CHANGELOG:()=>Vs,CONTEXT_TEMPLATE_VERSION:()=>Tu,COUNCIL_MAX_ANSWER:()=>DA,DEFAULT_BRANCH_PATTERN:()=>yd,DEFAULT_HUB_URL:()=>mt,DEFAULT_INTERNAL_ISSUE_TYPE:()=>so,DEFAULT_INTERNAL_TRACKER_PREFIX:()=>ai,DEFAULT_LLM_PROVIDER:()=>Xe,DEFAULT_REGIMEN_ALIASES:()=>Yu,DEFAULT_TRACKER_PROVIDER:()=>d$,ENV_NAME_RE:()=>Je,FALLBACK_MODEL:()=>Wu,GIT_HOST_DOMAINS:()=>Xr,INTERNAL_ISSUE_TYPES:()=>Ya,INTERNAL_TRACKER_CONFIG_PATH:()=>ao,INTERNAL_TRACKER_COUNTER_PATH:()=>zr,INTERNAL_TRACKER_DEFAULT_STATUS:()=>l$,INTERNAL_TRACKER_PREFIX_RE:()=>vr,INTERNAL_TRACKER_STATUSES:()=>ci,LANE_PHASES:()=>bb,LANE_SEGMENTS:()=>ma,LANGUAGE_AUTO:()=>$e,LANGUAGE_SUGGESTIONS:()=>Yr,LANGUAGE_VALUE_MAX_LENGTH:()=>oo,LEGACY_CONTEXT_STAMP_FILE:()=>Kr,LLM_PROVIDER_SUGGESTIONS:()=>ya,MIN_SUPPORTED_PROTOCOL:()=>xu,MODEL_ALIAS_SUGGESTIONS:()=>oi,MODEL_DERIVED_DIR:()=>fb,MODEL_DERIVED_INDEX_PATH:()=>Qo,MODEL_DIR:()=>ub,MODEL_EDGE_KINDS:()=>ia,MODEL_ENTITY_ID_RE:()=>Pu,MODEL_FACTS_DIR:()=>pb,MODEL_FAMILY_PREFERENCE:()=>qu,MODEL_HAIKU:()=>ni,MODEL_LEVELS:()=>Cu,MODEL_OPUS:()=>Pe,MODEL_README_PATH:()=>db,MODEL_RELATES_PATH:()=>hr,MODEL_SEARCH_MAX_LIMIT:()=>ca,MODEL_SEARCH_MAX_ROWS:()=>hb,MODEL_SEARCH_ROW_TEXT_MAX:()=>ti,MODEL_SONNET:()=>to,MODEL_SUB_ROLES:()=>Hu,OBSERVER_MAX_DECISION:()=>OA,OBSERVER_MAX_SUMMARY:()=>LA,OFFICIAL_MARKETPLACES:()=>id,PHASES:()=>fa,PIPELINE_COLUMNS:()=>Uu,PLANNING_LANE_MAX_JOBS:()=>Sb,PLANNING_ROLES:()=>Fu,PLATFORM_VERSION:()=>Ve,PROJECT_ID_RE:()=>Wt,PROJECT_LANGUAGE_SECTIONS:()=>no,PROJECT_MODEL_FORMAT_VERSION:()=>Oe,PROJECT_SETTINGS_MANIFEST:()=>Zu,PROMPT_ROLES:()=>nd,PROTOCOL_VERSION:()=>ht,RECOMMENDED_ROLE_MODELS:()=>ro,RELATES_MIN_OVERLAP:()=>sa,ROLE_MAX_DESCRIPTION:()=>PA,ROLE_MAX_REFS:()=>CA,ROLE_NAME_RE:()=>ja,ROLE_SCENARIOS:()=>si,SKILL_MAX_DESCRIPTION:()=>jA,SKILL_NAME_RE:()=>Ua,SOLUTION_STATUSES:()=>Jb,STRING_MAP_MAX_ENTRIES:()=>Ia,STRING_MAP_MAX_VALUE_LENGTH:()=>Ca,additionsSince:()=>Js,ago:()=>a$,attentionFor:()=>s$,autoLanguageConfig:()=>Xu,autoModelDefault:()=>ka,canonicalizeModelEdgeSheet:()=>Au,canonicalizeModelIdentityTable:()=>ju,canonicalizeModelShard:()=>_u,canonicalizeModelTaskEvent:()=>Nu,changesSince:()=>Zs,classifyAttentionReason:()=>$d,compilePlanRework:()=>Vb,contextRepoName:()=>xt,deserializeModelConfig:()=>Cb,emptyModelConfig:()=>qr,enabledPluginsSetting:()=>Gb,extractLanguageConfig:()=>Nb,extractTaskMdBody:()=>co,findSettingField:()=>Qu,firstFreeInternalTrackerPrefix:()=>Va,flattenSettingFields:()=>Aa,fmtDuration:()=>Td,fmtUptime:()=>c$,ghRunnerHostLabel:()=>Ha,ghRunnerRunsOnSnippet:()=>t$,gitCloneUrlDomain:()=>xr,httpsTokenUser:()=>lo,internalIssueYamlPath:()=>Vr,isAllAutoLanguage:()=>Ob,isAutoLanguage:()=>Ju,isBodyEditFrozen:()=>kb,isModelEntityId:()=>ei,isPromptRole:()=>Ma,isProtocolCompatible:()=>Vn,isReservedEnvName:()=>Ot,isTerminalPhase:()=>wb,isValidBranchName:()=>io,jobLane:()=>xb,laneSegmentForPhase:()=>$b,makeTaskId:()=>o$,mergeRoles:()=>Oa,mergeSkills:()=>Fa,mismatchedIds:()=>zb,modelAnnotationPath:()=>ta,modelComponentSlug:()=>Iu,modelCorrelatesPath:()=>ra,modelEventPath:()=>gr,modelIdentityPath:()=>Zn,modelNodeKey:()=>ye,modelShardNeedsRebuild:()=>gb,modelStructureShardPath:()=>oa,modelTaskNodeKey:()=>xe,modelTouchedPath:()=>na,parseActionDefinition:()=>Sa,parseCodepipeCommand:()=>$r,parseContextStamp:()=>Xs,parseMarketplaceSource:()=>sd,parseMarketplaces:()=>Bb,parseModelConfig:()=>Rb,parseModelNodeKey:()=>re,parsePlanItems:()=>Ga,parseRepoMirror:()=>Wa,parseSolutionItems:()=>Qb,pipelineColumnForPhase:()=>vb,pipelineRepoSpec:()=>qa,prescribedSkills:()=>Ka,promptOverridePath:()=>Da,renderContextStamp:()=>Xn,resolveBranchName:()=>r$,resolveModelForRole:()=>Eb,resolveProvider:()=>Tb,rolesForScenario:()=>La,serializeModelConfig:()=>Ib,serializeModelEdgeSheet:()=>yr,serializeModelIdentityTable:()=>da,serializeModelShard:()=>ua,serializeModelTaskEvent:()=>Wr,serializeModelYaml:()=>kr,solutionCoverage:()=>e$,suggestInternalTrackerPrefix:()=>za,validateActionInput:()=>Ea,validateCouncilVerdict:()=>Hb,validateModelEdgeSheet:()=>Qn,validateModelIdentityTable:()=>eo,validateModelShard:()=>jt,validateModelTaskEvent:()=>Nt,validateObserverPlan:()=>Kb,validateRoleDefinition:()=>Na,validateSettingEdit:()=>_a,validateSkill:()=>Ba,youtrackIssueUrl:()=>n$,zeroUsage:()=>Ht});var Xa,p$,B=x(()=>{"use strict";Su();Eu();Ru();pa();Du();Bu();ga();ba();ed();Ra();Ta();rd();od();ad();ld();ud();dd();pd();fd();md();hd();gd();kd();bd();vd();Sd();Ed();Rd();Id();Pd();Ad();Od();Xa=20,p$=15});function X(t){return process.env[`CODEPIPE_${t}`]??process.env[`DEVPIPE_${t}`]}var Fe=x(()=>{"use strict"});import{existsSync as f$,readFileSync as m$,readdirSync as h$}from"node:fs";import{dirname as g$,join as Ja}from"node:path";import{parse as y$}from"yaml";function w$(t=process.cwd()){let e=t;for(;;){if(f$(Ja(e,ot,"project.yaml")))return e;let r=g$(e);if(r===e)return null;e=r}}function k$(t){return Ja(t,ot)}function Ae(t=process.cwd()){let e=w$(t);if(!e)return null;let r=k$(e),n=b$(m$(Ja(r,"project.yaml"),"utf-8"));return{root:e,contextDir:r,spec:n}}function Md(t,e,r){return h$(t).filter(o=>o!==".DS_Store").length===0?!0:e?r.some(o=>o.host===e.host&&o.owner===e.owner&&o.repoName===e.repoName):!1}function Jr(t,e=process.cwd()){try{let r=Ae(e);return r&&r.spec.projectId===t?r:null}catch{return null}}function b$(t){let e=y$(t);if(!e||typeof e!="object")throw new Error("project.yaml is empty or malformed");let r=String(e.id??""),n=String(e.name??r),o=Array.isArray(e.repos)?e.repos:[],i=[];for(let s of o){if(!s||typeof s!="object")continue;let a=s,c=String(a.repo??a.repoName??""),l=String(a.name??c);if(!l||!c)continue;let u=a.host,p=u==="bitbucket"?"bitbucket":u==="gitlab"?"gitlab":"github",d=Wa(a.mirror);i.push({name:l,host:p,owner:String(a.owner??""),repoName:c,defaultBranch:String(a.default_branch??a.defaultBranch??"main"),mountAs:String(a.mount_as??a.mountAs??l),...d?{mirror:d}:{}})}return{projectId:r,name:n,repos:i}}function ui(t){return t.host==="github"?`git@github.com:${t.owner}/${t.repoName}.git`:t.host==="gitlab"?`git@gitlab.com:${t.owner}/${t.repoName}.git`:`git@bitbucket.org:${t.owner}/${t.repoName}.git`}var ot,it=x(()=>{"use strict";B();ot=".codepipe"});import{homedir as Dd}from"node:os";import{mkdirSync as $$,readFileSync as v$,writeFileSync as x$,existsSync as Za}from"node:fs";import{dirname as Bd,join as di,resolve as S$}from"node:path";import{fileURLToPath as E$}from"node:url";function Fd(t){let e=di(Ud,".env");if(Za(e)&&process.loadEnvFile(e),t){let r=di(Ud,"profiles",t,".env");Za(r)&&process.loadEnvFile(r)}}function Zr(t){let e=X("CONFIG");return e||(t?di(Dd(),".codepipe","profiles",t,"config.json"):di(Dd(),".codepipe","config.json"))}function wt(t){let e=Zr(t);if(!Za(e))return null;let r=v$(e,"utf-8");return JSON.parse(r)}function Mt(t,e){let r=Zr(e);$$(Bd(r),{recursive:!0}),x$(r,JSON.stringify(t,null,2)+`
|
|
16
16
|
`,{mode:384})}function Qr(t){if(t)return{cfg:st(t),profile:t};let e;try{e=Ae()?.spec.projectId||void 0}catch{}if(e){let r=wt(e);if(r)return console.log(`[profile] ${e} \u2014 resolved from this folder's workspace`),{cfg:r,profile:e};console.error(`this folder is the workspace of project '${e}', but that CLI profile is not initialised on this machine \u2014 run \`codepipe init\` here (or pass --profile).`),process.exit(1)}return{cfg:st(void 0),profile:void 0}}function st(t){let e=wt(t);if(!e){let r=t?`codepipe init --profile ${t} --hub <url> --token <token> --project ${t}`:"codepipe init --hub <url> --token <token> --project <id>";console.error(t?`CLI profile '${t}' is not initialised. run \`${r}\` first.`:`CLI is not initialised. run \`${r}\` first.`),process.exit(1)}return e.projectId||(console.error(`config at ${Zr(t)} is missing 'projectId'. re-run init with --force.`),process.exit(1)),e}var Ud,Ge=x(()=>{"use strict";Fe();it();Ud=S$(Bd(E$(import.meta.url)),"..")});import{homedir as Gd}from"node:os";import{existsSync as Kd,mkdirSync as Hd,readFileSync as Wd,writeFileSync as qd}from"node:fs";import{dirname as Yd,join as zd}from"node:path";function Vd(t,e,r){let n=q(t);if(!n)throw new Error("no secrets file for this project on the CLI");n.secrets={...n.secrets??{},[e]:r},ae(n)}function Xd(t,e){let r=q(t);return!r?.secrets||!(e in r.secrets)?!1:(delete r.secrets[e],ae(r),!0)}function Jd(t){return Object.keys(q(t)?.secrets??{}).sort()}function pi(t,e,r){let n=q(t);if(!n)return"mismatch";let o=n.sandboxPins??{},i=o[e];return i&&i===r?"ok":i&&i!==r?"mismatch":(o[e]=r,n.sandboxPins=o,ae(n),"pinned")}function Zd(t,e){let r=q(t);return r?.sandboxPins?.[e]?(delete r.sandboxPins[e],ae(r),!0):!1}function St(t){return zd(Gd(),".codepipe","secrets",`${t}.json`)}function q(t){let e=St(t);return Kd(e)?JSON.parse(Wd(e,"utf-8")):null}function ae(t){let e=St(t.projectId);Hd(Yd(e),{recursive:!0}),qd(e,JSON.stringify(t,null,2)+`
|
|
@@ -812,7 +812,7 @@ Produced by the interactive chat (mock runner).
|
|
|
812
812
|
${s.join("").trim()||"(no stderr)"}`))})})}function Ne(t,e,r){return new Promise((n,o)=>{let i=ty("git",e,{cwd:t,stdio:["ignore","pipe","pipe"],env:r??{...process.env}}),s=[],a=[];i.stdout.setEncoding("utf-8"),i.stderr.setEncoding("utf-8"),i.stdout.on("data",c=>s.push(c)),i.stderr.on("data",c=>a.push(c)),i.on("error",o),i.on("close",c=>{if(c===0)return n(s.join(""));o(new Error(`git ${e[0]} failed (exit ${c}):
|
|
813
813
|
${a.join("").trim()||"(no stderr)"}`))})})}function dy(t,e){ys(t)&&Nl(t,{recursive:!0,force:!0}),Uo(In(t),{recursive:!0}),KT(e,t,"dir")}async function py(t,e,r){await de(t,["worktree","prune"]).catch(()=>{}),Uo(In(r),{recursive:!0}),await de(t,["worktree","add","--detach",r,`origin/${e}`])}async function qT(t,e,r){Uo(In(r),{recursive:!0}),await de(In(r),["clone","--quiet","--no-checkout",t,r]),await de(r,["checkout","--force","--detach",e])}async function fy(t,e,r,n="worktree",o,i){return r.length===0?[]:ny(e,async()=>{let s=[];for(let a of r){let c=cr(ry(i),e,a.name);console.log(`[git] code: ensure ${a.cloneUrl} @ ${a.ref} \u2192 ${c}`);let l;try{l=await oy(c,a.cloneUrl,a.ref,a.defaultBranch,o)}catch(d){throw new Error(`failed to materialize project repo "${a.name}" (${a.cloneUrl}): `+(d instanceof Error?d.message:String(d)))}let u=(await Ne(c,["rev-parse","HEAD"])).trim(),p=cr(t,"code",a.name);n==="direct"?(dy(p,c),console.log(`[git] code: linked ${p} \u2192 ${c} @ ${u.slice(0,10)}`)):n==="clone"?(await qT(c,u,p),console.log(`[git] code: clone ${p} \u2190 ${c} @ ${u.slice(0,10)}`)):(await py(c,l,p),console.log(`[git] code: worktree ${p} \u2190 ${c} @ ${u.slice(0,10)}`)),s.push({name:a.name,workspacePath:p,cachePath:c,ref:l,baseSha:u})}return s})}async function my(t,e,r,n="worktree",o,i){if(!r||!r.cloneUrl)return null;let s=r;return ny(e,async()=>{let a=cr(ry(i),e,"_context");console.log(`[git] context: ensure ${s.cloneUrl} @ ${s.ref} \u2192 ${a}`);try{await oy(a,s.cloneUrl,s.ref,void 0,o)}catch(u){throw new Error(`failed to materialize context repo (${s.cloneUrl}): `+(u instanceof Error?u.message:String(u)))}let c=cr(t,"context");n==="direct"?(dy(c,a),console.log(`[git] context: linked ${c} \u2192 ${a}`)):(await py(a,s.ref,c),console.log(`[git] context: worktree ${c} \u2190 ${a}`));let l=(await Ne(a,["rev-parse","HEAD"])).trim();return{workspacePath:c,cachePath:a,baseSha:l}})}async function hy(t,e=[]){let r=t.workspacePath,n=["knowledge",...e];await de(r,["add","-A",...n]).catch(()=>{});let o;try{o=await Ne(r,["diff","--cached","--name-only","--diff-filter=d",t.baseSha,"--",...n])}catch{return[]}let i=o.split(`
|
|
814
814
|
`).map(a=>a.trim()).filter(a=>a.length>0),s=[];for(let a of i)try{let c=GT(cr(r,a)).toString("base64");s.push({path:a,contentBase64:c})}catch{}return s}var Rn,Cn,Pn,gy=x(()=>{"use strict";B();Rn=new Map;Cn="CodePipe Agent",Pn="codepipe@codepartner.ee"});import{existsSync as YT,readFileSync as zT}from"node:fs";import{join as VT}from"node:path";import{parse as XT}from"yaml";function yy(t){if(!t)return!1;let e=VT(t,Ll);if(!YT(e))return!1;try{let r=XT(zT(e,"utf-8"));if(!r||typeof r!="object")return!1;let n=r.steps;return!Array.isArray(n)||n.length===0?!1:n.some(o=>o!=null&&typeof o=="object"&&typeof o.run=="string"&&o.run.trim().length>0)}catch{return!1}}var Ll,wy=x(()=>{"use strict";Ll="knowledge/build.yaml"});import{readFileSync as JT}from"node:fs";import{join as ZT}from"node:path";function ky(t){let e=ZT(t,Bo),r;try{r=JT(e,"utf-8")}catch{throw new lr(`BUILD produced no ${Bo} verdict \u2014 inconclusive run`)}let n;try{n=JSON.parse(r)}catch(u){throw new lr(`${Bo} is not valid JSON: ${u instanceof Error?u.message:String(u)}`)}if(!n||typeof n!="object")throw new lr(`${Bo} must be a JSON object`);let o=n;if(typeof o.ok!="boolean")throw new lr(`${Bo}: "ok" must be a boolean`);let i=o.ok,a=(Array.isArray(o.steps)?o.steps:[]).flatMap(u=>{if(!u||typeof u!="object")return[];let p=u,d=typeof p.name=="string"?p.name:null,m=typeof p.exitCode=="number"?p.exitCode:null;if(d===null||m===null)return[];let f={name:d,exitCode:m};return typeof p.durationMs=="number"&&(f.durationMs=p.durationMs),[f]}),c=typeof o.logTail=="string"?QT(o.logTail):"",l={ok:i,steps:a,logTail:c};if(typeof o.failedStep=="string"&&o.failedStep)l.failedStep=o.failedStep;else if(!i){let u=a.find(p=>p.exitCode!==0);u&&(l.failedStep=u.name)}return l}function QT(t){let e=Buffer.from(t,"utf-8");return e.length<=Ml?t:`\u2026 [${e.length-Ml} bytes elided] \u2026
|
|
815
|
-
`+e.subarray(e.length-Ml).toString("utf-8")}var Ml,lr,Bo,by=x(()=>{"use strict";Ml=8*1024,lr=class extends Error{},Bo="meta/build-result.json"});import{readFileSync as eR}from"node:fs";import{join as tR}from"node:path";function $y(t){let e=tR(t,An),r;try{r=eR(e,"utf-8")}catch{throw new Gt(`code review produced no ${An} verdict \u2014 inconclusive run`)}let n;try{n=JSON.parse(r)}catch(l){throw new Gt(`${An} is not valid JSON: ${l instanceof Error?l.message:String(l)}`)}if(!n||typeof n!="object")throw new Gt(`${An} must be a JSON object`);let o=n;if(typeof o.approved!="boolean")throw new Gt(`${An}: "approved" must be a boolean`);let i=o.approved,s=typeof o.remarks=="string"?Nr(o.remarks,rR):"";if(!i&&s.trim().length===0)throw new Gt(`${An}: "approved" is false but "remarks" is empty \u2014 nothing to rework on`);let a=typeof o.summary=="string"?Nr(o.summary,nR):"",c=iR(o.findings);return{approved:i,remarks:s,summary:a,...c.length>0?{findings:c}:{}}}function iR(t){if(!Array.isArray(t))return[];let e=[];for(let r of t.slice(0,oR)){if(!r||typeof r!="object")continue;let n=r,o=typeof n.title=="string"?Nr(n.title,512).trim():"",i=typeof n.problem=="string"?Nr(n.problem,Dl).trim():"";if(!o||!i)continue;let s=typeof n.line=="number"&&Number.isInteger(n.line)&&n.line>0?n.line:void 0;e.push({severity:n.severity==="blocker"
|
|
815
|
+
`+e.subarray(e.length-Ml).toString("utf-8")}var Ml,lr,Bo,by=x(()=>{"use strict";Ml=8*1024,lr=class extends Error{},Bo="meta/build-result.json"});import{readFileSync as eR}from"node:fs";import{join as tR}from"node:path";function $y(t){let e=tR(t,An),r;try{r=eR(e,"utf-8")}catch{throw new Gt(`code review produced no ${An} verdict \u2014 inconclusive run`)}let n;try{n=JSON.parse(r)}catch(l){throw new Gt(`${An} is not valid JSON: ${l instanceof Error?l.message:String(l)}`)}if(!n||typeof n!="object")throw new Gt(`${An} must be a JSON object`);let o=n;if(typeof o.approved!="boolean")throw new Gt(`${An}: "approved" must be a boolean`);let i=o.approved,s=typeof o.remarks=="string"?Nr(o.remarks,rR):"";if(!i&&s.trim().length===0)throw new Gt(`${An}: "approved" is false but "remarks" is empty \u2014 nothing to rework on`);let a=typeof o.summary=="string"?Nr(o.summary,nR):"",c=iR(o.findings);return{approved:i,remarks:s,summary:a,...c.length>0?{findings:c}:{}}}function iR(t){if(!Array.isArray(t))return[];let e=[];for(let r of t.slice(0,oR)){if(!r||typeof r!="object")continue;let n=r,o=typeof n.title=="string"?Nr(n.title,512).trim():"",i=typeof n.problem=="string"?Nr(n.problem,Dl).trim():"";if(!o||!i)continue;let s=typeof n.line=="number"&&Number.isInteger(n.line)&&n.line>0?n.line:void 0;e.push({severity:n.severity==="blocker"||n.severity==="major"||n.severity==="minor"?n.severity:"other",title:o,problem:i,...typeof n.repo=="string"&&n.repo?{repo:n.repo}:{},...typeof n.file=="string"&&n.file?{file:Nr(n.file,1024)}:{},...s!==void 0?{line:s}:{},...typeof n.scenario=="string"&&n.scenario.trim()?{scenario:Nr(n.scenario,Dl)}:{},...typeof n.suggestion=="string"&&n.suggestion.trim()?{suggestion:Nr(n.suggestion,Dl)}:{}})}return e}function Nr(t,e){let r=Buffer.from(t,"utf-8");return r.length<=e?t:r.subarray(0,e).toString("utf-8")+`
|
|
816
816
|
\u2026 [${r.length-e} bytes elided]`}var rR,nR,Gt,An,Dl,oR,vy=x(()=>{"use strict";rR=16*1024,nR=4*1024,Gt=class extends Error{},An="meta/review-result.json";Dl=8*1024,oR=50});import{readFileSync as sR,statSync as aR}from"node:fs";import{join as xy}from"node:path";function mR(t){return t.startsWith("meta/")||fR.has(t)}function hR(t,e,r,n){return`[codepipe] artifact omitted from upload: ${t} was ${e} bytes, exceeds the SANDBOX upload budget (per-artifact ${r} / total ${n}). The delivered code (git) and the build/review verdict are unaffected \u2014 only this display/durability copy was dropped.`}function gR(t){return`[codepipe] artifact unreadable at upload time: ${t} could not be read from the workspace \u2014 content omitted.`}function Sy(t,e,r){let n=r?.maxBytes??cR,o=r?.totalBytes??lR,i=r?.maxCount??uR,s=e.map((f,g)=>{let k=null;try{k=aR(xy(t,f)).size}catch{}return{path:f,index:g,size:k}}),a=[...s].sort((f,g)=>{let k=h=>mR(h.path)?0:1;return k(f)!==k(g)?k(f)-k(g):(f.size??0)-(g.size??0)}),c=a.slice(0,i),l=a.slice(i).sort((f,g)=>f.index-g.index).map(f=>f.path),u=new Array(s.length),p=[],d=0;for(let f of c){let g=null;if(f.size!==null&&f.size<=n&&d+f.size<=o)try{g=sR(xy(t,f.path))}catch{}if(g!==null){d+=g.length,u[f.index]={path:f.path,contentBase64:g.toString("base64")};continue}let k=f.size===null?gR(f.path):hR(f.path,f.size,n,o),h=Buffer.from(k,"utf-8");d+=h.length,u[f.index]={path:f.path,contentBase64:h.toString("base64")},p.push({path:f.path,bytes:f.size??0})}let m=u.filter(f=>f!==void 0);if(l.length>0){let f=l.slice(0,pR),g=`# Artifacts omitted from upload
|
|
817
817
|
|
|
818
818
|
${l.length} file(s) exceeded the SANDBOX artifact count budget (${i}) and were dropped from the listing. The delivered code (git) and the build/review verdicts are unaffected. Usually this means a job left a stray tree in the workspace \u2014 throwaway copies belong in the workspace's \`scratch/\` directory, which is never uploaded.
|
|
@@ -871,7 +871,7 @@ ${n}`}function jI(t,e,r,n){let o=La(e,r);if(o.length===0)return{roles:[],files:[
|
|
|
871
871
|
|
|
872
872
|
\u2026 [${s} bytes elided \u2014 log capped at ${Ts} bytes for upload] \u2026
|
|
873
873
|
|
|
874
|
-
${i}`}function qI(){let t=[],e=!1,r=null,n=i=>{if(r){let s=r;r=null,s({value:i,done:!1})}else t.push(i)},o=()=>{if(r){let i=r;r=null,i({value:void 0,done:!0})}};return{push(i){e||n(i)},finalize(){e||(n({kind:"finalize"}),e=!0)},close(){e=!0,t.length=0,o()},iterable:{[Symbol.asyncIterator](){return{next(){return t.length>0?Promise.resolve({value:t.shift(),done:!1}):e?Promise.resolve({value:void 0,done:!0}):new Promise(i=>{r=i})}}}}}}async function Go(t={}){let e=Le(t.profile);e||(console.error("sandbox not registered. run `codepipe worker register` first."),process.exit(1));let r=e.sealPrivateKey,n=e.sandboxId,o=e.llm,i=kg(t.profile,e.sandboxId,!!X("SANDBOX_CONFIG")),s=It(GI(),".codepipe","logs"),a=mi("SANDBOX_LOG",i,s);if(a.enabled){let A=new rn(a);hi(A),console.log(`[log] file logging \u2192 ${A.path} (rotate at ${a.maxBytes}B, keep ${a.maxFiles})`)}console.log(`codepipe-sandbox v${Ve} (protocol ${ht})`),console.log(`starting sandbox ${e.sandboxId} (${e.name}) \u2192 ${e.hubUrl}`);let c=jg(e.llm);console.log(`llm backend: ${c?c.name():"(none \u2014 will not claim agent jobs)"}`);let l=Dg();console.log(`llm retry: maxAttempts=${l.maxAttempts} backoff=${l.baseDelayMs}\u2013${l.maxDelayMs}ms budget=${l.totalBudgetMs}ms`);let u=new $n(e.hubUrl,e.token),p=!1,d=new AbortController,m=new Map,f=null,g=null,k=!1,h=()=>{let A=u.openControlSocket();return f=A,A.on("open",()=>{console.log("[ws] connected");let y={type:"sandbox_hello",platformVersion:Ve,protocolVersion:ht};A.send(JSON.stringify(y))}),A.on("message",y=>{let U=y.toString("utf-8"),j=null;try{let H=JSON.parse(U);H&&typeof H=="object"&&(j=H)}catch{}if(j&&j.type==="hello"){let H=j;g=Vn(H.protocolVersion);let J=g?"compatible":"INCOMPATIBLE";console.log(`[ws] hub v${H.platformVersion} (protocol ${H.protocolVersion}) \u2014 ${J}`),g&&(k=!1);return}if(j&&j.type==="pause_job"){let H=typeof j.jobId=="string"?j.jobId:"",J=H?m.get(H):void 0;J?(console.warn(`[ws] pause_job ${H} \u2014 aborting agent`),J.paused=!0,J.abort.abort()):console.log(`[ws] pause_job ${H} \u2014 not a running job, ignoring`),H&&A.send(JSON.stringify({type:"job_paused",jobId:H}));return}if(j&&(j.type==="chat_user_message"||j.type==="chat_finalize")){let H=typeof j.jobId=="string"?j.jobId:"",J=H?m.get(H):void 0;if(J?.chatInbox)if(j.type==="chat_user_message"){let oe=typeof j.text=="string"?j.text:"";oe.trim()&&J.chatInbox.push({kind:"user",text:oe})}else J.chatInbox.finalize();else console.log(`[ws] ${String(j.type)} ${H} \u2014 not a live chat job, ignoring`);return}console.log(`[ws] ${U}`)}),A.on("close",(y,U)=>{console.log(`[ws] closed code=${y} reason=${U?.toString()||""}`),f===A&&(f=null),!p&&setTimeout(h,2e3)}),A.on("error",y=>console.warn(`[ws] error: ${y.message}`)),A},w=h(),$=async A=>{for(;!p;){if(g===!1){k||(console.error(`[claim] HUB protocol incompatible with this SANDBOX (v${Ve}, protocol ${ht}) \u2014 not claiming jobs until versions align.`),k=!0),await new Promise(y=>setTimeout(y,5e3));continue}try{let y=await u.claim(d.signal,A);if(y.status===204)continue;if(y.status===401){console.error("[claim] 401 unauthorized \u2014 the HUB does not know this worker registration. It was removed; re-register with `codepipe up --reregister` (or `codepipe worker register --force`). exiting."),process.exitCode=1,p=!0;break}if(!y.ok){console.warn(`[claim:${A}] ${y.status} \u2014 backoff 5s`),await new Promise(j=>setTimeout(j,5e3));continue}let U=await y.json();await S(u,U)}catch(y){if(d.signal.aborted)break;let U=y instanceof Error?y.message:String(y);console.warn(`[claim:${A}] error: ${U} \u2014 backoff 5s`),await new Promise(j=>setTimeout(j,5e3))}}};async function S(A,y){let U={abort:new AbortController,paused:!1};y.role==="chat"&&(U.chatInbox=qI()),m.set(y.jobId,U);let j=!1,H=null,J=null,oe=Number(process.env.SANDBOX_HEARTBEAT_INTERVAL_MS??3e4),At=async()=>{try{await A.heartbeat(y.jobId)==="claim_lost"&&(j=!0,console.warn(`[job] ${y.jobId} claim lost \u2014 HUB sweeper took it`))}catch(N){let pe=N instanceof Error?N.message:String(N);console.warn(`[job] ${y.jobId} heartbeat error: ${pe}`)}};At();let pt=setInterval(()=>{At()},oe),Ue=new Date().toISOString();console.log(`[job] ${y.jobId} claimed \u2014 role=${y.role} task=${y.taskId} phase=${y.phase}`),console.log(`[job] ${y.jobId} prompt (${y.prompt.length} chars):`),console.log(v(y.prompt," \u2502 "));let L=[],F=null,M=400,Y=25,W=500,E=()=>{if(F&&(clearTimeout(F),F=null),L.length===0)return;let N=L.splice(0,L.length),pe=f;if(!pe||pe.readyState!==pe.OPEN)return;let Te={type:"agent_activity",jobId:y.jobId,taskId:y.taskId,projectId:y.projectId,role:y.role,phase:y.phase,events:N};try{pe.send(JSON.stringify(Te))}catch{}},I=N=>{L.push(N),L.length>W&&L.shift(),L.length>=Y?E():F||(F=setTimeout(E,M))},Q=y.role==="analysis"&&y.taskId.startsWith("draft::")?y.taskId.slice(7):null,ie=new Set,P=null;try{if(!c){j||await A.submitResult({jobId:y.jobId,status:"failed",artifacts:[],error:{message:"sandbox has no LLM backend configured"},startedAt:Ue,finishedAt:new Date().toISOString()});return}if(!Ng(o,y.provider??null)){j||await A.submitResult({jobId:y.jobId,status:"failed",artifacts:[],error:{message:`llm provider mismatch: worker backend "${o}" does not serve provider "${y.provider??"claude"}"`},startedAt:Ue,finishedAt:new Date().toISOString()});return}let N=Iy(y.jobId);console.log(`[job] ${y.jobId} workspace=${N.dir}`);let pe=T(y,r);H=pe.gitCreds,J=pe.contextGitCreds;let Te=H?.env,ft=pe.claudeOauthToken?{CLAUDE_CODE_OAUTH_TOKEN:pe.claudeOauthToken}:void 0,fe=[],ne=null,Gs=null;try{let O=y.role==="build"?"clone":"worktree";fe=await fy(N.dir,y.projectId,y.projectRepos,O,Te,n);let D=await my(N.dir,y.projectId,y.contextRepo,"worktree",Te,n);Gs=D,ne=D?.workspacePath??null}catch(O){let D=O instanceof Error?O.message:String(O);console.warn(`[job] ${y.jobId} materialize failed: ${D}`),j||await A.submitResult({jobId:y.jobId,status:"failed",artifacts:[],error:{message:`materialize failed: ${D}`},startedAt:Ue,finishedAt:new Date().toISOString()}),N.dispose();return}let Hn=y.model;y.role==="build"&&y.modelDiscovery&&!yy(ne)&&(Hn=y.modelDiscovery,console.log(`[job] ${y.jobId} BUILD discovery (no steps in ${Ll}) \u2014 model=${Hn}`));let hu=async()=>{if(!y.deliveries||y.deliveries.length===0)return[];let O=y.contextRepo?.cloneUrl;if(!O||!Te)throw new Error(O?"no git credentials in bundle":"no contextRepo cloneUrl in job spec");let D=[];for(let ee of y.deliveries){let Z=fe.find(le=>le.name===ee.name);if(Z){if(y.role==="implement"&&ee.baseSha&&ee.baseSha!==Z.baseSha){let le=await uy(Z,ee.deliveryRef,ee.deliverySha,ee.baseSha,O,Te);console.log(`[job] ${y.jobId} ${Z.name}: base moved ${ee.baseSha.slice(0,10)} \u2192 ${Z.baseSha.slice(0,10)} \u2014 re-applied delivery ${ee.deliverySha.slice(0,10)} (${le.length} conflicted file(s))`),le.length>0&&D.push(`- **${Z.name}**:`,...le.map(tt=>` - \`${tt}\``));continue}await ly(Z,ee.deliveryRef,ee.deliverySha,O,Te),console.log(`[job] ${y.jobId} ${Z.name}: checked out delivery ${ee.deliverySha.slice(0,10)} for ${y.role}`)}}return D},Ks=[];if(y.role==="build"||y.role==="implement"||y.role==="code-review")try{Ks=await hu()}catch(O){let D=O instanceof Error?O.message:String(O);console.warn(`[job] ${y.jobId} delivery checkout failed: ${D}`),j||await A.submitResult({jobId:y.jobId,status:"failed",artifacts:[],error:{message:`delivery checkout failed: ${D}`},startedAt:Ue,finishedAt:new Date().toISOString()}),N.dispose();return}let Hs=y.role==="resolve-conflict"?y.metadata?.taskBranchByRepo??{}:{},gu="";if(y.role==="resolve-conflict"){if(!fe.some(O=>Hs[O.name])){let O="resolve-conflict job carries no
|
|
874
|
+
${i}`}function qI(){let t=[],e=!1,r=null,n=i=>{if(r){let s=r;r=null,s({value:i,done:!1})}else t.push(i)},o=()=>{if(r){let i=r;r=null,i({value:void 0,done:!0})}};return{push(i){e||n(i)},finalize(){e||(n({kind:"finalize"}),e=!0)},close(){e=!0,t.length=0,o()},iterable:{[Symbol.asyncIterator](){return{next(){return t.length>0?Promise.resolve({value:t.shift(),done:!1}):e?Promise.resolve({value:void 0,done:!0}):new Promise(i=>{r=i})}}}}}}async function Go(t={}){let e=Le(t.profile);e||(console.error("sandbox not registered. run `codepipe worker register` first."),process.exit(1));let r=e.sealPrivateKey,n=e.sandboxId,o=e.llm,i=kg(t.profile,e.sandboxId,!!X("SANDBOX_CONFIG")),s=It(GI(),".codepipe","logs"),a=mi("SANDBOX_LOG",i,s);if(a.enabled){let A=new rn(a);hi(A),console.log(`[log] file logging \u2192 ${A.path} (rotate at ${a.maxBytes}B, keep ${a.maxFiles})`)}console.log(`codepipe-sandbox v${Ve} (protocol ${ht})`),console.log(`starting sandbox ${e.sandboxId} (${e.name}) \u2192 ${e.hubUrl}`);let c=jg(e.llm);console.log(`llm backend: ${c?c.name():"(none \u2014 will not claim agent jobs)"}`);let l=Dg();console.log(`llm retry: maxAttempts=${l.maxAttempts} backoff=${l.baseDelayMs}\u2013${l.maxDelayMs}ms budget=${l.totalBudgetMs}ms`);let u=new $n(e.hubUrl,e.token),p=!1,d=new AbortController,m=new Map,f=null,g=null,k=!1,h=()=>{let A=u.openControlSocket();return f=A,A.on("open",()=>{console.log("[ws] connected");let y={type:"sandbox_hello",platformVersion:Ve,protocolVersion:ht};A.send(JSON.stringify(y))}),A.on("message",y=>{let U=y.toString("utf-8"),j=null;try{let H=JSON.parse(U);H&&typeof H=="object"&&(j=H)}catch{}if(j&&j.type==="hello"){let H=j;g=Vn(H.protocolVersion);let J=g?"compatible":"INCOMPATIBLE";console.log(`[ws] hub v${H.platformVersion} (protocol ${H.protocolVersion}) \u2014 ${J}`),g&&(k=!1);return}if(j&&j.type==="pause_job"){let H=typeof j.jobId=="string"?j.jobId:"",J=H?m.get(H):void 0;J?(console.warn(`[ws] pause_job ${H} \u2014 aborting agent`),J.paused=!0,J.abort.abort()):console.log(`[ws] pause_job ${H} \u2014 not a running job, ignoring`),H&&A.send(JSON.stringify({type:"job_paused",jobId:H}));return}if(j&&(j.type==="chat_user_message"||j.type==="chat_finalize")){let H=typeof j.jobId=="string"?j.jobId:"",J=H?m.get(H):void 0;if(J?.chatInbox)if(j.type==="chat_user_message"){let oe=typeof j.text=="string"?j.text:"";oe.trim()&&J.chatInbox.push({kind:"user",text:oe})}else J.chatInbox.finalize();else console.log(`[ws] ${String(j.type)} ${H} \u2014 not a live chat job, ignoring`);return}console.log(`[ws] ${U}`)}),A.on("close",(y,U)=>{console.log(`[ws] closed code=${y} reason=${U?.toString()||""}`),f===A&&(f=null),!p&&setTimeout(h,2e3)}),A.on("error",y=>console.warn(`[ws] error: ${y.message}`)),A},w=h(),$=async A=>{for(;!p;){if(g===!1){k||(console.error(`[claim] HUB protocol incompatible with this SANDBOX (v${Ve}, protocol ${ht}) \u2014 not claiming jobs until versions align.`),k=!0),await new Promise(y=>setTimeout(y,5e3));continue}try{let y=await u.claim(d.signal,A);if(y.status===204)continue;if(y.status===401){console.error("[claim] 401 unauthorized \u2014 the HUB does not know this worker registration. It was removed; re-register with `codepipe up --reregister` (or `codepipe worker register --force`). exiting."),process.exitCode=1,p=!0;break}if(!y.ok){console.warn(`[claim:${A}] ${y.status} \u2014 backoff 5s`),await new Promise(j=>setTimeout(j,5e3));continue}let U=await y.json();await S(u,U)}catch(y){if(d.signal.aborted)break;let U=y instanceof Error?y.message:String(y);console.warn(`[claim:${A}] error: ${U} \u2014 backoff 5s`),await new Promise(j=>setTimeout(j,5e3))}}};async function S(A,y){let U={abort:new AbortController,paused:!1};y.role==="chat"&&(U.chatInbox=qI()),m.set(y.jobId,U);let j=!1,H=null,J=null,oe=Number(process.env.SANDBOX_HEARTBEAT_INTERVAL_MS??3e4),At=async()=>{try{await A.heartbeat(y.jobId)==="claim_lost"&&(j=!0,console.warn(`[job] ${y.jobId} claim lost \u2014 HUB sweeper took it`))}catch(N){let pe=N instanceof Error?N.message:String(N);console.warn(`[job] ${y.jobId} heartbeat error: ${pe}`)}};At();let pt=setInterval(()=>{At()},oe),Ue=new Date().toISOString();console.log(`[job] ${y.jobId} claimed \u2014 role=${y.role} task=${y.taskId} phase=${y.phase}`),console.log(`[job] ${y.jobId} prompt (${y.prompt.length} chars):`),console.log(v(y.prompt," \u2502 "));let L=[],F=null,M=400,Y=25,W=500,E=()=>{if(F&&(clearTimeout(F),F=null),L.length===0)return;let N=L.splice(0,L.length),pe=f;if(!pe||pe.readyState!==pe.OPEN)return;let Te={type:"agent_activity",jobId:y.jobId,taskId:y.taskId,projectId:y.projectId,role:y.role,phase:y.phase,events:N};try{pe.send(JSON.stringify(Te))}catch{}},I=N=>{L.push(N),L.length>W&&L.shift(),L.length>=Y?E():F||(F=setTimeout(E,M))},Q=y.role==="analysis"&&y.taskId.startsWith("draft::")?y.taskId.slice(7):null,ie=new Set,P=null;try{if(!c){j||await A.submitResult({jobId:y.jobId,status:"failed",artifacts:[],error:{message:"sandbox has no LLM backend configured"},startedAt:Ue,finishedAt:new Date().toISOString()});return}if(!Ng(o,y.provider??null)){j||await A.submitResult({jobId:y.jobId,status:"failed",artifacts:[],error:{message:`llm provider mismatch: worker backend "${o}" does not serve provider "${y.provider??"claude"}"`},startedAt:Ue,finishedAt:new Date().toISOString()});return}let N=Iy(y.jobId);console.log(`[job] ${y.jobId} workspace=${N.dir}`);let pe=T(y,r);H=pe.gitCreds,J=pe.contextGitCreds;let Te=H?.env,ft=pe.claudeOauthToken?{CLAUDE_CODE_OAUTH_TOKEN:pe.claudeOauthToken}:void 0,fe=[],ne=null,Gs=null;try{let O=y.role==="build"?"clone":"worktree";fe=await fy(N.dir,y.projectId,y.projectRepos,O,Te,n);let D=await my(N.dir,y.projectId,y.contextRepo,"worktree",Te,n);Gs=D,ne=D?.workspacePath??null}catch(O){let D=O instanceof Error?O.message:String(O);console.warn(`[job] ${y.jobId} materialize failed: ${D}`),j||await A.submitResult({jobId:y.jobId,status:"failed",artifacts:[],error:{message:`materialize failed: ${D}`},startedAt:Ue,finishedAt:new Date().toISOString()}),N.dispose();return}let Hn=y.model;y.role==="build"&&y.modelDiscovery&&!yy(ne)&&(Hn=y.modelDiscovery,console.log(`[job] ${y.jobId} BUILD discovery (no steps in ${Ll}) \u2014 model=${Hn}`));let hu=async()=>{if(!y.deliveries||y.deliveries.length===0)return[];let O=y.contextRepo?.cloneUrl;if(!O||!Te)throw new Error(O?"no git credentials in bundle":"no contextRepo cloneUrl in job spec");let D=[];for(let ee of y.deliveries){let Z=fe.find(le=>le.name===ee.name);if(Z){if(y.role==="implement"&&ee.baseSha&&ee.baseSha!==Z.baseSha){let le=await uy(Z,ee.deliveryRef,ee.deliverySha,ee.baseSha,O,Te);console.log(`[job] ${y.jobId} ${Z.name}: base moved ${ee.baseSha.slice(0,10)} \u2192 ${Z.baseSha.slice(0,10)} \u2014 re-applied delivery ${ee.deliverySha.slice(0,10)} (${le.length} conflicted file(s))`),le.length>0&&D.push(`- **${Z.name}**:`,...le.map(tt=>` - \`${tt}\``));continue}await ly(Z,ee.deliveryRef,ee.deliverySha,O,Te),console.log(`[job] ${y.jobId} ${Z.name}: checked out delivery ${ee.deliverySha.slice(0,10)} for ${y.role}`)}}return D},Ks=[];if(y.role==="build"||y.role==="implement"||y.role==="code-review")try{Ks=await hu()}catch(O){let D=O instanceof Error?O.message:String(O);console.warn(`[job] ${y.jobId} delivery checkout failed: ${D}`),j||await A.submitResult({jobId:y.jobId,status:"failed",artifacts:[],error:{message:`delivery checkout failed: ${D}`},startedAt:Ue,finishedAt:new Date().toISOString()}),N.dispose();return}let Hs=y.role==="resolve-conflict"?y.metadata?.mergeBranchByRepo??y.metadata?.taskBranchByRepo??{}:{},gu="";if(y.role==="resolve-conflict"){if(!fe.some(O=>Hs[O.name])){let O="resolve-conflict job carries no branch to merge for any repo \u2014 nothing to resolve. The task branch could not be identified on the hub (the apply step may have failed before recording it); make sure the task branch exists upstream, then retry the update.";console.warn(`[job] ${y.jobId} ${O}`),j||await A.submitResult({jobId:y.jobId,status:"failed",artifacts:[],error:{message:O},startedAt:Ue,finishedAt:new Date().toISOString()}),N.dispose();return}try{let O=[];for(let D of fe){let ee=Hs[D.name];if(!ee)continue;let Z=await Ol(D,ee,Te);console.log(`[job] ${y.jobId} ${D.name}: merged ${ee} into ${D.ref} \u2014 ${Z.length} conflicted file(s)`),Z.length>0?O.push(`- **${D.name}**:`,...Z.map(le=>` - \`${le}\``)):O.push(`- **${D.name}**: merged cleanly (no markers \u2014 verify it still builds)`)}gu=`
|
|
875
875
|
|
|
876
876
|
## Conflicts to resolve
|
|
877
877
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-partner/codepipe",
|
|
3
|
-
"version": "0.13.1-dev.
|
|
3
|
+
"version": "0.13.1-dev.265.g11b4c39",
|
|
4
4
|
"description": "CodePipe turns tasks into reviewed pull requests: an AI agent analyzes, implements, and opens a PR under your control.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|