@code-partner/codepipe 0.5.4-dev.165.g6b64326 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Df=Object.defineProperty;var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var Lf=(t,e)=>{for(var r in e)Df(t,r,{get:e[r],enumerable:!0})};var Te,We,Xo=S(()=>{"use strict";Te="0.
|
|
2
|
+
var Df=Object.defineProperty;var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var Lf=(t,e)=>{for(var r in e)Df(t,r,{get:e[r],enumerable:!0})};var Te,We,Xo=S(()=>{"use strict";Te="0.6.0",We="https://hub.codepipe.dev"});function _n(t){return typeof t!="number"||!Number.isFinite(t)?!1:t>=Uf&&t<=qe}var qe,Uf,Us=S(()=>{"use strict";Xo();qe=4,Uf=4});var Bs=S(()=>{"use strict";Xo()});function Nn(t=3){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 Gs(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 Fs(t,e=Ms){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 Hs(t,e=Ms){return e.filter(r=>r.version>t)}var Ye,Gr,Ms,Ks=S(()=>{"use strict";Ye=".codepipe-context.yaml",Gr=".devpipe-context.yaml",Ms=[{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",Ye]},{version:2,summary:"Rename the format-version stamp .devpipe-context.yaml \u2192 .codepipe-context.yaml (drop the devpipe-brand leftover)",addedPaths:[Ye]},{version:3,summary:"Custom project actions (the RUN tab): actions/ scaffold with the format README",addedPaths:["actions/README.md"]}]});var Ws=S(()=>{"use strict"});var Bf,k$,qs=S(()=>{"use strict";Bf=[{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"]}],k$=Bf.flatMap(t=>t.phases)});function _t(){return{inputTokens:0,outputTokens:0,cacheReadInputTokens:0,cacheCreationInputTokens:0,totalCostUsd:0,model:"",numTurns:0,durationMs:0}}var Ys,Qo=S(()=>{"use strict";Ys=["estimate","analyze","implement","resolve-conflict","rework","draft","build","code-review","index","backfill","analysis","chat"]});function Vs(t,e){return e.toLowerCase().includes(t.toLowerCase())}function Xs(t){let e=t.filter(o=>o&&typeof o.id=="string"&&o.id.trim().length>0);if(e.length===0||Gf.every(o=>e.some(i=>Vs(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 Mf){let i=n.find(s=>Vs(o,s.id));if(i)return i.id}return n[0].id}var Ve,Js,Le,Fr,zs,Zo,ei,Mf,Gf,ti=S(()=>{"use strict";Ve="claude",Js=[Ve],Le="opus",Fr="sonnet",zs="haiku",Zo=[Le,Fr,zs],ei={analyze:Le,implement:Le,"resolve-conflict":Le,rework:Le,estimate:Fr,build:Fr,"code-review":Le,draft:Fr,index:Le,backfill:Le,analysis:Le,chat:Le},Mf=[Le,Fr,zs],Gf=Array.from(new Set(Object.values(ei)))});function ft(t){return Ff.has(t)?!0:Hf.some(e=>t.startsWith(e))}function On(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Nt(t,e){if(t!=null){if(typeof t!="string")throw new Error(`${e} must be a string`);return t}}function ri(t,e){if(t!=null){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} must be a number`);return t}}function ra(t,e){let r=On(e,"action definition"),n=t.replace(/\.(yml|yaml)$/i,""),o=Nt(r.id,"id")??n;if(!Qs.test(o))throw new Error(`id must match ${Qs} (got "${o}")`);if(o!==n)throw new Error(`id "${o}" must match the file name ("${n}")`);let i=Nt(r.title,"title")?.trim()||o,s;if(r.env!==void 0&&r.env!==null){let f=On(r.env,"env");s={};for(let[u,m]of Object.entries(f)){if(!Ce.test(u))throw new Error(`env name "${u}" must match ${Ce}`);if(typeof m!="string"&&typeof m!="number"&&typeof m!="boolean")throw new Error(`env.${u} must be a scalar`);s[u]=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>Zs)throw new Error(`too many params (max ${Zs})`);let f=new Set;a=c.map((u,m)=>Kf(u,m,f))}let l=r.steps;if(!Array.isArray(l)||l.length===0)throw new Error("steps must be a non-empty list");if(l.length>ea)throw new Error(`too many steps (max ${ea})`);let d=l.map((f,u)=>{let m=On(f,`steps[${u}]`),p=Nt(m.run,`steps[${u}].run`);if(!p||p.trim().length===0)throw new Error(`steps[${u}].run is required`);let h=Nt(m.name,`steps[${u}].name`),y=ri(m.timeout_sec,`steps[${u}].timeout_sec`);if(y!==void 0&&(!Number.isInteger(y)||y<=0))throw new Error(`steps[${u}].timeout_sec must be a positive integer`);return{run:p,...h?{name:h}:{},...y!==void 0?{timeout_sec:y}:{}}});return{id:o,title:i,...s?{env:s}:{},...a?{params:a}:{},steps:d}}function Kf(t,e,r){let n=On(t,`params[${e}]`),o=Nt(n.name,`params[${e}].name`);if(!o||!Ce.test(o))throw new Error(`params[${e}].name must match ${Ce}`);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(p=>typeof p=="string"))throw new Error(`params[${e}].enum must be a non-empty string list`);s=m}let a=Nt(n.label,`params[${e}].label`),c=Nt(n.help,`params[${e}].help`),l=n.required===!0,d=ri(n.min,`params[${e}].min`),f=ri(n.max,`params[${e}].max`),u=n.default;if(u!=null&&typeof u!="string"&&typeof u!="number"&&typeof u!="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}:{},...d!==void 0?{min:d}:{},...f!==void 0?{max:f}:{},...u!=null?{default:u}:{}}}function na(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 Ce,Ff,Hf,ta,Qs,Zs,ea,ni=S(()=>{"use strict";Ce=/^[A-Z][A-Z0-9_]*$/,Ff=new Set(["GH_TOKEN","GITHUB_TOKEN","GITLAB_TOKEN"]),Hf=["BITBUCKET_","YOUTRACK_","CLAUDE_","INPUT_"];ta=600,Qs=/^[a-z0-9-]+$/,Zs=32,ea=64});function aa(t=Wf){let e=[];for(let r of t)e.push(...r.fields),r.groups&&e.push(...aa(r.groups));return e}function qf(t,e){let r=JSON.stringify(e);return aa().find(n=>n.file===t&&JSON.stringify(n.path)===r)}function ca(t){let e=qf(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>oa)return{ok:!1,error:`${e.id} must have \u2264 ${oa} entries`};let s={};for(let[a,c]of i){if(!Ce.test(a))return{ok:!1,error:`${e.id}: name "${a}" must match ${Ce}`};if(ft(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>ia)return{ok:!1,error:`${e.id}: value of "${a}" must be \u2264 ${ia} chars`};s[a]=c}return{ok:!0,field:e,value:s}}}}var oa,ia,sa,Wf,la=S(()=>{"use strict";ni();Qo();ti();oa=64,ia=2e3,sa=2e3,Wf=[{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:[...Js],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:[...Zo],help:"Overrides the recommended defaults for every role not listed below."},...Ys.map(t=>({id:`llm.models.${t}`,file:"regimen.yaml",path:["llm","models",t],type:"model",label:t,nullable:!0,suggestions:[...Zo],help:`recommended: ${ei[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:sa,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:sa,help:'e.g. "Russian, implementation details, bullet list of what was done". Empty \u21D2 the default PR body.'}]},{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:"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."}]}]});var ua=S(()=>{"use strict"});var da=S(()=>{"use strict"});var pa=S(()=>{"use strict"});var fa=S(()=>{"use strict"});function ma(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 ot(t){return`${t}${Yf}`}var Ot,Yf,ga=S(()=>{"use strict";Ot=/^[a-z][a-z0-9-]{1,30}$/,Yf="-codepipe-ctx"});var ha=S(()=>{"use strict"});var ya=S(()=>{"use strict"});function Jt(t){for(let e of Vf){let r=t.match(e.pattern);if(r)return{name:e.name,args:(r[1]??"").trim()}}return null}var Vf,wa=S(()=>{"use strict";Vf=[{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}]});var ba=S(()=>{"use strict"});var ka=S(()=>{"use strict"});var $a=S(()=>{"use strict"});function va(t){return t.toUpperCase().replace(/[^A-Z0-9]/g,"").replace(/^[^A-Z]+/,"").slice(0,10)}function Sa(t){let e=t.split(/[^A-Za-z0-9]+/).filter(Boolean),r=va(e.length>=2?e.map(o=>o[0]).join(""):(e[0]??"").slice(0,4));if(zt.test(r))return r;let n=va(t);return zt.test(n)?n:oi}function Ra(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 Kr(t){return`tasks/${t}/issue.yaml`}var xa,Dn,oi,zt,ii,N$,Ln,Hr,Ia=S(()=>{"use strict";xa=["bug","feature","epic"],Dn="feature",oi="TASK",zt=/^[A-Z][A-Z0-9]{1,9}$/;ii={backlog:"Backlog",source:["To Do"],inProgress:"In Progress",review:"Review",done:["Done"],rejected:["Rejected"],statusColumns:["Backlog","To Do","In Progress","Review","Done","Rejected"]},N$=ii.backlog,Ln="tracker/config.yaml",Hr="tracker/counter"});var Ta=S(()=>{"use strict"});function Xt(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 Un(t){switch(t){case Wr.gitlab:return"oauth2";case Wr.bitbucket:return"x-token-auth";default:return"x-access-token"}}var Wr,Dt,Ca=S(()=>{"use strict";Wr={github:"github.com",gitlab:"gitlab.com",bitbucket:"bitbucket.org"};Dt="x-bitbucket-api-token-auth"});var Pa=S(()=>{"use strict"});var Ea=S(()=>{"use strict";Ta();Ca();Pa()});var ja,W=S(()=>{"use strict";Us();Bs();Ks();Ws();qs();Qo();ti();la();ni();ua();da();pa();fa();ga();ha();ya();wa();ba();ka();$a();Ia();Ea();ja=20});function M(t){return process.env[`CODEPIPE_${t}`]??process.env[`DEVPIPE_${t}`]}var Pe=S(()=>{"use strict"});import{existsSync as Aa,renameSync as Jf}from"node:fs";function Lt(t,e,r=n=>console.error(n)){if(Aa(e)||!Aa(t))return!1;try{return Jf(t,e),r(`migrated ${t} \u2192 ${e} (DevPipe \u2192 CodePipe)`),!0}catch(n){return r(`failed to migrate ${t} \u2192 ${e}: ${n instanceof Error?n.message:String(n)} \u2014 continuing with the legacy path untouched`),!1}}var Bn=S(()=>{"use strict"});import{existsSync as Mn,readFileSync as _a,readdirSync as zf,writeFileSync as Xf}from"node:fs";import{dirname as Qf,join as mt}from"node:path";import{parse as Zf}from"yaml";function em(t=process.cwd()){let e=t;for(;;){if(Mn(mt(e,Je,"project.yaml")))return e;if(Mn(mt(e,si,"project.yaml")))return Lt(mt(e,si),mt(e,Je))&&rm(e),e;let r=Qf(e);if(r===e)return null;e=r}}function tm(t){let e=mt(t,Je);return Mn(e)?e:mt(t,si)}function rm(t){let e=mt(t,".gitignore");if(!Mn(e))return;let r=_a(e,"utf-8"),n=r.split(/\r?\n/).map(o=>{let i=o.trim();return i===".devpipe"||i===".devpipe/"||i==="/.devpipe"||i==="/.devpipe/"?o.replace(".devpipe",".codepipe"):o}).join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-partner/codepipe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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",
|