@code-partner/codepipe 0.14.1-dev.406.g8dba0f6e → 0.14.1-dev.407.g6df0fcfe
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 +3 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var IT=Object.defineProperty;var v=(t,e)=>()=>(t&&(e=t(t=0)),e);var me=(t,e)=>{for(var r in e)IT(t,r,{get:e[r],enumerable:!0})};var ye,_t,ou=v(()=>{"use strict";ye="0.14.1-dev.
|
|
2
|
+
var IT=Object.defineProperty;var v=(t,e)=>()=>(t&&(e=t(t=0)),e);var me=(t,e)=>{for(var r in e)IT(t,r,{get:e[r],enumerable:!0})};var ye,_t,ou=v(()=>{"use strict";ye="0.14.1-dev.407.g6df0fcfe",_t="https://hub.dev.codepipe.dev"});function Ei(t){return typeof t!="number"||!Number.isFinite(t)?!1:t>=Qh&&t<=Pt}var Pt,Qh,eg=v(()=>{"use strict";ou();Pt=4,Qh=4});var tg=v(()=>{"use strict";ou()});var iu,rg=v(()=>{"use strict";iu="local-owner@localhost"});function Ii(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 au(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 cu(t,e=su){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 lu(t,e=su){return e.filter(r=>r.version>t)}var ng,Yt,lo,su,og=v(()=>{"use strict";ng=6,Yt=".codepipe-context.yaml",lo=".devpipe-context.yaml",su=[{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",Yt]},{version:2,summary:"Rename the format-version stamp .devpipe-context.yaml \u2192 .codepipe-context.yaml (drop the devpipe-brand leftover)",addedPaths:[Yt]},{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 Ti(t){return`model/facts/identity/${t}.yaml`}function In(t){return`model/facts/events/${t}.yaml`}function pu(t){return`model/facts/annotations/${t}.md`}function fu(t){return`model/derived/correlates/${t}.yaml`}function mu(t){return`model/derived/touched/${t}.yaml`}function ig(t){return t===""?"root":t.replace(/\//g,"-")}function hu(t,e){return`model/derived/structure/${t}/${ig(e)}.yaml`}function ia(t){return typeof t=="string"&&ag.test(t)}function se(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(!sg.includes(n))return null;let o=t.slice(e+1,r),i=t.slice(r+1);return o===""&&!_T.includes(n)||i===""?null:{level:n,repo:o,path:i}}function Fe(t){return`task::${t}`}function Oe(t,e,r){return`${t}:${e}:${r}`}function Ci(t){let e=[];return ar(t)?(aa(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(!ar(r)){e.push(`edges[${n}]: not an object`);return}gu.includes(r.kind)||e.push(`edges[${n}].kind: unknown "${String(r.kind)}"`),se(r.from)||e.push(`edges[${n}].from: malformed nodeKey`),se(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 cg(t){return{...t,edges:uo(t.edges,e=>`${e.kind} ${e.from} ${e.to}`)}}function Rn(t){return Tn(cg(t))}function ar(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function aa(t){return typeof t=="number"&&Number.isInteger(t)&&t>0}function zt(t){return typeof t=="string"&&t.length>0}function jT(t){return t.modelFormatVersion!==2}function $r(t){let e=[];if(!ar(t))return{ok:!1,errors:["shard: not an object"]};aa(t.modelFormatVersion)||e.push("modelFormatVersion: missing or not a positive integer"),zt(t.repo)||e.push("repo: missing or empty"),zt(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(!ar(o)){e.push(`nodes[${i}]: not an object`);return}let s=se(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&&!ia(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(!ar(o)){e.push(`edges[${i}]: not an object`);return}gu.includes(o.kind)||e.push(`edges[${i}].kind: unknown "${String(o.kind)}"`),(!zt(o.to)||!se(o.to))&&e.push(`edges[${i}].to: malformed nodeKey`),(!zt(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 Ai(t){let e=[];if(!ar(t))return{ok:!1,errors:["identity: not an object"]};if(aa(t.modelFormatVersion)||e.push("modelFormatVersion: missing or not a positive integer"),zt(t.repo)||e.push("repo: missing or empty"),t.builtFromCommit!==void 0&&!zt(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(!ar(n)){e.push(`entities[${o}]: not an object`);return}ia(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)})`),se(n.currentKey)||e.push(`entities[${o}].currentKey: malformed nodeKey`),n.status!=="active"&&n.status!=="orphaned"&&e.push(`entities[${o}].status: expected active|orphaned`),zt(n.firstSeen)||e.push(`entities[${o}].firstSeen: missing`),zt(n.lastSeen)||e.push(`entities[${o}].lastSeen: missing`),n.aliases!==void 0&&(Array.isArray(n.aliases)?n.aliases.forEach((i,s)=>{(!ar(i)||!se(i.key)||!zt(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 Sr(t){let e=[];return ar(t)?(aa(t.modelFormatVersion)||e.push("modelFormatVersion: missing or not a positive integer"),zt(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=>!zt(r)))&&e.push("commits: not an array of non-empty strings"),Array.isArray(t.files)?t.files.forEach((r,n)=>{if(!ar(r)||!se(r.key)){e.push(`files[${n}].key: malformed nodeKey`);return}r.entityId!==void 0&&!ia(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 uo(t,e){return[...t].sort((r,n)=>e(r)<e(n)?-1:e(r)>e(n)?1:0)}function lg(t){return{...t,nodes:uo(t.nodes,e=>e.key),edges:uo(t.edges,e=>`${e.kind}\0${e.from}\0${e.to}`)}}function ug(t){return{...t,entities:uo(t.entities,e=>e.entityId).map(e=>e.aliases?{...e,aliases:uo(e.aliases,r=>`${r.key}\0${r.until}`)}:e)}}function dg(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:uo(t.files,r=>r.key),...e?{links:e}:{}}}function Ri(t){return NT.test(t)?t:JSON.stringify(t)}function pg(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 fg(t){return t===null||["boolean","number","string"].includes(typeof t)}function uu(t){return Object.entries(t).filter(([,e])=>e!==void 0).sort(([e],[r])=>e<r?-1:e>r?1:0)}function mg(t,e,r){if(Array.isArray(t)){for(let n of t)if(fg(n))r.push(`${e}- ${pg(n)}`);else{if(Array.isArray(n))throw new Error("model yaml: nested arrays are not part of the model schema");{let o=uu(n);if(o.length===0){r.push(`${e}- {}`);continue}o.forEach(([i,s],a)=>{let c=a===0?`${e}- `:`${e} `;du(i,s,c,`${e} `,r)})}}return}for(let[n,o]of uu(t))du(n,o,e,e,r)}function du(t,e,r,n,o){if(fg(e))o.push(`${r}${Ri(t)}: ${pg(e)}`);else if(Array.isArray(e))e.length===0?o.push(`${r}${Ri(t)}: []`):(o.push(`${r}${Ri(t)}:`),mg(e,`${n} `,o));else{let i=uu(e);if(i.length===0)o.push(`${r}${Ri(t)}: {}`);else{o.push(`${r}${Ri(t)}:`);for(let[s,a]of i)du(s,a,`${n} `,`${n} `,o)}}}function Tn(t){let e=[];return mg(t,"",e),e.join(`
|
|
@@ -20,7 +20,7 @@ ${a.trim()}`.trim();continue}a.trim()||(i=null)}let s=[...r.entries()].filter(([
|
|
|
20
20
|
`)){let i=UC.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}
|
|
21
21
|
${o.trim()}`.trim())}let n={};for(let o of e)n[o.id]=o;return{items:e,byId:n}}function FC(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 MC,UC,cy=v(()=>{"use strict";MC=["done","deviated","partial","dropped"],UC=/^\s*[-*]\s+(?:\*\*)?\[([A-Z][0-9]+)\](?:\*\*)?\s*[—:-]?\s*(done|deviated|partial|dropped)\b\s*[—:-]?\s*(.*)$/i});var ly=v(()=>{"use strict"});var uy=v(()=>{"use strict"});var dy=v(()=>{"use strict"});function hd(t){return`codepipe-host-${t}`}function GC(t){let e=t.filter(r=>r!=="self-hosted");return`runs-on: [self-hosted${e.length?", "+e.join(", "):""}]`}var py=v(()=>{"use strict"});function Ui(t){return ur(t)!==null}function ur(t){let e=(t??"").trim();if(!e)return null;if(e.startsWith("file://")){let r=e.slice(7);return r.startsWith("/")?r:null}return/^[a-z][a-z0-9+.-]*:\/\//i.test(e)||/^[^/\\]+@[^/\\]+:/.test(e)?null:e.startsWith("/")||e.startsWith("~")||e.startsWith(".")?e:null}var fy=v(()=>{"use strict"});function gd(){return{source:{kind:"local_snapshot"},delivery:{target:"working_repo",done:"branch"},publication:{push:"off",pullRequest:"off",merge:"off"}}}function yd(){return{source:{kind:"upstream"},delivery:{target:"managed_clone",done:"merged"},publication:{push:"auto",pullRequest:"auto",merge:"manual"}}}function wd(t){return t.delivery.target==="remote_branch"}function wo(t,e,r,n,o){return t==null?r:typeof t=="string"&&e.includes(t)?t:(o.push(`${n}: unknown value ${JSON.stringify(t)} \u2014 using ${JSON.stringify(r)}`),r)}function my(t){let e=t.pull_request!==!1,r=t.done!=="branch",n=t.auto_merge==="on_ci_green";return{source:{kind:"upstream"},delivery:{target:"managed_clone",done:r?"merged":"published"},publication:{push:"auto",pullRequest:e?"auto":"off",merge:e?n?"on_ci_green":"manual":r?"auto":"off"}}}function ba(t,e){let r=t[e];return r&&typeof r=="object"&&!Array.isArray(r)?r:null}function bd(t,e={}){let r=[],n=ba(t,"source"),o=ba(t,"delivery"),i=ba(t,"publication"),s=ba(t,"apply");if(n||o||i){let a=s?my(s):e.localFirstDefault?gd():yd(),c={source:{kind:wo(n?.kind,["local_snapshot","upstream","mirror"],a.source.kind,"source.kind",r)},delivery:{target:wo(o?.target,["working_repo","managed_clone","mirror","remote_branch"],a.delivery.target,"delivery.target",r),done:wo(o?.done,["branch","published","merged"],a.delivery.done,"delivery.done",r)},publication:{push:wo(i?.push,["off","manual","auto"],a.publication.push,"publication.push",r),pullRequest:wo(i?.pull_request,["off","manual","auto"],a.publication.pullRequest,"publication.pull_request",r),merge:wo(i?.merge,["off","manual","auto","on_ci_green"],a.publication.merge,"publication.merge",r)}};return c.publication.pullRequest!=="off"&&c.publication.push==="off"&&!wd(c)&&(r.push("publication.pull_request requires publication.push \u2014 disabling the PR step"),c.publication.pullRequest="off"),c.publication.merge!=="off"&&c.publication.pullRequest==="off"&&c.publication.push==="off"&&!wd(c)&&(r.push("publication.merge requires a published branch (push, a PR, or remote_branch delivery) \u2014 disabling the merge step"),c.publication.merge="off"),{config:c,legacy:!1,errors:r}}return s?{config:my(s),legacy:!0,errors:r}:{config:e.localFirstDefault?gd():yd(),legacy:!1,errors:r}}var hy=v(()=>{"use strict"});function HC(t,e){if(!e.clientCliMaterializer)return e.remoteGitWriter?{ok:!0,plan:{target:"remote_branch",transport:"remote_git",done:t.delivery.done==="merged"?"merged":"published",publication:t.publication,forcedRemoteDelivery:!0}}:{ok:!1,error:"NO_REACHABLE_DELIVERY_TARGET",reason:"no trusted materializer is registered: neither a client CLI nor a remote git writer"};switch(t.delivery.target){case"working_repo":return e.workingRepoReachable?{ok:!0,plan:{target:"working_repo",transport:"context_repo",done:t.delivery.done,publication:t.publication,forcedRemoteDelivery:!1}}:{ok:!1,error:"NO_REACHABLE_DELIVERY_TARGET",reason:"delivery.target is working_repo, but the working repository is not reachable from the trusted materializer (farm-hosted CLI)"};case"remote_branch":return e.remoteGitWriter?{ok:!0,plan:{target:"remote_branch",transport:"remote_git",done:t.delivery.done,publication:t.publication,forcedRemoteDelivery:!1}}:{ok:!1,error:"NO_REACHABLE_DELIVERY_TARGET",reason:"delivery.target is remote_branch, but no trusted writer can reach the git host"};case"managed_clone":case"mirror":return{ok:!0,plan:{target:t.delivery.target,transport:"context_repo",done:t.delivery.done,publication:t.publication,forcedRemoteDelivery:!1}}}}function KC(t){return t.target==="remote_branch"}var gy=v(()=>{"use strict"});function VC(t,e){if(e.startsWith("-"))return!1;switch(t){case"local_relay":return e.startsWith("/");case"context_repo":return e.startsWith("/")||e.startsWith("https://")||e.startsWith("ssh://")||/^[A-Za-z0-9._-]+@[A-Za-z0-9._-]+:/.test(e);case"remote_git":return e==="";default:return!1}}function bo(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.sha=="string"&&WC.test(e.sha)&&(e.transport==="local_relay"||e.transport==="context_repo"||e.transport==="remote_git")&&typeof e.source=="string"&&typeof e.ref=="string"&&e.ref.startsWith("refs/")&&St(e.ref.slice(5))&&VC(e.transport,e.source)}function qC(t){if(!t)return null;try{let e=JSON.parse(t);return bo(e)?e:null}catch{return null}}function YC(t){return{sha:t.deliverySha,transport:"context_repo",source:t.contextRepoCloneUrl,ref:t.deliveryRef.startsWith("refs/")?t.deliveryRef:`refs/heads/${t.deliveryRef}`}}function zC(t){return{sha:t.headSha,transport:"local_relay",source:t.relayPath,ref:t.ref}}function JC(t,e){return{sha:e,transport:"remote_git",source:"",ref:`refs/heads/${t}`}}var WC,yy=v(()=>{"use strict";ha();WC=/^[0-9a-f]{40}$/});function kd(t,e,r=Date.now()){return!Number.isFinite(t.expiresAt)||!(r<t.expiresAt)?{ok:!1,reason:"lease expired"}:t.projectId!==e.projectId?{ok:!1,reason:"lease is for another project"}:t.repoNames.includes(e.repoName)?t.branch!==e.branch?{ok:!1,reason:"branch outside the lease"}:t.revisionSha!==e.revision.sha?{ok:!1,reason:"revision outside the lease"}:{ok:!0}:{ok:!1,reason:"repo outside the lease"}}var wy=v(()=>{"use strict"});function XC(t,e,r=72){let n=(t||by).replace(/\{key\}/g,e.key).replace(/\{summary\}/g,e.summary).replace(/\s+/g," ").trim(),o=Number.isFinite(r)&&r>0?Math.floor(r):72;if(n.length<=o)return n;let i=n.slice(0,o),s=i.lastIndexOf(" ");return s>=Math.floor(o/2)?i.slice(0,s).trimEnd():i.trimEnd()}var by,_H,ky=v(()=>{"use strict";by="{key}: {summary}",_H=72});function ZC(t,e){return`${t}:${e}`}var vy=v(()=>{"use strict"});function xy(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 QC(t){for(let e=t.length-1;e>=0;e--){let r=t[e];if(r.to==="NEEDS_MANUAL")return r}return null}function eA(t,e){if(t==="AWAITING_ANSWER")return{kind:"question"};if(t==="NEEDS_MANUAL"){let n=QC(e)?.reason,o={kind:xy(n)};return n&&(o.reason=n),o}}var $y=v(()=>{"use strict"});function jn(t){for(let e of Sy){let r=t.match(e.pattern);if(r)return{name:e.name,args:(r[1]??"").trim()}}return null}var Sy,Ey=v(()=>{"use strict";Sy=[{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 Iy=v(()=>{"use strict"});function Ry(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 tA(t,e=Date.now()){return`${Ry((e-t)/1e3)} ago`}function rA(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 Ty=v(()=>{"use strict"});var Cy=v(()=>{"use strict"});function Ay(t){return t.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/^[^A-Z]+/,"").slice(0,10)}function xd(t){let e=t.split(/[^A-Za-z0-9]+/).filter(Boolean),r=Ay(e.length>=2?e.map(o=>o[0]).join(""):(e[0]??"").slice(0,4));if(Nn.test(r))return r;let n=Ay(t);return Nn.test(n)?n:ka}function $d(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 vo(t){return`tasks/${t}/issue.yaml`}var vd,Bi,ka,Nn,va,nA,Fi,ko,_y=v(()=>{"use strict";vd=["bug","feature","epic"],Bi="feature",ka="TASK",Nn=/^[A-Z][A-Z0-9]{1,9}$/;va={backlog:"Backlog",source:["To Do"],inProgress:"In Progress",review:"Review",done:["Done"],rejected:["Rejected"],statusColumns:["Backlog","To Do","In Progress","Review","Done","Rejected"]},nA=va.backlog,Fi="tracker/config.yaml",ko="tracker/counter"});function Gi(t){let e=t.split(`
|
|
22
22
|
`),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(`
|
|
23
|
-
`).trim();if(!(!i||i==="_(no description)_"))return i}function oA(t){return`{{ancestorExcerpt:${t}}}`}var xa,Py=v(()=>{"use strict";xa=/\{\{ancestorExcerpt:([^}]+)\}\}/g});var iA,jy=v(()=>{"use strict";iA="youtrack"});function On(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 Hi(t){switch(t){case xo.gitlab:return"oauth2";case xo.bitbucket:return"x-token-auth";default:return"x-access-token"}}var xo,Rr,Ny=v(()=>{"use strict";xo={github:"github.com",gitlab:"gitlab.com",bitbucket:"bitbucket.org"};Rr="x-bitbucket-api-token-auth"});var Oy=v(()=>{"use strict"});function Sd(t,e){return e?e.harness!==t.harness?{ok:!1,reason:`lease is for ${e.harness}, this worker runs ${t.harness}`}:t.authFlows.includes(e.authFlow)?{ok:!0}:{ok:!1,reason:`${t.harness} does not accept ${e.authFlow} credentials`}:t.authFlows.includes("machine_login")?{ok:!0}:{ok:!1,reason:`${t.harness}: no account lease for a harness that requires one`}}function Ki(t){let{runner:e,capabilities:r}=t;return{id:()=>r.harness,capabilities:()=>r,checkAvailability:t.checkAvailability??(async()=>({available:!0})),async execute(n,o,i){return i.aborted?{artifactPaths:[],log:"",usage:je(),errorCategory:"cancelled"}:await e.run(n.input)}}}var Ly=v(()=>{"use strict";Pi()});function sA(t){return"event"in t}function aA(t){let e=t.toLowerCase();return e===""||e==="success"?{failed:!1}:e.includes("max_turns")?{failed:!0,category:"vendor_error"}:e.includes("rate")||e.includes("429")?{failed:!0,category:"rate_limit"}:e.includes("timeout")?{failed:!0,category:"timeout"}:e.includes("auth")||e.includes("401")?{failed:!0,category:"auth"}:e.includes("cancel")||e.includes("abort")?{failed:!0,category:"cancelled"}:e.includes("error")?{failed:!0,category:"vendor_error"}:{failed:!1}}function Ed(t,e={}){let r=new Date(t.ts).toISOString();switch(t.kind){case"start":return{type:"started",at:r};case"tool":{let n=t.tool??"";return t.file&&Dy.has(n)?{type:"file_read",path:t.file,at:r}:t.file&&My.has(n)?{type:"file_changed",path:t.file,at:r}:{type:"command_started",commandClass:n||"unknown",at:r}}case"tool_result":{let n=e.lastTool??"";return Dy.has(n)||My.has(n)?null:{type:"command_finished",exitCode:t.isError?1:0,at:r}}case"result":{let n=aA(t.text??"");return n.failed?{type:"failed",category:n.category,at:r,...t.text?{detail:t.text}:{}}:{type:"completed",at:r}}case"system":case"text":return null}}function Id(t,e=new Date().toISOString()){return{type:"usage",usage:t,at:e}}function $a(t,e,r=new Date().toISOString()){return{type:"failed",category:t,at:r,...e?{detail:e}:{}}}function Rd(t){return t.map(e=>JSON.stringify(e)).join(`
|
|
23
|
+
`).trim();if(!(!i||i==="_(no description)_"))return i}function oA(t){return`{{ancestorExcerpt:${t}}}`}var xa,Py=v(()=>{"use strict";xa=/\{\{ancestorExcerpt:([^}]+)\}\}/g});var iA,jy=v(()=>{"use strict";iA="youtrack"});function On(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 Hi(t){switch(t){case xo.gitlab:return"oauth2";case xo.bitbucket:return"x-token-auth";default:return"x-access-token"}}var xo,Rr,Ny=v(()=>{"use strict";xo={github:"github.com",gitlab:"gitlab.com",bitbucket:"bitbucket.org"};Rr="x-bitbucket-api-token-auth"});var Oy=v(()=>{"use strict"});function Sd(t,e){return e?e.harness!==t.harness?{ok:!1,reason:`lease is for ${e.harness}, this worker runs ${t.harness}`}:t.authFlows.includes(e.authFlow)?{ok:!0}:{ok:!1,reason:`${t.harness} does not accept ${e.authFlow} credentials`}:t.authFlows.includes("machine_login")?{ok:!0}:{ok:!1,reason:`${t.harness}: no account lease for a harness that requires one`}}function Ki(t){let{runner:e,capabilities:r}=t;return{id:()=>r.harness,capabilities:()=>r,checkAvailability:t.checkAvailability??(async()=>({available:!0})),async execute(n,o,i){return i.aborted?{artifactPaths:[],log:"",usage:je(),errorCategory:"cancelled"}:await e.run(n.input)}}}var Ly=v(()=>{"use strict";Pi()});function sA(t){return"event"in t}function aA(t){let e=t.toLowerCase();return e===""||e==="success"?{failed:!1}:e.includes("max_turns")?{failed:!0,category:"vendor_error"}:e.includes("rate")||e.includes("429")?{failed:!0,category:"rate_limit"}:e.includes("timeout")?{failed:!0,category:"timeout"}:e.includes("auth")||e.includes("401")?{failed:!0,category:"auth"}:e.includes("cancel")||e.includes("abort")?{failed:!0,category:"cancelled"}:e.includes("error")?{failed:!0,category:"vendor_error"}:{failed:!1}}function Ed(t,e={}){let r=new Date(t.ts).toISOString();switch(t.kind){case"start":return{type:"started",at:r};case"tool":{let n=t.tool??"";return t.file&&Dy.has(n)?{type:"file_read",path:t.file,at:r}:t.file&&My.has(n)?{type:"file_changed",path:t.file,at:r}:{type:"command_started",commandClass:n||"unknown",at:r}}case"tool_result":{let n=e.lastTool??"";return Dy.has(n)||My.has(n)?null:{type:"command_finished",exitCode:t.isError?1:0,at:r}}case"result":{let n=t.isError?{failed:!0,category:"vendor_error"}:aA(t.text??"");return n.failed?{type:"failed",category:n.category,at:r,...t.text?{detail:t.text}:{}}:{type:"completed",at:r}}case"system":case"text":return null}}function Id(t,e=new Date().toISOString()){return{type:"usage",usage:t,at:e}}function $a(t,e,r=new Date().toISOString()){return{type:"failed",category:t,at:r,...e?{detail:e}:{}}}function Rd(t){return t.map(e=>JSON.stringify(e)).join(`
|
|
24
24
|
`)+(t.length>0?`
|
|
25
25
|
`:"")}function cA(t){let e=[];for(let r of t.split(`
|
|
26
26
|
`)){let n=r.trim();if(n!=="")try{e.push(JSON.parse(n))}catch{}}return e}var Dy,My,Uy=v(()=>{"use strict";Dy=new Set(["Read","NotebookRead","Glob","Grep"]),My=new Set(["Write","Edit","MultiEdit","NotebookEdit"])});var By=v(()=>{"use strict";jy();Ny();Oy();Ly();Uy()});function lA(t){let e=(t??"").trim();return e?Ln.find(n=>Td[n]===e)??null:null}function Ad(t,e,r={}){let n=[],o=r.defaultHarness&&Ln.includes(r.defaultHarness)?r.defaultHarness:$o.harness,i=t?.roles?.[e],s=t?.default,a=d=>i?.[d]!==void 0?{value:i[d],where:`routing.${e}.${String(d)}`}:{value:s?.[d],where:`routing.default.${String(d)}`},{value:c,where:l}=a("harness"),u=o;c!==void 0&&(Ln.includes(c)?u=c:n.push(`${l}: unknown harness ${JSON.stringify(c)} \u2014 using ${o}`));let p=(d,f)=>{let{value:m,where:y}=a(d);return m===void 0?f:typeof m=="string"&&m.trim()!==""?m.trim():(n.push(`${y}: expected a non-empty string \u2014 using ${JSON.stringify(f)}`),f)};return{harness:u,endpoint:p("endpoint",Cd[u]??$o.endpoint),account:p("account",$o.account),model:p("model",""),errors:n}}function Sa(t,e={}){if(t==null)return{config:null,errors:[]};if(typeof t!="object"||Array.isArray(t))return{config:null,errors:["routing: expected a mapping of role \u2192 axes"]};let r=[],n=t,o=n.roles,i=o&&typeof o=="object"&&!Array.isArray(o)?{...n.default!==void 0?{default:n.default}:{},...n.fallback!==void 0?{fallback:n.fallback}:{},...o}:n,s=(p,d)=>{if(p==null)return;if(typeof p!="object"||Array.isArray(p)){r.push(`${d}: expected a mapping of axis \u2192 value`);return}let f=p,m={};for(let y of["harness","model","endpoint","account"]){let w=f[y];if(w!=null){if(typeof w!="string"||w.trim()===""){r.push(`${d}.${y}: expected a non-empty string`);continue}if(y==="harness"){let b=w.trim();if(!Ln.includes(b)){r.push(`${d}.harness: unknown harness ${JSON.stringify(w)} (known: ${Ln.join(", ")})`);continue}m.harness=b}else m[y]=w.trim()}}if(Object.keys(m).length===0){r.push(`${d}: no routing axis recognized (expected harness/model/endpoint/account)`);return}return m},a={},c=s(i.default,"routing.default");c&&(a.default=c);let l=i.fallback;if(l!=null){let p=s(l,"routing.fallback");p?.harness?a.fallback={...p,harness:p.harness}:p&&r.push("routing.fallback: expected a `harness` value")}let u={};for(let[p,d]of Object.entries(i)){if(p==="default"||p==="fallback")continue;if(e.knownRoles&&!e.knownRoles.includes(p)){r.push(`routing.${p}: unknown role (known: ${e.knownRoles.join(", ")})`);continue}let f=s(d,`routing.${p}`);f&&(u[p]=f)}return Object.keys(u).length>0&&(a.roles=u),{config:a.default||a.roles||a.fallback?a:null,errors:r}}function uA(t){if(!t)return null;try{let e=JSON.parse(t);return typeof e?.harness=="string"&&typeof e?.jobId=="string"?e:null}catch{return null}}function dA(t,e,r,n){if(r!=="infrastructure")return null;let o=t?.fallback?.harness;return!o||o===e||o===n?null:Ln.includes(o)?o:null}function pA(t,e,r){return{...t,harness:e,model:r?.model??"",endpoint:r?.endpoint??Cd[e]??$o.endpoint,account:r?.account??$o.account,requiredCapabilities:t.requiredCapabilities.filter(n=>!n.startsWith("harness:")&&!n.startsWith("provider:")).concat([`harness:${e}`,`provider:${Td[e]??e}`]),attempt:(t.attempt??1)+1,previousHarness:t.harness}}var JH,$o,Ln,Td,Cd,Fy=v(()=>{"use strict";JH=1,$o={harness:"claude-code",model:"",endpoint:"anthropic-managed",account:"project-default"},Ln=["claude-code","codex","mock"],Td={"claude-code":"claude",codex:"codex","kimi-code":"kimi",mock:"mock"},Cd={"claude-code":"anthropic-managed",codex:"openai-managed","kimi-code":"kimi-managed",mock:"none"}});function _d(){return{constraints:[],conventions:[]}}function Wi(t){return t.constraints.length===0&&t.conventions.length===0}function Pd(t){let e=[];if(t==null)return{canon:_d(),errors:e};if(typeof t!="object"||Array.isArray(t))return{canon:_d(),errors:["instructions: expected a mapping"]};let r=t,n=(o,i)=>{if(o==null)return[];if(!Array.isArray(o))return e.push(`${i}: expected a list of rules`),[];let s=[],a=new Set;for(let[c,l]of o.entries()){if(!l||typeof l!="object"||Array.isArray(l)){e.push(`${i}[${c}]: expected a mapping with id and text`);continue}let u=l,p=typeof u.id=="string"?u.id.trim():"",d=typeof u.text=="string"?u.text.trim():"";if(p===""||d===""){e.push(`${i}[${c}]: both id and text are required`);continue}if(a.has(p)){e.push(`${i}[${c}]: duplicate id ${JSON.stringify(p)}`);continue}a.add(p);let f=u.enforcement,m;if(typeof f=="string"&&f.trim()!==""){let y=f.trim();Gy.includes(y)?m=y:e.push(`${i}[${c}].enforcement: unknown value ${JSON.stringify(f)} (known: ${Gy.join(", ")})`)}s.push({id:p,text:d,...m?{enforcement:m}:{}})}return s};return{canon:{constraints:n(r.constraints,"instructions.constraints"),conventions:n(r.conventions,"instructions.conventions")},errors:e}}function Nd(t){return t.includes(jd)}function Od(t,e,r={}){let n=[jd,`# Project instructions${r.projectName?` \u2014 ${r.projectName}`:""}`,"","GENERATED FILE \u2014 do not edit. The canon lives in the Context Repo","(`instructions.yaml`); this projection is rewritten on every job.",""];if(t.constraints.length>0){n.push("## Constraints","");for(let o of t.constraints)n.push(`- **${o.id}**: ${o.text}${Hy(o.enforcement)}`);n.push("")}if(t.conventions.length>0){n.push("## Conventions","");for(let o of t.conventions)n.push(`- **${o.id}**: ${o.text}${Hy(o.enforcement)}`);n.push("")}return Wi(t)&&n.push("_No canonical instructions are defined for this project yet._",""),n.push(`_Projection target: ${e}._`,""),n.join(`
|
|
@@ -926,7 +926,7 @@ ${o.slice(-20).join(`
|
|
|
926
926
|
`)}`);return{artifactPaths:[],log:o.join(`
|
|
927
927
|
`),usage:i??je()}}async runChat(e,r){let n=null,o=[],i=je(),s=mr(e.metadata),a=new AbortController,c=()=>a.abort();e.signal?.addEventListener("abort",c,{once:!0});let l=null,u=!1,p=()=>{l&&clearTimeout(l),l=setTimeout(()=>{u=!0,console.warn(`[codex:chat] idle for ${Jo}ms \u2014 ending session`),a.abort()},Jo),l.unref?.()};p();let d=()=>{try{e.onUsage?.({inputTokens:i.inputTokens,outputTokens:i.outputTokens,cacheReadTokens:i.cacheReadInputTokens,cacheCreationTokens:i.cacheCreationInputTokens,turns:i.numTurns,...i.model?{model:i.model}:{},at:Date.now()})}catch{}},f=async m=>{let y=await this.runTurn({...e,signal:a.signal,...e.onUsage?{onUsage:void 0}:{}},m,{chat:!0,onThreadId:w=>{n=w},onActivity:p});o.push(y.log),i=PO(i,y.usage),d(),p()};try{await f(this.execArgs(e,e.prompt,r));let m=async(w,b)=>{if(n===null)throw new sl("codex: the session reported no thread id, so the conversation cannot continue \u2014 this build of codex may not support `exec resume`");if(b)try{e.onActivity?.({ts:Date.now(),kind:"text",author:"user",text:w.slice(0,Rs)})}catch{}let k=nl(s);await f(this.resumeArgs(e,n,k?`${k}
|
|
928
928
|
|
|
929
|
-
${w}`:w))},y=e.interactive.inbox[Symbol.asyncIterator]();for(;!a.signal.aborted;){let w=new Promise(x=>{let g=setInterval(()=>{a.signal.aborted&&(clearInterval(g),x("idle"))},1e3);g.unref?.()}),b=await Promise.race([y.next(),w]);if(b==="idle"||b.done)break;let k=b.value;if(k.kind==="finalize"){await m(Qf,!1);break}if(k.text.trim()!=="")try{await m(k.text,!0)}catch(x){if(a.signal.aborted||x instanceof sl)throw x;let g=x instanceof Error?x.message:String(x);o.push(`[turn failed] ${g}`);try{e.onActivity?.({ts:Date.now(),kind:"result",text:`turn failed: ${g}`.slice(0,200)})}catch{}}}}finally{l&&clearTimeout(l),e.signal?.removeEventListener("abort",c)}if(u&&!e.signal?.aborted)throw new Error(`chat session ended: idle for ${Jo}ms without a reply`);return{artifactPaths:[],log:o.join(`
|
|
929
|
+
${w}`:w))},y=e.interactive.inbox[Symbol.asyncIterator]();for(;!a.signal.aborted;){let w=new Promise(x=>{let g=setInterval(()=>{a.signal.aborted&&(clearInterval(g),x("idle"))},1e3);g.unref?.()}),b=await Promise.race([y.next(),w]);if(b==="idle"||b.done)break;let k=b.value;if(k.kind==="finalize"){await m(Qf,!1);break}if(k.text.trim()!=="")try{await m(k.text,!0)}catch(x){if(a.signal.aborted||x instanceof sl)throw x;let g=x instanceof Error?x.message:String(x);o.push(`[turn failed] ${g}`);try{e.onActivity?.({ts:Date.now(),kind:"result",isError:!0,text:`turn failed: ${g}`.slice(0,200)})}catch{}}}}finally{l&&clearTimeout(l),e.signal?.removeEventListener("abort",c)}if(u&&!e.signal?.aborted)throw new Error(`chat session ended: idle for ${Jo}ms without a reply`);return{artifactPaths:[],log:o.join(`
|
|
930
930
|
`),usage:i}}},sl=class extends Error{}});import{mkdirSync as NO,writeFileSync as Zo}from"node:fs";import{dirname as OO,join as Qo}from"node:path";function T$(t,e,r){let n=Qo(t,e);NO(OO(n),{recursive:!0}),Zo(n,r)}function LO(t,e,r){return`# ${t} \u2014 Estimate
|
|
931
931
|
|
|
932
932
|
**Title:** ${e}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-partner/codepipe",
|
|
3
|
-
"version": "0.14.1-dev.
|
|
3
|
+
"version": "0.14.1-dev.407.g6df0fcfe",
|
|
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",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@types/ws": "^8.5.13",
|
|
30
30
|
"esbuild": "^0.21.5",
|
|
31
31
|
"vitest": "2.1.9",
|
|
32
|
-
"@codepipe/
|
|
33
|
-
"@codepipe/
|
|
32
|
+
"@codepipe/shared": "0.0.0",
|
|
33
|
+
"@codepipe/sandbox": "0.1.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsc -p tsconfig.json && chmod +x dist/index.js",
|