werkmeister 0.44.3 → 0.44.4

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/mcp.js CHANGED
@@ -815,7 +815,7 @@ These hold for every PR this workspace produces, whatever skill or command was a
815
815
  2. **PRs come only from code worktrees** \u2014 one per repo touched at a time, from that repo's PR file (below).
816
816
  3. **Gate.** Before a PR opens, all of these hold: every earlier stage/phase is done; the PR file's acceptance table is all PASS; the code worktree is clean; each touched service's registry test command passes (\`.werkmeister/werkmeister-context.md\`); the exercise evidence is all PASS (or \`skip_exercise\` gives the reason); the repo's release check passes; the PR file reads \`status: approved\`.
817
817
  4. **Only \`werkmeister pr open\` opens PRs.** \`gh pr create\`, \`/create-pr\` and \`finishing-a-development-branch\` are blocked inside a workspace.
818
- 5. **Auto-fix is always on.** Right after \`werkmeister pr open\`, in the Claude desktop app: bind the PR to this session (\`ccd_pr\` \`get_status\`; \`bind_pr\` with the PR's URL if it isn't bound), then turn on Auto-fix with \`ccd_pr\` \`set_monitor\` (\`auto_fix: true\`, \`address_comments: true\`, the PR's \`url\`). Don't ask first. Never turn on auto-merge.
818
+ 5. **Auto-fix is always on.** \`werkmeister pr open\` prints a \`<pr-created>\` line with each PR's URL; the Claude desktop app counts the session as the PR's opener from it. Right after, in the desktop app: bind the PR to this session (\`ccd_pr\` \`get_status\`; \`bind_pr\` with the PR's URL if it isn't bound), then turn on Auto-fix with \`ccd_pr\` \`set_monitor\` (\`auto_fix: true\`, \`address_comments: true\`, the PR's \`url\`). Don't ask first. If \`set_monitor\` is refused, don't retry: ask the person to turn Auto-fix on from the PR bar, and don't rely on \`get_status\` to confirm it. Never turn on auto-merge.
819
819
  6. **Merge is the person's act.** Tooling never merges. Squash is the default. A PR whose commit SHAs must survive (e.g. a commit listed in \`.git-blame-ignore-revs\`) says "Merge with a merge commit" at the top of its body, and the person merges it that way; squash and rebase both rewrite SHAs.
820
820
  7. **Close out only when every PR file is \`shipped\`, \`closed\` or \`abandoned\`, and after the post-mortem:** the werkmeister \`postmortem\` skill writes \`postmortem.md\` at the workspace root. \`werkmeister close-out\` refuses without it unless \`--skip-postmortem "<reason>"\`.
821
821
 
@@ -1035,7 +1035,7 @@ ${(W.stdout+W.stderr).trimEnd().split(`
1035
1035
  `).slice(-5).join(`
1036
1036
  `)}`:""}`)}}return a("approved",Bt(t)==="approved",`status: ${Bt(t)}`),{ok:o.every(H=>H.ok),checks:o}}s(pqe,"gateChecks");function tse(e,t){return[`${e}: gate ${t.ok?"passed":"FAILED"}`,...t.checks.map(r=>` ${r.ok?"\u2713":"\u2717"} ${r.name}: ${r.detail.replace(/\n/g,`
1037
1037
  `)}`)]}s(tse,"formatGate");async function Cz(e,t,r=tf()){let i=ro(e),n=rse(e,i,t,c=>!dqe(c,i)),o=[],a=!0;for(let c of n){let l=await jz(e,c,r);a&&=l.ok,o.push(...tse(c.stem,l))}return{ok:a,lines:o}}s(Cz,"gatePrs");function dqe(e,t){return ef.has(Bt(e))&&t.some(r=>r!==e&&r.dir===e.dir&&!ef.has(Bt(r)))}s(dqe,"superseded");function rse(e,t,r,i){let n=t.filter(i);if(r&&(n=t.filter(o=>o.stem===r||o.dir===r),n.length>1&&(n=n.filter(i))),!n.length){let o=Pz(e)??"this workspace (no stage holds PR files)",a=`format: ${pY(e)}`;throw new de(r?`No PR file for ${r} in ${o} (${a}).`:`No matching PR file in ${o}. Write pr-<worktree>[-<slug>].md there (${a}) and have the person set status: approved.`)}return n}s(rse,"selectFiles");async function Nz(e,t,r=tf()){let i=ro(e),n=rse(e,i,t,l=>Bt(l)==="approved"),o=[],a=!0,c=[];for(let l of n){let u=String(l.fm.branch??""),p=i.find(x=>x!==l&&x.dir===l.dir&&String(x.fm.branch??"")===u&&["merged","shipped","closed"].includes(Bt(x)));if(p){a=!1,o.push(`${l.stem}: branch ${u} was already used by ${p.stem} (${Bt(p)}) \u2014 cut a new one with \`werkmeister pr new ${l.dir} --slug <slug>\``);continue}let d=await jz(e,l,r);if(!d.ok){a=!1,o.push(...tse(l.stem,d));continue}let m=xe.join(e,l.dir),h=await r.run("git",["-C",m,"push","-u","origin",u]);if(h.code!==0){a=!1,o.push(`${l.stem}: push failed \u2014 ${h.stderr.trim()}`);continue}let g=await r.run("gh",["pr","list","--repo",l.fm.repo,"--head",u,"--state","open","--json","url","--jq",".[0].url // empty"],m),v=g.code===0?g.stdout.trim():"";if(!v){let x=xe.join(Oe.mkdtempSync(xe.join(Xoe.tmpdir(),"werkmeister-pr-")),"body.md");Oe.writeFileSync(x,l.body);let $=await r.run("gh",["pr","create","--repo",l.fm.repo,"--base",String(l.fm.base??"main"),"--head",u,"--title",l.title,"--body-file",x],m);if(Oe.rmSync(xe.dirname(x),{recursive:!0,force:!0}),v=$.stdout.trim().split(`
1038
- `).pop()??"",$.code!==0||!v.startsWith("http")){a=!1,o.push(`${l.stem}: gh pr create failed \u2014 ${$.stderr.trim()||$.stdout.trim()}`);continue}}vc(l,{status:"open",url:v,...await r.session(e)}),c.push(xe.relative(e,l.path)),o.push(`${l.stem}: open ${v}`);let y=await r.run("git",["-C",m,"diff",`origin/${String(l.fm.base??"main")}...HEAD`,"--",".git-blame-ignore-revs"]);/^\+[0-9a-f]{7,40}\b/m.test(y.stdout)&&o.push(" warning: this branch adds a SHA to .git-blame-ignore-revs \u2014 merge with a merge commit, not squash or rebase, and say so at the top of the PR body");let _=Qr(e,null),k=Ds(_);if(k){let x=i.some(C=>C!==l&&C.dir===l.dir),{tracker:$,statuses:E}=Az(_,k,r),O=await Av($,k,"in_review",E,{comment:`${x?"Follow-up PR":"PR"} opened: ${v}`,...x?{alwaysComment:!0}:{}});O&&o.push(` issue ${O}`)}}return c.length&&o.push((await r.commitRecord(e,"chore: record opened PR(s)",c)).message),a&&c.length&&o.push(await r.stop(e)),{ok:a,lines:o}}s(Nz,"openPrs");async function W$(e,t=tf(),r={}){let i=[],n=[],o={shipped:[],merged:[],closed:[],changesRequested:[],reReview:[]};for(let c of ro(e)){let l=Bt(c),u=c.fm.review;if(r.gh!==!1&&l==="open"&&c.fm.url){let d=await t.run("gh",["pr","view",String(c.fm.url),"--json","state,mergeCommit,reviewDecision,latestReviews"]);if(d.code!==0){i.push(`${c.stem}: gh pr view failed \u2014 ${d.stderr.trim()}`);continue}let m=JSON.parse(d.stdout),h=m.reviewDecision==="CHANGES_REQUESTED"||(m.latestReviews??[]).some(v=>v.state==="CHANGES_REQUESTED"),g=String(c.fm.url);m.state==="MERGED"?(vc(c,{status:"merged",merge_sha:m.mergeCommit?.oid??""}),o.merged.push(g)):m.state==="CLOSED"?(vc(c,{status:"closed",reason:Qd(c.fm.reason)||"closed on GitHub"}),o.closed.push(g)):h?u!=="changes_requested"&&(vc(c,{review:"changes_requested"}),o.changesRequested.push(g)):u==="changes_requested"&&(vc(c,{review:void 0}),o.reReview.push(g))}if(Bt(c)==="merged"){let d=t.repos[c.dir]??{};if(d.ship!=="tag")vc(c,{status:"shipped"});else{let m=xe.join(e,c.dir);await t.run("git",["-C",m,"fetch","-q","--tags","origin"]);let h=await t.run("git",["-C",m,"tag","--contains",String(c.fm.merge_sha),"--list",String(d.release_tag),"--sort=creatordate"]),g=h.code===0?h.stdout.split(`
1038
+ `).pop()??"",$.code!==0||!v.startsWith("http")){a=!1,o.push(`${l.stem}: gh pr create failed \u2014 ${$.stderr.trim()||$.stdout.trim()}`);continue}}vc(l,{status:"open",url:v,...await r.session(e)}),c.push(xe.relative(e,l.path)),o.push(`${l.stem}: open ${v}`),o.push(`<pr-created>${v}</pr-created>`);let y=await r.run("git",["-C",m,"diff",`origin/${String(l.fm.base??"main")}...HEAD`,"--",".git-blame-ignore-revs"]);/^\+[0-9a-f]{7,40}\b/m.test(y.stdout)&&o.push(" warning: this branch adds a SHA to .git-blame-ignore-revs \u2014 merge with a merge commit, not squash or rebase, and say so at the top of the PR body");let _=Qr(e,null),k=Ds(_);if(k){let x=i.some(C=>C!==l&&C.dir===l.dir),{tracker:$,statuses:E}=Az(_,k,r),O=await Av($,k,"in_review",E,{comment:`${x?"Follow-up PR":"PR"} opened: ${v}`,...x?{alwaysComment:!0}:{}});O&&o.push(` issue ${O}`)}}return c.length&&o.push((await r.commitRecord(e,"chore: record opened PR(s)",c)).message),a&&c.length&&o.push(await r.stop(e)),{ok:a,lines:o}}s(Nz,"openPrs");async function W$(e,t=tf(),r={}){let i=[],n=[],o={shipped:[],merged:[],closed:[],changesRequested:[],reReview:[]};for(let c of ro(e)){let l=Bt(c),u=c.fm.review;if(r.gh!==!1&&l==="open"&&c.fm.url){let d=await t.run("gh",["pr","view",String(c.fm.url),"--json","state,mergeCommit,reviewDecision,latestReviews"]);if(d.code!==0){i.push(`${c.stem}: gh pr view failed \u2014 ${d.stderr.trim()}`);continue}let m=JSON.parse(d.stdout),h=m.reviewDecision==="CHANGES_REQUESTED"||(m.latestReviews??[]).some(v=>v.state==="CHANGES_REQUESTED"),g=String(c.fm.url);m.state==="MERGED"?(vc(c,{status:"merged",merge_sha:m.mergeCommit?.oid??""}),o.merged.push(g)):m.state==="CLOSED"?(vc(c,{status:"closed",reason:Qd(c.fm.reason)||"closed on GitHub"}),o.closed.push(g)):h?u!=="changes_requested"&&(vc(c,{review:"changes_requested"}),o.changesRequested.push(g)):u==="changes_requested"&&(vc(c,{review:void 0}),o.reReview.push(g))}if(Bt(c)==="merged"){let d=t.repos[c.dir]??{};if(d.ship!=="tag")vc(c,{status:"shipped"});else{let m=xe.join(e,c.dir);await t.run("git",["-C",m,"fetch","-q","--tags","origin"]);let h=await t.run("git",["-C",m,"tag","--contains",String(c.fm.merge_sha),"--list",String(d.release_tag),"--sort=creatordate"]),g=h.code===0?h.stdout.split(`
1039
1039
  `).map(v=>v.trim()).find(Boolean):void 0;g&&vc(c,{status:"shipped",release:g})}}let p=Bt(c);p==="shipped"&&l!=="shipped"&&o.shipped.push(c),(p!==l||c.fm.review!==u)&&n.push(xe.relative(e,c.path)),i.push(`${c.stem}: ${p}${c.fm.release?` (${c.fm.release})`:""}${c.fm.url?` ${c.fm.url}`:""}`)}let a=await fqe(e,o,t);return a&&i.push(`issue ${a}`),(o.merged.length||o.shipped.length)&&i.push(await t.stop(e)),n.length&&i.push((await t.commitRecord(e,"chore: record PR status",n)).message),{lines:i,changed:n.length>0}}s(W$,"refreshPrStatus");var nse=s(e=>`Shipped: ${e.map(t=>`${t.fm.release??"merge"} \u2014 ${t.fm.url}`).join("; ")||"no PRs"}`,"shippedComment");async function fqe(e,t,r){let n=Object.values(t).some(d=>d.length)?Qr(e,null):null,o=Ds(n);if(!o)return"";let a=ro(e),c=rf(e).state,{tracker:l,statuses:u}=Az(n,o,r),p=s((d,m,h=!1)=>Av(l,o,d,u,{comment:m,back:h}),"move");return t.shipped.length&&c==="shipped"?p("done",nse(a.filter(d=>Bt(d)==="shipped"))):t.merged.length&&a.every(d=>ef.has(Bt(d)))?p("merged",`Merged: ${t.merged.join(", ")}`):t.changesRequested.length?p("in_progress",`Changes requested: ${t.changesRequested.join(", ")}`,!0):t.closed.length&&!a.some(d=>Bt(d)==="open")?p("in_progress",`PR closed without merging: ${t.closed.join(", ")}`,!0):t.reReview.length?p("in_review",`Back in review: ${t.reReview.join(", ")}`):""}s(fqe,"moveIssueForPrs");var mqe=15*6e4;async function hqe(e,t){let r=t.CLAUDE_CODE_SESSION_ID||(await Cv(xe.basename(e)).catch(()=>null))?.sessionId;if(!r)return{};let i=t.CLAUDE_CODE_HOST_SESSION_ID,n=await use(r);return{session:r,...i&&{host_session:i},...n&&{session_cwd:n}}}s(hqe,"callbackFields");function ise(e){for(let t=0;t<2;t++)try{return Oe.closeSync(Oe.openSync(e,"wx")),!0}catch(r){if(r.code!=="EEXIST")throw r;try{if(Date.now()-Oe.statSync(e).mtimeMs<mqe)return!1;Oe.rmSync(e,{force:!0})}catch{}}return!1}s(ise,"takeLock");async function ose(e,t,r=xe.join(Mr(),"pr-callbacks.lock")){let i=e.filter(o=>{try{return ro(o).some(a=>Bt(a)==="merged")}catch{return!1}});if(!i.length)return[];if(Oe.mkdirSync(xe.dirname(r),{recursive:!0}),!ise(r))return["another PR watch pass is running"];let n=[];try{let o=t??tf();for(let a of i)for(let c of(await W$(a,o,{gh:!1})).lines)n.push(`${xe.basename(a)}/${c}`)}finally{Oe.rmSync(r,{force:!0})}return n}s(ose,"shipMerged");function rf(e){let t=[];try{t=ro(e)}catch{}let r=t.map(o=>({dir:o.dir,stem:o.stem,status:Bt(o),url:o.fm.url?String(o.fm.url):null,release:o.fm.release?String(o.fm.release):null})),i=s(o=>r.every(a=>o.has(a.status)),"all"),n;return Oe.existsSync(xe.join(e,"closeout.md"))?n="closed-out":r.length?i(new Set(["abandoned"]))?n="abandoned":i(ese)?n="shipped":i(ef)?n="merged":r.some(o=>o.status==="open")?n="pr-open":i(new Set(["approved"]))?n="ready":n="working":n="working",{state:n,prs:r}}s(rf,"lifecycleOf");async function sse(e,t,r=Z$){if(Oe.existsSync(xe.join(e,"closeout.md")))return[];let i=ro(e),n=[];for(let{repo:o,dir:a}of t){let c=i.filter(m=>m.dir===o),l=c.find(m=>Bt(m)==="open");if(l){n.push(`${o}: PR is open (${l.fm.url})`);continue}if(c.length&&c.every(m=>ef.has(Bt(m))))continue;let u=c.find(m=>!ef.has(Bt(m))),p=u?.fm.base?`origin/${u.fm.base}`:await ase(a,r),d=await Lz(a,p,r)??0;d>0&&n.push(`${o}: ${d} commit(s) not on ${p} and no merged PR`)}return n}s(sse,"removalBlockers");async function ase(e,t){let r=await t("git",["-C",e,"rev-parse","--abbrev-ref","origin/HEAD"]);return r.code===0&&r.stdout.trim()?r.stdout.trim():"origin/main"}s(ase,"originBase");async function Lz(e,t,r=Z$){let i=await r("git",["-C",e,"rev-list","--count",`${t??await ase(e,r)}..HEAD`]);return i.code===0?Number(i.stdout.trim()):null}s(Lz,"commitsAhead");function cse(e,t,r){let i=s(n=>n?String(n).replace(/\|/g,"\\|"):"\u2014","cell");return["# Close-out","",`Date: ${new Date().toISOString().slice(0,10)}`,`Issue: ${t}`,...r?[r]:[],"","| repo | PR | status | merge_sha | release | reason |","|---|---|---|---|---|---|",...e.map(n=>`| ${i(n.fm.repo??n.dir)} | ${i(n.fm.url)} | ${Bt(n)} | ${i(n.fm.merge_sha)} | ${i(n.fm.release)} | ${i(n.fm.reason)} |`),""].join(`
1040
1040
  `)}s(cse,"renderCloseout");function Dz(e,t){let r=ro(e);for(let i of r)ese.has(Bt(i))||vc(i,{status:"abandoned",reason:t});Oe.writeFileSync(xe.join(e,"closeout.md"),cse(r,"not closed (abandoned)",`Abandoned: ${t}`))}s(Dz,"abandonWorkspace");async function gqe(e,t=Z$){let r=await t("ps",["-axo","pid=,tty=,comm="]);if(r.code!==0)return[];let i=new Map;for(let c of r.stdout.split(`
1041
1041
  `)){let l=/^\s*(\d+)\s+(\S+)\s+(.+?)\s*$/.exec(c);l&&xe.basename(l[3])==="claude"&&l[2]!=="??"&&l[2]!=="?"&&i.set(l[1],l[2])}if(!i.size)return[];let n=await t("lsof",["-a","-d","cwd","-Fpn","-p",[...i.keys()].join(",")]),o=[],a="";for(let c of n.stdout.split(`
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "werkmeister",
3
- "version": "0.44.3",
3
+ "version": "0.44.4",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Multi-feature concurrent development orchestrator CLI tool",
6
6
  "type": "module",
@@ -53,7 +53,7 @@
53
53
  "typescript": "^5.7.0",
54
54
  "vitest": "^3.0.0",
55
55
  "yaml": "^2.7.0",
56
- "werkmeister-core": "0.44.3"
56
+ "werkmeister-core": "0.44.4"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "node esbuild.mjs",