werkmeister 0.57.0 → 0.58.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/main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __sandboxCreateRequire } from "node:module";
3
3
  const require = __sandboxCreateRequire(import.meta.url);
4
- var yY=Object.create;var fm=Object.defineProperty;var wY=Object.getOwnPropertyDescriptor;var bY=Object.getOwnPropertyNames;var vY=Object.getPrototypeOf,kY=Object.prototype.hasOwnProperty;var i=(e,t)=>fm(e,"name",{value:t,configurable:!0}),se=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var R=(e,t)=>()=>(e&&(t=e(e=0)),t);var $=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ce=(e,t)=>{for(var r in t)fm(e,r,{get:t[r],enumerable:!0})},_Y=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of bY(t))!kY.call(e,s)&&s!==r&&fm(e,s,{get:()=>t[s],enumerable:!(n=wY(t,s))||n.enumerable});return e};var Re=(e,t,r)=>(r=e!=null?yY(vY(e)):{},_Y(t||!e||!e.__esModule?fm(r,"default",{value:e,enumerable:!0}):r,e));var _,h=R(()=>{_={sha:"905cfd6cc30300bc22446a4ea311904f0a6d2bb6",dirty:!1}});var _f=$(zb=>{h();var dm=class extends Error{static{i(this,"CommanderError")}constructor(t,r,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=t,this.nestedError=void 0}},Yb=class extends dm{static{i(this,"InvalidArgumentError")}constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};zb.CommanderError=dm;zb.InvalidArgumentError=Yb});var pm=$(Xb=>{h();var{InvalidArgumentError:EY}=_f(),Jb=class{static{i(this,"Argument")}constructor(t,r){switch(this.description=r||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new EY(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,n):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function $Y(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}i($Y,"humanReadableArgName");Xb.Argument=Jb;Xb.humanReadableArgName=$Y});var ev=$(Zb=>{h();var{humanReadableArgName:OY}=pm(),Qb=class{static{i(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let r=t.commands.filter(s=>!s._hidden),n=t._getHelpCommand();return n&&!n._hidden&&r.push(n),this.sortSubcommands&&r.sort((s,o)=>s.name().localeCompare(o.name())),r}compareOptions(t,r){let n=i(s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,""),"getSortKey");return n(t).localeCompare(n(r))}visibleOptions(t){let r=t.options.filter(s=>!s.hidden),n=t._getHelpOption();if(n&&!n.hidden){let s=n.short&&t._findOption(n.short),o=n.long&&t._findOption(n.long);!s&&!o?r.push(n):n.long&&!o?r.push(t.createOption(n.long,n.description)):n.short&&!s&&r.push(t.createOption(n.short,n.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let r=[];for(let n=t.parent;n;n=n.parent){let s=n.options.filter(o=>!o.hidden);r.push(...s)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(r=>{r.description=r.description||t._argsDescription[r.name()]||""}),t.registeredArguments.find(r=>r.description)?t.registeredArguments:[]}subcommandTerm(t){let r=t.registeredArguments.map(n=>OY(n)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce((n,s)=>Math.max(n,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(s)))),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce((n,s)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(s)))),0)}longestGlobalOptionTermLength(t,r){return r.visibleGlobalOptions(t).reduce((n,s)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(s)))),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce((n,s)=>Math.max(n,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(s)))),0)}commandUsage(t){let r=t._name;t._aliases[0]&&(r=r+"|"+t._aliases[0]);let n="";for(let s=t.parent;s;s=s.parent)n=s.name()+" "+n;return n+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&r.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&r.push(`env: ${t.envVar}`),r.length>0){let n=`(${r.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}argumentDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),r.length>0){let n=`(${r.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}formatItemList(t,r,n){return r.length===0?[]:[n.styleTitle(t),...r,""]}groupItems(t,r,n){let s=new Map;return t.forEach(o=>{let a=n(o);s.has(a)||s.set(a,[])}),r.forEach(o=>{let a=n(o);s.has(a)||s.set(a,[]),s.get(a).push(o)}),s}formatHelp(t,r){let n=r.padWidth(t,r),s=r.helpWidth??80;function o(d,p){return r.formatItem(d,n,p,r)}i(o,"callFormatItem");let a=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(t))}`,""],c=r.commandDescription(t);c.length>0&&(a=a.concat([r.boxWrap(r.styleCommandDescription(c),s),""]));let l=r.visibleArguments(t).map(d=>o(r.styleArgumentTerm(r.argumentTerm(d)),r.styleArgumentDescription(r.argumentDescription(d))));if(a=a.concat(this.formatItemList("Arguments:",l,r)),this.groupItems(t.options,r.visibleOptions(t),d=>d.helpGroupHeading??"Options:").forEach((d,p)=>{let m=d.map(y=>o(r.styleOptionTerm(r.optionTerm(y)),r.styleOptionDescription(r.optionDescription(y))));a=a.concat(this.formatItemList(p,m,r))}),r.showGlobalOptions){let d=r.visibleGlobalOptions(t).map(p=>o(r.styleOptionTerm(r.optionTerm(p)),r.styleOptionDescription(r.optionDescription(p))));a=a.concat(this.formatItemList("Global Options:",d,r))}return this.groupItems(t.commands,r.visibleCommands(t),d=>d.helpGroup()||"Commands:").forEach((d,p)=>{let m=d.map(y=>o(r.styleSubcommandTerm(r.subcommandTerm(y)),r.styleSubcommandDescription(r.subcommandDescription(y))));a=a.concat(this.formatItemList(p,m,r))}),a.join(`
4
+ var yY=Object.create;var fm=Object.defineProperty;var wY=Object.getOwnPropertyDescriptor;var bY=Object.getOwnPropertyNames;var vY=Object.getPrototypeOf,kY=Object.prototype.hasOwnProperty;var i=(e,t)=>fm(e,"name",{value:t,configurable:!0}),se=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var R=(e,t)=>()=>(e&&(t=e(e=0)),t);var $=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ce=(e,t)=>{for(var r in t)fm(e,r,{get:t[r],enumerable:!0})},_Y=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of bY(t))!kY.call(e,s)&&s!==r&&fm(e,s,{get:()=>t[s],enumerable:!(n=wY(t,s))||n.enumerable});return e};var Re=(e,t,r)=>(r=e!=null?yY(vY(e)):{},_Y(t||!e||!e.__esModule?fm(r,"default",{value:e,enumerable:!0}):r,e));var _,h=R(()=>{_={sha:"e387b8f028dba662e3140157eb0b7ab4b61d406d",dirty:!1}});var _f=$(zb=>{h();var dm=class extends Error{static{i(this,"CommanderError")}constructor(t,r,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=t,this.nestedError=void 0}},Yb=class extends dm{static{i(this,"InvalidArgumentError")}constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};zb.CommanderError=dm;zb.InvalidArgumentError=Yb});var pm=$(Xb=>{h();var{InvalidArgumentError:EY}=_f(),Jb=class{static{i(this,"Argument")}constructor(t,r){switch(this.description=r||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new EY(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,n):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function $Y(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}i($Y,"humanReadableArgName");Xb.Argument=Jb;Xb.humanReadableArgName=$Y});var ev=$(Zb=>{h();var{humanReadableArgName:OY}=pm(),Qb=class{static{i(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let r=t.commands.filter(s=>!s._hidden),n=t._getHelpCommand();return n&&!n._hidden&&r.push(n),this.sortSubcommands&&r.sort((s,o)=>s.name().localeCompare(o.name())),r}compareOptions(t,r){let n=i(s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,""),"getSortKey");return n(t).localeCompare(n(r))}visibleOptions(t){let r=t.options.filter(s=>!s.hidden),n=t._getHelpOption();if(n&&!n.hidden){let s=n.short&&t._findOption(n.short),o=n.long&&t._findOption(n.long);!s&&!o?r.push(n):n.long&&!o?r.push(t.createOption(n.long,n.description)):n.short&&!s&&r.push(t.createOption(n.short,n.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let r=[];for(let n=t.parent;n;n=n.parent){let s=n.options.filter(o=>!o.hidden);r.push(...s)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(r=>{r.description=r.description||t._argsDescription[r.name()]||""}),t.registeredArguments.find(r=>r.description)?t.registeredArguments:[]}subcommandTerm(t){let r=t.registeredArguments.map(n=>OY(n)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce((n,s)=>Math.max(n,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(s)))),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce((n,s)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(s)))),0)}longestGlobalOptionTermLength(t,r){return r.visibleGlobalOptions(t).reduce((n,s)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(s)))),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce((n,s)=>Math.max(n,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(s)))),0)}commandUsage(t){let r=t._name;t._aliases[0]&&(r=r+"|"+t._aliases[0]);let n="";for(let s=t.parent;s;s=s.parent)n=s.name()+" "+n;return n+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&r.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&r.push(`env: ${t.envVar}`),r.length>0){let n=`(${r.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}argumentDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),r.length>0){let n=`(${r.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}formatItemList(t,r,n){return r.length===0?[]:[n.styleTitle(t),...r,""]}groupItems(t,r,n){let s=new Map;return t.forEach(o=>{let a=n(o);s.has(a)||s.set(a,[])}),r.forEach(o=>{let a=n(o);s.has(a)||s.set(a,[]),s.get(a).push(o)}),s}formatHelp(t,r){let n=r.padWidth(t,r),s=r.helpWidth??80;function o(d,p){return r.formatItem(d,n,p,r)}i(o,"callFormatItem");let a=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(t))}`,""],c=r.commandDescription(t);c.length>0&&(a=a.concat([r.boxWrap(r.styleCommandDescription(c),s),""]));let l=r.visibleArguments(t).map(d=>o(r.styleArgumentTerm(r.argumentTerm(d)),r.styleArgumentDescription(r.argumentDescription(d))));if(a=a.concat(this.formatItemList("Arguments:",l,r)),this.groupItems(t.options,r.visibleOptions(t),d=>d.helpGroupHeading??"Options:").forEach((d,p)=>{let m=d.map(y=>o(r.styleOptionTerm(r.optionTerm(y)),r.styleOptionDescription(r.optionDescription(y))));a=a.concat(this.formatItemList(p,m,r))}),r.showGlobalOptions){let d=r.visibleGlobalOptions(t).map(p=>o(r.styleOptionTerm(r.optionTerm(p)),r.styleOptionDescription(r.optionDescription(p))));a=a.concat(this.formatItemList("Global Options:",d,r))}return this.groupItems(t.commands,r.visibleCommands(t),d=>d.helpGroup()||"Commands:").forEach((d,p)=>{let m=d.map(y=>o(r.styleSubcommandTerm(r.subcommandTerm(y)),r.styleSubcommandDescription(r.subcommandDescription(y))));a=a.concat(this.formatItemList(p,m,r))}),a.join(`
5
5
  `)}displayWidth(t){return bA(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r==="[command]"?this.styleSubcommandText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleCommandText(r)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleSubcommandText(r)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,r){return Math.max(r.longestOptionTermLength(t,r),r.longestGlobalOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,r,n,s){let a=" ".repeat(2);if(!n)return a+t;let c=t.padEnd(r+t.length-s.displayWidth(t)),l=2,f=(this.helpWidth??80)-r-l-2,d;return f<this.minWidthToWrap||s.preformatted(n)?d=n:d=s.boxWrap(n,f).replace(/\n/g,`
6
6
  `+" ".repeat(r+l)),a+c+" ".repeat(l)+d.replace(/\n/g,`
7
7
  ${a}`)}boxWrap(t,r){if(r<this.minWidthToWrap)return t;let n=t.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,o=[];return n.forEach(a=>{let c=a.match(s);if(c===null){o.push("");return}let l=[c.shift()],u=this.displayWidth(l[0]);c.forEach(f=>{let d=this.displayWidth(f);if(u+d<=r){l.push(f),u+=d;return}o.push(l.join(""));let p=f.trimStart();l=[p],u=this.displayWidth(p)}),o.push(l.join(""))}),o.join(`
@@ -853,7 +853,7 @@ else {`),this._emit("cb()")),this._emitLine("}")},"compileIf"),r.compileIfAsync=
853
853
  `:"");let a=o&&!o.endsWith(`
854
854
  `)?`
855
855
  `:"";ps.writeFileSync(s,o+a+(o?`
856
- `:"")+n),yF(e)}function S1(e,t,r){let n=new Set,s=(e??"").split(",").map(c=>c.trim()).filter(c=>c);for(let c of s)n.add(c);let o=(t??"").split(",").map(c=>c.trim()).filter(c=>c),a=[];for(let c of o){let l=r[c],u=typeof l=="object"&&l!==null&&!Array.isArray(l)?l.repo:null;u?n.add(u):a.push(c)}return[[...n].sort(),o,a]}function Cfe(e){H(["git","-C",e,"fetch","origin","--prune","--quiet"],{capture:!0});let t=i(()=>{let n=H(["git","-C",e,"symbolic-ref","--quiet","refs/remotes/origin/HEAD"],{capture:!0}),s=n.stdout.trim(),o="refs/remotes/";return n.status===0&&s.startsWith(o)?s.slice(o.length):null},"originHead"),r=t();if(r||(H(["git","-C",e,"remote","set-head","origin","--auto"],{capture:!0}),r=t(),r))return r;for(let n of["origin/main","origin/master"])if(H(["git","-C",e,"rev-parse","--verify","--quiet",n],{capture:!0}).status===0)return n;throw new Error(`Could not determine default branch for ${e}`)}function E1(e,t,r,{force:n=!1}={}){let s=xp.basename(e),o=H(["git","-C",e,"rev-parse","--verify","--quiet",`refs/heads/${r}`],{capture:!0}),a;if(o.status===0)O(` ${s}: worktree \u2192 ${r} (existing branch)`),a=["git","-C",e,"worktree","add",t,r];else{let l=Cfe(e),u=`origin/${r}`,f=H(["git","-C",e,"rev-parse","--verify","--quiet",u],{capture:!0});if(f.status===0&&n){let d=H(["git","-C",e,"push","origin","--delete",r],{capture:!0});if(d.status!==0)throw new Error(`${s}: could not delete ${u}: ${d.stderr.trim()}`);O(` ${s}: deleted ${u} (--force)`)}else if(f.status===0){let d=H(["git","-C",e,"log","-1","--format=%cs %s",u],{capture:!0}).stdout.trim();throw new Error(`${s}: branch '${r}' already exists on origin (last commit: ${d}), left by an earlier workspace of the same name.
856
+ `:"")+n),yF(e)}function S1(e,t,r){let n=new Set,s=(e??"").split(",").map(c=>c.trim()).filter(c=>c);for(let c of s)n.add(c);let o=(t??"").split(",").map(c=>c.trim()).filter(c=>c),a=[];for(let c of o){let l=r[c],u=typeof l=="object"&&l!==null&&!Array.isArray(l)?l:{};u.repo?n.add(u.repo):(typeof u.image!="string"||!u.image)&&a.push(c)}return[[...n].sort(),o,a]}function Cfe(e){H(["git","-C",e,"fetch","origin","--prune","--quiet"],{capture:!0});let t=i(()=>{let n=H(["git","-C",e,"symbolic-ref","--quiet","refs/remotes/origin/HEAD"],{capture:!0}),s=n.stdout.trim(),o="refs/remotes/";return n.status===0&&s.startsWith(o)?s.slice(o.length):null},"originHead"),r=t();if(r||(H(["git","-C",e,"remote","set-head","origin","--auto"],{capture:!0}),r=t(),r))return r;for(let n of["origin/main","origin/master"])if(H(["git","-C",e,"rev-parse","--verify","--quiet",n],{capture:!0}).status===0)return n;throw new Error(`Could not determine default branch for ${e}`)}function E1(e,t,r,{force:n=!1}={}){let s=xp.basename(e),o=H(["git","-C",e,"rev-parse","--verify","--quiet",`refs/heads/${r}`],{capture:!0}),a;if(o.status===0)O(` ${s}: worktree \u2192 ${r} (existing branch)`),a=["git","-C",e,"worktree","add",t,r];else{let l=Cfe(e),u=`origin/${r}`,f=H(["git","-C",e,"rev-parse","--verify","--quiet",u],{capture:!0});if(f.status===0&&n){let d=H(["git","-C",e,"push","origin","--delete",r],{capture:!0});if(d.status!==0)throw new Error(`${s}: could not delete ${u}: ${d.stderr.trim()}`);O(` ${s}: deleted ${u} (--force)`)}else if(f.status===0){let d=H(["git","-C",e,"log","-1","--format=%cs %s",u],{capture:!0}).stdout.trim();throw new Error(`${s}: branch '${r}' already exists on origin (last commit: ${d}), left by an earlier workspace of the same name.
857
857
  Continue that work (nothing lost): git -C ${e} branch ${r} ${u}
858
858
  then rerun; the worktree lands on that branch.
859
859
  Start over (deletes the remote branch): rerun with --force
@@ -1263,9 +1263,9 @@ ${My.default.stringify(m)}---
1263
1263
  `).map(t=>` ${t}`).join(`
1264
1264
  `),"indent");i(Zhe,"wakeMessage");x2=i((e,t,r="")=>`${e??"someone"}${r?` on ${r}`:""}: ${t.trim().split(`
1265
1265
  `).slice(0,5).map(n=>n.slice(0,200)).join(`
1266
- `)}`,"quoteOf");i(eme,"wakeEvents");i(Gy,"takeLock");i(tme,"claimCallbacks");i(O3,"shipMerged");i(rme,"deliverHeadless");i(Vy,"watchPrs");i(Yy,"adoptPr");i(zy,"newPr");i(Ac,"lifecycleOf");i(T3,"removalBlockers");i(R3,"originBase");i(v2,"commitsAhead");i(A3,"renderCloseout");i(k2,"abandonWorkspace");i(nme,"openTerminalSessions");i(eh,"closeOut");i(sme,"closeOutLocked")});import*as ew from"node:fs";import*as Uo from"node:path";function lme(e){let t=`${e.home}/.claude`,r=P3(e.workspaceRoot,e.workspacesRoot)?e.workspacesRoot:e.workspaceRoot,n=P3(e.reposRoot,r)?[]:[C3(e.reposRoot)],s=`printf '{"Authorization":"Bearer %s"}' "$(cat ${JSON.stringify(Uo.join(e.workspaceRoot,".werkmeister/token"))})"`,o={type:"http",url:`http://host.docker.internal:${e.port}/mcp`,headersHelper:s},a=['sudo chown node:node "$HOME" "$HOME/.claude"',"npm install -g @anthropic-ai/claude-code","(claude mcp remove --scope user werkmeister >/dev/null 2>&1 || true)",`claude mcp add-json --scope user werkmeister ${cme(JSON.stringify(o))}`].join(" && ");return{name:e.workspaceName,image:"mcr.microsoft.com/devcontainers/javascript-node:22",features:{"ghcr.io/devcontainers/features/github-cli:1":{}},workspaceMount:C3(r),workspaceFolder:e.workspaceRoot,mounts:[...n,`source=${ime}-${e.workspaceName},target=${t},type=volume`],runArgs:["--add-host=host.docker.internal:host-gateway"],containerEnv:{HOME:e.home,GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:"safe.directory",GIT_CONFIG_VALUE_0:"*"},remoteUser:"node",postCreateCommand:a}}function N3(e){let t=Uo.join(e.workspaceRoot,ome);return ew.mkdirSync(Uo.dirname(t),{recursive:!0}),ew.writeFileSync(t,ame+JSON.stringify(lme(e),null,2)+`
1267
- `),t}var ome,ime,ame,C3,cme,P3,I3=R(()=>{"use strict";h();ome=".devcontainer/devcontainer.json",ime="features-claude-home",ame="// GENERATED by `werkmeister workspace init` (packages/werkmeister-core/src/devcontainer_gen.ts) \u2014 do not edit; rerun init-workspace.\n",C3=i(e=>`source=${e},target=${e},type=bind`,"bind"),cme=i(e=>`'${e.replaceAll("'","'\\''")}'`,"shellQuote"),P3=i((e,t)=>{let r=Uo.relative(t,e);return!r.startsWith("..")&&!Uo.isAbsolute(r)},"within");i(lme,"buildDevcontainer");i(N3,"writeWorkspaceDevcontainer")});import*as Zi from"node:fs";import*as L3 from"node:path";function j3(e,t){let r=new Set;for(let n of Object.keys(e)){let s=t[n]??{};for(let o of s.mcp_servers??[])r.add(o)}return[...r].sort()}function D3(e,t){let r=[];for(let n of Object.keys(e).sort()){let s=e[n];if(!(typeof s!="object"||s===null||Array.isArray(s)))for(let o of s.mcp_servers??[])o in t||r.push(`services.yaml: archetype '${n}' lists MCP server '${o}' \u2014 no \`mcp_servers.${o}\` definition`)}return r}function S2(e,t){return typeof e=="string"?e.replace(/\$\{(\w+)\}/g,(r,n)=>Object.hasOwn(t,n)?t[n]:r):Array.isArray(e)?e.map(r=>S2(r,t)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([r,n])=>[r,S2(n,t)])):e}function F3(e,t,r,n={}){let s=L3.join(e,".mcp.json"),o=Zi.existsSync(s)&&Zi.statSync(s).isFile(),a={};if(o)try{let u=JSON.parse(Zi.readFileSync(s,"utf8"));if(typeof u=="object"&&u!==null&&!Array.isArray(u))a=u;else return s}catch{return s}let c={};for(let u of t)u in r&&(c[u]=S2(r[u],n));if(Object.keys(c).length===0&&!o)return null;"mcpServers"in a||(a.mcpServers={});let l=a.mcpServers;for(let u of Object.keys(l))u in r&&!(u in c)&&delete l[u];return Object.assign(l,c),Zi.writeFileSync(s,JSON.stringify(a,null,2)+`
1268
- `),s}var M3=R(()=>{"use strict";h();i(j3,"resolveWorkspaceMcpServers");i(D3,"validateArchetypeMcpServers");i(S2,"substituteVars");i(F3,"writeWorkspaceMcp")});import*as ut from"node:fs";import*as Uu from"node:os";import*as Ce from"node:path";function Hn(e){throw j(e),new Ir(e)}async function ume(e,t,r){if(r.issue)j$(e,r.issue);else if(r.refresh){if(!t)throw new Ir("--refresh-issue: this workspace has no issue_id.");try{let n=be({project:r.project,text:t});j$(e,await Pu(t,void 0,n))}catch(n){throw n instanceof vc?new Ir(`${n.message}; run \`werkmeister infra connect\` to check the issue tracker.`):n}}return m9(e,t,r.project)}function fme(e){try{return ut.statSync(e).isDirectory()}catch{return!1}}function dme(){for(let e of["LOGNAME","USER","LNAME","USERNAME"]){let t=process.env[e];if(t)return t}return Uu.userInfo().username}function hme(e){return e.split(",").map(t=>t.trim()).filter(t=>t)}function mme(e,t){if(t&&ut.existsSync(ki(t)))return!0;let r=Ae("WORKSPACE_CONFIG");if(r&&ut.existsSync(ki(r)))return!0;let n=W(e);return _i.some(s=>ut.existsSync(Ce.join(n,s)))}function q3(e,t){if(Object.keys(t).length===0)return;let r=W(e),n=Ce.join(r,_i[0]),s=_i.slice(1).map(u=>Ce.join(r,u)),o={};for(let u of[n,...s])if(ut.existsSync(u)&&ut.statSync(u).isFile())try{let f=jl(u);if(typeof f=="object"&&f!==null&&!Array.isArray(f)){o=f;break}}catch{}delete o._generator,delete o.$schema;let a={...o};for(let[,,u]of Dl)if(u in t){let f=t[u];if(pme.has(u)&&typeof f=="string"&&(f=hme(f)),(u==="autonomous"||u==="auto_stop")&&(f=f==="true"),u==="auto_stop"&&f===!1&&!(u in o))continue;a[u]=f}let c=B3.stringify(a,{sortMapEntries:!0,blockQuote:"literal"}),l=gme+c;if(!(ut.existsSync(n)&&ut.readFileSync(n,"utf8")===l)){ut.mkdirSync(r,{recursive:!0}),ut.writeFileSync(n,l),D(`Persisted inputs to ${n}`);for(let u of s)ut.existsSync(u)&&(ut.unlinkSync(u),O(`Removed legacy ${Ce.basename(u)} (superseded by workspace.yml)`))}}function yme(e,t){let r=(e||"").trim().toLowerCase(),n=(t||"").trim().toLowerCase();return n?`${n}-${r}`:r}function wme(e,t){return`${e}/${t}`}function U3(){return Nn()}function W3(){let e=Cl().workspaces_root;return e?Ce.resolve(pt(e)):Ce.resolve(Ce.join(Uu.homedir(),"workspace"))}function bme(e,t,r){let n=U3(),s=Ce.join(n,Wn);if(O(`Workspace: ${e}`),O(`Branch: ${t}`),ut.existsSync(Ce.join(s,".git"))){let o=Aa()||n2(),a=o?Vp(s,Fu(o)):null;a!==null&&Hn(`${s}'s origin is ${a||"unset"}, but the configured workspace repo is ${o} \u2014 this workspace's record would push to the wrong repo. Run \`werkmeister machine setup\` to repoint it, then rerun.`);try{E1(s,e,t,{force:r})}catch(c){Hn(`Failed to create workspace root worktree: ${c.message}`)}D(`Created workspace root (worktree of ${Wn}) at ${e}`)}else P(`No '${Wn}' repo at ${s} \u2014 workspace root will be a plain directory (no git history for notes/config).`),ut.mkdirSync(e,{recursive:!0})}function vme(e,t){if(ut.existsSync(Ce.join(e,".git")))try{if(H(["git","-C",e,"add","-A"],{capture:!0,check:!0}),H(["git","-C",e,"diff","--cached","--quiet"],{capture:!0}).status===0)return;H(["git","-C",e,"commit","-q","-m",`chore: initialize workspace ${t}`],{capture:!0,check:!0}),D("Committed initial workspace state (branch not pushed \u2014 push when ready).")}catch(r){P(`Could not commit initial workspace state: ${r.message}`)}}function K3(){for(let e of Ji({generatedOnly:!0}))e.ok?e.detail.startsWith("generated")&&O(`Registry: ${e.detail}`):P(`Registry not refreshed: ${e.detail}`)}async function kme(e,t){let r=de(),[n,,s]=S1(e??null,t??null,r);return s.length&&Hn(`Unknown service(s): ${s.join(", ")}. See \`werkmeister feature services\` / config/services.yaml.`),n.length||Hn("No repos selected. Choose at least one service or repo in the wizard, or pass --services svc1,svc2 / --repos r1,r2."),n}function _me(){let e=Ce.resolve(process.cwd()),t=xE(e,Gr());if(t!==null)return t;for(let n of[e,...Sme(e)])if(ut.existsSync(Ce.join(n,".git")))return Ce.dirname(n);let r=Gr().join(", ");throw new rh(`${w.RED}[err] Not inside a workspace (checked: ${r}) and no parent \`.git\` directory found.
1266
+ `)}`,"quoteOf");i(eme,"wakeEvents");i(Gy,"takeLock");i(tme,"claimCallbacks");i(O3,"shipMerged");i(rme,"deliverHeadless");i(Vy,"watchPrs");i(Yy,"adoptPr");i(zy,"newPr");i(Ac,"lifecycleOf");i(T3,"removalBlockers");i(R3,"originBase");i(v2,"commitsAhead");i(A3,"renderCloseout");i(k2,"abandonWorkspace");i(nme,"openTerminalSessions");i(eh,"closeOut");i(sme,"closeOutLocked")});import*as ew from"node:fs";import*as Uo from"node:path";function lme(e){let t=`${e.home}/.claude`,r=P3(e.workspaceRoot,e.workspacesRoot)?e.workspacesRoot:e.workspaceRoot,n=P3(e.reposRoot,r)?[]:[C3(e.reposRoot)],s=`printf '{"Authorization":"Bearer %s"}' "$(cat ${JSON.stringify(Uo.join(e.workspaceRoot,".werkmeister/token"))})"`,o={type:"http",url:`http://host.docker.internal:${e.port}/mcp`,headersHelper:s},a=['sudo chown node:node "$HOME" "$HOME/.claude"',"npm install -g @anthropic-ai/claude-code","(claude mcp remove --scope user werkmeister >/dev/null 2>&1 || true)",`claude mcp add-json --scope user werkmeister ${cme(JSON.stringify(o))}`].join(" && ");return{name:e.workspaceName,image:"mcr.microsoft.com/devcontainers/javascript-node:22",features:{"ghcr.io/devcontainers/features/github-cli:1":{}},workspaceMount:C3(r),workspaceFolder:e.workspaceRoot,mounts:[...n,`source=${ime},target=${t},type=volume`],runArgs:["--add-host=host.docker.internal:host-gateway"],containerEnv:{HOME:e.home,GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:"safe.directory",GIT_CONFIG_VALUE_0:"*"},remoteEnv:{CLAUDE_CODE_OAUTH_TOKEN:"${localEnv:CLAUDE_CODE_OAUTH_TOKEN}"},remoteUser:"node",postCreateCommand:a}}function N3(e){let t=Uo.join(e.workspaceRoot,ome);return ew.mkdirSync(Uo.dirname(t),{recursive:!0}),ew.writeFileSync(t,ame+JSON.stringify(lme(e),null,2)+`
1267
+ `),t}var ome,ime,ame,C3,cme,P3,I3=R(()=>{"use strict";h();ome=".devcontainer/devcontainer.json",ime="werkmeister-claude-home",ame="// GENERATED by `werkmeister workspace init` (packages/werkmeister-core/src/devcontainer_gen.ts) \u2014 do not edit; rerun init-workspace.\n",C3=i(e=>`source=${e},target=${e},type=bind`,"bind"),cme=i(e=>`'${e.replaceAll("'","'\\''")}'`,"shellQuote"),P3=i((e,t)=>{let r=Uo.relative(t,e);return!r.startsWith("..")&&!Uo.isAbsolute(r)},"within");i(lme,"buildDevcontainer");i(N3,"writeWorkspaceDevcontainer")});import*as Zi from"node:fs";import*as L3 from"node:path";function j3(e,t){let r=new Set;for(let n of Object.keys(e)){let s=t[n]??{};for(let o of s.mcp_servers??[])r.add(o)}return[...r].sort()}function D3(e,t){let r=[];for(let n of Object.keys(e).sort()){let s=e[n];if(!(typeof s!="object"||s===null||Array.isArray(s)))for(let o of s.mcp_servers??[])o in t||r.push(`services.yaml: archetype '${n}' lists MCP server '${o}' \u2014 no \`mcp_servers.${o}\` definition`)}return r}function S2(e,t){return typeof e=="string"?e.replace(/\$\{(\w+)\}/g,(r,n)=>Object.hasOwn(t,n)?t[n]:r):Array.isArray(e)?e.map(r=>S2(r,t)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([r,n])=>[r,S2(n,t)])):e}function F3(e,t,r,n={}){let s=L3.join(e,".mcp.json"),o=Zi.existsSync(s)&&Zi.statSync(s).isFile(),a={};if(o)try{let u=JSON.parse(Zi.readFileSync(s,"utf8"));if(typeof u=="object"&&u!==null&&!Array.isArray(u))a=u;else return s}catch{return s}let c={};for(let u of t)u in r&&(c[u]=S2(r[u],n));if(Object.keys(c).length===0&&!o)return null;"mcpServers"in a||(a.mcpServers={});let l=a.mcpServers;for(let u of Object.keys(l))u in r&&!(u in c)&&delete l[u];return Object.assign(l,c),Zi.writeFileSync(s,JSON.stringify(a,null,2)+`
1268
+ `),s}var M3=R(()=>{"use strict";h();i(j3,"resolveWorkspaceMcpServers");i(D3,"validateArchetypeMcpServers");i(S2,"substituteVars");i(F3,"writeWorkspaceMcp")});import*as ut from"node:fs";import*as Uu from"node:os";import*as Ce from"node:path";function Hn(e){throw j(e),new Ir(e)}async function ume(e,t,r){if(r.issue)j$(e,r.issue);else if(r.refresh){if(!t)throw new Ir("--refresh-issue: this workspace has no issue_id.");try{let n=be({project:r.project,text:t});j$(e,await Pu(t,void 0,n))}catch(n){throw n instanceof vc?new Ir(`${n.message}; run \`werkmeister infra connect\` to check the issue tracker.`):n}}return m9(e,t,r.project)}function fme(e){try{return ut.statSync(e).isDirectory()}catch{return!1}}function dme(){for(let e of["LOGNAME","USER","LNAME","USERNAME"]){let t=process.env[e];if(t)return t}return Uu.userInfo().username}function hme(e){return e.split(",").map(t=>t.trim()).filter(t=>t)}function mme(e,t){if(t&&ut.existsSync(ki(t)))return!0;let r=Ae("WORKSPACE_CONFIG");if(r&&ut.existsSync(ki(r)))return!0;let n=W(e);return _i.some(s=>ut.existsSync(Ce.join(n,s)))}function q3(e,t){if(Object.keys(t).length===0)return;let r=W(e),n=Ce.join(r,_i[0]),s=_i.slice(1).map(u=>Ce.join(r,u)),o={};for(let u of[n,...s])if(ut.existsSync(u)&&ut.statSync(u).isFile())try{let f=jl(u);if(typeof f=="object"&&f!==null&&!Array.isArray(f)){o=f;break}}catch{}delete o._generator,delete o.$schema;let a={...o};for(let[,,u]of Dl)if(u in t){let f=t[u];if(pme.has(u)&&typeof f=="string"&&(f=hme(f)),(u==="autonomous"||u==="auto_stop")&&(f=f==="true"),u==="auto_stop"&&f===!1&&!(u in o))continue;a[u]=f}let c=B3.stringify(a,{sortMapEntries:!0,blockQuote:"literal"}),l=gme+c;if(!(ut.existsSync(n)&&ut.readFileSync(n,"utf8")===l)){ut.mkdirSync(r,{recursive:!0}),ut.writeFileSync(n,l),D(`Persisted inputs to ${n}`);for(let u of s)ut.existsSync(u)&&(ut.unlinkSync(u),O(`Removed legacy ${Ce.basename(u)} (superseded by workspace.yml)`))}}function yme(e,t){let r=(e||"").trim().toLowerCase(),n=(t||"").trim().toLowerCase();return n?`${n}-${r}`:r}function wme(e,t){return`${e}/${t}`}function U3(){return Nn()}function W3(){let e=Cl().workspaces_root;return e?Ce.resolve(pt(e)):Ce.resolve(Ce.join(Uu.homedir(),"workspace"))}function bme(e,t,r){let n=U3(),s=Ce.join(n,Wn);if(O(`Workspace: ${e}`),O(`Branch: ${t}`),ut.existsSync(Ce.join(s,".git"))){let o=Aa()||n2(),a=o?Vp(s,Fu(o)):null;a!==null&&Hn(`${s}'s origin is ${a||"unset"}, but the configured workspace repo is ${o} \u2014 this workspace's record would push to the wrong repo. Run \`werkmeister machine setup\` to repoint it, then rerun.`);try{E1(s,e,t,{force:r})}catch(c){Hn(`Failed to create workspace root worktree: ${c.message}`)}D(`Created workspace root (worktree of ${Wn}) at ${e}`)}else P(`No '${Wn}' repo at ${s} \u2014 workspace root will be a plain directory (no git history for notes/config).`),ut.mkdirSync(e,{recursive:!0})}function vme(e,t){if(ut.existsSync(Ce.join(e,".git")))try{if(H(["git","-C",e,"add","-A"],{capture:!0,check:!0}),H(["git","-C",e,"diff","--cached","--quiet"],{capture:!0}).status===0)return;H(["git","-C",e,"commit","-q","-m",`chore: initialize workspace ${t}`],{capture:!0,check:!0}),D("Committed initial workspace state (branch not pushed \u2014 push when ready).")}catch(r){P(`Could not commit initial workspace state: ${r.message}`)}}function K3(){for(let e of Ji({generatedOnly:!0}))e.ok?e.detail.startsWith("generated")&&O(`Registry: ${e.detail}`):P(`Registry not refreshed: ${e.detail}`)}async function kme(e,t){let r=de(),[n,s,o]=S1(e??null,t??null,r);return o.length&&Hn(`Unknown service(s): ${o.join(", ")}. See \`werkmeister feature services\` / config/services.yaml.`),!n.length&&!s.length&&Hn("No repos selected. Choose at least one service or repo in the wizard, or pass --services svc1,svc2 / --repos r1,r2."),n}function _me(){let e=Ce.resolve(process.cwd()),t=xE(e,Gr());if(t!==null)return t;for(let n of[e,...Sme(e)])if(ut.existsSync(Ce.join(n,".git")))return Ce.dirname(n);let r=Gr().join(", ");throw new rh(`${w.RED}[err] Not inside a workspace (checked: ${r}) and no parent \`.git\` directory found.
1269
1269
  The workspaces root comes from ~/.werkmeister/config.yaml \u2014 run \`werkmeister machine config --write\` to set it (or \`werkmeister machine config --check\` to verify). See docs/known-issues.md for details.${w.RESET}`)}function Sme(e){let t=[],r=e;for(;;){let n=Ce.dirname(r);if(n===r)break;t.push(n),r=n}return t}function H3(e){let r=H(["git","-C",e,"branch","--show-current"],{capture:!0}).stdout.trim();return r||H(["git","-C",e,"rev-parse","--short","HEAD"],{capture:!0}).stdout.trim()||"unknown"}function G3(e){return Ua(e).map(t=>[Ce.basename(t),H3(t)])}function Eme(e){if(ut.existsSync(Ce.join(e,".git"))){let t=H3(e);if(t&&t!=="unknown")return t}return`${dme()}/${Ce.basename(e)}`}function $me(e,t,r){let n=Nn(),s=t.filter(p=>p!==Wn),o=new Set(s),a=new Set(G3(e).map(([p])=>p)),c=s.filter(p=>!a.has(p)),l=[...a].filter(p=>!o.has(p)).sort(),u=c.filter(p=>!fme(Ce.join(n,p)));if(u.length&&Hn(`Source repo(s) not found under ${n}: ${u.join(", ")}. Clone them there (or fix \`repos\` in .werkmeister/workspace.yml) and rerun.`),l.length&&!r){let p=l.filter(m=>vF(Ce.join(e,m)));p.length&&Hn(`Refusing to remove worktree(s) with uncommitted changes: ${p.join(", ")}. Commit or stash them, or rerun with --force to discard them.`)}if(!c.length&&!l.length)return;let f=Eme(e);for(let p of l){let[m,y]=$1(Ce.join(n,p),Ce.join(e,p),f);m?(D(`Removed worktree '${p}' (no longer in workspace.yml).`),y&&P(y)):Hn(`Could not remove worktree '${p}': ${y}`)}let d=[];try{for(let p of c){let m=Ce.join(n,p),y=Ce.join(e,p);E1(m,y,f,{force:r}),d.push([y,m])}}catch(p){let m=`Failed to create worktree: ${p.message}`;j(m),P("Rolling back worktrees created this run...");for(let[y,g]of[...d].reverse())$1(g,y,f);throw new Ir(m)}(c.length||l.length)&&D(`Worktrees reconciled (+${c.length} / -${l.length}).`)}function Ome(e,t,r){if(e)return[e.trim(),{}];let n=r?.().trim();return n?[n,{}]:[w_(t),{}]}function Tme(e){if(!ut.existsSync(e))return;ut.readFileSync(e,"utf8").includes("## Layout")?P("CLAUDE.md already initialised \u2014 overwriting with fresh content."):O("Replacing stub CLAUDE.md with full workspace context.")}function Rme(e,t){O(`Task: ${e}`);for(let[r,n]of[["FEATURE","Feature"],["SERVICES","Services"],["ISSUE_ID","Issue"],["TEST_PATH","Test path"]]){let s=t[r];s&&O(` ${(n+":").padEnd(10)} ${s}`)}}async function E2(e,t,r={}){let n=t??_me(),s=Ce.basename(n);O(`Workspace root: ${n}`),K3();let o=La(e,n),a=TE(ix(o.context_strategy));!mme(n,e.config_file??null)&&!o.feature&&Hn("No .werkmeister/workspace.yml found and no --feature given. Run `werkmeister workspace new <name>` to create and initialise a workspace, then rerun `werkmeister workspace init` from inside it to reconcile changes."),q3(n,o);let l=o.project??"",u=o.issue_id?be({project:l,text:o.issue_id}).parseRef(o.issue_id)??o.issue_id:"",f;try{f=await ume(n,u,{issue:r.issue,refresh:!!e.refresh_issue,project:l})}catch(L){throw L instanceof Ir&&Hn(L.message),L}if(o.repos){let[L]=an(),[F,,A]=S1(o.repos,o.services,L);A.length&&P(`Unknown service(s) in workspace.yml (no owning repo): ${A.join(", ")}`),$me(n,F,!!e.force)}let d=Ce.join(n,"CLAUDE.md");Tme(d),O("Scanning for git repos...");let p=G3(n);if(!p.length)P("No git repos found in workspace. CLAUDE.md will have an empty layout.");else{for(let[L,F]of p)O(` ${L}/ \u2192 ${F}`);bF(n,p.map(([L])=>L))}let[m,y]=Ome(o.task,s,r.readStdinTask),g={feature:"FEATURE",services:"SERVICES",issue_id:"ISSUE_ID",test_path:"TEST_PATH",description:"DESCRIPTION"};for(let[L,F]of Object.entries(g))L in o&&(y[F]=o[L]);Rme(m,y);let x=Ce.join(n,".env");EF(x,y),D(`Wrote ${x}`),D(`Wrote ${Y0(n)}`),a.init({workspaceRoot:n,workspaceName:s,repos:p,task:m,meta:y,inputs:o,configOverride:e.config??null,issue:f,isCreate:!!r.issue});for(let L of Yr)L!==a.id&&iD(n,TE(L),a,!!e.prune_context);let[k,v]=an(),b=Et(),S=G0(p,y,k,v,b),E=Qk();for(let L of D3(b,E))P(L);let T=(y.FEATURE??"").trim(),C=F3(n,j3(S,b),E,T?{FEATURE:T}:{});C&&D(`Wrote ${C}`),Jj(s,n),D(`Workspace token: ${Ce.relative(n,Hd(n))}`);let I=N3({workspaceName:s,workspaceRoot:n,workspacesRoot:W3(),reposRoot:U3(),home:Uu.homedir(),port:Gd()});D(`Wrote ${Ce.relative(n,I)}`);for(let L of Ry())P(L);let N=(y.FEATURE??"").trim();if(N&&await AF(N,y.SERVICES??"",n,(y.TEST_PATH??"").trim(),p.map(([F])=>F))!==null&&r.build!==!1){O("Building Docker images (--no-start)...");let F=va(),A=Ce.join(n,Oe);VS(A),HS(N,A);let M=H(KS(N,["up","--build","--no-start"],A),{cwd:n,...F?{stdio:"inherit"}:{capture:!0}});F||(M.stdout&&te(M.stdout),M.stderr&&te(M.stderr,"stderr")),M.status===0?D("Docker images built successfully."):P("docker compose build exited non-zero \u2014 images may be incomplete.")}te(`
1270
1270
  ${w.BOLD}Workspace initialised.${w.RESET} Open a new Claude Code session from the workspace root to pick up the context.
1271
1271
 
package/dist/mcp.js CHANGED
@@ -630,7 +630,7 @@ exit "$status"
630
630
  `:"");let a=o&&!o.endsWith(`
631
631
  `)?`
632
632
  `:"";fo.writeFileSync(n,o+a+(o?`
633
- `:"")+i),Woe(e)}s(Voe,"writeWorkspaceGitignore");function Bz(e,t,r){let i=new Set,n=(e??"").split(",").map(c=>c.trim()).filter(c=>c);for(let c of n)i.add(c);let o=(t??"").split(",").map(c=>c.trim()).filter(c=>c),a=[];for(let c of o){let l=r[c],u=typeof l=="object"&&l!==null&&!Array.isArray(l)?l.repo:null;u?i.add(u):a.push(c)}return[[...i].sort(),o,a]}s(Bz,"resolveRepos");function dqe(e){re(["git","-C",e,"fetch","origin","--prune","--quiet"],{capture:!0});let t=s(()=>{let i=re(["git","-C",e,"symbolic-ref","--quiet","refs/remotes/origin/HEAD"],{capture:!0}),n=i.stdout.trim(),o="refs/remotes/";return i.status===0&&n.startsWith(o)?n.slice(o.length):null},"originHead"),r=t();if(r||(re(["git","-C",e,"remote","set-head","origin","--auto"],{capture:!0}),r=t(),r))return r;for(let i of["origin/main","origin/master"])if(re(["git","-C",e,"rev-parse","--verify","--quiet",i],{capture:!0}).status===0)return i;throw new Error(`Could not determine default branch for ${e}`)}s(dqe,"defaultBaseRef");function Hz(e,t,r,{force:i=!1}={}){let n=xv.basename(e),o=re(["git","-C",e,"rev-parse","--verify","--quiet",`refs/heads/${r}`],{capture:!0}),a;if(o.status===0)P(` ${n}: worktree \u2192 ${r} (existing branch)`),a=["git","-C",e,"worktree","add",t,r];else{let l=dqe(e),u=`origin/${r}`,p=re(["git","-C",e,"rev-parse","--verify","--quiet",u],{capture:!0});if(p.status===0&&i){let d=re(["git","-C",e,"push","origin","--delete",r],{capture:!0});if(d.status!==0)throw new Error(`${n}: could not delete ${u}: ${d.stderr.trim()}`);P(` ${n}: deleted ${u} (--force)`)}else if(p.status===0){let d=re(["git","-C",e,"log","-1","--format=%cs %s",u],{capture:!0}).stdout.trim();throw new Error(`${n}: branch '${r}' already exists on origin (last commit: ${d}), left by an earlier workspace of the same name.
633
+ `:"")+i),Woe(e)}s(Voe,"writeWorkspaceGitignore");function Bz(e,t,r){let i=new Set,n=(e??"").split(",").map(c=>c.trim()).filter(c=>c);for(let c of n)i.add(c);let o=(t??"").split(",").map(c=>c.trim()).filter(c=>c),a=[];for(let c of o){let l=r[c],u=typeof l=="object"&&l!==null&&!Array.isArray(l)?l:{};u.repo?i.add(u.repo):(typeof u.image!="string"||!u.image)&&a.push(c)}return[[...i].sort(),o,a]}s(Bz,"resolveRepos");function dqe(e){re(["git","-C",e,"fetch","origin","--prune","--quiet"],{capture:!0});let t=s(()=>{let i=re(["git","-C",e,"symbolic-ref","--quiet","refs/remotes/origin/HEAD"],{capture:!0}),n=i.stdout.trim(),o="refs/remotes/";return i.status===0&&n.startsWith(o)?n.slice(o.length):null},"originHead"),r=t();if(r||(re(["git","-C",e,"remote","set-head","origin","--auto"],{capture:!0}),r=t(),r))return r;for(let i of["origin/main","origin/master"])if(re(["git","-C",e,"rev-parse","--verify","--quiet",i],{capture:!0}).status===0)return i;throw new Error(`Could not determine default branch for ${e}`)}s(dqe,"defaultBaseRef");function Hz(e,t,r,{force:i=!1}={}){let n=xv.basename(e),o=re(["git","-C",e,"rev-parse","--verify","--quiet",`refs/heads/${r}`],{capture:!0}),a;if(o.status===0)P(` ${n}: worktree \u2192 ${r} (existing branch)`),a=["git","-C",e,"worktree","add",t,r];else{let l=dqe(e),u=`origin/${r}`,p=re(["git","-C",e,"rev-parse","--verify","--quiet",u],{capture:!0});if(p.status===0&&i){let d=re(["git","-C",e,"push","origin","--delete",r],{capture:!0});if(d.status!==0)throw new Error(`${n}: could not delete ${u}: ${d.stderr.trim()}`);P(` ${n}: deleted ${u} (--force)`)}else if(p.status===0){let d=re(["git","-C",e,"log","-1","--format=%cs %s",u],{capture:!0}).stdout.trim();throw new Error(`${n}: branch '${r}' already exists on origin (last commit: ${d}), left by an earlier workspace of the same name.
634
634
  Continue that work (nothing lost): git -C ${e} branch ${r} ${u}
635
635
  then rerun; the worktree lands on that branch.
636
636
  Start over (deletes the remote branch): rerun with --force
@@ -1145,7 +1145,7 @@ ${d.stdout.trimEnd()}`:"clean");let m=r.services,h=r.repos[t.dir]??{},y=null;try
1145
1145
  `))if(c.startsWith("p"))a=c.slice(1);else if(c.startsWith("n")&&i.has(a)){let l=c.slice(1);(l===e||l.startsWith(e+we.sep))&&o.push(`terminal session: pid ${a} on ${i.get(a)} in ${l} \u2014 /exit it`)}return o}s(D5e,"openTerminalSessions");async function q6(e,t={},r=Mf()){let i=t.abandon?.trim();if(t.abandon!==void 0&&!i)throw new fe(`Abandon needs a reason: werkmeister workspace abandon "<reason>" ${e}`);let n=t.skipPostmortem?.trim();if(t.skipPostmortem!==void 0&&!n)throw new fe(`Skipping the post-mortem needs a reason: werkmeister workspace close ${e} --skip-postmortem "<reason>"`);let o=await _u(e).catch(c=>{throw/^No such workspace/.test(c.message)?new fe(`${c.message} \u2014 already closed out, or never created.`):c}),a=we.join(yr(),`close-out-${we.basename(o)}.lock`);if(Re.mkdirSync(we.dirname(a),{recursive:!0}),!vle(a))throw new fe(`close-out of '${e}' is already running; that run reports the result. If none is, delete ${a}.`);try{return await z5e(e,o,i,n,r)}finally{Re.rmSync(a,{force:!0})}}s(q6,"closeOut");async function z5e(e,t,r,i,n){let o=`werkmeister workspace ${r?"abandon <reason>":"close"} ${e}`,a=tn(t,null),c=we.join(t,"postmortem.md"),l=!i&&!Re.existsSync(we.join(t,"closeout.md"))&&!Re.existsSync(c)?`'${e}' has no postmortem.md. Run the post-mortem first: ask Claude to close out (the werkmeister \`postmortem\` skill), or skip it with \`werkmeister workspace ${r?'abandon "<reason>"':"close"} ${e} --skip-postmortem "<reason>"\`.`:null;if(r&&l)throw new fe(l);r&&F6(t,r);let u=Ff(t),p=u.prs.length===0&&String(a.work_type??"").trim().toLowerCase()==="spike";if(!(u.state==="shipped"||u.state==="abandoned"||u.state==="closed-out"||p)){let k=u.prs.map(_=>`${_.stem}: ${_.status}`).join(", ")||"no PR files";throw new fe(`'${e}' is ${u.state} (${k}). Close-out needs every PR shipped, closed or abandoned \u2014 run \`werkmeister pr status\` after the release, or give up with \`werkmeister workspace abandon "<reason>" ${e}\`.`)}if(l)throw new fe(l);let d=!!r||u.state==="abandoned"||u.state==="closed-out"&&u.prs.some(k=>k.status==="abandoned"),m=[],h=po(a),y="none";if(h){let{tracker:k,statuses:_}=C6(a,h,n);if(r)y=await qv(k,h,"abandoned",_,{comment:`Abandoned: ${r}`,alwaysComment:!0});else if(d){let $=(await k.fetchIssue(h))?.status??"";y=`${h} left ${$||"as is"} (abandoned)`}else y=await qv(k,h,"done",_,{comment:yle(go(t).filter($=>Wt($)==="shipped"))})||`${h} left as is (no done status configured)`;m.push(`Issue: ${y}`)}let g=go(t);try{let k=await cle(t,e,a,d?"abandoned":"shipped");Re.writeFileSync(we.join(t,"closeout.md"),_le(g,y,[r&&`Abandoned: ${r}`,i?`Post-mortem skipped: ${i}`:Re.existsSync(c)&&"Post-mortem: postmortem.md",k].filter(Boolean).join(`
1146
1146
  `)||void 0))}catch(k){if(k.code!=="ENOENT"||Re.existsSync(t))throw k;return m.push(`'${e}' is already closed out or removed: ${t} is gone.`),{command:o,output:m.join(`
1147
1147
  `),path:t,terminals:[]}}let v=[];for(let k of d?[]:g.filter(_=>(Wt(_)==="merged"||Wt(_)==="shipped")&&!_.fm.adopted)){let _=await n.sourceOf(we.join(t,k.dir));_&&k.fm.branch&&v.push({src:_,branch:String(k.fm.branch)})}let x=await n.terminals(t);m.push((await n.remove(e,d)).output);for(let{src:k,branch:_}of v){let $=await n.run("git",["-C",k,"branch","-D",_]);if(m.push($.code===0?`deleted local ${_}`:`local ${_}: ${$.stderr.trim()}`),(await n.run("git",["-C",k,"ls-remote","--exit-code","--heads","origin",_])).code===0){let O=await n.run("git",["-C",k,"push","origin","--delete",_]);m.push(O.code===0?`deleted origin/${_}`:`origin/${_}: ${O.stderr.trim()}`)}else m.push(`origin/${_} already gone`)}return m.push(...x),{command:o,output:m.filter(Boolean).join(`
1148
- `),path:t,terminals:x}}s(z5e,"closeOutLocked");st();f();var Ale=Qe(Rt(),1);import*as Dt from"node:fs";import*as Uf from"node:os";import*as Xe from"node:path";Ms();Qn();Jn();ye();Fy();f();import*as f1 from"node:fs";import*as la from"node:path";var M5e=".devcontainer/devcontainer.json",F5e="features-claude-home",q5e="// GENERATED by `werkmeister workspace init` (packages/werkmeister-core/src/devcontainer_gen.ts) \u2014 do not edit; rerun init-workspace.\n",$le=s(e=>`source=${e},target=${e},type=bind`,"bind"),U5e=s(e=>`'${e.replaceAll("'","'\\''")}'`,"shellQuote"),Ele=s((e,t)=>{let r=la.relative(t,e);return!r.startsWith("..")&&!la.isAbsolute(r)},"within");function B5e(e){let t=`${e.home}/.claude`,r=Ele(e.workspaceRoot,e.workspacesRoot)?e.workspacesRoot:e.workspaceRoot,i=Ele(e.reposRoot,r)?[]:[$le(e.reposRoot)],n=`printf '{"Authorization":"Bearer %s"}' "$(cat ${JSON.stringify(la.join(e.workspaceRoot,".werkmeister/token"))})"`,o={type:"http",url:`http://host.docker.internal:${e.port}/mcp`,headersHelper:n},a=['sudo chown node:node "$HOME" "$HOME/.claude"',"npm install -g @anthropic-ai/claude-code","(claude mcp remove --scope user werkmeister >/dev/null 2>&1 || true)",`claude mcp add-json --scope user werkmeister ${U5e(JSON.stringify(o))}`].join(" && ");return{name:e.workspaceName,image:"mcr.microsoft.com/devcontainers/javascript-node:22",features:{"ghcr.io/devcontainers/features/github-cli:1":{}},workspaceMount:$le(r),workspaceFolder:e.workspaceRoot,mounts:[...i,`source=${F5e}-${e.workspaceName},target=${t},type=volume`],runArgs:["--add-host=host.docker.internal:host-gateway"],containerEnv:{HOME:e.home,GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:"safe.directory",GIT_CONFIG_VALUE_0:"*"},remoteUser:"node",postCreateCommand:a}}s(B5e,"buildDevcontainer");function Tle(e){let t=la.join(e.workspaceRoot,M5e);return f1.mkdirSync(la.dirname(t),{recursive:!0}),f1.writeFileSync(t,q5e+JSON.stringify(B5e(e),null,2)+`
1148
+ `),path:t,terminals:x}}s(z5e,"closeOutLocked");st();f();var Ale=Qe(Rt(),1);import*as Dt from"node:fs";import*as Uf from"node:os";import*as Xe from"node:path";Ms();Qn();Jn();ye();Fy();f();import*as f1 from"node:fs";import*as la from"node:path";var M5e=".devcontainer/devcontainer.json",F5e="werkmeister-claude-home",q5e="// GENERATED by `werkmeister workspace init` (packages/werkmeister-core/src/devcontainer_gen.ts) \u2014 do not edit; rerun init-workspace.\n",$le=s(e=>`source=${e},target=${e},type=bind`,"bind"),U5e=s(e=>`'${e.replaceAll("'","'\\''")}'`,"shellQuote"),Ele=s((e,t)=>{let r=la.relative(t,e);return!r.startsWith("..")&&!la.isAbsolute(r)},"within");function B5e(e){let t=`${e.home}/.claude`,r=Ele(e.workspaceRoot,e.workspacesRoot)?e.workspacesRoot:e.workspaceRoot,i=Ele(e.reposRoot,r)?[]:[$le(e.reposRoot)],n=`printf '{"Authorization":"Bearer %s"}' "$(cat ${JSON.stringify(la.join(e.workspaceRoot,".werkmeister/token"))})"`,o={type:"http",url:`http://host.docker.internal:${e.port}/mcp`,headersHelper:n},a=['sudo chown node:node "$HOME" "$HOME/.claude"',"npm install -g @anthropic-ai/claude-code","(claude mcp remove --scope user werkmeister >/dev/null 2>&1 || true)",`claude mcp add-json --scope user werkmeister ${U5e(JSON.stringify(o))}`].join(" && ");return{name:e.workspaceName,image:"mcr.microsoft.com/devcontainers/javascript-node:22",features:{"ghcr.io/devcontainers/features/github-cli:1":{}},workspaceMount:$le(r),workspaceFolder:e.workspaceRoot,mounts:[...i,`source=${F5e},target=${t},type=volume`],runArgs:["--add-host=host.docker.internal:host-gateway"],containerEnv:{HOME:e.home,GIT_CONFIG_COUNT:"1",GIT_CONFIG_KEY_0:"safe.directory",GIT_CONFIG_VALUE_0:"*"},remoteEnv:{CLAUDE_CODE_OAUTH_TOKEN:"${localEnv:CLAUDE_CODE_OAUTH_TOKEN}"},remoteUser:"node",postCreateCommand:a}}s(B5e,"buildDevcontainer");function Tle(e){let t=la.join(e.workspaceRoot,M5e);return f1.mkdirSync(la.dirname(t),{recursive:!0}),f1.writeFileSync(t,q5e+JSON.stringify(B5e(e),null,2)+`
1149
1149
  `),t}s(Tle,"writeWorkspaceDevcontainer");Qr();Jt();f();import*as Mc from"node:fs";import*as Ole from"node:path";function Rle(e,t){let r=new Set;for(let i of Object.keys(e)){let n=t[i]??{};for(let o of n.mcp_servers??[])r.add(o)}return[...r].sort()}s(Rle,"resolveWorkspaceMcpServers");function Ile(e,t){let r=[];for(let i of Object.keys(e).sort()){let n=e[i];if(!(typeof n!="object"||n===null||Array.isArray(n)))for(let o of n.mcp_servers??[])o in t||r.push(`services.yaml: archetype '${i}' lists MCP server '${o}' \u2014 no \`mcp_servers.${o}\` definition`)}return r}s(Ile,"validateArchetypeMcpServers");function H6(e,t){return typeof e=="string"?e.replace(/\$\{(\w+)\}/g,(r,i)=>Object.hasOwn(t,i)?t[i]:r):Array.isArray(e)?e.map(r=>H6(r,t)):typeof e=="object"&&e!==null?Object.fromEntries(Object.entries(e).map(([r,i])=>[r,H6(i,t)])):e}s(H6,"substituteVars");function Ple(e,t,r,i={}){let n=Ole.join(e,".mcp.json"),o=Mc.existsSync(n)&&Mc.statSync(n).isFile(),a={};if(o)try{let u=JSON.parse(Mc.readFileSync(n,"utf8"));if(typeof u=="object"&&u!==null&&!Array.isArray(u))a=u;else return n}catch{return n}let c={};for(let u of t)u in r&&(c[u]=H6(r[u],i));if(Object.keys(c).length===0&&!o)return null;"mcpServers"in a||(a.mcpServers={});let l=a.mcpServers;for(let u of Object.keys(l))u in r&&!(u in c)&&delete l[u];return Object.assign(l,c),Mc.writeFileSync(n,JSON.stringify(a,null,2)+`
1150
1150
  `),n}s(Ple,"writeWorkspaceMcp");tr();st();Dy();var yo=class extends oe{static{s(this,"WorkspaceInitError")}constructor(t){super(t,"WORKSPACE_INIT"),this.name="WorkspaceInitError"}};function Fi(e){throw he(e),new yo(e)}s(Fi,"fail");async function H5e(e,t,r){if(r.issue)E6(e,r.issue);else if(r.refresh){if(!t)throw new yo("--refresh-issue: this workspace has no issue_id.");try{let i=dt({project:r.project,text:t});E6(e,await i1(t,void 0,i))}catch(i){throw i instanceof wu?new yo(`${i.message}; run \`werkmeister infra connect\` to check the issue tracker.`):i}}return Mce(e,t,r.project)}s(H5e,"resolveIssueCopy");var W6=class extends Error{static{s(this,"WorkspaceRootError")}};function W5e(e){try{return Dt.statSync(e).isDirectory()}catch{return!1}}s(W5e,"isDir");function Z5e(){for(let e of["LOGNAME","USER","LNAME","USERNAME"]){let t=process.env[e];if(t)return t}return Uf.userInfo().username}s(Z5e,"getuser");var V5e=new Set(["labels"]);function K5e(e){return e.split(",").map(t=>t.trim()).filter(t=>t)}s(K5e,"splitMultiValue");function G5e(e,t){if(t&&Dt.existsSync(Ic(t)))return!0;let r=jt("WORKSPACE_CONFIG");if(r&&Dt.existsSync(Ic(r)))return!0;let i=J(e);return Pc.some(n=>Dt.existsSync(Xe.join(i,n)))}s(G5e,"hasWorkspaceConfig");var J5e=`# AUTO-GENERATED \u2014 durable source of truth for workspace inputs.
1151
1151
  # Tool: werkmeister workspace init
@@ -1162,7 +1162,7 @@ ${d.stdout.trimEnd()}`:"clean");let m=r.services,h=r.repos[t.dir]??{},y=null;try
1162
1162
  # ~/.werkmeister/services.yaml instead.
1163
1163
  # Format: YAML \u2014 line comments (\`#\`) are supported. The loader also
1164
1164
  # accepts legacy JSONC and JSON for back-compat.
1165
- `;function jle(e,t){if(Object.keys(t).length===0)return;let r=J(e),i=Xe.join(r,Pc[0]),n=Pc.slice(1).map(u=>Xe.join(r,u)),o={};for(let u of[i,...n])if(Dt.existsSync(u)&&Dt.statSync(u).isFile())try{let p=wf(u);if(typeof p=="object"&&p!==null&&!Array.isArray(p)){o=p;break}}catch{}delete o._generator,delete o.$schema;let a={...o};for(let[,,u]of xf)if(u in t){let p=t[u];if(V5e.has(u)&&typeof p=="string"&&(p=K5e(p)),(u==="autonomous"||u==="auto_stop")&&(p=p==="true"),u==="auto_stop"&&p===!1&&!(u in o))continue;a[u]=p}let c=Ale.stringify(a,{sortMapEntries:!0,blockQuote:"literal"}),l=J5e+c;if(!(Dt.existsSync(i)&&Dt.readFileSync(i,"utf8")===l)){Dt.mkdirSync(r,{recursive:!0}),Dt.writeFileSync(i,l),ee(`Persisted inputs to ${i}`);for(let u of n)Dt.existsSync(u)&&(Dt.unlinkSync(u),P(`Removed legacy ${Xe.basename(u)} (superseded by workspace.yml)`))}}s(jle,"writeWorkspaceConfig");var Y5e=/^[a-z0-9]+(-[a-z0-9]+)*$/;function X5e(e,t){let r=(e||"").trim().toLowerCase(),i=(t||"").trim().toLowerCase();return i?`${i}-${r}`:r}s(X5e,"buildWorkspaceName");function Q5e(e,t){return`${e}/${t}`}s(Q5e,"buildBranchName");function Cle(){return Ho()}s(Cle,"resolveReposRoot");function Nle(){let e=p$().workspaces_root;return e?Xe.resolve(vn(e)):Xe.resolve(Xe.join(Uf.homedir(),"workspace"))}s(Nle,"resolveWorkspacesRoot");function eBe(e,t,r){let i=Cle(),n=Xe.join(i,Nf);if(P(`Workspace: ${e}`),P(`Branch: ${t}`),Dt.existsSync(Xe.join(n,".git"))){let o=d$()||ile(),a=o?nle(n,rle(o)):null;a!==null&&Fi(`${n}'s origin is ${a||"unset"}, but the configured workspace repo is ${o} \u2014 this workspace's record would push to the wrong repo. Run \`werkmeister machine setup\` to repoint it, then rerun.`);try{Hz(n,e,t,{force:r})}catch(c){Fi(`Failed to create workspace root worktree: ${c.message}`)}ee(`Created workspace root (worktree of ${Nf}) at ${e}`)}else N(`No '${Nf}' repo at ${n} \u2014 workspace root will be a plain directory (no git history for notes/config).`),Dt.mkdirSync(e,{recursive:!0})}s(eBe,"createWorkspaceRoot");function tBe(e,t){if(Dt.existsSync(Xe.join(e,".git")))try{if(re(["git","-C",e,"add","-A"],{capture:!0,check:!0}),re(["git","-C",e,"diff","--cached","--quiet"],{capture:!0}).status===0)return;re(["git","-C",e,"commit","-q","-m",`chore: initialize workspace ${t}`],{capture:!0,check:!0}),ee("Committed initial workspace state (branch not pushed \u2014 push when ready).")}catch(r){N(`Could not commit initial workspace state: ${r.message}`)}}s(tBe,"commitWorkspaceState");function Lle(){for(let e of Lv({generatedOnly:!0}))e.ok?e.detail.startsWith("generated")&&P(`Registry: ${e.detail}`):N(`Registry not refreshed: ${e.detail}`)}s(Lle,"refreshRegistry");async function rBe(e,t){let r=Le(),[i,,n]=Bz(e??null,t??null,r);return n.length&&Fi(`Unknown service(s): ${n.join(", ")}. See \`werkmeister feature services\` / config/services.yaml.`),i.length||Fi("No repos selected. Choose at least one service or repo in the wizard, or pass --services svc1,svc2 / --repos r1,r2."),i}s(rBe,"selectRepos");function nBe(){let e=Xe.resolve(process.cwd()),t=EM(e,h2());if(t!==null)return t;for(let i of[e,...iBe(e)])if(Dt.existsSync(Xe.join(i,".git")))return Xe.dirname(i);let r=h2().join(", ");throw new W6(`${me.RED}[err] Not inside a workspace (checked: ${r}) and no parent \`.git\` directory found.
1165
+ `;function jle(e,t){if(Object.keys(t).length===0)return;let r=J(e),i=Xe.join(r,Pc[0]),n=Pc.slice(1).map(u=>Xe.join(r,u)),o={};for(let u of[i,...n])if(Dt.existsSync(u)&&Dt.statSync(u).isFile())try{let p=wf(u);if(typeof p=="object"&&p!==null&&!Array.isArray(p)){o=p;break}}catch{}delete o._generator,delete o.$schema;let a={...o};for(let[,,u]of xf)if(u in t){let p=t[u];if(V5e.has(u)&&typeof p=="string"&&(p=K5e(p)),(u==="autonomous"||u==="auto_stop")&&(p=p==="true"),u==="auto_stop"&&p===!1&&!(u in o))continue;a[u]=p}let c=Ale.stringify(a,{sortMapEntries:!0,blockQuote:"literal"}),l=J5e+c;if(!(Dt.existsSync(i)&&Dt.readFileSync(i,"utf8")===l)){Dt.mkdirSync(r,{recursive:!0}),Dt.writeFileSync(i,l),ee(`Persisted inputs to ${i}`);for(let u of n)Dt.existsSync(u)&&(Dt.unlinkSync(u),P(`Removed legacy ${Xe.basename(u)} (superseded by workspace.yml)`))}}s(jle,"writeWorkspaceConfig");var Y5e=/^[a-z0-9]+(-[a-z0-9]+)*$/;function X5e(e,t){let r=(e||"").trim().toLowerCase(),i=(t||"").trim().toLowerCase();return i?`${i}-${r}`:r}s(X5e,"buildWorkspaceName");function Q5e(e,t){return`${e}/${t}`}s(Q5e,"buildBranchName");function Cle(){return Ho()}s(Cle,"resolveReposRoot");function Nle(){let e=p$().workspaces_root;return e?Xe.resolve(vn(e)):Xe.resolve(Xe.join(Uf.homedir(),"workspace"))}s(Nle,"resolveWorkspacesRoot");function eBe(e,t,r){let i=Cle(),n=Xe.join(i,Nf);if(P(`Workspace: ${e}`),P(`Branch: ${t}`),Dt.existsSync(Xe.join(n,".git"))){let o=d$()||ile(),a=o?nle(n,rle(o)):null;a!==null&&Fi(`${n}'s origin is ${a||"unset"}, but the configured workspace repo is ${o} \u2014 this workspace's record would push to the wrong repo. Run \`werkmeister machine setup\` to repoint it, then rerun.`);try{Hz(n,e,t,{force:r})}catch(c){Fi(`Failed to create workspace root worktree: ${c.message}`)}ee(`Created workspace root (worktree of ${Nf}) at ${e}`)}else N(`No '${Nf}' repo at ${n} \u2014 workspace root will be a plain directory (no git history for notes/config).`),Dt.mkdirSync(e,{recursive:!0})}s(eBe,"createWorkspaceRoot");function tBe(e,t){if(Dt.existsSync(Xe.join(e,".git")))try{if(re(["git","-C",e,"add","-A"],{capture:!0,check:!0}),re(["git","-C",e,"diff","--cached","--quiet"],{capture:!0}).status===0)return;re(["git","-C",e,"commit","-q","-m",`chore: initialize workspace ${t}`],{capture:!0,check:!0}),ee("Committed initial workspace state (branch not pushed \u2014 push when ready).")}catch(r){N(`Could not commit initial workspace state: ${r.message}`)}}s(tBe,"commitWorkspaceState");function Lle(){for(let e of Lv({generatedOnly:!0}))e.ok?e.detail.startsWith("generated")&&P(`Registry: ${e.detail}`):N(`Registry not refreshed: ${e.detail}`)}s(Lle,"refreshRegistry");async function rBe(e,t){let r=Le(),[i,n,o]=Bz(e??null,t??null,r);return o.length&&Fi(`Unknown service(s): ${o.join(", ")}. See \`werkmeister feature services\` / config/services.yaml.`),!i.length&&!n.length&&Fi("No repos selected. Choose at least one service or repo in the wizard, or pass --services svc1,svc2 / --repos r1,r2."),i}s(rBe,"selectRepos");function nBe(){let e=Xe.resolve(process.cwd()),t=EM(e,h2());if(t!==null)return t;for(let i of[e,...iBe(e)])if(Dt.existsSync(Xe.join(i,".git")))return Xe.dirname(i);let r=h2().join(", ");throw new W6(`${me.RED}[err] Not inside a workspace (checked: ${r}) and no parent \`.git\` directory found.
1166
1166
  The workspaces root comes from ~/.werkmeister/config.yaml \u2014 run \`werkmeister machine config --write\` to set it (or \`werkmeister machine config --check\` to verify). See docs/known-issues.md for details.${me.RESET}`)}s(nBe,"findWorkspaceRoot");function iBe(e){let t=[],r=e;for(;;){let i=Xe.dirname(r);if(i===r)break;t.push(i),r=i}return t}s(iBe,"ancestors");function Dle(e){let r=re(["git","-C",e,"branch","--show-current"],{capture:!0}).stdout.trim();return r||re(["git","-C",e,"rev-parse","--short","HEAD"],{capture:!0}).stdout.trim()||"unknown"}s(Dle,"getBranch");function zle(e){return ru(e).map(t=>[Xe.basename(t),Dle(t)])}s(zle,"discoverRepos");function oBe(e){if(Dt.existsSync(Xe.join(e,".git"))){let t=Dle(e);if(t&&t!=="unknown")return t}return`${Z5e()}/${Xe.basename(e)}`}s(oBe,"workspaceBranch");function sBe(e,t,r){let i=Ho(),n=t.filter(m=>m!==Nf),o=new Set(n),a=new Set(zle(e).map(([m])=>m)),c=n.filter(m=>!a.has(m)),l=[...a].filter(m=>!o.has(m)).sort(),u=c.filter(m=>!W5e(Xe.join(i,m)));if(u.length&&Fi(`Source repo(s) not found under ${i}: ${u.join(", ")}. Clone them there (or fix \`repos\` in .werkmeister/workspace.yml) and rerun.`),l.length&&!r){let m=l.filter(h=>Koe(Xe.join(e,h)));m.length&&Fi(`Refusing to remove worktree(s) with uncommitted changes: ${m.join(", ")}. Commit or stash them, or rerun with --force to discard them.`)}if(!c.length&&!l.length)return;let p=oBe(e);for(let m of l){let[h,y]=Wz(Xe.join(i,m),Xe.join(e,m),p);h?(ee(`Removed worktree '${m}' (no longer in workspace.yml).`),y&&N(y)):Fi(`Could not remove worktree '${m}': ${y}`)}let d=[];try{for(let m of c){let h=Xe.join(i,m),y=Xe.join(e,m);Hz(h,y,p,{force:r}),d.push([y,h])}}catch(m){let h=`Failed to create worktree: ${m.message}`;he(h),N("Rolling back worktrees created this run...");for(let[y,g]of[...d].reverse())Wz(g,y,p);throw new yo(h)}(c.length||l.length)&&ee(`Worktrees reconciled (+${c.length} / -${l.length}).`)}s(sBe,"reconcileWorktrees");function aBe(e,t,r){if(e)return[e.trim(),{}];let i=r?.().trim();return i?[i,{}]:[Fz(t),{}]}s(aBe,"resolveTask");function cBe(e){if(!Dt.existsSync(e))return;Dt.readFileSync(e,"utf8").includes("## Layout")?N("CLAUDE.md already initialised \u2014 overwriting with fresh content."):P("Replacing stub CLAUDE.md with full workspace context.")}s(cBe,"warnIfExisting");function lBe(e,t){P(`Task: ${e}`);for(let[r,i]of[["FEATURE","Feature"],["SERVICES","Services"],["ISSUE_ID","Issue"],["TEST_PATH","Test path"]]){let n=t[r];n&&P(` ${(i+":").padEnd(10)} ${n}`)}}s(lBe,"logMeta");async function Z6(e,t,r={}){let i=t??nBe(),n=Xe.basename(i);P(`Workspace root: ${i}`),Lle();let o=bv(e,i),a=IM(LE(o.context_strategy));!G5e(i,e.config_file??null)&&!o.feature&&Fi("No .werkmeister/workspace.yml found and no --feature given. Run `werkmeister workspace new <name>` to create and initialise a workspace, then rerun `werkmeister workspace init` from inside it to reconcile changes."),jle(i,o);let l=o.project??"",u=o.issue_id?dt({project:l,text:o.issue_id}).parseRef(o.issue_id)??o.issue_id:"",p;try{p=await H5e(i,u,{issue:r.issue,refresh:!!e.refresh_issue,project:l})}catch(U){throw U instanceof yo&&Fi(U.message),U}if(o.repos){let[U]=ri(),[se,,R]=Bz(o.repos,o.services,U);R.length&&N(`Unknown service(s) in workspace.yml (no owning repo): ${R.join(", ")}`),sBe(i,se,!!e.force)}let d=Xe.join(i,"CLAUDE.md");cBe(d),P("Scanning for git repos...");let m=zle(i);if(!m.length)N("No git repos found in workspace. CLAUDE.md will have an empty layout.");else{for(let[U,se]of m)P(` ${U}/ \u2192 ${se}`);Voe(i,m.map(([U])=>U))}let[h,y]=aBe(o.task,n,r.readStdinTask),g={feature:"FEATURE",services:"SERVICES",issue_id:"ISSUE_ID",test_path:"TEST_PATH",description:"DESCRIPTION"};for(let[U,se]of Object.entries(g))U in o&&(y[se]=o[U]);lBe(h,y);let v=Xe.join(i,".env");Xoe(v,y),ee(`Wrote ${v}`),ee(`Wrote ${Uoe(i)}`),a.init({workspaceRoot:i,workspaceName:n,repos:m,task:h,meta:y,inputs:o,configOverride:e.config??null,issue:p,isCreate:!!r.issue});for(let U of Un)U!==a.id&&uae(i,IM(U),a,!!e.prune_context);let[x,k]=ri(),_=ar(),$=_$(m,y,x,k,_),E=iQ();for(let U of Ile(_,E))N(U);let O=(y.FEATURE??"").trim(),C=Ple(i,Rle($,_),E,O?{FEATURE:O}:{});C&&ee(`Wrote ${C}`),Ite(n,i),ee(`Workspace token: ${Xe.relative(i,Ly(i))}`);let j=Tle({workspaceName:n,workspaceRoot:i,workspacesRoot:Nle(),reposRoot:Cle(),home:Uf.homedir(),port:My()});ee(`Wrote ${Xe.relative(i,j)}`);for(let U of O6())N(U);let q=(y.FEATURE??"").trim();if(q&&await nse(q,y.SERVICES??"",i,(y.TEST_PATH??"").trim(),m.map(([se])=>se))!==null&&r.build!==!1){P("Building Docker images (--no-start)...");let se=Dd(),R=Xe.join(i,Ke);C2(R),P2(q,R);let K=re(I2(q,["up","--build","--no-start"],R),{cwd:i,...se?{stdio:"inherit"}:{capture:!0}});se||(K.stdout&&ge(K.stdout),K.stderr&&ge(K.stderr,"stderr")),K.status===0?ee("Docker images built successfully."):N("docker compose build exited non-zero \u2014 images may be incomplete.")}ge(`
1167
1167
  ${me.BOLD}Workspace initialised.${me.RESET} Open a new Claude Code session from the workspace root to pick up the context.
1168
1168
 
Binary file
@@ -163,7 +163,10 @@ services:{% if not local_services | length %} {}{% endif %}
163
163
  com.werkmeister.slot: "{{ slot }}"
164
164
  com.werkmeister.service: "{{ svc.name }}"
165
165
  com.werkmeister.role: "app"
166
+ {# SW-230: no repo = image-only: no /app mount, the image's own workdir and CMD. #}
167
+ {% if svc.repo %}
166
168
  working_dir: /app
169
+ {% endif %}
167
170
  {% if idle %}
168
171
  restart: on-failure:3
169
172
  {# `sleep` as PID 1 ignores SIGTERM, so stop would wait out compose's 10 s. #}
@@ -171,9 +174,14 @@ services:{% if not local_services | length %} {}{% endif %}
171
174
  {% else %}
172
175
  restart: unless-stopped
173
176
  {% endif %}
177
+ {# A bare `volumes:` is YAML null, which compose rejects. #}
178
+ {% if svc.repo or svc.node_modules_volume or svc.extra_volumes | length or svc.dev_links | length %}
174
179
  volumes:
180
+ {% endif %}
181
+ {% if svc.repo %}
175
182
  - {{ workspace_path }}/{{ svc.repo }}:/app
176
- {% if svc.worktree_gitdir %}
183
+ {% endif %}
184
+ {% if svc.repo and svc.worktree_gitdir %}
177
185
  - {{ svc.worktree_gitdir }}:{{ svc.worktree_gitdir }}:ro
178
186
  {% endif %}
179
187
  {% if svc.node_modules_volume %}
@@ -211,7 +219,14 @@ services:{% if not local_services | length %} {}{% endif %}
211
219
  - "{{ key }}={{ value }}"
212
220
  {% endfor %}
213
221
  {% endif %}
214
- {% if svc.command or idle %}
222
+ {# Image-only: the image may have no git, so no token preamble. #}
223
+ {% if not svc.repo and svc.command %}
224
+ command:
225
+ - /bin/sh
226
+ - -c
227
+ - |
228
+ {{ svc.command }}
229
+ {% elif svc.command or idle %}
215
230
  command:
216
231
  - /bin/sh
217
232
  - -c
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "werkmeister",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Multi-feature concurrent development orchestrator CLI tool",
6
6
  "type": "module",
@@ -118,8 +118,8 @@
118
118
  "typescript": "^5.7.0",
119
119
  "vitest": "^3.0.0",
120
120
  "yaml": "^2.7.0",
121
- "werkmeister-core": "0.57.0",
122
- "werkmeister-mcp": "0.8.5"
121
+ "werkmeister-core": "0.58.0",
122
+ "werkmeister-mcp": "0.8.6"
123
123
  },
124
124
  "scripts": {
125
125
  "build": "node esbuild.mjs",