werkmeister 0.85.5 → 0.85.7
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 +24 -19
- package/dist/mcp.js +220 -215
- package/dist/werkmeister-workspaces.vsix +0 -0
- package/man/werkmeister-feature-test.1 +1 -1
- package/man/werkmeister-feature-up.1 +2 -2
- package/man/werkmeister-machine-migrate.1 +1 -1
- package/man/werkmeister-machine-tokens.1 +1 -1
- package/man/werkmeister-pr.1 +1 -1
- package/package.json +3 -3
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 wee=Object.create;var eg=Object.defineProperty;var xee=Object.getOwnPropertyDescriptor;var kee=Object.getOwnPropertyNames;var bee=Object.getPrototypeOf,vee=Object.prototype.hasOwnProperty;var i=(e,t)=>eg(e,"name",{value:t,configurable:!0}),oe=(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 A=(e,t)=>()=>(e&&(t=e(e=0)),t);var T=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ie=(e,t)=>{for(var r in t)eg(e,r,{get:t[r],enumerable:!0})},See=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of kee(t))!vee.call(e,s)&&s!==r&&eg(e,s,{get:()=>t[s],enumerable:!(n=xee(t,s))||n.enumerable});return e};var Oe=(e,t,r)=>(r=e!=null?wee(bee(e)):{},See(t||!e||!e.__esModule?eg(r,"default",{value:e,enumerable:!0}):r,e));var v,h=A(()=>{v={sha:"
|
|
4
|
+
var wee=Object.create;var eg=Object.defineProperty;var xee=Object.getOwnPropertyDescriptor;var kee=Object.getOwnPropertyNames;var bee=Object.getPrototypeOf,vee=Object.prototype.hasOwnProperty;var i=(e,t)=>eg(e,"name",{value:t,configurable:!0}),oe=(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 A=(e,t)=>()=>(e&&(t=e(e=0)),t);var T=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ie=(e,t)=>{for(var r in t)eg(e,r,{get:t[r],enumerable:!0})},See=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of kee(t))!vee.call(e,s)&&s!==r&&eg(e,s,{get:()=>t[s],enumerable:!(n=xee(t,s))||n.enumerable});return e};var Oe=(e,t,r)=>(r=e!=null?wee(bee(e)):{},See(t||!e||!e.__esModule?eg(r,"default",{value:e,enumerable:!0}):r,e));var v,h=A(()=>{v={sha:"3fcf3c24364c11c317313817bd01d0e5ac0638e3",dirty:!1}});var Hd=T(hS=>{h();var tg=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}},pS=class extends tg{static{i(this,"InvalidArgumentError")}constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};hS.CommanderError=tg;hS.InvalidArgumentError=pS});var rg=T(gS=>{h();var{InvalidArgumentError:Eee}=Hd(),mS=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 Eee(`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 $ee(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}i($ee,"humanReadableArgName");gS.Argument=mS;gS.humanReadableArgName=$ee});var xS=T(wS=>{h();var{humanReadableArgName:Oee}=rg(),yS=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=>Oee(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(w=>o(r.styleOptionTerm(r.optionTerm(w)),r.styleOptionDescription(r.optionDescription(w))));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(w=>o(r.styleSubcommandTerm(r.subcommandTerm(w)),r.styleSubcommandDescription(r.subcommandDescription(w))));a=a.concat(this.formatItemList(p,m,r))}),a.join(`
|
|
5
5
|
`)}displayWidth(t){return jI(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(`
|
|
@@ -619,7 +619,7 @@ ${J4}
|
|
|
619
619
|
${V$}`}function Y$(e){let t=[e.issueId,e.task].filter(Boolean).join(" ")||e.name,r=t.lastIndexOf(" ",58);return{title:t.length<60?t:`${t.slice(0,r>40?r:58).trimEnd()}\u2026`,...e.model?{model:e.model}:{},prompt:Q4(e.autonomous),background:`Workspace \`${e.name}\`${e.issueId?` for ${e.issueId}`:""}. Read \`CLAUDE.md\`, then \`.werkmeister/issue.md\`; its routing table picks the stage.`}}var J4,V$,Pw,X4,ece,tce,rce,Iw=A(()=>{"use strict";h();J4="This is an interactive run: check with me at each stage's human check.",V$="Run `werkmeister feature up` only when the gate needs it, and `werkmeister feature stop` this workspace's containers right after `werkmeister pr open` succeeds.",Pw=["Tests never call the real Jira or GitHub APIs; the tracker is mocked. The only real issue updates are the status moves `werkmeister issue start` and `werkmeister pr open` make for this ticket and its `group:` members; run both.","Never read or write the real `~/.werkmeister`; tests use a temporary HOME. To see the machine config's shape run `werkmeister machine config`: it masks secrets such as `jira.api_token`.","No `npm link`, `npm`/`pnpm install -g`, `npm publish`, `werkmeister infra proxy-reload`, and no other workspaces.",'Where the ticket says "to confirm", use it as written unless the code shows a reason to change it, and record each choice in the stage output for PR review.',V$].map(e=>`- ${e}`).join(`
|
|
620
620
|
`),X4=[[/werkmeister registry sync/,"- Registry sync: the next `werkmeister registry sync` after merge picks up the change; the gate reads the branch's own `.werkmeister/services.yaml` fragment."],[/werkmeister infra proxy-reload/,"- Proxy reload: the next `werkmeister infra proxy-reload` after merge applies the change."],[/(?:npm|pnpm|yarn) link\b/,"- Linking the CLI: after merge, if at all; the run runs the built binary with `node`."],[/(?:(?:npm|pnpm|yarn) (?:install|i|add)\b[^`\n]*?(?: -g\b| --global\b)|yarn global add\b)/,"- Global installs: after merge, if at all; the run uses the workspace's own install."]],ece=i(e=>new RegExp(`(?:^|(?<!["\u201C'])\\brun )\`?${e.source}`,"i"),"stepRe"),tce=X4.map(([e])=>ece(e)),rce=/^(\s*(?:[-*]|\d+\.) +(?:\[[ x]\] +)?)?(.*)$/;i(gh,"deferMachineSteps");i(Q4,"startPrompt");i(Y$,"buildStartArgs")});import*as xo from"node:fs";import*as gi from"node:path";function e5(e){return gi.join(W(e),"graduations.yml")}function Z4(e){try{let t=Nw.parse(xo.readFileSync(e5(e),"utf8"));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}catch{return{}}}function ice(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"decision"}function ace(e){let t=gi.join(e,"stages"),r;try{r=xo.readdirSync(t).sort()}catch{return[]}return r.flatMap(n=>{let s=gi.join(t,n,"output");try{return xo.readdirSync(s).filter(o=>o.endsWith(".md")).sort().map(o=>gi.join(s,o))}catch{return[]}})}function cce(e,t){let r=e.split(`
|
|
621
621
|
`),n=0;if(r[0]==="---"){let l=r.indexOf("---",1);l!==-1&&(n=l+1)}let s=[],o=new Set,a=!1;for(let l=n;l<r.length;l++){if(oce.test(r[l])){a=!a;continue}if(a)continue;let u=sce.exec(r[l]);u?s.push({at:l,level:u[1].length,title:u[2]}):nce.test(r[l].trim())&&o.add(s.length-1)}s.length&&o.delete(-1);let c=new Map;return[...o].map(l=>{let u=s[l],f=u?s.slice(l+1).find(w=>w.level<=u.level):s[0],d=ice(u?u.title:t),p=(c.get(d)??0)+1;c.set(d,p),p>1&&(d=`${d}-${p}`);let m=r.slice(u?u.at:n,f?f.at:r.length).join(`
|
|
622
|
-
`);return{slug:d,body:m}})}function z$(e,t){return gi.relative(e,t.path)}var Nw,nce,sce,oce,t5,r5=A(()=>{"use strict";h();Nw=Oe(Ye(),1);Kr();nce=/^status:\s*decided\b/,sce=/^(#{1,6})\s+(.+?)\s*#*$/,oce=/^\s*(```|~~~)/;i(e5,"statePath");i(Z4,"readState");i(ice,"slugify");i(ace,"outputFiles");i(cce,"decidedSections");i(z$,"decisionId");t5={open(e){let t=Z4(e),r=[],n=0;for(let s of ace(e)){let o=cce(xo.readFileSync(s,"utf8"),gi.basename(s,".md"));for(let{slug:a,body:c}of o){n+=1;let l={path:`${s}#${a}`,number:n,type:"decision",slug:a,frontmatter:{},body:c},u=t[z$(e,l)]??{};l.frontmatter={type:"decision",status:"decided",refs:[],...u},!["graduated","superseded"].includes(l.frontmatter.status)&&r.push(l)}}return r},mark(e,t,r){let n=Z4(e),s=z$(e,t);n[s]={...n[s],...r},xo.mkdirSync(W(e),{recursive:!0}),xo.writeFileSync(e5(e),Nw.stringify(n))},cite:i((e,t)=>`decision ${String(t.number).padStart(3,"0")}, see ${z$(e,t)}`,"cite")}});function sf(e){let t=e.trim().toLowerCase();return Object.hasOwn(J$,t)?J$[t]:J$.feature}function js(e){return e.map((t,r)=>`${String(r+1).padStart(2,"0")}_${t.name}`)}function i1(e){let t=e.findIndex(r=>r.name==="propose");return t<0?null:js(e)[t]}function jw(e){return i1(e)??js(e)[e.length-1]}var X$,Q$,Z$,o5,i5,lce,a5,c5,l5,e1,t1,r1,yh,u5,n1,uce,f5,d5,p5,wh,xh,h5,m5,s1,n5,o1,fce,s5,dce,pce,J$,a1=A(()=>{"use strict";h();An();Cw();X$="If the container is not running, run `werkmeister feature up` once first; `docker restart` only reloads one that is already running. Never run `werkmeister feature restart` or `werkmeister workspace init` to reload \u2014 they are slower, and init rewrites the stage contracts.",Q$="A library or CLI has no service to restart: build it, then exercise the built artifact exactly as its Validation text in `werkmeister-context.md` \xA7 How to validate says.",Z$=["Confirm ponytail is active (see `_shared/standards.md`; invoke the skill only if it is not), then read the standards rows above. Restate the rule you are applying beside each edit."],o5="If the repo uses biome (`biome.json` or `biome.jsonc`), first run `pnpm exec biome check --write <the files you touched>` (never a folder), so formatting lands in the ticket's own commit. Run the test command exactly as `../../.werkmeister/werkmeister-context.md` states it: through `.werkmeister/bin/with-temp-home`, which gives it a fresh temporary HOME \u2014 never hand-roll `HOME=\u2026`. That run is on the host, without the container's env (`HOST`, `WERKMEISTER_SLOT`, `NODE_ENV`, `<SVC>_URL`, \u2026), and the PR gate runs the same commands in the workspace container. When a service's How-to-validate text in `werkmeister-context.md` says to run in its container (`docker exec`), follow that text instead: starting this workspace's own container with `werkmeister feature up --service <name>` is expected for it and allowed. ",i5='A subagent you brief to run tests or the CLI gets that wrapped command verbatim in its brief. A skipped test is not a pass: name each one with its skip reason, and run it where it can run (the workspace container) or say where it will (the gate, CI). Redirect output to a file as one group, so every command in an `&&` chain lands there. For a background job (`run_in_background`) write background: `{ <test command>; } > <log> 2>&1` and read the exit code from the job\'s completion notice; for a foreground call write foreground: `{ <test command>; } > <log> 2>&1; echo "exit $?"`. Read back only the failing slice.',lce=o5+"Once it passes, run `werkmeister pr gate --tests` (from the workspace, detached when it may pass 10 minutes) and fix what it fails; record both exit codes. "+i5,a5=`${o5}Record its exit code. ${i5}`,c5="Once the review's fixes are in, run `werkmeister pr gate --tests` (from the workspace, detached when it may pass 10 minutes) and fix what it fails; record its exit code. A fix here reruns the host test step first.",l5="If the exercise below changes code, rerun the review on that delta: a fresh subagent with the same brief, over the commits and changes made since the first review. Fix its **Must fix** findings, rerun the host test step, and append the result as new rows to `output/review.md`; the gate's review row covers them.",e1=i(e=>`Before running tests, read \`git diff\` in each repo you touched and tick off each edit \`${e}\` settled against it: an edit reported as applied can be missing.`,"diffCheck"),t1="Before asking for approval, list the exercise rows only a person can run (a real VS Code window, a device, a browser). Ask the person for each one's result, one question per row (pass / fail / not run), and write the answer into `exercise.md`: PASS or FAIL in the table, and for a row not run a `MANUAL: not run (person's reason)` line under it (the table's result cell stays PASS or FAIL). An approval that skips this keeps those rows MANUAL, and the PR file says why.",r1="every skipped test by name with its skip reason and where it ran instead",yh=i(e=>e.map(t=>`\`${t}\``).join(", "),"keys"),u5="`git commit --fixup <sha>`, then `git rebase --autosquash $(git merge-base HEAD origin/main)`",n1=i(e=>e.group.length?[`This workspace is a grouped PR (\`group\` in \`workspace.yml\`): one commit per ticket, for the workspace's issue and each member, ${yh(e.group)}, so each can be reverted alone. Take the tickets one at a time: make that ticket's changes and tests, run the diff check below on them, then commit on the worktree's branch with a message that starts with its key (\`<KEY> <summary>\`) before starting the next. Each commit builds and passes the host tests on its own. A ticket that changes a released package carries its release entry (changeset) in its own commit. When a ticket's change alters a generated snapshot (e.g. \`strategy-jit.snapshot.json\`), regenerate it in that ticket's commit, so the commit passes the snapshot test alone; a brief that says to regenerate once for the whole PR does not override this. Commit order across tickets is free; a ticket whose change depends on another's evidence (a measurement) can come last. Never reorder commits to match the spec.`]:[],"groupStep"),uce="a `| criterion | result | evidence |` table whose result cell is exactly `PASS` or `FAIL` \u2014 nothing else in the cell \u2014 with the proof in the evidence column",f5=i((e,t)=>`Review the diff: for each code worktree you touched, start a fresh subagent and brief it with only the worktree path and "run the \`ponytail:ponytail-review\` skill over this worktree's ${t.length?"commits in `origin/main...HEAD` (the PR's base in place of `main` when it differs), plus any uncommitted changes and untracked files":"uncommitted changes, untracked files included"}" \u2014 not how you built it, so the review is not anchored on your reasoning. If the change adds or widens an allow rule or another pre-approved command, add to the brief: "this change pre-approves a command: list every file, env var, network address or process it can reach from its arguments, and treat each that leaves the workspace or its temp HOME as Must fix". Always add: "any finding where the change can restart or write the host daemon, the real \`~/.werkmeister\` or another workspace, whether through an allow rule, a script or a test, is Must fix". Fix every **Must fix** finding in place, and any **Should fix** finding that shows the change's own docs, comments, help text or changeset state something false (fix the code, or reword that text so it is true), ${t.length?`fold each fix into the commit of the ticket it belongs to (${u5}), `:""}then ${e}. Leave the other **Should fix** and **Nice to have** findings as they are. Write \`output/review.md\`: per worktree, the findings as the review grouped them, each marked \`fixed\` or \`left: <why>\`, then ${uce}, with one row per worktree (\`PASS\` means no Must fix left open). The PR gate refuses to open a PR while \`review.md\` is missing or has a row that is not \`PASS\`; a file of prose alone fails with \`has no PASS row\`.`,"reviewStep"),d5=i(e=>f5("rerun the host test step above",e.group),"implementReview"),p5='For each decision that renames, keeps or removes a name, a fallback or an alias, record its definition site (file and line) and the commit that introduced it (`git log -S <name>`, in the repo that defines it). When that commit marks it as a transition or legacy alias, list "remove" as an option beside rename and keep.',wh=i((e,t)=>`${t} Then change \`status: proposed\` at the top of \`output/${e}\` to \`status: decided\`: that flip is the approval, and the next session starts without asking again. ${wo}`,"statusGate"),xh=", its first line `status: proposed`",h5=i(e=>e?`Ask this check through \`${e}\`: at most 4 questions per call (more than 4: batches of 4, one call after another), each standing on its own (what was checked, 2\u20133 concrete options with the exact wording or behaviour, the recommended one first; "Other" takes edits). Write each answer into the output file as its status, noted \`${mi.chat}\` (a PR file: \`${mi.chatPr}\`). A check left as a sentence at the end of a reply is not asked.`:`Ask this check as one numbered block at the end of your reply: each question stands on its own, options lettered with the recommended one first, then "reply with the letters, or your edits". Write each answer into the output file as its status, noted \`${mi.chat}\` (a PR file: \`${mi.chatPr}\`).`,"askLine"),m5="Review `output/` once against `../../BRIEF.md` and the live issue (`werkmeister issue view`). Flip every `status: proposed` to `status: decided` yourself, and record each decision \u2014 and anything you would have asked a person \u2014 under `## Recommendations for reviewer` in the PR body. Then start the next stage without asking.",s1=i(e=>`a \`| check | result | ${e} |\` table whose result cell is exactly \`PASS\` or \`FAIL\` \u2014 nothing else in the cell \u2014 with the captured output in the ${e} column. The rule holds for every table in \`exercise.md\`; describe a superseded run in prose, not as a \`FAIL\` row`,"exerciseFormat"),n5="the repo's lint command (the `&& <lint>` tail of the test command in `werkmeister-context.md`, when it has one, which the PR gate's lint row runs) and fix what it fails, release entry included.",o1={name:"propose",job:"acceptance walk and PR files",writes:"the code commits (one per repo, or one per ticket in a grouped PR), `output/pr-<worktree>.md` per repo",check:"approve each PR file; `werkmeister pr open` opens it",standards:"none",contract:i(e=>({oneJob:`One job: prove each acceptance criterion, ${e.group.length?"check the per-ticket commits in":"commit in"} each code worktree, and write one PR file per repo touched. ${e.autonomous?"You approve it after the self-check":"Approving is the person's act"}; opening is \`werkmeister pr open\`.`,inputs:["Working (this run): `../../BRIEF.md` \xA7 Acceptance criteria","Working (this run): `../*/output/` \u2014 every prior stage's artifacts","Working (this run): `git status` and `git diff --stat` in each repo you touched","Reference (every run): `../../_shared/pr-rules.md` \u2014 the PR file format and the gate"],doNotLoad:"`_shared/standards.md` (no code is written here), source files, `.werkmeister/`.",process:["Walk every acceptance criterion in `BRIEF.md`. For each, write a row whose result cell is exactly PASS or FAIL (MANUAL for a criterion only the reviewer can check, e.g. it needs a real PR or the desktop app, with why in the evidence; never PASS for a check nobody ran), with the file and line in a prior `output/` that proves it in a separate evidence column. A FAIL routes back to the owning stage \u2014 do not fix it here.",e.group.length?`The commits are already made, one per ticket: keep them, never squash to one per repo. For a repo with \`ship: tag\` and a \`release_check\` in the registry, write the release entry it needs (e.g. a changeset). Run ${n5} Then fold everything uncommitted into its ticket's commit (${u5}), each ticket's release entry into that ticket's own commit, and check that \`git log --oneline origin/main..HEAD\` in each worktree shows one commit per ticket (the workspace's issue and ${yh(e.group)}), each message starting with its key.`:`In each code worktree you touched (\`git -C <repo>\`), commit on its branch with a message that names the change, not the stage. For a repo with \`ship: tag\` and a \`release_check\` in the registry, add the release entry it needs (e.g. a changeset) in the same commit. Before committing, run ${n5}`,"Before the PR file: for each follow-up a decided question in `decisions.md` promises, file it through `../../_shared/issues-report.md` and write its issue key beside that decision. The gate's follow-ups check stays as the backstop.","Write `output/pr-<worktree>.md` per repo touched, in the format of `_shared/pr-rules.md`, at `status: draft`, with `repo:` taken from `git -C <worktree> remote get-url origin` (as `owner/repo`; the gate rejects any other value). Title: `<type>(<scope>): <ISSUE-ID> <summary>`. Body: summary, the test and exercise results from prior outputs (every table with a `result` column \u2014 the gate reads them all \u2014 has a result cell of exactly `PASS` and the output in its own column: a FAIL cell anywhere in the PR file stops the PR, so describe a pre-fix reproduction in prose, not as a FAIL row), the acceptance table from step 1, and `Fixes <issue>` when the tracker is GitHub."+(e.group.length?" Start the body with `Rebase and merge, not squash: one commit per ticket, each revertable alone.` and list each member under the summary.":""),"Commit and push this folder's branch \u2014 the record. Never open a PR for it."],outputs:[e.group.length?"The per-ticket commits, kept, on each worktree's branch":"One commit per code repo touched, on that worktree's branch","`output/pr-<worktree>.md` per repo"],humanCheck:`Read each \`pr-*.md\`. Set \`status: approved\` on each one to open \u2014 that flip is the approval. Then \`werkmeister pr open\`, run detached as \`_shared/pr-rules.md\` rule 3 shows, runs the gate and opens it. Merging is yours. After the release, \`werkmeister pr status\`, then ${e.group.length?`check each member reads Done \u2014 \`werkmeister issue view <KEY>\` for ${yh(e.group)}; \`pr status\` moves them with the workspace's issue, so move one by hand only if it didn't \u2014 then `:""}the post-mortem (\`postmortem\` skill), then ask the person before \`werkmeister workspace close\`. Code written after a PR merged (e.g. found at release) is a follow-up: \`werkmeister pr new <worktree> --slug <slug>\`. ${wo}`,selfCheck:"Review each `pr-*.md` once against `../../BRIEF.md` and the live issue. Add `## Recommendations for reviewer` to its body \u2014 every decision and question collected on the way \u2014 then set `status: approved` yourself and run `werkmeister pr open` detached, as `_shared/pr-rules.md` rule 3 shows. Stop at the PR URL. Merging is the person's."+(e.group.length?` When the PR ships, check each member reads Done (\`werkmeister issue view <KEY>\` for ${yh(e.group)}) before the post-mortem; \`pr status\` moves them with the workspace's issue, so move one by hand only if it didn't.`:"")}),"contract")},fce=[{name:"research",job:"inventory the code, surface decisions",writes:"`output/inventory.md`, `output/decisions.md`",check:"answer every open question in `decisions.md`",standards:"none",contract:i(e=>({oneJob:"One job: establish what the code the brief touches does today, and turn the brief's open questions into an editable decision sheet. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} that \`BRIEF.md\` names \u2014 grep for call sites, don't read whole trees`],doNotLoad:`\`_shared/standards.md\` (nothing is written here), other stages' contracts, \`.werkmeister/*.yml\`, \`${be}\`.`,process:['List what exists that the brief touches: entry points, routes or exports, data shapes, and the tests that cover them. For each module the change adds an export to, grep the tests for whole-module mocks of it (e.g. `vi.mock("<module>"`, `mock.module`) and list every hit as a fixture the change must update. For each value the change alters (a string, a default, a command), grep tests and fixtures for that exact value and list the hits; never write that no test covers it without that grep.',"Find the test command in `../../.werkmeister/werkmeister-context.md` and copy it verbatim \u2014 do not restate it from memory.","Check what is already installed that could do the job before recommending anything new.","Write `output/inventory.md`: steps 1\u20133.",p5,"Write `output/decisions.md`: every open question in `BRIEF.md`, each as a heading with `status: proposed`, your recommended answer, and the evidence from steps 1\u20133 and 5. Leave the answer blank when only a person can give it (a ticket key, a preference)."],outputs:["`output/inventory.md`","`output/decisions.md`"],humanCheck:`Open \`output/decisions.md\`. Edit each answer as needed and change its \`status: proposed\` to \`status: decided\`. The next stage must not start while any question is still \`proposed\`. When every question reads \`decided\`, that is the approval \u2014 the next session starts the next stage without asking for confirmation. ${wo}`}),"contract")},{name:"spec",job:"write the spec for the change",gate:"spec.md",writes:"`output/spec.md`, any checkable artifact in the repo",check:"the spec covers every acceptance criterion",enter:"every question in `stages/01_research/output/decisions.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:i(e=>({oneJob:"One job: turn the settled decisions into a spec precise enough that the next stage needs no judgment calls, and prove any machine-checkable part of it.",inputs:[`Working (this run): \`${e.at("research")}/output/inventory.md\``,`Working (this run): \`${e.at("research")}/output/decisions.md\` \u2014 every entry must read \`status: decided\`; if not, stop and route back to that stage's human check`,"Reference (every run): `../../BRIEF.md` \xA7 Acceptance criteria"],doNotLoad:"source files already summarised in `inventory.md` (if it looks wrong, fix `inventory.md` and tell the person), `.werkmeister/*.yml`, other stages.",process:[`Write \`output/spec.md\`: what changes, file by file; the interfaces or schemas added; the tests that will prove it; what is explicitly out of scope.${e.group.length?" This is a grouped PR: list one commit per ticket (`<KEY> \u2026`) and what each holds, but do not fix their order.":""}`,"If the change has a machine-checkable artifact (a schema, an API document, a migration), write it in the repo and validate it with a command that needs no new dependency. Record the exact command in `spec.md`.","Map each acceptance criterion in `BRIEF.md` to the step or test in `spec.md` that satisfies it. A criterion with no mapping is a defect in this stage.","Load every `_shared/standards.md` row whose Applies-when matches a file `spec.md` changes, not only the universal ones. Under `## Conflicts` in `spec.md`, write one line per place the ticket's proposed shape breaks a loaded standard (the rule, and the shape that would satisfy it), or `none`.","In `spec.md`, answer: how does an existing user turn this on? Name the setup or config path (a setup command, a config key or file) and the doc that describes it, or say none is needed. Map the answer to a criterion as in step 3; a missing answer is a defect in this stage."],outputs:[`\`output/spec.md\`${xh}`,"Any artifact from step 2, in the repo"],humanCheck:wh("spec.md","Read `output/spec.md` against the brief. Edit it directly \u2014 the next stage builds whatever is on disk.")}),"contract")},{name:"implement",job:"build it and prove it",gate:"review.md",writes:"code diff, `output/exercise.md`, `output/review.md`",check:"read the diff and `review.md`; tests green",standards:"all",contract:i(e=>({oneJob:"One job: make the changes `spec.md` lists, add the tests it names, and prove them against the running service.",inputs:[`Working (this run): \`${e.at("spec")}/output/spec.md\` and the files it names`,`Working (this run): \`${e.at("research")}/output/decisions.md\``,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, test command"],doNotLoad:`\`BRIEF.md\` (\`decisions.md\` and \`spec.md\` carry the settled scope), \`inventory.md\`, \`.werkmeister/*.yml\`, \`${be}\`, other stages.`,process:[...Z$,...n1(e),"Make the changes `spec.md` lists, and only those. No new runtime dependency unless `decisions.md` justified one in a line.","Add the tests `spec.md` names. Match the style of the nearest existing test; no new test framework.",e1("spec.md"),a5,d5(e),c5,l5,`Reload the running code: ${e.restart}. ${X$} Then exercise the change as the How-to-validate section of \`werkmeister-context.md\` describes for each service touched, and capture the output. ${Q$}`,`Write \`output/exercise.md\`: \`git diff --stat\` for each repo you touched, the host and \`pr gate --tests\` exit codes and summary lines, ${r1}, any deviation from \`spec.md\` with its reason, and the exercise checks as ${s1("evidence")}.`,t1],outputs:[e.group.length?"Code changes, one commit per ticket (`<KEY> \u2026`), on the worktree's branch \u2014 the next stage keeps them":"Code changes, uncommitted \u2014 the next stage commits after the person reads the diff","`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${xh}`],humanCheck:wh("review.md",e.group.length?"Read each ticket's commit (`git log -p origin/main..HEAD` in each worktree) and `review.md`. Run the tests yourself. Edit the code in place if something is off and fold it into that ticket's commit \u2014 the next stage keeps the commits as they are.":"Read the diff and `review.md`. Run the tests yourself. Edit the code in place if something is off \u2014 the next stage commits what is on disk.")}),"contract")},o1],s5=[{name:"reproduce",job:"reproduce and locate the root cause",writes:"`output/repro.md`",check:"agree the root cause",standards:"none",contract:i(e=>({oneJob:"One job: make the failure happen on demand and name its root cause. No fix is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} on the failing path \u2014 follow the call chain, don't read whole trees`,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, logs, test command"],doNotLoad:"`_shared/standards.md` (nothing is written here), other stages' contracts, `.werkmeister/*.yml`.",process:["Reproduce the failure against the running service or with a test. Record the exact command and its output. Judge each run by its exit code, or by a check you have shown fails on a known-bad run \u2014 never by grepping the output for a line that may not be printed.","Write the smallest failing test that captures it, in the style of the nearest existing test. Do not commit it yet.","Trace to the root cause: the first place the code does something other than intended. A symptom site is not a root cause.","List every other caller of the function at the root cause and what each does with the result (an early return, a printed value, a stored state), so the fix's return shape is checked against every caller before the fix stage \u2014 a fix there reaches them too. When the fix belongs in shared code, list its call sites through every helper or entry point that reaches that code, not one argument shape, and record the search commands (greps) you used in `repro.md`.","When the proposed fix branches on a predicate, list each condition that makes it true and give each one a test.",p5,"When the root cause is a permission rule (allow, deny, ask), step 4 lists every source of a matching rule: each builder, each rule derived from a registered command (its `&&` segments included), rules recorded in existing workspaces and how a refresh or migrate removes them, and the list a headless wake passes (`--allowedTools` / `--disallowedTools`). The failing test probes each source.","Write `output/repro.md`: steps 1\u20137, and a proposed fix in one paragraph under a `status: proposed` line."],outputs:["`output/repro.md`","One failing test, uncommitted"],humanCheck:`Read \`output/repro.md\`. Correct the root cause or the proposed fix if needed, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts the fix without asking again. ${wo}`}),"contract")},{name:"fix",job:"fix it at the root cause",gate:"fix.md",writes:"code diff, `output/fix.md`",check:"read the diff; the failing test now passes",enter:"`stages/01_reproduce/output/repro.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:i(e=>({oneJob:"One job: make the failing test pass by changing the code at the root cause, and nothing else.",inputs:[`Working (this run): \`${e.at("reproduce")}/output/repro.md\` \u2014 must read \`status: decided\`; if not, stop and route back`,"Working (this run): the failing test and the files at the root cause","Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 test command"],doNotLoad:"`BRIEF.md` (`repro.md` carries the settled scope), `.werkmeister/*.yml`, other stages.",process:[...Z$,...n1(e),"Apply the fix `repro.md` settled, at the root cause. Every caller `repro.md` lists gets the fix through the shared function \u2014 do not patch callers one by one.",e1("repro.md"),lce,`Write \`output/fix.md\`: \`git diff --stat\` per repo, the failing test's name, the test exit code and summary line, and ${r1}.`],outputs:[e.group.length?"Code changes plus the test, one commit per ticket":"Code changes plus the test, uncommitted",`\`output/fix.md\`${xh}`],humanCheck:wh("fix.md",`${e.group.length?"Read each ticket's commit (`git log -p origin/main..HEAD`)":"Read the diff"}. Confirm the fix sits where \`repro.md\` put the root cause. Edit in place if not.`)}),"contract")},{name:"exercise",job:"prove it against the running service or the built CLI",gate:"review.md",writes:"`output/exercise.md`, `output/review.md`",check:"the original reproduction no longer fails",standards:"all",contract:i(e=>({oneJob:"One job: show the original failure is gone in the running service or the built binary, not just in the test. Then review the diff and fix what must be fixed.",inputs:[`Working (this run): \`${e.at("reproduce")}/output/repro.md\` \u2014 the reproduction steps`,`Working (this run): \`${e.at("fix")}/output/fix.md\``,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, test command"],doNotLoad:"`BRIEF.md` (`repro.md` carries the settled scope), `.werkmeister/*.yml`.",process:[`Reload the running code: ${e.restart}. ${X$} ${Q$}`,"Rerun the reproduction steps from `repro.md` exactly. Capture the output.","Exercise one neighbouring path through each caller `repro.md` listed. Capture the output.",`Write \`output/exercise.md\`: steps 2\u20133 as ${s1("detail")}.`,f5("rerun the test command exactly as `../../.werkmeister/werkmeister-context.md` states it (through `.werkmeister/bin/with-temp-home`), rerun steps 2\u20133 and update `exercise.md`",e.group),t1],outputs:["`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${xh}`,e.group.length?"Code changes from Must fix findings, folded into their tickets' commits":"Code changes from Must fix findings, uncommitted"],humanCheck:wh("review.md","Read `exercise.md` and `review.md`. A FAIL sends the run back to the fix stage.")}),"contract")},o1],dce=[{name:"scope",job:"fix the boundary and the invariants",writes:"`output/scope.md`",check:"agree what must not change",standards:"none",contract:i(e=>({oneJob:"One job: pin down what the refactor may touch and what behaviour must not change. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} that \`BRIEF.md\` names, and their callers`],doNotLoad:"`_shared/standards.md` (nothing is written here), other stages' contracts, `.werkmeister/*.yml`.",process:["List the files in scope and every caller outside it.","State the invariants: observable behaviour that must be identical after the refactor.","Name the existing tests that pin each invariant, and the gaps no test covers.",`Write \`output/scope.md\`: steps 1\u20133, the sequence of small steps you propose${e.group.length?` under one heading per ticket key (the workspace's issue, then ${yh(e.group)})`:""}, and a \`status: proposed\` line.`],outputs:["`output/scope.md`"],humanCheck:`Read \`output/scope.md\`. Correct the scope or invariants, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts without asking again. ${wo}`}),"contract")},{name:"implement",job:"refactor in green steps",gate:"review.md",writes:"code diff, `output/exercise.md`, `output/review.md`",check:"read the diff and `review.md`; tests green at every step",enter:"`stages/01_scope/output/scope.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:i(e=>({oneJob:"One job: carry out the steps `scope.md` settled, keeping every invariant true after each one.",inputs:[`Working (this run): \`${e.at("scope")}/output/scope.md\` \u2014 must read \`status: decided\``,"Working (this run): the files in scope","Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 test command"],doNotLoad:"`BRIEF.md` (`scope.md` carries the settled scope), `.werkmeister/*.yml`, other stages.",process:[...Z$,...n1(e),"First add a test for each invariant gap `scope.md` named. They must pass before any code moves.",`${e.group.length?"For each ticket, take its `scope.md` steps in order, then commit it before the next ticket; do not commit after every step. After each step":"Take the steps in order. After each one"}: ${e1("scope.md")} ${a5}`,d5(e),c5,l5,`After the last step, reload and exercise the service: ${e.restart}. ${X$} ${Q$}`,`Write \`output/exercise.md\`: \`git diff --stat\` per repo, the test result after each step, the \`pr gate --tests\` exit code, ${r1}, and the final exercise checks as ${s1("evidence")}.`,t1],outputs:[e.group.length?"Code changes, one commit per ticket (`<KEY> \u2026`)":"Code changes, uncommitted","`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${xh}`],humanCheck:wh("review.md",`Read the diff against \`scope.md\`. Anything outside scope goes back.${e.group.length?" Read it per commit: `git log -p origin/main..HEAD`.":""}`)}),"contract")},o1],pce=[{name:"questions",job:"frame what the spike must answer",writes:"`output/questions.md`",check:"agree the questions and what settles them",standards:"none",contract:i(()=>({oneJob:"One job: turn the brief into questions, each with the evidence that would settle it. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`"],doNotLoad:"source trees, `_shared/standards.md`, `.werkmeister/*.yml`.",process:["List the questions the brief asks or implies, most decision-relevant first.","For each: how it will be answered (read code, measure, prototype) and what result settles it.","Write `output/questions.md`: steps 1\u20132 and a `status: proposed` line."],outputs:["`output/questions.md`"],humanCheck:`Edit the questions, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts without asking again. ${wo}`}),"contract")},{name:"findings",job:"answer them with evidence",writes:"`output/findings.md`",check:"decide the next piece of work",enter:"`stages/01_questions/output/questions.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"none",contract:i(e=>({oneJob:"One job: answer each settled question with evidence, and recommend what to build next.",inputs:[`Working (this run): \`${e.at("questions")}/output/questions.md\` \u2014 must read \`status: decided\``,`Working (this run): whatever each question's method names, in ${e.repos}`,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 ports, containers","Reference (when the brief asks for a repo deliverable): `../../_shared/pr-rules.md` \u2014 the PR file format and the gate"],doNotLoad:"`_shared/standards.md` (prototype code is throwaway), `.werkmeister/*.yml`.",process:["Answer each question by its method. Prototype code lives in `output/` or on a scratch branch, never on the workspace branch.","Write `output/findings.md`: per question, the answer, the evidence (commands and output), and confidence.","End `findings.md` with a recommendation: the next work item and its work type.","If the brief asks for a deliverable in a code repo (e.g. a doc opened as a PR): commit it on that worktree's branch, and write `output/pr-<worktree>.md` in the format of `_shared/pr-rules.md` at `status: draft`, with `repo:` taken from `git -C <worktree> remote get-url origin` (as `owner/repo`; the gate rejects any other value), an acceptance table and `skip_exercise: <reason>` when there is nothing to exercise."],outputs:["`output/findings.md`","`output/pr-<worktree>.md` per repo \u2014 only when the brief asks for a repo deliverable"],humanCheck:"Read `findings.md`. The recommendation becomes the brief of the next workspace, or the spike ends here. If there is a `pr-*.md`, set `status: approved`; `werkmeister pr open` runs the gate and opens it, and close-out waits for it to ship. Otherwise, when the recommendation is recorded where it is needed, the post-mortem (`postmortem` skill), then `werkmeister workspace close`."}),"contract")}],J$={feature:fce,bugfix:s5,incident:s5,refactor:dce,spike:pce};i(sf,"templateFor");i(js,"stageDirs");i(i1,"proposeDir");i(jw,"prDir")});function Xc(e){let t=e.url?`[${e.ref}](${e.url})`:e.ref,r=e.title?`: ${e.title}`:"",n=e.fetchedAt?`Copy taken ${e.fetchedAt.slice(0,10)}: \`.werkmeister/issue.md\`.`:"No stored copy; run `werkmeister workspace init --refresh-issue`.";return["## Issue","",`${t}${r}. ${n}`,"Before each stage, re-read the live issue for newer direction: `werkmeister issue view`","Its status moves by itself (In Progress \u2192 In Review \u2192 Done): `docs/workspace-lifecycle.md` \xA7 Issue status in the werkmeister repo.",""].join(`
|
|
622
|
+
`);return{slug:d,body:m}})}function z$(e,t){return gi.relative(e,t.path)}var Nw,nce,sce,oce,t5,r5=A(()=>{"use strict";h();Nw=Oe(Ye(),1);Kr();nce=/^status:\s*decided\b/,sce=/^(#{1,6})\s+(.+?)\s*#*$/,oce=/^\s*(```|~~~)/;i(e5,"statePath");i(Z4,"readState");i(ice,"slugify");i(ace,"outputFiles");i(cce,"decidedSections");i(z$,"decisionId");t5={open(e){let t=Z4(e),r=[],n=0;for(let s of ace(e)){let o=cce(xo.readFileSync(s,"utf8"),gi.basename(s,".md"));for(let{slug:a,body:c}of o){n+=1;let l={path:`${s}#${a}`,number:n,type:"decision",slug:a,frontmatter:{},body:c},u=t[z$(e,l)]??{};l.frontmatter={type:"decision",status:"decided",refs:[],...u},!["graduated","superseded"].includes(l.frontmatter.status)&&r.push(l)}}return r},mark(e,t,r){let n=Z4(e),s=z$(e,t);n[s]={...n[s],...r},xo.mkdirSync(W(e),{recursive:!0}),xo.writeFileSync(e5(e),Nw.stringify(n))},cite:i((e,t)=>`decision ${String(t.number).padStart(3,"0")}, see ${z$(e,t)}`,"cite")}});function sf(e){let t=e.trim().toLowerCase();return Object.hasOwn(J$,t)?J$[t]:J$.feature}function js(e){return e.map((t,r)=>`${String(r+1).padStart(2,"0")}_${t.name}`)}function i1(e){let t=e.findIndex(r=>r.name==="propose");return t<0?null:js(e)[t]}function jw(e){return i1(e)??js(e)[e.length-1]}var X$,Q$,Z$,o5,i5,lce,a5,c5,l5,e1,t1,r1,yh,u5,n1,uce,f5,d5,p5,wh,xh,h5,m5,s1,n5,o1,fce,s5,dce,pce,J$,a1=A(()=>{"use strict";h();An();Cw();X$="If the container is not running, run `werkmeister feature up` once first; `docker restart` only reloads one that is already running. Never run `werkmeister feature restart` or `werkmeister workspace init` to reload \u2014 they are slower, and init rewrites the stage contracts.",Q$="A library or CLI has no service to restart: build it, then exercise the built artifact exactly as its Validation text in `werkmeister-context.md` \xA7 How to validate says.",Z$=["Confirm ponytail is active (see `_shared/standards.md`; invoke the skill only if it is not), then read the standards rows above. Restate the rule you are applying beside each edit."],o5="If the repo uses biome (`biome.json` or `biome.jsonc`), first run `pnpm exec biome check --write <the files you touched>` (never a folder), so formatting lands in the ticket's own commit. Run the test command exactly as `../../.werkmeister/werkmeister-context.md` states it: through `.werkmeister/bin/with-temp-home`, which gives it a fresh temporary HOME \u2014 never hand-roll `HOME=\u2026`. That run is on the host, without the container's env (`HOST`, `WERKMEISTER_SLOT`, `NODE_ENV`, `<SVC>_URL`, \u2026), and the PR gate runs the same commands in the workspace container. When a service's How-to-validate text in `werkmeister-context.md` says to run in its container (`docker exec`), follow that text instead: starting this workspace's own container with `werkmeister feature up --service <name>` is expected for it and allowed. ",i5='A subagent you brief to run tests or the CLI gets that wrapped command verbatim in its brief. A skipped test is not a pass: name each one with its skip reason, and run it where it can run (the workspace container) or say where it will (the gate, CI). Redirect output to a file as one group, so every command in an `&&` chain lands there. For a background job (`run_in_background`) write background: `{ <test command>; } > <log> 2>&1` and read the exit code from the job\'s completion notice; for a foreground call write foreground: `{ <test command>; } > <log> 2>&1; echo "exit $?"`. Read back only the failing slice.',lce=o5+"Once it passes, run `werkmeister pr gate --tests` (from the workspace, detached when it may pass 10 minutes) and fix what it fails; record both exit codes. "+i5,a5=`${o5}Record its exit code. ${i5}`,c5="Once the review's fixes are in, run `werkmeister pr gate --tests` (from the workspace, detached when it may pass 10 minutes) and fix what it fails; record its exit code. A fix here reruns the host test step first.",l5="If the exercise below changes code, rerun the review on that delta: a fresh subagent with the same brief, over the commits and changes made since the first review. Fix its **Must fix** findings, rerun the host test step, and append the result as new rows to `output/review.md`; the gate's review row covers them.",e1=i(e=>`Before running tests, read \`git diff\` in each repo you touched and tick off each edit \`${e}\` settled against it: an edit reported as applied can be missing.`,"diffCheck"),t1="Before asking for approval, list the exercise rows only a person can run (a real VS Code window, a device, a browser). Ask the person for each one's result, one question per row (pass / fail / not run), and write the answer into `exercise.md`: PASS or FAIL in the table, and for a row not run a `MANUAL: not run (person's reason)` line under it (the table's result cell stays PASS or FAIL). An approval that skips this keeps those rows MANUAL, and the PR file says why.",r1="every skipped test by name with its skip reason and where it ran instead",yh=i(e=>e.map(t=>`\`${t}\``).join(", "),"keys"),u5="`git commit --fixup <sha>`, then `git rebase --autosquash $(git merge-base HEAD origin/main)`",n1=i(e=>e.group.length?[`This workspace is a grouped PR (\`group\` in \`workspace.yml\`): one commit per ticket, for the workspace's issue and each member, ${yh(e.group)}, so each can be reverted alone. Take the tickets one at a time: make that ticket's changes and tests, run the diff check below on them, then commit on the worktree's branch with a message that starts with its key (\`<KEY> <summary>\`) before starting the next. Each commit builds and passes the host tests on its own. A ticket that changes a released package carries its release entry (changeset) in its own commit. When a ticket's change alters a generated snapshot (e.g. \`strategy-jit.snapshot.json\`), regenerate it in that ticket's commit, so the commit passes the snapshot test alone; a brief that says to regenerate once for the whole PR does not override this. Commit order across tickets is free; a ticket whose change depends on another's evidence (a measurement) can come last. Never reorder commits to match the spec.`]:[],"groupStep"),uce="a `| criterion | result | evidence |` table whose result cell is exactly `PASS` or `FAIL` \u2014 nothing else in the cell \u2014 with the proof in the evidence column",f5=i((e,t)=>`Review the diff: for each code worktree you touched, start a fresh subagent and brief it with only the worktree path and "run the \`ponytail:ponytail-review\` skill over this worktree's ${t.length?"commits in `origin/main...HEAD` (the PR's base in place of `main` when it differs), plus any uncommitted changes and untracked files":"uncommitted changes, untracked files included"}" \u2014 not how you built it, so the review is not anchored on your reasoning. If the change adds or widens an allow rule or another pre-approved command, add to the brief: "this change pre-approves a command: list every file, env var, network address or process it can reach from its arguments, and treat each that leaves the workspace or its temp HOME as Must fix". Always add: "any finding where the change can restart or write the host daemon, the real \`~/.werkmeister\` or another workspace, whether through an allow rule, a script or a test, is Must fix". Fix every **Must fix** finding in place, and any **Should fix** finding that shows the change's own docs, comments, help text or changeset state something false (fix the code, or reword that text so it is true), ${t.length?`fold each fix into the commit of the ticket it belongs to (${u5}), `:""}then ${e}. Leave the other **Should fix** and **Nice to have** findings as they are. Write \`output/review.md\`: per worktree, the findings as the review grouped them, each marked \`fixed\` or \`left: <why>\`, then ${uce}, with one row per worktree (\`PASS\` means no Must fix left open). The PR gate refuses to open a PR while \`review.md\` is missing or has a row that is not \`PASS\`; a file of prose alone fails with \`has no PASS row\`.`,"reviewStep"),d5=i(e=>f5("rerun the host test step above",e.group),"implementReview"),p5='For each decision that renames, keeps or removes a name, a fallback or an alias, record its definition site (file and line) and the commit that introduced it (`git log -S <name>`, in the repo that defines it). When that commit marks it as a transition or legacy alias, list "remove" as an option beside rename and keep.',wh=i((e,t)=>`${t} Then change \`status: proposed\` at the top of \`output/${e}\` to \`status: decided\`: that flip is the approval, and the next session starts without asking again. ${wo}`,"statusGate"),xh=", its first line `status: proposed`",h5=i(e=>e?`Ask this check through \`${e}\`: at most 4 questions per call (more than 4: batches of 4, one call after another), each standing on its own (what was checked, 2\u20133 concrete options with the exact wording or behaviour, the recommended one first; "Other" takes edits). Write each answer into the output file as its status, noted \`${mi.chat}\` (a PR file: \`${mi.chatPr}\`). A check left as a sentence at the end of a reply is not asked.`:`Ask this check as one numbered block at the end of your reply: each question stands on its own, options lettered with the recommended one first, then "reply with the letters, or your edits". Write each answer into the output file as its status, noted \`${mi.chat}\` (a PR file: \`${mi.chatPr}\`).`,"askLine"),m5="Review `output/` once against `../../BRIEF.md` and the live issue (`werkmeister issue view`). Flip every `status: proposed` to `status: decided` yourself, and record each decision \u2014 and anything you would have asked a person \u2014 under `## Recommendations for reviewer` in the PR body. Then start the next stage without asking.",s1=i(e=>`a \`| check | result | ${e} |\` table whose result cell is exactly \`PASS\` or \`FAIL\` \u2014 nothing else in the cell \u2014 with the captured output in the ${e} column. The rule holds for every table in \`exercise.md\`; describe a superseded run in prose, not as a \`FAIL\` row`,"exerciseFormat"),n5="the repo's lint command (the `&& <lint>` tail of the test command in `werkmeister-context.md`, when it has one, which the PR gate's lint row runs) and fix what it fails, release entry included.",o1={name:"propose",job:"acceptance walk and PR files",writes:"the code commits (one per repo, or one per ticket in a grouped PR), `output/pr-<worktree>.md` per repo",check:"approve each PR file; `werkmeister pr open` opens it",standards:"none",contract:i(e=>({oneJob:`One job: prove each acceptance criterion, ${e.group.length?"check the per-ticket commits in":"commit in"} each code worktree, and write one PR file per repo touched. ${e.autonomous?"You approve it after the self-check":"Approving is the person's act"}; opening is \`werkmeister pr open\`.`,inputs:["Working (this run): `../../BRIEF.md` \xA7 Acceptance criteria","Working (this run): `../*/output/` \u2014 every prior stage's artifacts","Working (this run): `git status` and `git diff --stat` in each repo you touched","Reference (every run): `../../_shared/pr-rules.md` \u2014 the PR file format and the gate"],doNotLoad:"`_shared/standards.md` (no code is written here), source files, `.werkmeister/`.",process:["Walk every acceptance criterion in `BRIEF.md`. For each, write a row whose result cell is exactly PASS or FAIL (MANUAL for a criterion only the reviewer can check, e.g. it needs a real PR or the desktop app, with why in the evidence; never PASS for a check nobody ran), with the file and line in a prior `output/` that proves it in a separate evidence column. A FAIL routes back to the owning stage \u2014 do not fix it here.",e.group.length?`The commits are already made, one per ticket: keep them, never squash to one per repo. For a repo with \`ship: tag\` and a \`release_check\` in the registry, write the release entry it needs (e.g. a changeset). Run ${n5} Then fold everything uncommitted into its ticket's commit (${u5}), each ticket's release entry into that ticket's own commit, and check that \`git log --oneline origin/main..HEAD\` in each worktree shows one commit per ticket (the workspace's issue and ${yh(e.group)}), each message starting with its key.`:`In each code worktree you touched (\`git -C <repo>\`), commit on its branch with a message that names the change, not the stage. For a repo with \`ship: tag\` and a \`release_check\` in the registry, add the release entry it needs (e.g. a changeset) in the same commit. Before committing, run ${n5}`,"Before the PR file: for each follow-up a decided question in `decisions.md` promises, file it through `../../_shared/issues-report.md` and write its issue key beside that decision. The gate's follow-ups check stays as the backstop.","Write `output/pr-<worktree>.md` per repo touched, in the format of `_shared/pr-rules.md`, at `status: draft`, with `repo:` taken from `git -C <worktree> remote get-url origin` (as `owner/repo`; the gate rejects any other value). Title: `<type>(<scope>): <ISSUE-ID> <summary>`. Body: summary, the test and exercise results from prior outputs (every table with a `result` column \u2014 the gate reads them all \u2014 has a result cell of exactly `PASS` and the output in its own column: a FAIL cell anywhere in the PR file stops the PR, so describe a pre-fix reproduction in prose, not as a FAIL row), the acceptance table from step 1, and `Fixes <issue>` when the tracker is GitHub."+(e.group.length?" Start the body with `Rebase and merge, not squash: one commit per ticket, each revertable alone.` and list each member under the summary.":""),"Commit and push this folder's branch \u2014 the record. Never open a PR for it."],outputs:[e.group.length?"The per-ticket commits, kept, on each worktree's branch":"One commit per code repo touched, on that worktree's branch","`output/pr-<worktree>.md` per repo"],humanCheck:`Read each \`pr-*.md\`. Set \`status: approved\` on each one to open \u2014 that flip is the approval. Then \`werkmeister pr open\`, run detached as \`_shared/pr-rules.md\` rule 3 shows, runs the gate and opens it. Merging is yours. After the release, \`werkmeister pr status\`, then ${e.group.length?`check each member reads Done \u2014 \`werkmeister issue view <KEY>\` for ${yh(e.group)}; \`pr status\` moves them with the workspace's issue, so move one by hand only if it didn't \u2014 then `:""}the post-mortem (\`postmortem\` skill), then ask the person before \`werkmeister workspace close\`. Code written after a PR merged (e.g. found at release) is a follow-up: \`werkmeister pr new <worktree> --slug <slug>\`. ${wo}`,selfCheck:"Review each `pr-*.md` once against `../../BRIEF.md` and the live issue. Add `## Recommendations for reviewer` to its body \u2014 every decision and question collected on the way \u2014 then set `status: approved` yourself and run `werkmeister pr open` detached, as `_shared/pr-rules.md` rule 3 shows. Stop at the PR URL. Merging is the person's."+(e.group.length?` When the PR ships, check each member reads Done (\`werkmeister issue view <KEY>\` for ${yh(e.group)}) before the post-mortem; \`pr status\` moves them with the workspace's issue, so move one by hand only if it didn't.`:"")}),"contract")},fce=[{name:"research",job:"inventory the code, surface decisions",writes:"`output/inventory.md`, `output/decisions.md`",check:"answer every open question in `decisions.md`",standards:"none",contract:i(e=>({oneJob:"One job: establish what the code the brief touches does today, and turn the brief's open questions into an editable decision sheet. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} that \`BRIEF.md\` names \u2014 grep for call sites, don't read whole trees`],doNotLoad:`\`_shared/standards.md\` (nothing is written here), other stages' contracts, \`.werkmeister/*.yml\`, \`${be}\`.`,process:['List what exists that the brief touches: entry points, routes or exports, data shapes, and the tests that cover them. For each module the change adds an export to, grep the tests for whole-module mocks of it (e.g. `vi.mock("<module>"`, `mock.module`) and list every hit as a fixture the change must update. For each value the change alters (a string, a default, a command), grep tests and fixtures for that exact value and list the hits; never write that no test covers it without that grep.',"Find the test command in `../../.werkmeister/werkmeister-context.md` and copy it verbatim \u2014 do not restate it from memory.","Check what is already installed that could do the job before recommending anything new. When a decision rests on how an external tool behaves (a CLI command or flag, a plugin API, an event name), check it against the installed tool, not only its docs: record `<bin> --version`, and confirm each fact with `<bin> <cmd> --help` or a real run or plugin load. `decisions.md` names the version and, beside each fact, the command that confirmed it; a fact only the docs support is marked `unverified: docs only`, and no decision rests on it. If the tool cannot be installed, say so and mark every such fact `unverified`.","Write `output/inventory.md`: steps 1\u20133.",p5,"Write `output/decisions.md`: every open question in `BRIEF.md`, each as a heading with `status: proposed`, your recommended answer, and the evidence from steps 1\u20133 and 5. Leave the answer blank when only a person can give it (a ticket key, a preference)."],outputs:["`output/inventory.md`","`output/decisions.md`"],humanCheck:`Open \`output/decisions.md\`. Edit each answer as needed and change its \`status: proposed\` to \`status: decided\`. The next stage must not start while any question is still \`proposed\`. When every question reads \`decided\`, that is the approval \u2014 the next session starts the next stage without asking for confirmation. ${wo}`}),"contract")},{name:"spec",job:"write the spec for the change",gate:"spec.md",writes:"`output/spec.md`, any checkable artifact in the repo",check:"the spec covers every acceptance criterion",enter:"every question in `stages/01_research/output/decisions.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:i(e=>({oneJob:"One job: turn the settled decisions into a spec precise enough that the next stage needs no judgment calls, and prove any machine-checkable part of it.",inputs:[`Working (this run): \`${e.at("research")}/output/inventory.md\``,`Working (this run): \`${e.at("research")}/output/decisions.md\` \u2014 every entry must read \`status: decided\`; if not, stop and route back to that stage's human check`,"Reference (every run): `../../BRIEF.md` \xA7 Acceptance criteria"],doNotLoad:"source files already summarised in `inventory.md` (if it looks wrong, fix `inventory.md` and tell the person), `.werkmeister/*.yml`, other stages.",process:[`Write \`output/spec.md\`: what changes, file by file; the interfaces or schemas added; the tests that will prove it; what is explicitly out of scope.${e.group.length?" This is a grouped PR: list one commit per ticket (`<KEY> \u2026`) and what each holds, but do not fix their order.":""}`,"If the change has a machine-checkable artifact (a schema, an API document, a migration), write it in the repo and validate it with a command that needs no new dependency. Record the exact command in `spec.md`.","Map each acceptance criterion in `BRIEF.md` to the step or test in `spec.md` that satisfies it. A criterion with no mapping is a defect in this stage.","Load every `_shared/standards.md` row whose Applies-when matches a file `spec.md` changes, not only the universal ones. Under `## Conflicts` in `spec.md`, write one line per place the ticket's proposed shape breaks a loaded standard (the rule, and the shape that would satisfy it), or `none`.","In `spec.md`, answer: how does an existing user turn this on? Name the setup or config path (a setup command, a config key or file) and the doc that describes it, or say none is needed. Map the answer to a criterion as in step 3; a missing answer is a defect in this stage."],outputs:[`\`output/spec.md\`${xh}`,"Any artifact from step 2, in the repo"],humanCheck:wh("spec.md","Read `output/spec.md` against the brief. Edit it directly \u2014 the next stage builds whatever is on disk.")}),"contract")},{name:"implement",job:"build it and prove it",gate:"review.md",writes:"code diff, `output/exercise.md`, `output/review.md`",check:"read the diff and `review.md`; tests green",standards:"all",contract:i(e=>({oneJob:"One job: make the changes `spec.md` lists, add the tests it names, and prove them against the running service.",inputs:[`Working (this run): \`${e.at("spec")}/output/spec.md\` and the files it names`,`Working (this run): \`${e.at("research")}/output/decisions.md\``,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, test command"],doNotLoad:`\`BRIEF.md\` (\`decisions.md\` and \`spec.md\` carry the settled scope), \`inventory.md\`, \`.werkmeister/*.yml\`, \`${be}\`, other stages.`,process:[...Z$,...n1(e),"Make the changes `spec.md` lists, and only those. No new runtime dependency unless `decisions.md` justified one in a line.","Add the tests `spec.md` names. Match the style of the nearest existing test; no new test framework.",e1("spec.md"),a5,d5(e),c5,l5,`Reload the running code: ${e.restart}. ${X$} Then exercise the change as the How-to-validate section of \`werkmeister-context.md\` describes for each service touched, and capture the output. ${Q$}`,`Write \`output/exercise.md\`: \`git diff --stat\` for each repo you touched, the host and \`pr gate --tests\` exit codes and summary lines, ${r1}, any deviation from \`spec.md\` with its reason, and the exercise checks as ${s1("evidence")}.`,t1],outputs:[e.group.length?"Code changes, one commit per ticket (`<KEY> \u2026`), on the worktree's branch \u2014 the next stage keeps them":"Code changes, uncommitted \u2014 the next stage commits after the person reads the diff","`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${xh}`],humanCheck:wh("review.md",e.group.length?"Read each ticket's commit (`git log -p origin/main..HEAD` in each worktree) and `review.md`. Run the tests yourself. Edit the code in place if something is off and fold it into that ticket's commit \u2014 the next stage keeps the commits as they are.":"Read the diff and `review.md`. Run the tests yourself. Edit the code in place if something is off \u2014 the next stage commits what is on disk.")}),"contract")},o1],s5=[{name:"reproduce",job:"reproduce and locate the root cause",writes:"`output/repro.md`",check:"agree the root cause",standards:"none",contract:i(e=>({oneJob:"One job: make the failure happen on demand and name its root cause. No fix is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} on the failing path \u2014 follow the call chain, don't read whole trees`,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, logs, test command"],doNotLoad:"`_shared/standards.md` (nothing is written here), other stages' contracts, `.werkmeister/*.yml`.",process:["Reproduce the failure against the running service or with a test. Record the exact command and its output. Judge each run by its exit code, or by a check you have shown fails on a known-bad run \u2014 never by grepping the output for a line that may not be printed.","Write the smallest failing test that captures it, in the style of the nearest existing test. Do not commit it yet.","Trace to the root cause: the first place the code does something other than intended. A symptom site is not a root cause.","List every other caller of the function at the root cause and what each does with the result (an early return, a printed value, a stored state), so the fix's return shape is checked against every caller before the fix stage \u2014 a fix there reaches them too. When the fix belongs in shared code, list its call sites through every helper or entry point that reaches that code, not one argument shape, and record the search commands (greps) you used in `repro.md`.","When the proposed fix branches on a predicate, list each condition that makes it true and give each one a test.",p5,"When the root cause is a permission rule (allow, deny, ask), step 4 lists every source of a matching rule: each builder, each rule derived from a registered command (its `&&` segments included), rules recorded in existing workspaces and how a refresh or migrate removes them, and the list a headless wake passes (`--allowedTools` / `--disallowedTools`). The failing test probes each source.","Write `output/repro.md`: steps 1\u20137, and a proposed fix in one paragraph under a `status: proposed` line."],outputs:["`output/repro.md`","One failing test, uncommitted"],humanCheck:`Read \`output/repro.md\`. Correct the root cause or the proposed fix if needed, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts the fix without asking again. ${wo}`}),"contract")},{name:"fix",job:"fix it at the root cause",gate:"fix.md",writes:"code diff, `output/fix.md`",check:"read the diff; the failing test now passes",enter:"`stages/01_reproduce/output/repro.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:i(e=>({oneJob:"One job: make the failing test pass by changing the code at the root cause, and nothing else.",inputs:[`Working (this run): \`${e.at("reproduce")}/output/repro.md\` \u2014 must read \`status: decided\`; if not, stop and route back`,"Working (this run): the failing test and the files at the root cause","Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 test command"],doNotLoad:"`BRIEF.md` (`repro.md` carries the settled scope), `.werkmeister/*.yml`, other stages.",process:[...Z$,...n1(e),"Apply the fix `repro.md` settled, at the root cause. Every caller `repro.md` lists gets the fix through the shared function \u2014 do not patch callers one by one.",e1("repro.md"),lce,`Write \`output/fix.md\`: \`git diff --stat\` per repo, the failing test's name, the test exit code and summary line, and ${r1}.`],outputs:[e.group.length?"Code changes plus the test, one commit per ticket":"Code changes plus the test, uncommitted",`\`output/fix.md\`${xh}`],humanCheck:wh("fix.md",`${e.group.length?"Read each ticket's commit (`git log -p origin/main..HEAD`)":"Read the diff"}. Confirm the fix sits where \`repro.md\` put the root cause. Edit in place if not.`)}),"contract")},{name:"exercise",job:"prove it against the running service or the built CLI",gate:"review.md",writes:"`output/exercise.md`, `output/review.md`",check:"the original reproduction no longer fails",standards:"all",contract:i(e=>({oneJob:"One job: show the original failure is gone in the running service or the built binary, not just in the test. Then review the diff and fix what must be fixed.",inputs:[`Working (this run): \`${e.at("reproduce")}/output/repro.md\` \u2014 the reproduction steps`,`Working (this run): \`${e.at("fix")}/output/fix.md\``,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 container names, published ports, test command"],doNotLoad:"`BRIEF.md` (`repro.md` carries the settled scope), `.werkmeister/*.yml`.",process:[`Reload the running code: ${e.restart}. ${X$} ${Q$}`,"Rerun the reproduction steps from `repro.md` exactly. Capture the output.","Exercise one neighbouring path through each caller `repro.md` listed. Capture the output.",`Write \`output/exercise.md\`: steps 2\u20133 as ${s1("detail")}.`,f5("rerun the test command exactly as `../../.werkmeister/werkmeister-context.md` states it (through `.werkmeister/bin/with-temp-home`), rerun steps 2\u20133 and update `exercise.md`",e.group),t1],outputs:["`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${xh}`,e.group.length?"Code changes from Must fix findings, folded into their tickets' commits":"Code changes from Must fix findings, uncommitted"],humanCheck:wh("review.md","Read `exercise.md` and `review.md`. A FAIL sends the run back to the fix stage.")}),"contract")},o1],dce=[{name:"scope",job:"fix the boundary and the invariants",writes:"`output/scope.md`",check:"agree what must not change",standards:"none",contract:i(e=>({oneJob:"One job: pin down what the refactor may touch and what behaviour must not change. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`",`Working (this run): the files in ${e.repos} that \`BRIEF.md\` names, and their callers`],doNotLoad:"`_shared/standards.md` (nothing is written here), other stages' contracts, `.werkmeister/*.yml`.",process:["List the files in scope and every caller outside it.","State the invariants: observable behaviour that must be identical after the refactor.","Name the existing tests that pin each invariant, and the gaps no test covers.",`Write \`output/scope.md\`: steps 1\u20133, the sequence of small steps you propose${e.group.length?` under one heading per ticket key (the workspace's issue, then ${yh(e.group)})`:""}, and a \`status: proposed\` line.`],outputs:["`output/scope.md`"],humanCheck:`Read \`output/scope.md\`. Correct the scope or invariants, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts without asking again. ${wo}`}),"contract")},{name:"implement",job:"refactor in green steps",gate:"review.md",writes:"code diff, `output/exercise.md`, `output/review.md`",check:"read the diff and `review.md`; tests green at every step",enter:"`stages/01_scope/output/scope.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"all",contract:i(e=>({oneJob:"One job: carry out the steps `scope.md` settled, keeping every invariant true after each one.",inputs:[`Working (this run): \`${e.at("scope")}/output/scope.md\` \u2014 must read \`status: decided\``,"Working (this run): the files in scope","Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 test command"],doNotLoad:"`BRIEF.md` (`scope.md` carries the settled scope), `.werkmeister/*.yml`, other stages.",process:[...Z$,...n1(e),"First add a test for each invariant gap `scope.md` named. They must pass before any code moves.",`${e.group.length?"For each ticket, take its `scope.md` steps in order, then commit it before the next ticket; do not commit after every step. After each step":"Take the steps in order. After each one"}: ${e1("scope.md")} ${a5}`,d5(e),c5,l5,`After the last step, reload and exercise the service: ${e.restart}. ${X$} ${Q$}`,`Write \`output/exercise.md\`: \`git diff --stat\` per repo, the test result after each step, the \`pr gate --tests\` exit code, ${r1}, and the final exercise checks as ${s1("evidence")}.`,t1],outputs:[e.group.length?"Code changes, one commit per ticket (`<KEY> \u2026`)":"Code changes, uncommitted","`output/exercise.md`",`\`output/review.md\`: a \`| criterion | result | evidence |\` table, result exactly \`PASS\` or \`FAIL\`${xh}`],humanCheck:wh("review.md",`Read the diff against \`scope.md\`. Anything outside scope goes back.${e.group.length?" Read it per commit: `git log -p origin/main..HEAD`.":""}`)}),"contract")},o1],pce=[{name:"questions",job:"frame what the spike must answer",writes:"`output/questions.md`",check:"agree the questions and what settles them",standards:"none",contract:i(()=>({oneJob:"One job: turn the brief into questions, each with the evidence that would settle it. No code is written in this stage.",inputs:["Working (this run): `../../BRIEF.md`"],doNotLoad:"source trees, `_shared/standards.md`, `.werkmeister/*.yml`.",process:["List the questions the brief asks or implies, most decision-relevant first.","For each: how it will be answered (read code, measure, prototype) and what result settles it.","Write `output/questions.md`: steps 1\u20132 and a `status: proposed` line."],outputs:["`output/questions.md`"],humanCheck:`Edit the questions, then change \`status: proposed\` to \`status: decided\`. That is the approval \u2014 the next session starts without asking again. ${wo}`}),"contract")},{name:"findings",job:"answer them with evidence",writes:"`output/findings.md`",check:"decide the next piece of work",enter:"`stages/01_questions/output/questions.md` reads `status: decided` \u2014 the flip *is* the approval, do not ask again",standards:"none",contract:i(e=>({oneJob:"One job: answer each settled question with evidence, and recommend what to build next.",inputs:[`Working (this run): \`${e.at("questions")}/output/questions.md\` \u2014 must read \`status: decided\``,`Working (this run): whatever each question's method names, in ${e.repos}`,"Reference (every run): `../../.werkmeister/werkmeister-context.md` \u2014 ports, containers","Reference (when the brief asks for a repo deliverable): `../../_shared/pr-rules.md` \u2014 the PR file format and the gate"],doNotLoad:"`_shared/standards.md` (prototype code is throwaway), `.werkmeister/*.yml`.",process:["Answer each question by its method. Prototype code lives in `output/` or on a scratch branch, never on the workspace branch.","Write `output/findings.md`: per question, the answer, the evidence (commands and output), and confidence.","End `findings.md` with a recommendation: the next work item and its work type.","If the brief asks for a deliverable in a code repo (e.g. a doc opened as a PR): commit it on that worktree's branch, and write `output/pr-<worktree>.md` in the format of `_shared/pr-rules.md` at `status: draft`, with `repo:` taken from `git -C <worktree> remote get-url origin` (as `owner/repo`; the gate rejects any other value), an acceptance table and `skip_exercise: <reason>` when there is nothing to exercise."],outputs:["`output/findings.md`","`output/pr-<worktree>.md` per repo \u2014 only when the brief asks for a repo deliverable"],humanCheck:"Read `findings.md`. The recommendation becomes the brief of the next workspace, or the spike ends here. If there is a `pr-*.md`, set `status: approved`; `werkmeister pr open` runs the gate and opens it, and close-out waits for it to ship. Otherwise, when the recommendation is recorded where it is needed, the post-mortem (`postmortem` skill), then `werkmeister workspace close`."}),"contract")}],J$={feature:fce,bugfix:s5,incident:s5,refactor:dce,spike:pce};i(sf,"templateFor");i(js,"stageDirs");i(i1,"proposeDir");i(jw,"prDir")});function Xc(e){let t=e.url?`[${e.ref}](${e.url})`:e.ref,r=e.title?`: ${e.title}`:"",n=e.fetchedAt?`Copy taken ${e.fetchedAt.slice(0,10)}: \`.werkmeister/issue.md\`.`:"No stored copy; run `werkmeister workspace init --refresh-issue`.";return["## Issue","",`${t}${r}. ${n}`,"Before each stage, re-read the live issue for newer direction: `werkmeister issue view`","Its status moves by itself (In Progress \u2192 In Review \u2192 Done): `docs/workspace-lifecycle.md` \xA7 Issue status in the werkmeister repo.",""].join(`
|
|
623
623
|
`)}var Lw=A(()=>{"use strict";h();i(Xc,"renderIssueRef")});import*as vr from"node:fs";import*as Yt from"node:path";function c1(e){return(e??"").split(",").map(t=>t.trim()).filter(t=>t)}function w5(e,t){let r=js(t),n;try{n=vr.readdirSync(Yt.join(e,"stages")).filter(s=>/^\d+_/.test(s))}catch{return[]}return n.filter(s=>!r.includes(s)).sort()}function mce(e,t){let[r]=Nn(),n=i(c=>vu.includes(r[c]?.type??""),"isIdle"),s=i(c=>c.map(l=>`\`${e}-${l}\``).join(", "),"names"),o=t.filter(c=>!n(c)),a=t.filter(n);return[o.length?o.map(c=>`\`docker restart ${e}-${c}\``).join(", "):"",a.length?`${s(a)} run no watcher, so a restart rebuilds nothing: build and test inside them with \`docker exec\` as \`.werkmeister/werkmeister-context.md\` \xA7 Test commands shows`:""].filter(Boolean).join("; ")}function x5(e,t){let r=js(t),n=(e.meta.FEATURE??"").trim(),s=c1(e.meta.SERVICES),o=e.repos.map(([a])=>a);return{at:i(a=>`../${r[t.findIndex(c=>c.name===a)]}`,"at"),repos:o.length?o.map(a=>`\`../../${a}/\``).join(", "):"the code worktrees in this workspace",restart:n&&s.length?mce(n,s):"restart whatever serves the change as `.werkmeister/werkmeister-context.md` describes",standards:"",autonomous:In(e.inputs.autonomous),group:c1(e.inputs.group),questionTool:us(e.workspaceRoot).questionTool}}function gce(e){let t=ur(null,Dt(e.workspaceRoot));if(!Object.keys(t).length)return C(Cc()||`no standard modules found in ${Tt()} \u2014 _shared/standards.md lists none`),{active:[],notActive:[],modules:t};let[r,n]=Nn(),[s,o]=Uu(e.repos.map(([a])=>a),r,n,Ft(e.workspaceRoot,e.configOverride),t,c1(e.meta.SERVICES));return{active:s,notActive:o,modules:t}}function yce(e){let t=Array.isArray(e.applies_to)?e.applies_to.map(String):[];return!t.length||t.includes("**/*")?"any code edit":"editing "+t.map(r=>`\`${r}\``).join(", ")}function wce(e){let t=i(r=>Yt.relative(r,e.path).split(Yt.sep).join("/"),"rel");return e.repo?`${e.repo}/${t(Yt.resolve(e.root,"..",".."))}`:`<standards_dir>/${t(Tt())}`}function xce(e){let t=["# Coding standards (factory)","","Read from their one home, not copied. Load only the rows a stage's contract names.","","| Standard | Read | Applies when |","|---|---|---|",...e.active.map(r=>`| ${r} | \`${wce(e.modules[r])}\` | ${yce(e.modules[r])} |`),hce,"","`<standards_dir>` is this machine's standards tree: `werkmeister standards check` prints its path (`overrides.standards_dir` in `werkmeister machine config`), and `werkmeister machine setup` grants Claude Code read access to it.",""];return e.notActive.length&&t.push(`Not applicable to this workspace (do not load): ${e.notActive.join(", ")}.`,""),t.push("Before writing code on a path a standard governs, restate the one rule you are applying in a line next to the edit \u2014 a rule read twenty tool calls ago no longer steers.",""),t.join(`
|
|
624
624
|
`)}function kce(e,t){return e==="none"?"":`- Reference (every run): \`../../_shared/standards.md\` \u2014 rows ${[...t.active,"ponytail"].map(r=>`\`${r}\``).join(", ")}`}function _ce(e){let t=`${vce} ${Sce}`;return e?`${bce} Then: ${t}`:t}function Ece(e,t,r,n=""){let s=t.contract(r);return[`# ${e} \u2014 ${t.job}`,"",s.oneJob,"","## Inputs",...s.inputs.map(o=>`- ${o}`),...r.standards?[r.standards]:[],"",`Do NOT load: ${s.doNotLoad}`,"","## Process",...n?[`0. ${n}`]:[],...s.process.map((o,a)=>`${a+1}. ${o}`),"","## Outputs",...s.outputs.map(o=>`- ${o}`),"",...r.autonomous?["## Self-check",s.selfCheck??m5]:["## Human check",s.humanCheck,"",h5(r.questionTool)],""].join(`
|
|
625
625
|
`)}function $ce(e,t){let r=js(t),n=x5(e,t);return[`# Workspace: ${e.workspaceName}`,"",e.task,"",...e.issue?[Xc(e.issue)]:[],"Read this file, then `CONTEXT.md`, then only the one stage `CONTEXT.md` the routing table sends you to. Nothing else up front.","","## Where things live","","| Path | Holds |","|---|---|","| `BRIEF.md` | the run's input: goal, acceptance criteria, open questions |",...e.issue?.fetchedAt?["| `.werkmeister/issue.md` | the issue as fetched at creation; refresh with `werkmeister workspace init --refresh-issue` |"]:[],"| `CONTEXT.md` | the pipeline in one screen |","| `stages/NN_*/` | one stage each: `CONTEXT.md` (contract) + `output/` (this run's artifacts) |","| `_shared/` | factory: the coding standards and `issues-report.md` (fix a bug here or file an issue \u2014 bug, feature or task \u2014 and how), same every run |",...e.repos.map(([s,o])=>`| \`${s}/\` | code worktree${o?`, branch \`${o}\``:""} |`),"| this folder's git branch | the run's record (contracts + stage outputs): commit and push it; never open a PR from it or merge it |","| `.werkmeister/werkmeister-context.md` | generated infra facts: how to validate, test command, ports, container names |",`| \`.werkmeister/*.yml\`, \`${be}\`, \`.env\` | generated by \`werkmeister\`; do not hand-edit |`,"",`\`werkmeister feature up\` is safe here. Do not rerun \`werkmeister workspace init\` unless you mean to regenerate this file and the stage contracts. To reload code after an edit, ${n.restart}.`,"","## Route by what just happened","","| If | Go to | Stop when |","|---|---|---|",...t.map((s,o)=>`| ${o===0?"starting the run":s.enter??Oce(t[o-1],r[o-1],n.autonomous)} | \`stages/${r[o]}/CONTEXT.md\` | ${n.autonomous?"`output/` written and self-checked":"a person has read `output/`"} |`),"| asked to open or create a PR \u2014 including `/create-pr` or `finishing-a-development-branch` | `_shared/pr-rules.md`, then `werkmeister pr open` (rule 5: `pr watch` is the auto-fix) | PR URL is in the PR file |","| a PR merged or released, or asked to close out | `werkmeister pr status`, then the werkmeister `postmortem` skill (writes `postmortem.md`), then ask the person before `werkmeister workspace close` | `postmortem.md` written, then closed out after the person says yes |","| asked for status | `ls stages/*/output/` | report which stages hold artifacts |","| containers / ports / routing broken | `.werkmeister/werkmeister-context.md` | \u2014 |","| you hit a bug or need to log a feature/task \u2014 in the `werkmeister` tool or in a repo's code | `_shared/issues-report.md`: if this workspace's changes caused a bug, fix it here; otherwise file an issue where it belongs | fixed, or issue URL reported to the person |","",...n.autonomous?Rce(t):Tce,""].join(`
|
|
@@ -1536,26 +1536,26 @@ if (tool === "gh") {
|
|
|
1536
1536
|
}
|
|
1537
1537
|
`,$be=i((e,t)=>`#!/bin/sh
|
|
1538
1538
|
exec '${process.execPath}' '${Mi.join(e,"fake.mjs")}' ${t} '${e}' "$@"
|
|
1539
|
-
`,"shim");i(dK,"writeFakes");i(pK,"startFakeDaemon")});import{execFileSync as Obe}from"node:child_process";import*as qo from"node:fs";import*as at from"node:path";function yK({gate:e,bare:t,...r}){let n={};if(e&&r.services){let s=hb.default.parse(r.services)?.services?.lib;if(s?.repo!=="app"||s?.path!=="packages/lib")throw new Error("--gate needs a `lib` service in repo `app` (at packages/lib) in the --services registry")}return e&&Object.assign(n,{repos:[{name:"app",change:"packages/lib/index.js"}],prFile:!0,running:[Bt(YT,"lib")]}),t&&(n.feature=!1),{...n,...r}}function zn(e,t,r){qo.mkdirSync(at.dirname(e),{recursive:!0}),qo.writeFileSync(e,t,r===void 0?void 0:{mode:r})}function wK(e,t={}){let r=i((
|
|
1539
|
+
`,"shim");i(dK,"writeFakes");i(pK,"startFakeDaemon")});import{execFileSync as Obe}from"node:child_process";import*as qo from"node:fs";import*as at from"node:path";function yK({gate:e,bare:t,...r}){let n={};if(e&&r.services){let s=hb.default.parse(r.services)?.services?.lib;if(s?.repo!=="app"||s?.path!=="packages/lib")throw new Error("--gate needs a `lib` service in repo `app` (at packages/lib) in the --services registry")}return e&&Object.assign(n,{repos:[{name:"app",change:"packages/lib/index.js"}],prFile:!0,running:[Bt(YT,"lib")]}),t&&(n.feature=!1),{...n,...r}}function zn(e,t,r){qo.mkdirSync(at.dirname(e),{recursive:!0}),qo.writeFileSync(e,t,r===void 0?void 0:{mode:r})}function wK(e,t={}){let r=i((w,...g)=>Obe("git",g,{cwd:w,stdio:"pipe",env:{...ya(),...hK}}),"git"),n=t.repos??[{name:"app"}];zn(at.join(e,"services.yaml"),t.services??Tbe),zn(at.join(e,"ports.yaml"),Rbe);let s=at.join(e,"config.yaml");zn(s,`version: 1
|
|
1540
1540
|
paths:
|
|
1541
1541
|
repos_root: ${e}/repos
|
|
1542
1542
|
workspaces_root: ${e}/ws
|
|
1543
1543
|
overrides:
|
|
1544
1544
|
services_yaml: ${e}/services.yaml
|
|
1545
1545
|
ports_yaml: ${e}/ports.yaml
|
|
1546
|
-
${Abe(n.map(
|
|
1547
|
-
`);zn(at.join(c,"review.md"),VT)}for(let{name:
|
|
1548
|
-
`),r(
|
|
1549
|
-
`),r(
|
|
1550
|
-
repo: o/${
|
|
1546
|
+
${Abe(n.map(w=>w.name))}`);let o=at.join(e,"ws",YT),a={...t.feature===!1?{task:"demo",work_type:"feature"}:{feature:YT,services:(t.workspaceServices??["lib"]).join(",")},...t.issue?{issue_id:t.issue,project:gK}:{},...t.workspace};zn(at.join(W(o),"workspace.yml"),hb.default.stringify(a));let c=at.join(W(o),"notes");if(t.prFile&&a.context_strategy==="icm"){let w=sf(String(a.work_type??"")),g=js(w),y=jw(w);c=at.join(o,"stages",y,"output");for(let k of g.slice(0,g.indexOf(y)))zn(at.join(o,"stages",k,"output","seeded.md"),`seeded by the fixture
|
|
1547
|
+
`);zn(at.join(c,"review.md"),VT)}let{status:l="approved",...u}=t.prFields??{},f=Object.keys(u).length?hb.default.stringify(u):"";for(let{name:w,change:g}of n){let y=at.join(e,"remotes","o",`${w}.git`);qo.mkdirSync(y,{recursive:!0}),r(y,"init","-q","--bare","-b","main");let k=at.join(e,"repos",w);qo.mkdirSync(k,{recursive:!0}),r(k,"init","-q","-b","main"),r(k,"commit","-q","--allow-empty","-m","init"),r(k,"remote","add","origin",y),r(k,"push","-q","origin","main"),t.fragment&&w===n[0]?.name&&zn(at.join(k,".werkmeister","services.yaml"),t.fragment);let S=at.join(o,w);r(o,"clone","-q",y,w),g&&(zn(at.join(S,g),`base
|
|
1548
|
+
`),r(S,"add","."),r(S,"commit","-q","-m","base"),r(S,"push","-q","origin","main")),r(S,"switch","-q","-c",pb),r(k,"switch","-q","-c","fixture-source"),g&&(zn(at.join(S,g),`changed
|
|
1549
|
+
`),r(S,"commit","-q","-am",`change ${g}`)),t.prFile&&g&&zn(at.join(c,`pr-${w}.md`),`---
|
|
1550
|
+
repo: o/${w}
|
|
1551
1551
|
branch: ${pb}
|
|
1552
1552
|
base: main
|
|
1553
|
-
status:
|
|
1554
|
-
${
|
|
1553
|
+
status: ${l}
|
|
1554
|
+
${f}---
|
|
1555
1555
|
# feat: fixture change
|
|
1556
1556
|
|
|
1557
|
-
${VT}`)}t.prFile&&zn(at.join(c,"exercise.md"),VT);let
|
|
1558
|
-
`).join("")),r(o,"init","-q","-b",pb),r(o,"add","-A"),r(o,"commit","-q","-m","record"),r(o,"remote","add","origin",
|
|
1557
|
+
${VT}`)}t.prFile&&zn(at.join(c,"exercise.md"),VT);let d=at.join(e,"remotes","o","ws.git");qo.mkdirSync(d,{recursive:!0}),r(d,"init","-q","--bare","-b","main"),zn(at.join(o,".gitignore"),n.map(w=>`/${w.name}/
|
|
1558
|
+
`).join("")),r(o,"init","-q","-b",pb),r(o,"add","-A"),r(o,"commit","-q","-m","record"),r(o,"remote","add","origin",d),r(o,"push","-q","-u","origin",pb);let p=at.join(e,"home");qo.mkdirSync(p);let m=dK(at.join(e,"bin"),{prUrl:`https://github.com/${mK}/pull/1`,running:t.running??[],prState:t.merged?"MERGED":void 0,issue:a.issue_id?Cbe:void 0,execCwd:t.execRuns?at.join(o,n[0].name):void 0});return{root:e,configFile:s,workspace:o,repo:at.join(o,n[0].name),ghLog:m.ghLog,dockerLog:m.dockerLog,env:{...hK,HOME:p,CODEX_HOME:at.join(p,".codex"),WERKMEISTER_CONFIG_FILE:s,WERKMEISTER_FIXTURE:"1",WERKMEISTER_GH_BIN:m.gh,WERKMEISTER_DOCKER_BIN:m.docker,DOCKER_HOST:"unix:///nonexistent/werkmeister-fixture-docker.sock",JIRA_BASE_URL:"",JIRA_EMAIL:"",JIRA_API_TOKEN:"",ANTHROPIC_API_KEY:"",CLAUDE_CODE_OAUTH_TOKEN:"",KUBECONFIG:"",GH_TOKEN:"",GITHUB_TOKEN:"",WERKMEISTER_HOST:t.daemon??"http://127.0.0.1:1"}}}function Ibe(e){return at.join(W(e),"bin","with-fixture-workspace")}function mb(e){let t=Ibe(e);return zn(t,Pbe),qo.chmodSync(t,493),t}var hb,YT,pb,mK,Tbe,Rbe,gK,Abe,Cbe,VT,hK,Pbe,gb=A(()=>{"use strict";h();hb=Oe(Ye(),1);Q();Kr();GT();ut();a1();YT="demo",pb="me/demo",mK="o/app",Tbe=`services:
|
|
1559
1559
|
lib:
|
|
1560
1560
|
type: cli
|
|
1561
1561
|
repo: app
|
|
@@ -1594,6 +1594,11 @@ for f in "$ws"/*/apps/cli/dist/main.js; do
|
|
|
1594
1594
|
main=$f
|
|
1595
1595
|
done
|
|
1596
1596
|
[ -n "$main" ] || { echo "with-fixture-workspace: no built CLI at $ws/<worktree>/apps/cli/dist/main.js; build it first" >&2; exit 2; }
|
|
1597
|
+
# In the werkmeister container the worktree is also at /app, the only place its node_modules volume is mounted (SW-548).
|
|
1598
|
+
app=/app
|
|
1599
|
+
wt=\${main%/apps/cli/dist/main.js}
|
|
1600
|
+
[ ! "$app" -ef "$wt" ] || { wt=$app; main=$app/apps/cli/dist/main.js; }
|
|
1601
|
+
[ -n "$(ls -A "$wt/node_modules" 2>/dev/null)" ] || { echo "with-fixture-workspace: no node_modules in $wt (installed in the container); run it there: docker exec -w /app <container> $0 ..." >&2; exit 2; }
|
|
1597
1602
|
# --no-wait first goes to with-temp-home, like its own (SW-367).
|
|
1598
1603
|
nw=
|
|
1599
1604
|
[ "\${1:-}" != --no-wait ] || { nw=--no-wait; shift; }
|
|
@@ -1812,11 +1817,11 @@ ${x.BOLD}${e}${x.RESET}`)}async function WRe(e){let t=Pe(),r=lr(t);rs("1. Paths
|
|
|
1812
1817
|
`);return Q0(r,`${a}WERKMEISTER_MCP_TOKEN=${o}
|
|
1813
1818
|
`,e),{label:t,ok:!0,detail:`${e?"would replace":"replaced"} SANDBOX_MCP_TOKEN with WERKMEISTER_MCP_TOKEN from ${s}`}}function rAe(e,t){let r="workspace models",n=[],s=[];for(let c of lS(e).filter(l=>ae.existsSync(Ze.join(l,Nt)))){if(Ju(c))continue;let l=String(go(c,"harness")||fr[0]);try{let{model:u,tier:f}=Zy(null,l);if(!u)continue;t||(yb(c,{model:u}),l==="claude"&&ae.existsSync(Ze.join(c,".claude","settings.json"))&&$w(c,u)),n.push(`${Ze.basename(c)}: ${u} (${f})`)}catch(u){s.push(`${Ze.basename(c)}: ${u.message}`)}}let o=t?"would write":"wrote",a=[...n.length?[`${o} ${n.length}: ${n.join(", ")}`]:[],...s];return{label:r,ok:!s.length,detail:a.join("; ")||"every workspace records a model"}}function nAe(e,t){let r=lS(e).filter(c=>ae.existsSync(Ze.join(c,Nt))),n=r.filter(eAe);if(!t)for(let c of n){let l=ae.readFileSync(Ze.join(c,".claude","settings.json"),"utf8");/werkmeister hooks gate/.test(l)?rf(c):/werkmeister hooks pr-guard/.test(l)&&mh(c),Ta(c),ae.existsSync(fi(c))&&(Vy(c),mb(c))}let s=i(c=>c.map(l=>Ze.basename(l)).join(", "),"names"),o=r.filter(c=>{let l=Ze.join(c,".env");return ae.existsSync(l)&&!/^WERKMEISTER_FEATURE=/m.test(ae.readFileSync(l,"utf8"))}),a=Pu(void 0,t);return[{label:"workspace hooks and permission rules",ok:!0,detail:n.length?`${t?"would rewrite":"rewrote"} ${n.length}: ${s(n)}`:"every workspace uses the noun-group spellings"},tAe(t),{label:"Claude Desktop config",ok:!0,detail:a?`${t?"would launch":"now launches"} \`werkmeister internal mcp\``:"up to date"},...o.length?[{label:"feature env",ok:!0,optional:!0,detail:`${o.length} still export only SANDBOX_FEATURE \u2014 run \`werkmeister workspace init\` in ${s(o)}`}]:[]]}var qZ,X0,MZ,JRe,QRe,ZRe,HZ=A(()=>{"use strict";h();qZ=Oe(Ye(),1);An();Q();zr();Kr();gb();ze();nf();Hu();Rl();sh();Hn();Wu();Vm();Vt();X0=".sandbox";i(zRe,"dockerRunning");MZ=i((e,t)=>e!==void 0&&(e===t||e.startsWith(t+Ze.sep)),"within"),JRe=i(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeRe");i(RI,"repointed");i(BZ,"retireBlock");i(Q0,"writeIfChanged");i(lS,"workspaceDirs");i(XRe,"workspacesRootBeforeMove");i(WZ,"migrate");QRe=/werkmeister (?:hooks (?:gate|pr-guard|agent-state)|stop --if-idle)/,ZRe="werkmeister wait-load";i(UZ,"readJson");i(eAe,"workspaceStale");i(tAe,"secretsStep");i(rAe,"modelStep");i(nAe,"nounGroupSteps")});var KZ={};ie(KZ,{run:()=>sAe});async function sAe(e){let t=!!e.check,r=await WZ({checkOnly:t,workspaces:!!e.workspaces});for(let n of r){let s=n.ok?`${x.GREEN}\u2713${x.RESET}`:`${x.RED}\u2717${x.RESET}`;console.log(`${s} ${n.label}: ${n.detail}`)}r.some(n=>!n.ok)&&(C(t?"Migration would not complete.":"Migration did not complete."),process.exit(1)),F(t?"Nothing written (--check).":"Migrated: ~/.werkmeister and every workspace use the current spellings.")}var GZ=A(()=>{"use strict";h();HZ();Ee();i(sAe,"run")});var YZ={};ie(YZ,{run:()=>aAe});import oAe from"node:os";async function aAe(e){let t=await wx(),r=vf(oAe.cpus().length),n=To(),s=await qa();if(e.json){let a=i(c=>Number.isFinite(c)?c:null,"n");console.log(JSON.stringify({budget:{memory:a(t.memory),cpus:a(t.cpus),preempt:t.preempt},host_load:r,leases:n,waiting:s}));return}console.log(`Budget: ${VZ(t.memory/iAe," GiB")} memory, ${VZ(t.cpus," CPUs")}, host load ${r||"unchecked"}, preemption ${t.preempt?"on":"off"}`);let o=Object.entries(n).sort(([,a],[,c])=>a.slot-c.slot);console.log(o.length?"Slots:":"Slots: none held");for(let[a,c]of o)console.log(` ${c.slot} ${a}${c.workspace?` ${c.workspace}`:""}`);console.log(s.length?"Waiting:":"Waiting: none");for(let[a,c]of s.entries())console.log(` ${a+1}. ${c}`)}var iAe,VZ,zZ=A(()=>{"use strict";h();Sf();ul();iAe=2**30,VZ=i((e,t)=>Number.isFinite(e)?`${Number(e.toFixed(1))}${t}`:"no limit","limit");i(aAe,"run")});var JZ={};ie(JZ,{run:()=>cAe});async function cAe(e){let t=e.action;if(t==="restart")return V2(or);let r=t==="uninstall"?[AH()]:await AT(t==="status",t==="install");if(t==="status"){let n=await Fs(or),s=n.healthy||await Wh(or.port),o=s?await gL():null,a=vy(Ex(or)),c=o&&{loaded:o.loaded,onDisk:a,stale:o.loaded!==null&&a!==null&&o.loaded!==a};if(e.json){console.log(JSON.stringify({...n,serving:s,build:c,agent:r[0]?.detail??null}));return}let l=s?"serving":n.running?"running, not answering":"not running",u=n.pid??o?.pid;console.log(`${or.label}: ${l} on ${n.url}${u?` (pid ${u})`:""}`),c?.stale?console.log(`${x.YELLOW}!${x.RESET} build: stale (loaded ${c.loaded}, on disk ${c.onDisk})`+(o?.restartPending?"; restarts by itself once no call or queued feature is in flight":"")):c?.loaded&&console.log(`${x.GREEN}\u2713${x.RESET} build: ${c.loaded}`)}for(let n of r){let s=n.ok?`${x.GREEN}\u2713${x.RESET}`:`${x.RED}\u2717${x.RESET}`;console.log(`${s} ${n.label}: ${n.detail}`)}t!=="status"&&r.some(n=>!n.ok)&&process.exit(1)}var XZ=A(()=>{"use strict";h();ao();Rl();Ei();Ee();i(cAe,"run")});var QZ={};ie(QZ,{run:()=>lAe});async function lAe(e){if(e.install||e.uninstall)return e.install&&e.uninstall&&(M("Pick one of --install or --uninstall."),process.exit(1)),CI(e.install?Nm():RH(),e);if(e.action==="watch")return CI(await ib({desktop:!1}),e);let t=wa(process.cwd());t||(M("Not inside a workspace (no .werkmeister/workspace.yml above the current directory)."),process.exit(1));let r=e.repo??void 0;e.action==="new"&&!(r&&e.slug)&&(M("Usage: werkmeister pr new <worktree> --slug <slug>"),process.exit(1));let n=e.action==="adopt"?await ab(t,{pr:e.pr??void 0,noPr:e.noPr??void 0,repo:r}):e.action==="new"?await cb(t,r,e.slug):e.action==="gate"?await(e.tests?nb:rb)(t,r):e.action==="open"?await sb(t,r):{ok:!0,...await Pl(t)};e.action==="open"&&!e.json&&n.lines.push(`pr open: exit ${n.ok?0:1}`),CI(n,e)}function CI(e,t){t.json?console.log(JSON.stringify(e,null,2)):console.log(e.lines.join(`
|
|
1814
1819
|
`)),e.ok||process.exit(1)}var ZZ=A(()=>{"use strict";h();Sn();Rl();Du();Ee();i(lAe,"run");i(CI,"print")});import*as uS from"node:fs";import*as qd from"node:path";import{fileURLToPath as uAe}from"node:url";function tee(e={}){let t=e.run??((l,u)=>K(l,u)),r=i((l,u)=>{try{return t(l,{capture:!0,timeout:u})}catch{return null}},"safe"),n=e.cliDir??uS.realpathSync(eee),s=r(["git","-C",n,"rev-parse","--show-toplevel"],10);if(s?.status===0){let l=s.stdout.trim(),u=i((...w)=>r(["git","-C",l,...w],60),"git"),f=`git -C ${l} checkout main && git -C ${l} pull --ff-only origin main, then from ${l}: corepack pnpm install --frozen-lockfile && corepack pnpm turbo run build`,d=u("fetch","origin","main","--quiet");if(d?.status!==0){let w=d?.stderr?.trim().split(`
|
|
1815
|
-
`)[0]||"timed out";return{current:null,text:`could not check: fetch of origin main in ${l} failed (${w}); re-check with \`werkmeister issue start\``}}let p=u("rev-parse","--abbrev-ref","HEAD")?.stdout.trim();if(p!=="main")return{current:!1,text:`stale: linked checkout ${l} is on '${p}', not main. Fix: ${f}`};let m=u("rev-list","--count","HEAD..origin/main")?.stdout.trim();return u("merge-base","--is-ancestor","origin/main","HEAD")?.status===0?{current:!0,text:`current: linked checkout ${l} contains origin/main`}:{current:!1,text:`stale: linked checkout ${l} is ${m||"some"} commits behind origin/main. Fix: ${f}`}}let o=e.version??JSON.parse(uS.readFileSync(qd.join(eee,"package.json"),"utf8")).version,a=r(["npm","view","werkmeister","version"],30);if(a?.status!==0||!a.stdout.trim())return{current:null,text:`could not look up the latest release (installed ${o}), currency not checked`};let c=a.stdout.trim();return fAe(o,c)>=0?{current:!0,text:`current: ${o} is the latest release`}:{current:!1,text:`stale: installed ${o}, latest release ${c}. Fix: npm i -g werkmeister@latest`}}var eee,fAe,ree=A(()=>{"use strict";h();ut();eee=qd.resolve(qd.dirname(uAe(import.meta.url)),"..",".."),fAe=i((e,t)=>{let[r,n]=[e,t].map(s=>s.split(".").map(Number));for(let s=0;s<3;s++)if((r[s]??0)!==(n[s]??0))return(r[s]??0)-(n[s]??0);return 0},"cmp");i(tee,"checkCliCurrent")});var aee={};ie(aee,{newIssueFromArgs:()=>iee,run:()=>pAe,updateFromArgs:()=>oee});import*as see from"node:fs";function oee(e){let t=e.status||void 0,r=e.comment||void 0;return!t&&!r?"Nothing to update: pass --status <name> and/or --comment <text>.":{status:t,comment:r}}function iee(e,t=r=>see.readFileSync(r,"utf8")){let r=(e.project??"").trim().toUpperCase(),n=e.type??"",s=(e.title??"").trim(),o=e.bodyFile??"";if(!r)return"Pass --project <key> (the Jira project to file in).";if(!nee.includes(n))return`Pass --type ${nee.join("|")} (got '${n}').`;if(!s)return"Pass --title <text>.";if(!o)return"Pass --body-file <path> (or - for stdin).";let a;try{a=t(o==="-"?0:o)}catch(c){return`Could not read --body-file ${o}: ${c.message}`}return{project:r,type:n,title:s,body:a}}function qr(e){M(e),process.exit(1)}async function dAe(e){let t=gn();t.length||qr("no project: add one under projects: in ~/.werkmeister/config.yaml (docs/configuration.md \xA7 Projects)");let r=fs(process.cwd(),yn()),n=e.project||(r===null?"":pi(Ft(r,null))),s=n?t.find(c=>c.name===n):rh()??(t.length===1?t[0]:void 0),o=t.map(c=>c.name).join(", ");s||qr(n?`no project '${n}' (one of: ${o})`:`pass --project (one of: ${o})`);let a;try{a=await ve({project:s.name}).listReady(s.board)}catch(c){qr(`Could not list ready work in ${s.name}: ${c.message}`)}if(e.json)console.log(JSON.stringify(a,null,2));else if(!a.length)F(`Nothing ready in ${s.name}.`);else for(let c of a)console.log(`${c.ref} ${c.status??""} ${c.title??""}`)}async function pAe(e){if(e.action==="ready")return dAe(e);if(e.action==="create"){let l=String(e.project??"").toUpperCase(),u=gn().some(m=>m.tracker==="jira"&&m.scope.project===l)?mo("jira"):ve();u.createIssue||qr(`${u.label} issues are filed with its own CLI: gh issue create -R <owner>/<repo>.`);let f=iee(e);typeof f=="string"&&qr(f);let d=(e.relates??[]).map(m=>{let w=u.parseRef(m);return(!w||w!==m.trim().toUpperCase())&&qr(`--relates '${m}' is not a ${u.label} issue ID (e.g. ${u.refExample}).`),w});d.length&&!u.linkIssue&&qr(`${u.label} cannot link issues.`);let p;try{p=await u.createIssue(f)}catch(m){qr(`Could not create the issue in ${f.project}: ${m.message}`)}F(`Created ${p.ref} (${p.type}).`),console.log(p.url??p.ref);for(let m of d){try{await u.linkIssue?.(p.ref,m)}catch(w){qr(`Created ${p.ref}, but could not link it to ${m}: ${w.message}`)}F(`Linked ${p.ref} relates to ${m}.`)}return}if(e.action==="start"){let l=fs(process.cwd(),yn());l===null&&qr("Not inside a workspace \u2014 run this from a workspace folder or below.");let u=await VW(l)||"left as is (no in_progress status configured)";(u.includes("not moved")?C:F)(`Issue: ${u}`);for(let d of XU(await Do(l)))(d.ok?F:C)(`Worktree: ${d.text}`);let f=tee();(f.current===!0?F:C)(`CLI: ${f.text}`);return}let t=e.action==="update"?oee(e):null;typeof t=="string"&&qr(t);let r=e.ref??"",n="";if(!r){let l=fs(process.cwd(),yn());l===null&&qr("No issue given and not inside a workspace.");let u=Ft(l,null);r=hi(u),n=pi(u),r||qr("No issue given and this workspace has no issue (issue_id in .werkmeister/workspace.yml).")}let s=ve({project:n,text:r}),o=s.parseRef(r);if(o||qr(`'${r}' is not a ${s.label} issue ID (e.g. ${s.refExample}).`),t){try{await s.updateIssue(o,t)}catch(u){qr(`Could not update ${o}: ${u.message}`)}let l=[t.status&&`status \u2192 ${t.status}`,t.comment&&"comment added"].filter(Boolean);F(`Updated ${o}: ${l.join(", ")}.`);return}let a=[],c=await s.fetchIssue(o,a);c||qr(`Could not read ${o} from ${s.label}${a.length?`: ${a.join("; ")}`:""}.`),console.log(e.json?JSON.stringify(c,null,2):Vu(c,{full:!0}))}var nee,cee=A(()=>{"use strict";h();Ca();ze();lT();Pr();Rc();Vt();jf();ree();Ee();i(oee,"updateFromArgs");nee=["bug","feature","task"];i(iee,"newIssueFromArgs");i(qr,"fail");i(dAe,"ready");i(pAe,"run")});var pee={};ie(pee,{inside:()=>fS,parse:()=>dee,run:()=>gAe});import{spawn as hAe}from"node:child_process";import*as Ar from"node:fs";import*as uee from"node:os";import*as Xi from"node:path";function fS(e,t){let r=Ar.realpathSync(e),n=Xi.resolve(r,t);return Ar.existsSync(n)&&(n=Ar.realpathSync(n)),n.startsWith(r+Xi.sep)?n:null}function dee(e){let t={gate:!1,bare:!1,daemon:!1,execRuns:!1,merged:!1,issue:void 0,prFields:void 0,services:void 0,fragment:void 0,workspace:void 0},r=[],n=0;for(;n<e.length;n++){let o=e[n];if(o==="--gate")t.gate=!0;else if(o==="--bare")t.bare=!0;else if(o==="--daemon")t.daemon=!0;else if(o==="--exec-runs"&&n===0)t.execRuns=!0;else if(o==="--merged")t.merged=!0;else if(o==="--issue"){let a=e[++n]??"";if(!/^[A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*#\d+$/.test(a))return{bad:o};t.issue=a}else if(o==="--pr-field"){let a=/^(skip_release|skip_exercise|skip_review|release)=(.*)$/s.exec(e[++n]??"");if(!a)return{bad:o};t.prFields={...t.prFields,[a[1]]:a[2]}}else if(o==="--print"&&e[n+1]!==void 0)r.push(e[++n]);else if((o==="--services"||o==="--fragment")&&e[n+1]!==void 0){let a=fS(process.cwd(),e[++n]);if(!a||!Ar.existsSync(a))return{bad:o};t[o==="--services"?"services":"fragment"]=Ar.readFileSync(a,"utf8")}else if(o==="--workspace"&&e[n+1]!==void 0){let a=fS(process.cwd(),e[++n]),c=null;try{a&&Ar.existsSync(a)&&(c=fee.default.parse(Ar.readFileSync(a,"utf8")))}catch{}if(!c||typeof c!="object"||Array.isArray(c))return{bad:o};t.workspace=c}else break}let s=[[]];for(let o of e.slice(n))o==="--then"?s.push([]):s.at(-1).push(o);return{opts:t,print:r,steps:s}}function PI(e,t){let r=Ar.existsSync(t)?Ar.readFileSync(t,"utf8"):`(none)
|
|
1820
|
+
`)[0]||"timed out";return{current:null,text:`could not check: fetch of origin main in ${l} failed (${w}); re-check with \`werkmeister issue start\``}}let p=u("rev-parse","--abbrev-ref","HEAD")?.stdout.trim();if(p!=="main")return{current:!1,text:`stale: linked checkout ${l} is on '${p}', not main. Fix: ${f}`};let m=u("rev-list","--count","HEAD..origin/main")?.stdout.trim();return u("merge-base","--is-ancestor","origin/main","HEAD")?.status===0?{current:!0,text:`current: linked checkout ${l} contains origin/main`}:{current:!1,text:`stale: linked checkout ${l} is ${m||"some"} commits behind origin/main. Fix: ${f}`}}let o=e.version??JSON.parse(uS.readFileSync(qd.join(eee,"package.json"),"utf8")).version,a=r(["npm","view","werkmeister","version"],30);if(a?.status!==0||!a.stdout.trim())return{current:null,text:`could not look up the latest release (installed ${o}), currency not checked`};let c=a.stdout.trim();return fAe(o,c)>=0?{current:!0,text:`current: ${o} is the latest release`}:{current:!1,text:`stale: installed ${o}, latest release ${c}. Fix: npm i -g werkmeister@latest`}}var eee,fAe,ree=A(()=>{"use strict";h();ut();eee=qd.resolve(qd.dirname(uAe(import.meta.url)),"..",".."),fAe=i((e,t)=>{let[r,n]=[e,t].map(s=>s.split(".").map(Number));for(let s=0;s<3;s++)if((r[s]??0)!==(n[s]??0))return(r[s]??0)-(n[s]??0);return 0},"cmp");i(tee,"checkCliCurrent")});var aee={};ie(aee,{newIssueFromArgs:()=>iee,run:()=>pAe,updateFromArgs:()=>oee});import*as see from"node:fs";function oee(e){let t=e.status||void 0,r=e.comment||void 0;return!t&&!r?"Nothing to update: pass --status <name> and/or --comment <text>.":{status:t,comment:r}}function iee(e,t=r=>see.readFileSync(r,"utf8")){let r=(e.project??"").trim().toUpperCase(),n=e.type??"",s=(e.title??"").trim(),o=e.bodyFile??"";if(!r)return"Pass --project <key> (the Jira project to file in).";if(!nee.includes(n))return`Pass --type ${nee.join("|")} (got '${n}').`;if(!s)return"Pass --title <text>.";if(!o)return"Pass --body-file <path> (or - for stdin).";let a;try{a=t(o==="-"?0:o)}catch(c){return`Could not read --body-file ${o}: ${c.message}`}return{project:r,type:n,title:s,body:a}}function qr(e){M(e),process.exit(1)}async function dAe(e){let t=gn();t.length||qr("no project: add one under projects: in ~/.werkmeister/config.yaml (docs/configuration.md \xA7 Projects)");let r=fs(process.cwd(),yn()),n=e.project||(r===null?"":pi(Ft(r,null))),s=n?t.find(c=>c.name===n):rh()??(t.length===1?t[0]:void 0),o=t.map(c=>c.name).join(", ");s||qr(n?`no project '${n}' (one of: ${o})`:`pass --project (one of: ${o})`);let a;try{a=await ve({project:s.name}).listReady(s.board)}catch(c){qr(`Could not list ready work in ${s.name}: ${c.message}`)}if(e.json)console.log(JSON.stringify(a,null,2));else if(!a.length)F(`Nothing ready in ${s.name}.`);else for(let c of a)console.log(`${c.ref} ${c.status??""} ${c.title??""}`)}async function pAe(e){if(e.action==="ready")return dAe(e);if(e.action==="create"){let l=String(e.project??"").toUpperCase(),u=gn().some(m=>m.tracker==="jira"&&m.scope.project===l)?mo("jira"):ve();u.createIssue||qr(`${u.label} issues are filed with its own CLI: gh issue create -R <owner>/<repo>.`);let f=iee(e);typeof f=="string"&&qr(f);let d=(e.relates??[]).map(m=>{let w=u.parseRef(m);return(!w||w!==m.trim().toUpperCase())&&qr(`--relates '${m}' is not a ${u.label} issue ID (e.g. ${u.refExample}).`),w});d.length&&!u.linkIssue&&qr(`${u.label} cannot link issues.`);let p;try{p=await u.createIssue(f)}catch(m){qr(`Could not create the issue in ${f.project}: ${m.message}`)}F(`Created ${p.ref} (${p.type}).`),console.log(p.url??p.ref);for(let m of d){try{await u.linkIssue?.(p.ref,m)}catch(w){qr(`Created ${p.ref}, but could not link it to ${m}: ${w.message}`)}F(`Linked ${p.ref} relates to ${m}.`)}return}if(e.action==="start"){let l=fs(process.cwd(),yn());l===null&&qr("Not inside a workspace \u2014 run this from a workspace folder or below.");let u=await VW(l)||"left as is (no in_progress status configured)";(u.includes("not moved")?C:F)(`Issue: ${u}`);for(let d of XU(await Do(l)))(d.ok?F:C)(`Worktree: ${d.text}`);let f=tee();(f.current===!0?F:C)(`CLI: ${f.text}`);return}let t=e.action==="update"?oee(e):null;typeof t=="string"&&qr(t);let r=e.ref??"",n="";if(!r){let l=fs(process.cwd(),yn());l===null&&qr("No issue given and not inside a workspace.");let u=Ft(l,null);r=hi(u),n=pi(u),r||qr("No issue given and this workspace has no issue (issue_id in .werkmeister/workspace.yml).")}let s=ve({project:n,text:r}),o=s.parseRef(r);if(o||qr(`'${r}' is not a ${s.label} issue ID (e.g. ${s.refExample}).`),t){try{await s.updateIssue(o,t)}catch(u){qr(`Could not update ${o}: ${u.message}`)}let l=[t.status&&`status \u2192 ${t.status}`,t.comment&&"comment added"].filter(Boolean);F(`Updated ${o}: ${l.join(", ")}.`);return}let a=[],c=await s.fetchIssue(o,a);c||qr(`Could not read ${o} from ${s.label}${a.length?`: ${a.join("; ")}`:""}.`),console.log(e.json?JSON.stringify(c,null,2):Vu(c,{full:!0}))}var nee,cee=A(()=>{"use strict";h();Ca();ze();lT();Pr();Rc();Vt();jf();ree();Ee();i(oee,"updateFromArgs");nee=["bug","feature","task"];i(iee,"newIssueFromArgs");i(qr,"fail");i(dAe,"ready");i(pAe,"run")});var pee={};ie(pee,{inside:()=>fS,parse:()=>dee,run:()=>gAe});import{spawn as hAe}from"node:child_process";import*as Ar from"node:fs";import*as uee from"node:os";import*as Xi from"node:path";function fS(e,t){let r=Ar.realpathSync(e),n=Xi.resolve(r,t);return Ar.existsSync(n)&&(n=Ar.realpathSync(n)),n.startsWith(r+Xi.sep)?n:null}function dee(e){let t={gate:!1,bare:!1,daemon:!1,execRuns:!1,merged:!1,issue:void 0,prFields:void 0,services:void 0,fragment:void 0,workspace:void 0},r=[],n=0;for(;n<e.length;n++){let o=e[n];if(o==="--gate")t.gate=!0;else if(o==="--bare")t.bare=!0;else if(o==="--daemon")t.daemon=!0;else if(o==="--exec-runs"&&n===0)t.execRuns=!0;else if(o==="--merged")t.merged=!0;else if(o==="--issue"){let a=e[++n]??"";if(!/^[A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*#\d+$/.test(a))return{bad:o};t.issue=a}else if(o==="--pr-field"){let a=/^(skip_release|skip_exercise|skip_review|release|status)=(.*)$/s.exec(e[++n]??"");if(!a||a[1]==="status"&&/[\r\n\u2028\u2029\u0085]/.test(a[2]??""))return{bad:o};t.prFields={...t.prFields,[a[1]]:a[2]}}else if(o==="--print"&&e[n+1]!==void 0)r.push(e[++n]);else if((o==="--services"||o==="--fragment")&&e[n+1]!==void 0){let a=fS(process.cwd(),e[++n]);if(!a||!Ar.existsSync(a))return{bad:o};t[o==="--services"?"services":"fragment"]=Ar.readFileSync(a,"utf8")}else if(o==="--workspace"&&e[n+1]!==void 0){let a=fS(process.cwd(),e[++n]),c=null;try{a&&Ar.existsSync(a)&&(c=fee.default.parse(Ar.readFileSync(a,"utf8")))}catch{}if(!c||typeof c!="object"||Array.isArray(c))return{bad:o};t.workspace=c}else break}let s=[[]];for(let o of e.slice(n))o==="--then"?s.push([]):s.at(-1).push(o);return{opts:t,print:r,steps:s}}function PI(e,t){let r=Ar.existsSync(t)?Ar.readFileSync(t,"utf8"):`(none)
|
|
1816
1821
|
`;process.stdout.write(`--- ${e}
|
|
1817
1822
|
${r}${r.endsWith(`
|
|
1818
1823
|
`)?"":`
|
|
1819
|
-
`}`)}async function gAe(e){let t=dee(e);if("bad"in t||t.steps.some(l=>l.length===0)){"bad"in t&&console.error(t.bad==="--pr-field"?"--pr-field: skip_release, skip_exercise, skip_review or
|
|
1824
|
+
`}`)}async function gAe(e){let t=dee(e);if("bad"in t||t.steps.some(l=>l.length===0)){"bad"in t&&console.error(t.bad==="--pr-field"?"--pr-field: skip_release, skip_exercise, skip_review, release or status (one line) =<value>, with --gate":t.bad==="--issue"?"--issue: a GitHub issue as owner/repo#number, e.g. o/app#1":`${t.bad}: a file under the current folder${t.bad==="--workspace"?", holding a YAML mapping":""}`),console.error(lee),process.exitCode=2;return}let{opts:r,print:n,steps:s}=t,o;try{if(o=yK({...r,daemon:void 0}),r.prFields&&!o.prFile)throw new Error("--pr-field needs --gate")}catch(l){console.error(l.message),console.error(lee),process.exitCode=2;return}let a=Ar.realpathSync(Ar.mkdtempSync(Xi.join(uee.tmpdir(),"werkmeister-fixture-"))),c=r.daemon?await pK():null;try{let l=wK(a,{...o,daemon:c?.url}),u={...process.env,...l.env,WERKMEISTER_ROOT:Xi.resolve(Xi.dirname(process.argv[1]),"..")},f=0;for(let d of s)if(f=await mAe(d,l.workspace,u),f!==0)break;for(let d of n){let p=fS(l.workspace,d);p?PI(d,p):process.stdout.write(`--- ${d}
|
|
1820
1825
|
(outside the fixture workspace; not printed)
|
|
1821
1826
|
`)}PI("gh calls",l.ghLog),PI("docker calls",l.dockerLog),c&&process.stdout.write(`--- daemon calls
|
|
1822
1827
|
${c.calls.map(d=>`${d}
|
|
@@ -1938,7 +1943,7 @@ werkmeister feature logs my-feature
|
|
|
1938
1943
|
# Just frontend
|
|
1939
1944
|
werkmeister feature logs my-feature frontend
|
|
1940
1945
|
\`\`\`
|
|
1941
|
-
`;var M9="## Description\n\nLaunches the stdio MCP proxy for Claude Desktop and the werkmeister plugin. It forwards every tool call to the werkmeister daemon (`werkmeister machine setup` or `werkmeister infra connect` starts it), so a rebuild or upgrade reaches running sessions without a `/mcp` reconnect. The `werkmeister` wrapper launches it.\n";var B9="## Description\n\nA one-shot move of the pre-rename machine folder to `~/.werkmeister`, repointing every file that carries the old path. Safe to re-run; it refuses while containers the move would break are running. Pull and rebuild the CLI before you migrate.\n\nIt also brings what an older CLI wrote up to the noun-group spellings
|
|
1946
|
+
`;var M9="## Description\n\nLaunches the stdio MCP proxy for Claude Desktop and the werkmeister plugin. It forwards every tool call to the werkmeister daemon (`werkmeister machine setup` or `werkmeister infra connect` starts it), so a rebuild or upgrade reaches running sessions without a `/mcp` reconnect. The `werkmeister` wrapper launches it.\n";var B9="## Description\n\nA one-shot move of the pre-rename machine folder to `~/.werkmeister`, repointing every file that carries the old path. Safe to re-run; it refuses while containers the move would break are running. Pull and rebuild the CLI before you migrate.\n\nIt also brings what an older CLI wrote up to the noun-group spellings: each workspace's hooks, permission rules and `with-temp-home`, the stale pre-rename MCP token in `secrets.env`, and Claude Desktop's server args. A workspace whose `.env` still exports only `SANDBOX_FEATURE` is listed; run `werkmeister workspace init` there.\n\n## Examples\n\n```bash\nwerkmeister machine migrate --check\nwerkmeister machine migrate --workspaces\n```\n";var U9="## Description\n\n`context` prints the workspace's notes context for a fresh Claude Code window. It is the SessionStart hook's target: it reads the hook's payload on stdin, never fails, and always exits 0.\n\n`graduate` scaffolds an open `decision` note into the standards tree. At a terminal it asks for the domain and kind; otherwise pass `--domain` and `--kind`.\n\n## Examples\n\n```bash\nwerkmeister notes context\nwerkmeister notes graduate 3 --domain testing --kind rule\n```\n";var q9=`## Description
|
|
1942
1947
|
|
|
1943
1948
|
Launches an isolated Chrome window for a feature: it sets the \`X-Feature\` routing cookie and tags the window (title prefix and corner badge) so it is plainly that feature's window. It drives Chrome over the DevTools Protocol, without Playwright.
|
|
1944
1949
|
|
|
@@ -1971,7 +1976,7 @@ Freezes a workspace's running containers and holds its Claude session until \`we
|
|
|
1971
1976
|
werkmeister feature pause my-feature
|
|
1972
1977
|
werkmeister feature resume my-feature
|
|
1973
1978
|
\`\`\`
|
|
1974
|
-
`;var K9="## Description\n\nOpens PRs from a workspace and tracks them to a release. Each action:\n\n- `gate` runs the pre-PR gate for each PR file and changes nothing.\n- `gate --tests` runs only the gate's lint and test rows, in the workspace container, on each worktree's uncommitted tree (committed, staged, unstaged and untracked changes since its base). It needs no PR file and skips the PR-file, clean, baseline and release rows. It starts a container when none is running and stops it after. The implement stage runs it, so a failure that only happens with the container's env shows up before `pr open`.\n- `open` gates, pushes and opens a PR for each PR file at `status: approved`, and records its URL.\n- `gate` and `open` don't wait on host load before their checks
|
|
1979
|
+
`;var K9="## Description\n\nOpens PRs from a workspace and tracks them to a release. Each action:\n\n- `gate` runs the pre-PR gate for each PR file and changes nothing.\n- `gate --tests` runs only the gate's lint and test rows, in the workspace container, on each worktree's uncommitted tree (committed, staged, unstaged and untracked changes since its base). It needs no PR file and skips the PR-file, clean, baseline and release rows. It starts a container when none is running and stops it after. The implement stage runs it, so a failure that only happens with the container's env shows up before `pr open`.\n- `open` gates, pushes and opens a PR for each PR file at `status: approved`, and records its URL.\n- `gate` and `open` don't wait on host load before their checks: the 1-minute load counts the gate's own install and test rows, and the services the gate starts are already admitted against the budget. `--no-wait` is still accepted and does nothing. With tests, a gate can run past a 10-minute tool call: run `pr open` detached, as rule 3 of `_shared/pr-rules.md` shows. `.werkmeister/bin/with-temp-home` runs a shorter wait (up to 90 s) before its command and exits 75 without running it if load is still over (`WERKMEISTER_NO_WAIT=1` skips it). Each service the gate starts waits up to 10 minutes for room in the budget, then fails with `NO_CAPACITY`. A failed check ends with the host load.\n- `status` records merged, shipped or closed from GitHub and the repo's release tags.\n- `adopt` records a PR opened outside the workspace.\n- `watch` resumes each opening session once its PR merges, ships or closes; `--install` schedules it.\n- `new` starts a follow-up PR file and branch for a worktree whose PRs have merged.\n\nInside a workspace, `gh pr create` (and so `/create-pr`) is blocked by a PreToolUse hook; `werkmeister pr open` is the way to open a PR. The full process (PR files, the gate, ship detection, the PR guard) is in [docs/workspace-lifecycle.md](workspace-lifecycle.md).\n\n## Examples\n\n```bash\nwerkmeister pr gate\nwerkmeister pr gate --tests\nwerkmeister pr open\nwerkmeister pr status --json\n```\n\n## See also\n\n`werkmeister workspace close` ends the workspace once its PRs have shipped.\n";var G9="## Description\n\nReads all active slot assignments, regenerates `~/.werkmeister/infra/proxy/Caddyfile`, and reloads (or starts) Caddy. Useful after manual config changes or if the proxy gets out of sync.\nWarns about routed hostnames that do not resolve to 127.0.0.1 on this machine and prints the `/etc/hosts` line to add.\n";var V9="## Description\n\nRegenerates `~/.werkmeister/services.yaml` from every repo's `.werkmeister/services.yaml` fragment under `paths.repos_root`, merged under `~/.werkmeister/services.local.yaml`. It is the same step `werkmeister machine setup` runs, on its own: use it after cloning a new repo. `werkmeister pr status` runs it too when a merged PR changes a fragment and the repo sets `sync_on_merge: auto` ([Ship detection](workspace-lifecycle.md#ship-detection-registry-repo)).\n\nTo prove a fragment change before it merges, `--from <worktree>` takes that checkout's `.werkmeister/services.yaml` in place of its repo's fragment under `paths.repos_root`, and `--out <file>` writes the merged registry there instead of `~/.werkmeister/services.yaml` (which is never touched, nor is `services.local.yaml` seeded). `--check` compares against `--out` the same way.\n\n## Examples\n\n```bash\nwerkmeister registry # regenerate (sync is the default action)\nwerkmeister registry --check # report drift; nonzero exit when stale\nwerkmeister registry --from ./werkmeister --out /tmp/services.yaml # branch fragment, temp registry\nwerkmeister registry --check --from ./werkmeister --out /tmp/services.yaml # is that file current?\n```\n";var Y9=`## Description
|
|
1975
1980
|
|
|
1976
1981
|
Removes the service from the feature's local stack. The service will now be served from k8s. Config files are regenerated and Caddy is reloaded.
|
|
1977
1982
|
|
|
@@ -2085,7 +2090,7 @@ A feature's row ends with its CPU and memory and how long ago it started, when k
|
|
|
2085
2090
|
\`\`\`
|
|
2086
2091
|
|
|
2087
2092
|
When the forwards container is not running, it says so instead of listing rows: \`not running\` (start it with \`werkmeister infra connect\`), \`container w9r-k8s-forwards is down\`, or \`stopped \u2014 not needed by any running workspace\`.
|
|
2088
|
-
`;var Q2="## Description\n\nStops a feature's containers without removing them or releasing its slot. Bring it back with `werkmeister feature restart` or `werkmeister feature up`. Use `infra` as the feature name to stop the shared infrastructure.\n\nTwo modes run without a person: `--if-idle` is the SessionEnd hook behind a workspace's `auto_stop`, and `--idle` is one pass of the idle reaper over every workspace.\n\n## Examples\n\n```bash\nwerkmeister feature stop my-feature\nwerkmeister infra stop\nwerkmeister internal reap 30\n```\n\n## See also\n\n`werkmeister feature down` also releases the slot; `werkmeister feature pause` freezes the containers instead.\n";var oB="## Description\n\n**What it does:**\n\n1. Looks for a `playwright.config.ts` (or `.js`/`.mjs`) in the workspace root, then in each repo worktree under it (`~/workspace/<feature>/<repo>/`). There is no fallback to the Werkmeister root.\n2. If none is found, runs nothing and exits non-zero. The message lists each workspace service's test command and `validate:` guidance. Libraries, CLIs and extensions are validated that way, not with Playwright; see [Test commands and validation guidance](registry-fragments.md#test-commands-and-validation-guidance).\n3. Otherwise sets `WERKMEISTER_FEATURE`
|
|
2093
|
+
`;var Q2="## Description\n\nStops a feature's containers without removing them or releasing its slot. Bring it back with `werkmeister feature restart` or `werkmeister feature up`. Use `infra` as the feature name to stop the shared infrastructure.\n\nTwo modes run without a person: `--if-idle` is the SessionEnd hook behind a workspace's `auto_stop`, and `--idle` is one pass of the idle reaper over every workspace.\n\n## Examples\n\n```bash\nwerkmeister feature stop my-feature\nwerkmeister infra stop\nwerkmeister internal reap 30\n```\n\n## See also\n\n`werkmeister feature down` also releases the slot; `werkmeister feature pause` freezes the containers instead.\n";var oB="## Description\n\n**What it does:**\n\n1. Looks for a `playwright.config.ts` (or `.js`/`.mjs`) in the workspace root, then in each repo worktree under it (`~/workspace/<feature>/<repo>/`). There is no fallback to the Werkmeister root.\n2. If none is found, runs nothing and exits non-zero. The message lists each workspace service's test command and `validate:` guidance. Libraries, CLIs and extensions are validated that way, not with Playwright; see [Test commands and validation guidance](registry-fragments.md#test-commands-and-validation-guidance).\n3. Otherwise sets `WERKMEISTER_FEATURE` and, when the feature has a slot, `WERKMEISTER_SLOT` for the Playwright process and runs `npx playwright test` from that directory with a 10-minute timeout\n\n```bash\n# Run all tests\nwerkmeister feature test my-feature\n\n# Run specific test file\nwerkmeister feature test my-feature -- tests/homepage.spec.ts\n\n# Run with headed browser\nwerkmeister feature test my-feature -- --headed\n```\n\nThe feature doesn't need to have an active slot \u2014 if it doesn't, the command warns but proceeds with just the feature header routing.\n\n**`--scaffold`** writes a starter `playwright.config.ts` and spec into the workspace and installs the pinned Playwright, without running anything. It refuses a feature name that already has a slot.\n";var iB=`## Description
|
|
2089
2094
|
|
|
2090
2095
|
**What it does:**
|
|
2091
2096
|
|
|
@@ -2095,7 +2100,7 @@ When the forwards container is not running, it says so instead of listing rows:
|
|
|
2095
2100
|
Without \`--remove\` nothing changes. If the workspaces root cannot be read or holds no workspace folder, nothing is removed and the command exits 1.
|
|
2096
2101
|
|
|
2097
2102
|
**When to use:**
|
|
2098
|
-
- Once after upgrading past 0.74.0: core tests
|
|
2103
|
+
- Once after upgrading past 0.74.0: core tests from older versions left tokens there (see the release notes for the name prefixes)
|
|
2099
2104
|
- After deleting a workspace folder by hand
|
|
2100
2105
|
|
|
2101
2106
|
A removed token is minted again by the next \`werkmeister workspace init\` for that workspace.
|
|
@@ -2104,7 +2109,7 @@ A workspace that lives outside the workspaces root counts as stale: keep \`paths
|
|
|
2104
2109
|
`;var aB="## Description\n\nThe local services come from the workspace's `.werkmeister/workspace.yml` (via `werkmeister workspace init`), not from a flag.\n\n**What it does:**\n\n1. Loads the service registry and port configuration, and stops with a clear message if a secret one of the workspace's services needs is missing\n2. Resolves the workspace (`--workspace`, else `paths.workspaces_root` from the config, else the nearest enclosing repo's parent, else `~/workspace/`) and reads its local services from the `SERVICES=` line `werkmeister workspace init` wrote to the workspace `.env`\n3. Allocates a slot (1\u201312) if the feature doesn't already have one\n4. When the workspace has local services, checks the host's memory and CPU budget (`werkmeister budget status`). If the feature doesn't fit it waits in a queue and starts when another feature stops. A service start that doesn't fit may instead stop features whose session is idle or waiting on a person, oldest first, and says which; a feature a person starts may also stop working autonomous ones (`budget.preempt: false` turns both off)\n5. Generates per-feature files in the feature's workspace:\n - `compose.yml` \u2014 Docker Compose stack definition (workspace root)\n - `.env` \u2014 Environment variables with resolved service URLs (workspace root)\n - `<workspace>/.werkmeister/supergraph-config.yml` \u2014 GraphQL federation config (only when a service has a GraphQL type: `graphql-subgraph`, `graphql`, `subgraph` or `federation`)\n6. Verifies k8s port-forwards are healthy (restarts if needed), only when a local service needs the cluster\n7. Starts containers with `docker compose up -d --build --remove-orphans`\n8. Regenerates `~/.werkmeister/infra/proxy/Caddyfile` and reloads Caddy (or starts it, when something here is routed)\n9. Warns about routed hostnames that do not resolve to 127.0.0.1 on this machine and prints the `/etc/hosts` line to add (the command still succeeds)\n\n**Output example:**\n\n```\n=== werkmeister up: my-feature ===\n\n[info] Loading configuration...\n[ok] Allocated slot 1 for 'my-feature'\n\n Local services: backend, frontend\n\n[info] Checking k8s port-forwards...\n[info] Starting containers...\n[info] Configuring reverse proxy...\n\n=== Feature 'my-feature' is ready ===\n\n URL: https://frontend.local.werkmeister.io\n Cookie: X-Feature=my-feature\n Slot: 1 (ports 11100-11119)\n\n Local services:\n * backend -> localhost:11100\n * frontend -> localhost:11101\n\n k8s services: (everything not listed above)\n\n Useful commands:\n werkmeister feature status # view all features\n werkmeister feature logs my-feature # tail logs\n werkmeister feature test my-feature # run Playwright tests\n werkmeister feature down my-feature # tear down\n```\n\n**If the workspace lists no services**, the command still proceeds \u2014 the feature is registered and routes entirely to k8s. To add services later, list them in `.werkmeister/workspace.yml`, rerun `werkmeister workspace init`, then `werkmeister feature up`.\n\n**If the feature has to wait for capacity**, the command exits successfully without starting containers and prints `=== Feature '<name>' is waiting for capacity (position N) ===`. `werkmeister feature status` shows the queue.\n\n**If every slot is taken** (12 by default, `feature_slots.count`), the command exits with an error. Free a slot by running `werkmeister feature down` on another feature.\n\n**`--service <name>`** starts only that one service, the way the PR gate starts it, and prints `Started <feature>-<name>`.\n\n**Adding a service to a running feature.** To run another service locally, add it to the `services` field in the workspace's `.werkmeister/workspace.yml`, rerun `werkmeister workspace init` (this also adds the owning repo's worktree if it isn't there yet), then `werkmeister feature up`.\n";var cB="## Description\n\nWaits while the host's 1-minute load is above `budget.host_load` in `~/.werkmeister/config.yaml` (default: 2 \xD7 CPUs; `0` turns it off), for up to 90 seconds (under an agent's 2-minute Bash timeout). If load is still over the limit then, it exits 75 and the wrapper stops without running its command (SW-540). On macOS it returns at once: its load average counts idle daemons and is never the Linux VM's, so it is no signal to wait on (SW-556). `.werkmeister/bin/with-temp-home` runs it before its command; `WERKMEISTER_NO_WAIT=1` makes the wrapper skip it.\n";var lB="## Description\n\nCreates a new workspace under the workspaces root and initializes it. It resolves its inputs (flags, an existing `workspace.yml`, or the interactive wizard), creates the workspace folder as a git worktree of the workspace record repo (`overrides.workspace_repo`) on a `user/workspace` branch, writes `.werkmeister/workspace.yml`, and runs `werkmeister workspace init` inside it. The initial state is committed, not pushed.\n\n## Examples\n\n```bash\nwerkmeister workspace new my-feature --issue-id SW-180 --services backend,frontend\nwerkmeister workspace new my-feature --context-strategy icm --work-type refactor\n```\n\n## See also\n\n`werkmeister workspace init` owns everything derived from `workspace.yml`; `werkmeister workspace close` ends a workspace.\n";h();ut();import{execFileSync as uB}from"node:child_process";import*as fB from"node:fs";import*as dB from"node:path";var pB=typeof v>"u"?void 0:v,lhe="pnpm turbo run build --filter=werkmeister",uhe=["apps/cli","apps/werkmeister-mcp","packages/werkmeister-core","pnpm-lock.yaml"];function hB(e,t){if(!e?.sha||!fB.existsSync(dB.join(t,".git")))return null;let r;try{r=uB("git",["-C",t,"rev-parse","HEAD"],{encoding:"utf8",env:ya(),stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}if(r===e.sha)return null;try{return uB("git",["-C",t,"diff","--quiet",e.sha,r,"--",...uhe],{env:ya(),stdio:"ignore"}),null}catch{}return`warning: this werkmeister CLI was built from ${e.sha.slice(0,7)+(e.dirty?" (+uncommitted changes)":"")}, but ${t} is at ${r.slice(0,7)}.
|
|
2105
2110
|
Rebuild it from ${t}: ${lhe}`}i(hB,"staleBuildWarning");$i();var NI=Wd.resolve(Wd.dirname(wAe(import.meta.url)),"..");_e("ROOT")||(process.env.WERKMEISTER_ROOT=NI);var dS="\x1B[31m",xAe="\x1B[1m",Z0="\x1B[0m",kAe=`${xAe}Werkmeister CLI${Z0}
|
|
2106
2111
|
Multi-feature concurrent development orchestrator
|
|
2107
|
-
`,mee=["Features:","Workspaces:","PRs and issues:","Services and infra:","Agent context:","Machine:","Internal:"],bAe="0.58.0",vAe={feature:{description:"Run a feature's containers: up, down, stop, logs, test and the rest"},workspace:{description:"Create, reconcile, list, open and close workspaces",alias:"ws"},pr:{description:"Open and track this workspace's PRs from its PR files (docs/workspace-lifecycle.md)",help:K9},issue:{description:"Read, update or file an issue in this machine's issue tracker (see `werkmeister machine setup`)",help:L9},infra:{description:"Shared infrastructure: Caddy, k8s port-forwards and Telepresence"},machine:{description:"Machine-wide setup, config, migration and housekeeping"},budget:{description:"The scheduler's budget, the slots held and the features Waiting for room",help:_9},daemon:{description:"The host daemon (the MCP server on port 3002)",help:A9},internal:{description:"Hook, tool and sibling-app entry points; not typed by people"}},SAe=i((e,t)=>`werkmeister: '${e}' is deprecated and will be removed in ${bAe}; use 'werkmeister ${t}'. Run 'werkmeister machine migrate' to update hooks and permission rules.`,"deprecation"),gee=[{name:"feature up",old:"up",group:"Features:",help:aB,load:i(()=>Promise.resolve().then(()=>(IO(),PO)),"load"),configure:i(e=>{e.description("Detect services, allocate slot, generate config, start containers").argument("[feature]","Feature name (arbitrary label for slot/proxy routing). If omitted, read from FEATURE in a .env file in the current directory tree.").option("-w, --workspace <path>","Path to directory containing repo checkouts. Default: ~/workspace (override with WORKSPACE env var).").option("--dev","Run the file watchers in cli/library/extension containers, which otherwise idle.").option("--service <name>","Start only this service and wait for it, the way the PR gate does \u2014 including one behind the on-demand profile (SW-132). `feature stop` stops it.")},"configure"),namespace:i(([e],t)=>({feature:e??null,workspace:t.workspace??null,dev:t.dev??!1,...t.service?{service:t.service}:{}}),"namespace")},{name:"feature down",old:"down",group:"Features:",help:I9,load:i(()=>Promise.resolve().then(()=>(DO(),LO)),"load"),configure:i(e=>{e.description("Stop containers, release slot, update proxy (`infra <verb>` for shared infra)").argument("[feature]","Feature name or 'infra'. If omitted, read from FEATURE in a .env file.").option("-v, --volumes","Also remove Docker volumes (node_modules, caches)").option("--all-features","Stop and clean up all active features (ignores <feature> argument)")},"configure"),namespace:i(([e],t)=>({feature:e??null,volumes:!!t.volumes,all_features:!!t.allFeatures}),"namespace")},{name:"infra intercept",old:"intercept",group:"Services and infra:",help:j9,load:i(()=>Promise.resolve().then(()=>(yW(),gW)),"load"),configure:i(e=>{e.description("Route header-scoped k8s dev traffic to a local service (Telepresence OSS).").argument("[feature]","Feature name (defaults to FEATURE from a .env file in CWD).").option("-s, --service <name>","Local service to intercept (must be in the workspace's SERVICES and running via `werkmeister feature up`).").option("--leave","End the intercept for -s (or all of this feature's intercepts without -s).").option("--status","Show telepresence connection and intercept status.").option("--docker-daemon","Run the telepresence daemon in a container (connect --docker) \u2014 avoids the host TUN device, its sudo prompt, and VPN routing conflicts. In exchange the host loses cluster DNS: nothing on your laptop resolves <svc>.<ns> while connected this way.").option("--workspace <path>","Explicit workspace path (default: resolve from the feature name).")},"configure"),namespace:i(([e],t)=>({feature:e??null,service:t.service??null,leave:!!t.leave,status:!!t.status,docker_daemon:!!t.dockerDaemon,workspace:t.workspace??null}),"namespace")},{name:"feature restart",old:"restart",group:"Features:",help:J9,load:i(()=>Promise.resolve().then(()=>(MO(),FO)),"load"),configure:i(e=>{e.description("Restart containers (`infra <verb>` for shared infra)").argument("[feature]","Feature name or 'infra'. If omitted, read from FEATURE in a .env file.")},"configure"),namespace:i(([e])=>({feature:e??null}),"namespace")},{name:"feature pause",old:"pause",group:"Features:",help:H9,load:i(()=>Promise.resolve().then(()=>(BO(),wW)),"load"),configure:i(e=>{e.description("Freeze a workspace's running containers and hold its Claude session until resume").argument("[feature]","Feature name. If omitted, read from FEATURE in a .env file.")},"configure"),namespace:i(([e])=>({feature:e??null}),"namespace")},{name:"feature resume",old:"resume",group:"Features:",help:X9,load:i(()=>Promise.resolve().then(()=>(vG(),bG)),"load"),configure:i(e=>{e.description("Thaw exactly the containers pause froze, release the session, and tell it to continue").argument("[feature]","Feature name. If omitted, read from FEATURE in a .env file.")},"configure"),namespace:i(([e])=>({feature:e??null}),"namespace")},{name:"stop",deprecated:i(e=>e.if_idle?"internal session-end":e.idle?"internal reap <minutes>":e.feature==="infra"?"infra stop":"feature stop","deprecated"),group:"Features:",help:Q2,load:i(()=>Promise.resolve().then(()=>(pd(),dd)),"load"),configure:i(e=>{e.description("Stop containers without removing them or releasing the slot (`infra <verb>` for shared infra)").argument("[feature]","Feature name or 'infra'. If omitted, read from FEATURE in a .env file.").option("--if-idle","SessionEnd hook mode: stop the workspace's own feature unless another Claude session is open there; silent, always exits 0, never stops infra").option("--idle <minutes>","Stop every workspace's feature containers nothing has used for <minutes> (a busy or recently active session, a gate exec or a fresh start all count as use); with [feature], only that one").addOption(new ss("--via-daemon").hideHelp())},"configure"),namespace:i(([e],t)=>({feature:e??null,if_idle:!!t.ifIdle,idle:t.idle??null,via_daemon:!!t.viaDaemon}),"namespace")},{name:"status",deprecated:i(e=>e.k8s?"infra status":"feature status","deprecated"),group:"Features:",help:X2,load:i(()=>Promise.resolve().then(()=>(Rb(),Tb)),"load"),configure:i(e=>{e.description("Show all features, services, resource usage").option("-v, --verbose","Show individual container details").option("--k8s","Show k8s port-forward health only (replaces standalone k8s-status command)").option("--intercepts","Show Telepresence intercept state only (per feature service; cheap \u2014 skips docker and k8s probes).").option("--json","Output structured JSON (useful for agent-driven diagnosis)")},"configure"),namespace:i((e,t)=>({verbose:!!t.verbose,k8s:!!t.k8s,intercepts:!!t.intercepts,json:!!t.json}),"namespace")},{name:"machine detect",old:"detect",group:"Machine:",help:P9,load:i(()=>Promise.resolve().then(()=>(BQ(),MQ)),"load"),configure:i(e=>{e.description("Generate <repo>/.werkmeister/services.yaml from the repo's package manifests, Dockerfiles, compose, Helm and k8s files (re-runs only add what is missing)").argument("[repo]","Repo directory (default: the git repo containing the current directory)").option("--dry-run","Show the report and the proposed YAML; write nothing").option("-y, --yes","Write without asking").option("--assist","Ask Claude to resolve the fields the scan had to guess").option("--no-assist","Never ask Claude")},"configure"),namespace:i(([e],t)=>({repo:e??null,dryRun:!!t.dryRun,yes:!!t.yes,assist:t.assist}),"namespace")},{name:"feature services",old:"services",group:"Features:",help:Q9,load:i(()=>Promise.resolve().then(()=>(qQ(),UQ)),"load"),configure:i(e=>{e.description("List services and their endpoints for a feature").argument("<feature>","Feature name")},"configure"),namespace:i(([e])=>({feature:e}),"namespace")},{name:"feature logs",old:"logs",group:"Features:",help:F9,load:i(()=>Promise.resolve().then(()=>(HQ(),WQ)),"load"),configure:i(e=>{e.description("Tail a feature's container logs").argument("<feature>","Feature name").argument("[service]","Specific service to tail (optional)")},"configure"),namespace:i(([e,t])=>({feature:e,service:t??null}),"namespace")},{name:"feature drop",old:"remove",group:"Features:",help:Y9,load:i(()=>Promise.resolve().then(()=>(GQ(),KQ)),"load"),configure:i(e=>{e.description("Stop a local service, fall back to k8s").argument("<feature>","Feature name").argument("<service>","Service name to remove")},"configure"),namespace:i(([e,t])=>({feature:e,service:t}),"namespace")},{name:"feature test",old:"test",group:"Features:",help:oB,load:i(()=>Promise.resolve().then(()=>(zQ(),YQ)),"load"),configure:i(e=>{e.description("Run Playwright tests against a feature's stack").argument("<feature>","Feature name").argument("[extra...]","Additional arguments to pass to Playwright").option("--scaffold","Don't run: write playwright.config.ts + <feature>.spec.ts into the workspace (if missing) and install the pinned @playwright/test").option("-w, --workspace <path>","--scaffold: workspace directory (default: from cwd)").option("--base-url <url>","--scaffold: ingress URL to target (default: the first feature_router service)")},"configure"),namespace:i(([e,t],r)=>({feature:e,extra:t??[],scaffold:r.scaffold??!1,workspace:r.workspace??null,base_url:r.baseUrl??null}),"namespace")},{name:"workspace prompt",old:"starting-prompt",group:"Workspaces:",help:nB,load:i(e=>e.args?Promise.resolve().then(()=>(EI(),_I)):Promise.resolve().then(()=>(SI(),XQ)),"load"),configure:i(e=>{e.description("Print the enclosing workspace's starting_prompt from workspace.yml").option("--start <dir>","Directory to search up from (default: cwd)").option("--args","Print the start_session arguments (title, model, prompt, background) as JSON instead")},"configure"),namespace:i((e,t)=>({start:t.start??null,...t.args?{args:!0}:{}}),"namespace")},{name:"start-args",deprecated:i(()=>"workspace prompt --args","deprecated"),group:"Internal:",help:rB,load:i(()=>Promise.resolve().then(()=>(EI(),_I)),"load"),configure:i(e=>{e.description("Print the start_session arguments (title, model, prompt, background) for the enclosing workspace, as JSON").option("--start <dir>","Directory to search up from (default: cwd)")},"configure"),namespace:i((e,t)=>({start:t.start??null}),"namespace")},{name:"internal wait-load",old:"wait-load",group:"Internal:",help:cB,load:i(()=>Promise.resolve().then(()=>(ZQ(),QQ)),"load"),configure:i(e=>{e.description("Wait, up to 90 s, while host load is above budget.host_load; with-temp-home runs it first")},"configure"),namespace:i(()=>({}),"namespace")},{name:"feature open",old:"open",group:"Features:",help:q9,load:i(()=>Promise.resolve().then(()=>(tZ(),eZ)),"load"),configure:i(e=>{e.description("Open a feature-tagged Chrome window with the X-Feature cookie set (no Playwright)").argument("[feature]","Feature name -> sets X-Feature=<feature>. If omitted, read from FEATURE in a .env file.").option("--url <url>","Full start URL (overrides --path). Default: the first routed host's homepage.").option("--path <path>","Path appended to the first routed host (default: test_path from .werkmeister/workspace.yml, else TEST_PATH from .env, else '/').").option("--size <W,H>","Window size WIDTH,HEIGHT (default: 1440,900).","1440,900").option("--position <X,Y>","Window position X,Y (default: staggered by feature name).")},"configure"),namespace:i(([e],t)=>({feature:e??null,url:t.url??null,path:t.path??null,size:t.size,position:t.position??null}),"namespace")},{name:"infra connect",old:"connect",group:"Services and infra:",help:R9,load:i(()=>Promise.resolve().then(()=>(CO(),AO)),"load"),configure:i(e=>{e.description("Start all shared infrastructure (local + k8s port-forwards)").option("--k8s","Start/restart k8s port-forwards container only (replaces standalone k8s-connect command)")},"configure"),namespace:i((e,t)=>({k8s:!!t.k8s}),"namespace")},{name:"infra proxy-reload",old:"proxy-reload",group:"Services and infra:",help:G9,load:i(()=>Promise.resolve().then(()=>(nZ(),rZ)),"load"),configure:i(e=>{e.description("Regenerate Caddyfile and reload Caddy")},"configure"),namespace:i(()=>({}),"namespace")},{name:"machine clean",old:"clean",group:"Machine:",help:$9,load:i(()=>Promise.resolve().then(()=>(oZ(),sZ)),"load"),configure:i(e=>{e.description("Remove orphaned volumes and generated files from stopped features").option("--all","Also clean volumes for currently active features (implies werkmeister down for each)").option("--dry-run","Show what would be cleaned without actually removing anything")},"configure"),namespace:i((e,t)=>({all:!!t.all,dry_run:!!t.dryRun}),"namespace")},{name:"machine tokens",group:"Machine:",help:iB,load:i(()=>Promise.resolve().then(()=>(aZ(),iZ)),"load"),configure:i(e=>{e.description("List daemon tokens with no workspace; --remove deletes them").option("--remove","Delete the stale tokens (default: list only)")},"configure"),namespace:i((e,t)=>({remove:!!t.remove}),"namespace")},{name:"machine stats",old:"stats",group:"Machine:",help:sB,load:i(()=>Promise.resolve().then(()=>(hR(),CG)),"load"),configure:i(e=>{e.description("Show Docker container resource usage (CPU, memory)").option("--collect <MINUTES>","Collect stats over N minutes (default: snapshot only)",t=>Number.parseInt(t,10),0).option("-i, --interval <SECS>","Sampling interval in seconds (default: 10)",t=>Number.parseInt(t,10),10).option("--save","Save results to stats/ directory")},"configure"),namespace:i((e,t)=>({collect:t.collect,interval:t.interval,save:!!t.save}),"namespace")},{name:"machine optimize",old:"optimize",group:"Machine:",help:W9,load:i(()=>Promise.resolve().then(()=>(lZ(),cZ)),"load"),configure:i(e=>{e.description("Analyze resource usage vs configured limits, recommend changes").option("--collect <MINUTES>","Collect stats over N minutes before analyzing (default: quick snapshot)",t=>Number.parseInt(t,10),0).option("-i, --interval <SECS>","Sampling interval in seconds (default: 10)",t=>Number.parseInt(t,10),10)},"configure"),namespace:i((e,t)=>({collect:t.collect,interval:t.interval}),"namespace")},{name:"skills",group:"Agent context:",help:eB,load:i(()=>Promise.resolve().then(()=>(fZ(),uZ)),"load"),configure:i(e=>{e.description("Workspace w9r-* skill projection: verify freshness against the werkmeister repo (check) or rewrite it (sync)").addArgument(new Kd("<action>","check: exit 1 if the workspace's .claude/skills/w9r-* lag the repo; sync: refresh them").choices(["check","sync"]))},"configure"),namespace:i(([e])=>({action:e}),"namespace")},{name:"standards",group:"Agent context:",help:tB,load:i(()=>Promise.resolve().then(()=>(pZ(),dZ)),"load"),configure:i(e=>{e.description("Validate the configured standards tree (structural regression gate)").addArgument(new Kd("<action>","check: exit 1 if any standard module is structurally malformed").choices(["check"]))},"configure"),namespace:i(([e])=>({action:e}),"namespace")},{name:"hooks",deprecated:i(e=>`internal ${e.action}`,"deprecated"),group:"Internal:",help:J2,load:i(()=>Promise.resolve().then(()=>(OI(),$I)),"load"),configure:i(e=>{e.description("Claude Code hook entrypoints: the standards gate, the PR guard and the agent state").addArgument(new Kd("<action>","gate: deny or allow an Edit/Write per the standards gate; pr-guard: deny opening a PR except via `werkmeister pr open`; agent-state: record working / needs-you / done for the workspace pane and dashboard").choices(["gate","pr-guard","agent-state"]))},"configure"),namespace:i(([e])=>({action:e}),"namespace")},{name:"notes",group:"Agent context:",help:U9,load:i(()=>Promise.resolve().then(()=>(NO(),pW)),"load"),configure:i(e=>{e.description("Workspace notes (.werkmeister/notes/). `context` prints the latest handoff + open decisions for session-start injection (hook target); `graduate` scaffolds an open decision note into the standards tree.").addArgument(new Kd("<action>","context: print notes context for the enclosing workspace (silent if none); graduate: scaffold an open decision note into the standards tree").choices(["context","graduate"])).argument("[note_num]","graduate: note number to graduate (omit to pick interactively)").option("--domain <domain>","graduate: target <domain> in the standards tree (omit to infer from refs, or prompt)").addOption(new ss("--kind <kind>","graduate: content kind to scaffold (omit to prompt)").choices(["rule","example","anti-pattern"])).option("--slug <slug>","graduate: override the derived reference-file slug")},"configure"),namespace:i(([e,t],r)=>({action:e,note_num:t==null?null:Number.parseInt(t,10),domain:r.domain??null,kind:r.kind??null,slug:r.slug??null}),"namespace")},{name:"workspace new",group:"Workspaces:",help:lB,load:i(()=>Promise.resolve().then(()=>(kZ(),xZ)),"load"),configure:i(e=>{e.description("Create a new workspace under $WERKMEISTER_WORKSPACES_ROOT (git worktrees on a <user>/<workspace> branch) and run init-workspace inside it.").argument("[feature]","Feature name (lower-cased). Combined with --issue-id to form the workspace dir name, e.g. an issue + feature -> <issue-slug>-feature. If omitted, resolved from ./.werkmeister/workspace.yml, then interactively (TTY).").option("--issue-id <ref>","Issue ID in this machine's issue tracker (see `werkmeister machine setup`). Its slug is prefixed to the workspace dir name; passed through to init-workspace.").option("--project <name>","The project (projects: in ~/.werkmeister/config.yaml) whose tracker holds the issue. Default: the one whose scope holds --issue-id, else the default project.").option("-s, --services <list>","Comma-separated services to run locally. Their owning repos are added as worktrees, and the list is passed through to init-workspace.").option("-r, --repos <list>","Comma-separated repos to create worktrees for (union with the repos derived from --services). Interactive multi-select if neither --repos nor --services is given.").option("--labels <list>","Comma-separated free-form tags for filtering workspaces in the dashboard search; passed through to init-workspace.").option("--group <keys>","Comma-separated member issue keys of a grouped PR led by --issue-id (one PR, one commit per ticket); passed through to init-workspace.").option("-t, --task <title>","Task title for the workspace CLAUDE.md; passed through to init-workspace.").option("--test-path <path>","URL path for feature testing; passed through to init-workspace.").option("--description <text>","Free-form description for the CLAUDE.md header; passed through to init-workspace.").option("--starting-prompt <text>","First instruction for the agent; passed through to init-workspace.").addOption(new ss("--work-type <type>","Kind of work; selects the ICM stages and seeds the JIT first-phase handoff note. Passed through to init-workspace.").choices(["feature","bugfix","refactor","spike","incident"])).addOption(new ss("--context-strategy <id>","Context layer to generate: jit (skills, hooks, notes) or icm (staged folders). (env: WERKMEISTER_CONTEXT_STRATEGY; config: context_strategy).").choices([...kn])).addOption(new ss("--harness <id>","Agent harness that reads the workspace: claude (CLAUDE.md, .claude/, hooks), mcp (AGENTS.md, .agents/skills, no hooks), codex (AGENTS.md, .agents/skills, .codex/hooks.json, .codex/config.toml) or opencode (AGENTS.md, .agents/skills, opencode.json, hooks plugin) (env: WERKMEISTER_HARNESS; config: harness).").choices([...fr])).option("--autonomous","Run an icm workspace stage-to-PR with no human checks, and allow the Bash calls a headless session needs (env: WERKMEISTER_AUTONOMOUS; config: autonomous).").option("--model <tier|model>","Model tier (small, mid, frontier, advanced_frontier) or an explicit model; blank = models.default_tier in ~/.werkmeister/config.yaml (frontier) (env: WERKMEISTER_MODEL; config: model).").option("--auto-stop","Stop this workspace's feature containers when a Claude session in it ends and no other is open (a SessionEnd hook; env: WERKMEISTER_AUTO_STOP; config: auto_stop).").option("--browser-form","Collect inputs through the Werkmeister-branded browser form (the same form the Desktop MCP App renders), pre-filled from every flag given, then create the workspace. Opens a localhost page in the default browser and blocks until submit/cancel.").option("--no-distill","Store the issue but don't have a model rewrite it into description/starting_prompt.").option("--open","With --browser-form: launch VS Code on the new workspace after creating.").option("--force","Delete a <user>/<workspace> branch an earlier workspace of the same name left on origin, instead of aborting (that branch's work is gone; see the abort message for how to continue it instead).")},"configure"),namespace:i(([e],t)=>({feature:e??null,issue_id:t.issueId??null,project:t.project??null,services:t.services??null,repos:t.repos??null,labels:t.labels??null,group:t.group??null,task:t.task??null,test_path:t.testPath??null,description:t.description??null,starting_prompt:t.startingPrompt??null,work_type:t.workType??null,context_strategy:t.contextStrategy??null,harness:t.harness??null,autonomous:t.autonomous??null,model:t.model??null,auto_stop:t.autoStop??null,browser_form:!!t.browserForm,open_vscode:!!t.open,no_distill:t.distill===!1,force:!!t.force}),"namespace")},{name:"workspace list",old:"list-workspaces",group:"Workspaces:",help:D9,load:i(()=>Promise.resolve().then(()=>(vZ(),bZ)),"load"),configure:i(e=>{e.description("List the workspaces under the workspaces root with their issue and labels")},"configure"),namespace:i(()=>({}),"namespace")},{name:"remove-workspace",deprecated:i(()=>"workspace abandon <reason>","deprecated"),group:"Workspaces:",help:z9,load:i(()=>Promise.resolve().then(()=>(_Z(),SZ)),"load"),configure:i(e=>{e.description("Deprecated: use `werkmeister workspace abandon <reason>`. Hand off (commit + push) and delete a workspace").argument("<name>","Workspace directory name, as `werkmeister workspace list` reports it").option("-y, --yes","Skip the confirmation prompt").option("--abandon <reason>","Remove despite unshipped work; records the reason in closeout.md and the PR files")},"configure"),namespace:i(([e],t)=>({name:e,yes:!!t.yes,abandon:t.abandon??null}),"namespace")},{name:"close-out",deprecated:i(e=>e.abandon?"workspace abandon <reason>":"workspace close","deprecated"),group:"Workspaces:",help:z2,load:i(()=>Promise.resolve().then(()=>(aS(),iS)),"load"),configure:i(e=>{e.description("End a workspace. After every PR shipped: close the issue, write closeout.md, remove the workspace, delete merged branches. With --abandon: record the reason, push every branch and keep them, remove the workspace. Refuses without postmortem.md (run the post-mortem first) unless --skip-postmortem gives a reason").argument("[name]","Workspace directory name; defaults to the workspace you are in").option("-y, --yes","Skip the confirmation prompt").option("--abandon <reason>","Close out without shipping; the reason goes in closeout.md and the PR files").option("--skip-postmortem <reason>","Close out without a post-mortem; the reason goes in closeout.md").option("--no-pr <reason>","Close out as done although there are no PR files: the work changed no repo (clean worktrees, no commits ahead). Needs postmortem.md; the reason goes in closeout.md and on the issue")},"configure"),namespace:i(([e],t)=>({name:e??null,yes:!!t.yes,abandon:t.abandon??null,skipPostmortem:t.skipPostmortem??null,noPr:typeof t.pr=="string"?t.pr:null}),"namespace")},{name:"workspace code",old:"code",group:"Workspaces:",help:O9,load:i(()=>Promise.resolve().then(()=>($Z(),EZ)),"load"),configure:i(e=>{e.description("Open a workspace in VS Code").argument("[feature]","Workspace name, as `werkmeister workspace list` reports it. If omitted, read from FEATURE in a .env file.")},"configure"),namespace:i(([e])=>({feature:e??null}),"namespace")},{name:"machine setup",old:"setup",group:"Machine:",help:Z9,load:i(()=>Promise.resolve().then(()=>(AZ(),RZ)),"load"),configure:i(e=>{e.description("Guided machine setup: walks through paths, ingress domains and the ~/.werkmeister service registry, then converges the plugins, the sandbox-workspace checkout, the TLS certificate and the optional issue tracker, Telepresence and VS Code YAML-schema prerequisites").option("--check","Report prerequisite state without prompting or running any install/update commands").option("--yes","Non-interactive: accept every default and skip optional installs")},"configure"),namespace:i((e,t)=>({check:!!t.check,yes:!!t.yes}),"namespace")},{name:"machine config",old:"config",group:"Machine:",help:T9,load:i(()=>Promise.resolve().then(()=>(NZ(),IZ)),"load"),configure:i(e=>{e.description("Set up and maintain the machine-global werkmeister config (~/.werkmeister/config.yaml \u2014 the single source of truth); regenerates env.sh and wires up ~/.zshenv and the Desktop MCP config").option("--write","Write config.yaml (prompting on a TTY for unset values), regenerate env.sh, and wire up ~/.zshenv and the Desktop MCP config. Without it (or a value to set) the command only prints the config.").option("--repos-root <path>","Absolute path to the canonical source-repo clones (non-interactive set).").option("--workspaces-root <path>","Absolute path to the per-feature worktree workspaces (non-interactive set).").option("--show","Print the resolved config and each value's origin (the default).").option("--check","Validate config + derived files; nonzero exit on drift.")},"configure"),namespace:i((e,t)=>({write:!!t.write,repos_root:t.reposRoot??null,workspaces_root:t.workspacesRoot??null,show:!!t.show,check:!!t.check}),"namespace")},{name:"cache",group:"Machine:",help:E9,load:i(()=>Promise.resolve().then(()=>(LZ(),jZ)),"load"),configure:i(e=>{e.description("Prune the shared build and package caches (`caches:` in the registry) by each one's age or prune rule").argument("<action>","prune \u2014 the only action").argument("[name]","One cache; every cache when omitted").option("--reset","Empty the cache(s) instead of applying the rule.").option("--force","Prune a cache even while a running container mounts it.").option("--dry-run","Report what would be deleted; change nothing.")},"configure"),namespace:i(([e,t],r)=>({action:e,name:t??null,reset:!!r.reset,force:!!r.force,dry_run:!!r.dryRun}),"namespace")},{name:"registry",group:"Machine:",help:V9,load:i(()=>Promise.resolve().then(()=>(FZ(),DZ)),"load"),configure:i(e=>{e.description("Regenerate ~/.werkmeister/services.yaml from every <repo>/.werkmeister/services.yaml under paths.repos_root (merged under ~/.werkmeister/services.local.yaml)").argument("[action]","sync \u2014 the default and only action").option("--check","Report drift without writing; nonzero exit when stale.").option("--from <worktree>","Use this checkout's .werkmeister/services.yaml for its repo (needs --out).").option("--out <file>","Write the registry here instead of ~/.werkmeister/services.yaml.")},"configure"),namespace:i(([e],t)=>({action:e??"sync",check:!!t.check,from:t.from??null,out:t.out??null}),"namespace")},{name:"machine migrate",old:"migrate",group:"Machine:",help:B9,load:i(()=>Promise.resolve().then(()=>(GZ(),KZ)),"load"),configure:i(e=>{e.description("Move ~/.sandbox to ~/.werkmeister and repoint everything that names it: config.yaml, env.sh, the ~/.zshenv block, services.yaml, the pr-watch schedule and workspace compose files; then rewrite workspace hooks, permission rules and with-temp-home, secrets.env and Claude Desktop's args to the noun-group spellings. Safe to re-run; refuses while affected containers are running.").option("--workspaces","Also rename each workspace's .sandbox/ to .werkmeister/.").option("--check","Report what would change without writing.")},"configure"),namespace:i((e,t)=>({check:!!t.check,workspaces:!!t.workspaces}),"namespace")},{name:"workspace init",old:"init-workspace",group:"Workspaces:",help:N9,load:i(()=>Promise.resolve().then(()=>(TI(),mZ)),"load"),configure:i(e=>{e.description(`Reconcile a workspace from .werkmeister/workspace.yml: create/remove repo worktrees to match the \`repos\`/\`services\` fields, then (re)generate CLAUDE.md / .env / ${be}. Idempotent \u2014 edit workspace.yml and rerun. Inputs resolve as CLI flag > env (WERKMEISTER_*) > workspace.yml.`).option("-t, --task <title>","Task description / title (env: WERKMEISTER_TASK; config: task).").option("--feature <name>","Feature name for workspace slot routing (config: feature).").option("--services <list>","Comma-separated list of local services (env: WERKMEISTER_SERVICES; config: services). Their owning repos are added to the reconciled worktree set.").option("-r, --repos <list>","Comma-separated repos to keep as git worktrees (union with the repos owning --services). Persisted to workspace.yml; the worktree set is reconciled to match on every run (env: WERKMEISTER_REPOS; config: repos).").option("--force","When reconciling, delete repo worktrees dropped from workspace.yml even if they have uncommitted changes, and delete a <user>/<workspace> branch an earlier workspace left on origin instead of aborting (default: abort without changes).").option("--no-build","Write compose.yml and the context files but skip the image build (`docker compose up --build --no-start`), so no docker call is made.").option("--issue-id <ref>","Issue ID in this machine's issue tracker (see `werkmeister machine setup`) (env: WERKMEISTER_ISSUE_ID; config: issue_id).").option("--project <name>","The project (projects: in ~/.werkmeister/config.yaml) whose tracker holds the issue (env: WERKMEISTER_PROJECT; config: project).").option("--labels <list>","Comma-separated free-form tags for filtering workspaces in the dashboard search (env: WERKMEISTER_LABELS; config: labels).").option("--group <keys>","Comma-separated member issue keys of a grouped PR led by issue_id: one PR, one commit per ticket (env: WERKMEISTER_GROUP; config: group).").option("--test-path <path>","URL path for feature testing (env: WERKMEISTER_TEST_PATH; config: test_path).").option("--description <text>","Free-form description for the CLAUDE.md header (env: WERKMEISTER_DESCRIPTION; config: description).").option("--starting-prompt <text>","First instruction for the agent; persisted to .werkmeister/workspace.yml (env: WERKMEISTER_STARTING_PROMPT; config: starting_prompt).").addOption(new ss("--work-type <type>","Kind of work; selects the ICM stages and seeds the JIT first-phase handoff note (env: WERKMEISTER_WORK_TYPE; config: work_type).").choices(["feature","bugfix","refactor","spike","incident"])).addOption(new ss("--context-strategy <id>","Context layer to generate: jit (skills, hooks, notes) or icm (staged folders). (env: WERKMEISTER_CONTEXT_STRATEGY; config: context_strategy).").choices([...kn])).addOption(new ss("--harness <id>","Agent harness that reads the workspace: claude (CLAUDE.md, .claude/, hooks), mcp (AGENTS.md, .agents/skills, no hooks), codex (AGENTS.md, .agents/skills, .codex/hooks.json, .codex/config.toml) or opencode (AGENTS.md, .agents/skills, opencode.json, hooks plugin) (env: WERKMEISTER_HARNESS; config: harness).").choices([...fr])).option("--autonomous","Run an icm workspace stage-to-PR with no human checks, and allow the Bash calls a headless session needs (env: WERKMEISTER_AUTONOMOUS; config: autonomous).").option("--model <tier|model>","Model tier (small, mid, frontier, advanced_frontier) or an explicit model; blank = models.default_tier in ~/.werkmeister/config.yaml (frontier) (env: WERKMEISTER_MODEL; config: model).").option("--auto-stop","Stop this workspace's feature containers when a Claude session in it ends and no other is open (a SessionEnd hook; env: WERKMEISTER_AUTO_STOP; config: auto_stop).").option("--config <path>","Path to a YAML config file (JSONC/JSON also accepted). Defaults to <workspace>/.werkmeister/workspace.yml; legacy workspace.yaml / workspace.jsonc / workspace.json are migrated on next write (env: WERKMEISTER_WORKSPACE_CONFIG).").option("--prune-context","After a context_strategy change, delete the previous strategy's files that git tracks unmodified (anything else is kept and reported).").option("--refresh-issue","Re-fetch the workspace's issue into .werkmeister/issue.md (BRIEF.md is not rewritten, except an untouched placeholder brief).")},"configure"),namespace:i((e,t)=>({task:t.task??null,feature:t.feature??null,services:t.services??null,repos:t.repos??null,force:!!t.force,issue_id:t.issueId??null,project:t.project??null,labels:t.labels??null,group:t.group??null,test_path:t.testPath??null,description:t.description??null,starting_prompt:t.startingPrompt??null,work_type:t.workType??null,context_strategy:t.contextStrategy??null,harness:t.harness??null,autonomous:t.autonomous??null,model:t.model??null,auto_stop:t.autoStop??null,config_file:t.config??null,prune_context:!!t.pruneContext,refresh_issue:!!t.refreshIssue,build:t.build!==!1}),"namespace")},{name:"budget status",group:"Machine:",help:"",load:i(()=>Promise.resolve().then(()=>(zZ(),YZ)),"load"),configure:i(e=>{e.description("Show the budget, the slots held and the features Waiting for room").option("--json","Print JSON")},"configure"),namespace:i((e,t)=>({json:!!t.json}),"namespace")},...[["status","Say whether the daemon is serving and its launchd agent is current"],["install","Install or refresh the launchd agent (macOS)"],["uninstall","Remove the launchd agent; `infra connect` starts the daemon again"],["restart","Restart the daemon, through launchd when launchd owns it"]].map(([e,t])=>({name:`daemon ${e}`,group:"Machine:",help:"",load:i(()=>Promise.resolve().then(()=>(XZ(),JZ)),"load"),configure:i(r=>{r.description(t),e==="status"&&r.option("--json","Print JSON")},"configure"),namespace:i((r,n)=>({action:e,json:!!n.json}),"namespace")})),{name:"feature stop",group:"Features:",help:Q2,load:i(()=>Promise.resolve().then(()=>(pd(),dd)),"load"),configure:i(e=>{e.description("Stop containers without removing them or releasing the slot").argument("[feature]","Feature name. If omitted, read from FEATURE in a .env file.").addOption(new ss("--via-daemon").hideHelp())},"configure"),namespace:i(([e],t)=>({feature:e??null,if_idle:!1,idle:null,via_daemon:!!t.viaDaemon}),"namespace")},{name:"feature status",group:"Features:",help:X2,load:i(()=>Promise.resolve().then(()=>(Rb(),Tb)),"load"),configure:i(e=>{e.description("Show all features, services, resource usage").option("-v, --verbose","Show individual container details").option("--intercepts","Show Telepresence intercept state only (per feature service; cheap \u2014 skips docker and k8s probes).").option("--json","Output structured JSON (useful for agent-driven diagnosis)")},"configure"),namespace:i((e,t)=>({verbose:!!t.verbose,k8s:!1,intercepts:!!t.intercepts,json:!!t.json}),"namespace")},...["up","down","restart","stop"].map(e=>({name:`infra ${e}`,group:"Services and infra:",help:"",load:{up:i(()=>Promise.resolve().then(()=>(IO(),PO)),"up"),down:i(()=>Promise.resolve().then(()=>(DO(),LO)),"down"),restart:i(()=>Promise.resolve().then(()=>(MO(),FO)),"restart"),stop:i(()=>Promise.resolve().then(()=>(pd(),dd)),"stop")}[e],configure:i(t=>{t.description(`${e[0].toUpperCase()}${e.slice(1)} the shared infrastructure (Caddy, k8s port-forwards)`),e==="down"&&t.option("-v, --volumes","Also remove Docker volumes")},"configure"),namespace:i((t,r)=>({up:{feature:"infra",workspace:null,dev:!1},down:{feature:"infra",volumes:!!r.volumes,all_features:!1},restart:{feature:"infra"},stop:{feature:"infra",if_idle:!1,idle:null,via_daemon:!1}})[e],"namespace")})),{name:"infra status",group:"Services and infra:",help:"",load:i(()=>Promise.resolve().then(()=>(Rb(),Tb)),"load"),configure:i(e=>{e.description("Show k8s port-forward health").option("--json","Output structured JSON (useful for agent-driven diagnosis)")},"configure"),namespace:i((e,t)=>({verbose:!1,k8s:!0,intercepts:!1,json:!!t.json}),"namespace")},{name:"workspace close",group:"Workspaces:",help:z2,load:i(()=>Promise.resolve().then(()=>(aS(),iS)),"load"),configure:i(e=>{e.description("End a workspace after every PR shipped: close the issue, write closeout.md, remove the workspace, delete merged branches. Refuses without postmortem.md (run the post-mortem first) unless --skip-postmortem gives a reason").argument("[name]","Workspace directory name; defaults to the workspace you are in").option("-y, --yes","Skip the confirmation prompt").option("--skip-postmortem <reason>","Close out without a post-mortem; the reason goes in closeout.md").option("--no-pr <reason>","Close out as done although there are no PR files: the work changed no repo (clean worktrees, no commits ahead). Needs postmortem.md; the reason goes in closeout.md and on the issue")},"configure"),namespace:i(([e],t)=>({name:e??null,yes:!!t.yes,abandon:null,skipPostmortem:t.skipPostmortem??null,noPr:typeof t.pr=="string"?t.pr:null}),"namespace")},{name:"workspace abandon",group:"Workspaces:",help:S9,load:i(()=>Promise.resolve().then(()=>(aS(),iS)),"load"),configure:i(e=>{e.description("End a workspace without shipping: record the reason in closeout.md and the PR files, push every branch and keep them, remove the workspace").argument("<reason>","Why the work is abandoned").argument("[name]","Workspace directory name; defaults to the workspace you are in").option("-y, --yes","Skip the confirmation prompt").option("--skip-postmortem <reason>","Close out without a post-mortem; the reason goes in closeout.md")},"configure"),namespace:i(([e,t],r)=>({name:t??null,yes:!!r.yes,abandon:e,skipPostmortem:r.skipPostmortem??null,noPr:null}),"namespace")},...[["gate","Deny or allow an Edit/Write per the standards gate"],["pr-guard","Deny opening a PR except via `werkmeister pr open`"],["agent-state","Record working / needs-you / done for the workspace pane and dashboard"]].map(([e,t])=>({name:`internal ${e}`,group:"Internal:",help:e==="gate"?J2:"",load:i(()=>Promise.resolve().then(()=>(OI(),$I)),"load"),configure:i(r=>{r.description(`Claude Code hook: ${t}`)},"configure"),namespace:i(()=>({action:e}),"namespace")})),{name:"internal session-end",group:"Internal:",help:"",load:i(()=>Promise.resolve().then(()=>(pd(),dd)),"load"),configure:i(e=>{e.description("SessionEnd hook: stop the workspace's own feature unless another Claude session is open there; silent, always exits 0, never stops infra").addOption(new ss("--via-daemon").hideHelp())},"configure"),namespace:i((e,t)=>({feature:null,if_idle:!0,idle:null,via_daemon:!!t.viaDaemon}),"namespace")},{name:"internal reap",group:"Internal:",help:"",load:i(()=>Promise.resolve().then(()=>(pd(),dd)),"load"),configure:i(e=>{e.description("Stop every workspace's feature containers nothing has used for <minutes> (a busy or recently active session, a gate exec or a fresh start all count as use)").argument("<minutes>","Idle minutes before a feature is stopped").argument("[feature]","Only this feature")},"configure"),namespace:i(([e,t])=>({feature:t??null,if_idle:!1,idle:e,via_daemon:!1}),"namespace")},...[["gate","Run the pre-PR gate",["[repo]"],["wait","tests","json"]],["open","Gate, push and open each approved PR file",["[repo]"],["wait","json"]],["status","Record merged, shipped or closed for each PR file",["[repo]"],["json"]],["adopt","Record a PR opened outside the workspace",["[pr]","[repo]"],["no-pr","json"]],["watch","Resume each opening session once its PR merges, ships or closes (any workspace)",[],["install","json"]],["new","Start a follow-up PR file and branch for a worktree whose PRs have merged",["[worktree]"],["slug","json"]]].map(([e,t,r,n])=>({name:`pr ${e}`,group:"PRs and issues:",help:"",load:i(()=>Promise.resolve().then(()=>(ZZ(),QZ)),"load"),configure:i(s=>{s.description(t);let o={"[repo]":"Only this code worktree's PR files, or one PR file by its name (`werkmeister-why-page`)","[pr]":"The PR number or URL","[worktree]":"The code worktree the follow-up is for"};for(let c of r)s.argument(c,o[c]);let a=i(c=>n.includes(c),"has");a("slug")&&s.option("--slug <slug>","The follow-up's name, in its PR file and branch"),a("no-pr")&&s.option("--no-pr <reason>","No PR \u2014 the fix is already on base"),a("wait")&&s.addOption(new ss("--no-wait").hideHelp()),a("tests")&&s.option("--tests","Only the lint and test rows, on the uncommitted tree, before a PR file exists"),a("install")&&s.option("--install","Install a schedule (launchd on macOS, else crontab) that runs `pr watch` every 10 minutes").option("--uninstall","Remove that schedule"),s.option("--json","Print the result as JSON")},"configure"),namespace:i((s,o)=>{let a=s.filter(u=>u!=null),c=typeof o.pr=="string"?o.pr:null,l=e==="adopt"&&c===null?a[0]??null:null;return{action:e,pr:l,noPr:c,repo:a[l?1:0]??null,slug:o.slug??null,wait:o.wait!==!1,tests:!!o.tests,json:!!o.json,install:!!o.install,uninstall:!!o.uninstall}},"namespace")})),...[["view","Print the issue",["json"]],["update","Change the issue's status and/or add a comment",["status","comment"]],["create","File a new issue and print its URL (Jira)",["project","type","title","body-file","relates"]],["start","Move the workspace's issue to in progress and fast-forward its worktrees",[]],["ready","List a project's open work in priority order",["project","json"]]].map(([e,t,r])=>({name:`issue ${e}`,group:"PRs and issues:",help:"",load:i(()=>Promise.resolve().then(()=>(cee(),aee)),"load"),configure:i(n=>{n.description(t),e!=="create"&&e!=="ready"&&n.argument("[ref]","Issue ID; omit inside a workspace to use its .werkmeister/workspace.yml issue");let s={json:["--json","Print JSON"],status:["--status <name>","Move the issue to this status"],comment:["--comment <text>","Add this comment"],project:["--project <key>",e==="create"?"The Jira project key to file in":"A project from projects: in config.yaml"],type:["--type <type>","bug, feature or task (mapped to the tracker's issue type)"],title:["--title <text>","The issue's summary"],"body-file":["--body-file <path>","The issue's description, from a file (- for stdin)"],relates:["--relates <issue>","Link the new issue 'relates to' this one (repeatable)"]};for(let o of r)o==="relates"?n.option(...s[o],(a,c=[])=>[...c,a]):n.option(...s[o])},"configure"),namespace:i(([n],s)=>({action:e,ref:n??null,json:!!s.json,status:s.status??null,comment:s.comment??null,project:s.project??null,type:s.type??null,title:s.title??null,bodyFile:s.bodyFile??null,relates:s.relates??[]}),"namespace")}))];async function _Ae(e,t){let r=yAe.homedir();e.name!=="machine migrate"&&II.existsSync(Wd.join(r,".sandbox"))&&!II.existsSync(Wd.join(r,".werkmeister"))&&console.error(`${dS}Found ~/.sandbox but no ~/.werkmeister: run 'werkmeister machine migrate' first.${Z0}`);try{let{migrateSlotsJson:s}=await Promise.resolve().then(()=>(zt(),zM));await s()}catch{}let n;try{n=await e.load(t)}catch(s){throw s.code==="ERR_MODULE_NOT_FOUND"&&(console.log(`${dS}Failed to load command '${e.name}': ${s.message}${Z0}`),process.exit(1)),s}try{await n.run(t)}catch(s){if(s instanceof G&&s.code!==Cp?M(s.message):console.log(`${dS}Error: ${s.message}${Z0}`),_e("DEBUG"))throw s;process.exit(1)}}i(_Ae,"dispatch");async function EAe(e){let t=(process.env.COMP_LINE??"").slice(0,Number(process.env.COMP_POINT??0)),r=t.split(/\s+/),n=t.endsWith(" ")?"":r.pop()??"",s=e.commands.find(a=>a.name()===r[1]),o=[];if(!s)o=e.commands.map(a=>a.name());else if(n.startsWith("-"))o=s.options.flatMap(a=>a.long?[a.long]:[]);else if(s.registeredArguments.length){o=["infra"];try{let{listWorkspaces:a}=await Promise.resolve().then(()=>(Sn(),uR)),{workspaces:c}=await a();o.push(...c.map(l=>l.name))}catch{}}console.log(o.filter(a=>a.startsWith(n)).join(`
|
|
2112
|
+
`,mee=["Features:","Workspaces:","PRs and issues:","Services and infra:","Agent context:","Machine:","Internal:"],bAe="0.58.0",vAe={feature:{description:"Run a feature's containers: up, down, stop, logs, test and the rest"},workspace:{description:"Create, reconcile, list, open and close workspaces",alias:"ws"},pr:{description:"Open and track this workspace's PRs from its PR files (docs/workspace-lifecycle.md)",help:K9},issue:{description:"Read, update or file an issue in this machine's issue tracker (see `werkmeister machine setup`)",help:L9},infra:{description:"Shared infrastructure: Caddy, k8s port-forwards and Telepresence"},machine:{description:"Machine-wide setup, config, migration and housekeeping"},budget:{description:"The scheduler's budget, the slots held and the features Waiting for room",help:_9},daemon:{description:"The host daemon (the MCP server on port 3002)",help:A9},internal:{description:"Hook, tool and sibling-app entry points; not typed by people"}},SAe=i((e,t)=>`werkmeister: '${e}' is deprecated and will be removed in ${bAe}; use 'werkmeister ${t}'. Run 'werkmeister machine migrate' to update hooks and permission rules.`,"deprecation"),gee=[{name:"feature up",old:"up",group:"Features:",help:aB,load:i(()=>Promise.resolve().then(()=>(IO(),PO)),"load"),configure:i(e=>{e.description("Detect services, allocate slot, generate config, start containers").argument("[feature]","Feature name (arbitrary label for slot/proxy routing). If omitted, read from FEATURE in a .env file in the current directory tree.").option("-w, --workspace <path>","Path to directory containing repo checkouts. Default: ~/workspace (override with paths.workspaces_root in ~/.werkmeister/config.yaml).").option("--dev","Run the file watchers in cli/library/extension containers, which otherwise idle.").option("--service <name>","Start only this service and wait for it, the way the PR gate does \u2014 including one behind the on-demand profile. `feature stop` stops it.")},"configure"),namespace:i(([e],t)=>({feature:e??null,workspace:t.workspace??null,dev:t.dev??!1,...t.service?{service:t.service}:{}}),"namespace")},{name:"feature down",old:"down",group:"Features:",help:I9,load:i(()=>Promise.resolve().then(()=>(DO(),LO)),"load"),configure:i(e=>{e.description("Stop containers, release slot, update proxy (`infra <verb>` for shared infra)").argument("[feature]","Feature name or 'infra'. If omitted, read from FEATURE in a .env file.").option("-v, --volumes","Also remove Docker volumes (node_modules, caches)").option("--all-features","Stop and clean up all active features (ignores <feature> argument)")},"configure"),namespace:i(([e],t)=>({feature:e??null,volumes:!!t.volumes,all_features:!!t.allFeatures}),"namespace")},{name:"infra intercept",old:"intercept",group:"Services and infra:",help:j9,load:i(()=>Promise.resolve().then(()=>(yW(),gW)),"load"),configure:i(e=>{e.description("Route header-scoped k8s dev traffic to a local service (Telepresence OSS).").argument("[feature]","Feature name (defaults to FEATURE from a .env file in CWD).").option("-s, --service <name>","Local service to intercept (must be in the workspace's SERVICES and running via `werkmeister feature up`).").option("--leave","End the intercept for -s (or all of this feature's intercepts without -s).").option("--status","Show telepresence connection and intercept status.").option("--docker-daemon","Run the telepresence daemon in a container (connect --docker) \u2014 avoids the host TUN device, its sudo prompt, and VPN routing conflicts. In exchange the host loses cluster DNS: nothing on your laptop resolves <svc>.<ns> while connected this way.").option("--workspace <path>","Explicit workspace path (default: resolve from the feature name).")},"configure"),namespace:i(([e],t)=>({feature:e??null,service:t.service??null,leave:!!t.leave,status:!!t.status,docker_daemon:!!t.dockerDaemon,workspace:t.workspace??null}),"namespace")},{name:"feature restart",old:"restart",group:"Features:",help:J9,load:i(()=>Promise.resolve().then(()=>(MO(),FO)),"load"),configure:i(e=>{e.description("Restart containers (`infra <verb>` for shared infra)").argument("[feature]","Feature name or 'infra'. If omitted, read from FEATURE in a .env file.")},"configure"),namespace:i(([e])=>({feature:e??null}),"namespace")},{name:"feature pause",old:"pause",group:"Features:",help:H9,load:i(()=>Promise.resolve().then(()=>(BO(),wW)),"load"),configure:i(e=>{e.description("Freeze a workspace's running containers and hold its Claude session until resume").argument("[feature]","Feature name. If omitted, read from FEATURE in a .env file.")},"configure"),namespace:i(([e])=>({feature:e??null}),"namespace")},{name:"feature resume",old:"resume",group:"Features:",help:X9,load:i(()=>Promise.resolve().then(()=>(vG(),bG)),"load"),configure:i(e=>{e.description("Thaw exactly the containers pause froze, release the session, and tell it to continue").argument("[feature]","Feature name. If omitted, read from FEATURE in a .env file.")},"configure"),namespace:i(([e])=>({feature:e??null}),"namespace")},{name:"stop",deprecated:i(e=>e.if_idle?"internal session-end":e.idle?"internal reap <minutes>":e.feature==="infra"?"infra stop":"feature stop","deprecated"),group:"Features:",help:Q2,load:i(()=>Promise.resolve().then(()=>(pd(),dd)),"load"),configure:i(e=>{e.description("Stop containers without removing them or releasing the slot (`infra <verb>` for shared infra)").argument("[feature]","Feature name or 'infra'. If omitted, read from FEATURE in a .env file.").option("--if-idle","SessionEnd hook mode: stop the workspace's own feature unless another Claude session is open there; silent, always exits 0, never stops infra").option("--idle <minutes>","Stop every workspace's feature containers nothing has used for <minutes> (a busy or recently active session, a gate exec or a fresh start all count as use); with [feature], only that one").addOption(new ss("--via-daemon").hideHelp())},"configure"),namespace:i(([e],t)=>({feature:e??null,if_idle:!!t.ifIdle,idle:t.idle??null,via_daemon:!!t.viaDaemon}),"namespace")},{name:"status",deprecated:i(e=>e.k8s?"infra status":"feature status","deprecated"),group:"Features:",help:X2,load:i(()=>Promise.resolve().then(()=>(Rb(),Tb)),"load"),configure:i(e=>{e.description("Show all features, services, resource usage").option("-v, --verbose","Show individual container details").option("--k8s","Show k8s port-forward health only (replaces standalone k8s-status command)").option("--intercepts","Show Telepresence intercept state only (per feature service; cheap \u2014 skips docker and k8s probes).").option("--json","Output structured JSON (useful for agent-driven diagnosis)")},"configure"),namespace:i((e,t)=>({verbose:!!t.verbose,k8s:!!t.k8s,intercepts:!!t.intercepts,json:!!t.json}),"namespace")},{name:"machine detect",old:"detect",group:"Machine:",help:P9,load:i(()=>Promise.resolve().then(()=>(BQ(),MQ)),"load"),configure:i(e=>{e.description("Generate <repo>/.werkmeister/services.yaml from the repo's package manifests, Dockerfiles, compose, Helm and k8s files (re-runs only add what is missing)").argument("[repo]","Repo directory (default: the git repo containing the current directory)").option("--dry-run","Show the report and the proposed YAML; write nothing").option("-y, --yes","Write without asking").option("--assist","Ask Claude to resolve the fields the scan had to guess").option("--no-assist","Never ask Claude")},"configure"),namespace:i(([e],t)=>({repo:e??null,dryRun:!!t.dryRun,yes:!!t.yes,assist:t.assist}),"namespace")},{name:"feature services",old:"services",group:"Features:",help:Q9,load:i(()=>Promise.resolve().then(()=>(qQ(),UQ)),"load"),configure:i(e=>{e.description("List services and their endpoints for a feature").argument("<feature>","Feature name")},"configure"),namespace:i(([e])=>({feature:e}),"namespace")},{name:"feature logs",old:"logs",group:"Features:",help:F9,load:i(()=>Promise.resolve().then(()=>(HQ(),WQ)),"load"),configure:i(e=>{e.description("Tail a feature's container logs").argument("<feature>","Feature name").argument("[service]","Specific service to tail (optional)")},"configure"),namespace:i(([e,t])=>({feature:e,service:t??null}),"namespace")},{name:"feature drop",old:"remove",group:"Features:",help:Y9,load:i(()=>Promise.resolve().then(()=>(GQ(),KQ)),"load"),configure:i(e=>{e.description("Stop a local service, fall back to k8s").argument("<feature>","Feature name").argument("<service>","Service name to remove")},"configure"),namespace:i(([e,t])=>({feature:e,service:t}),"namespace")},{name:"feature test",old:"test",group:"Features:",help:oB,load:i(()=>Promise.resolve().then(()=>(zQ(),YQ)),"load"),configure:i(e=>{e.description("Run Playwright tests against a feature's stack").argument("<feature>","Feature name").argument("[extra...]","Additional arguments to pass to Playwright").option("--scaffold","Don't run: write playwright.config.ts + <feature>.spec.ts into the workspace (if missing) and install the pinned @playwright/test").option("-w, --workspace <path>","--scaffold: workspace directory (default: from cwd)").option("--base-url <url>","--scaffold: ingress URL to target (default: the first feature_router service)")},"configure"),namespace:i(([e,t],r)=>({feature:e,extra:t??[],scaffold:r.scaffold??!1,workspace:r.workspace??null,base_url:r.baseUrl??null}),"namespace")},{name:"workspace prompt",old:"starting-prompt",group:"Workspaces:",help:nB,load:i(e=>e.args?Promise.resolve().then(()=>(EI(),_I)):Promise.resolve().then(()=>(SI(),XQ)),"load"),configure:i(e=>{e.description("Print the enclosing workspace's starting_prompt from workspace.yml").option("--start <dir>","Directory to search up from (default: cwd)").option("--args","Print the start_session arguments (title, model, prompt, background) as JSON instead")},"configure"),namespace:i((e,t)=>({start:t.start??null,...t.args?{args:!0}:{}}),"namespace")},{name:"start-args",deprecated:i(()=>"workspace prompt --args","deprecated"),group:"Internal:",help:rB,load:i(()=>Promise.resolve().then(()=>(EI(),_I)),"load"),configure:i(e=>{e.description("Print the start_session arguments (title, model, prompt, background) for the enclosing workspace, as JSON").option("--start <dir>","Directory to search up from (default: cwd)")},"configure"),namespace:i((e,t)=>({start:t.start??null}),"namespace")},{name:"internal wait-load",old:"wait-load",group:"Internal:",help:cB,load:i(()=>Promise.resolve().then(()=>(ZQ(),QQ)),"load"),configure:i(e=>{e.description("Wait, up to 90 s, while host load is above budget.host_load; with-temp-home runs it first")},"configure"),namespace:i(()=>({}),"namespace")},{name:"feature open",old:"open",group:"Features:",help:q9,load:i(()=>Promise.resolve().then(()=>(tZ(),eZ)),"load"),configure:i(e=>{e.description("Open a feature-tagged Chrome window with the X-Feature cookie set (no Playwright)").argument("[feature]","Feature name -> sets X-Feature=<feature>. If omitted, read from FEATURE in a .env file.").option("--url <url>","Full start URL (overrides --path). Default: the first routed host's homepage.").option("--path <path>","Path appended to the first routed host (default: test_path from .werkmeister/workspace.yml, else TEST_PATH from .env, else '/').").option("--size <W,H>","Window size WIDTH,HEIGHT (default: 1440,900).","1440,900").option("--position <X,Y>","Window position X,Y (default: staggered by feature name).")},"configure"),namespace:i(([e],t)=>({feature:e??null,url:t.url??null,path:t.path??null,size:t.size,position:t.position??null}),"namespace")},{name:"infra connect",old:"connect",group:"Services and infra:",help:R9,load:i(()=>Promise.resolve().then(()=>(CO(),AO)),"load"),configure:i(e=>{e.description("Start all shared infrastructure (local + k8s port-forwards)").option("--k8s","Start/restart k8s port-forwards container only (replaces standalone k8s-connect command)")},"configure"),namespace:i((e,t)=>({k8s:!!t.k8s}),"namespace")},{name:"infra proxy-reload",old:"proxy-reload",group:"Services and infra:",help:G9,load:i(()=>Promise.resolve().then(()=>(nZ(),rZ)),"load"),configure:i(e=>{e.description("Regenerate Caddyfile and reload Caddy")},"configure"),namespace:i(()=>({}),"namespace")},{name:"machine clean",old:"clean",group:"Machine:",help:$9,load:i(()=>Promise.resolve().then(()=>(oZ(),sZ)),"load"),configure:i(e=>{e.description("Remove orphaned volumes and generated files from stopped features").option("--all","Also clean volumes for currently active features (implies werkmeister down for each)").option("--dry-run","Show what would be cleaned without actually removing anything")},"configure"),namespace:i((e,t)=>({all:!!t.all,dry_run:!!t.dryRun}),"namespace")},{name:"machine tokens",group:"Machine:",help:iB,load:i(()=>Promise.resolve().then(()=>(aZ(),iZ)),"load"),configure:i(e=>{e.description("List daemon tokens with no workspace; --remove deletes them").option("--remove","Delete the stale tokens (default: list only)")},"configure"),namespace:i((e,t)=>({remove:!!t.remove}),"namespace")},{name:"machine stats",old:"stats",group:"Machine:",help:sB,load:i(()=>Promise.resolve().then(()=>(hR(),CG)),"load"),configure:i(e=>{e.description("Show Docker container resource usage (CPU, memory)").option("--collect <MINUTES>","Collect stats over N minutes (default: snapshot only)",t=>Number.parseInt(t,10),0).option("-i, --interval <SECS>","Sampling interval in seconds (default: 10)",t=>Number.parseInt(t,10),10).option("--save","Save results to stats/ directory")},"configure"),namespace:i((e,t)=>({collect:t.collect,interval:t.interval,save:!!t.save}),"namespace")},{name:"machine optimize",old:"optimize",group:"Machine:",help:W9,load:i(()=>Promise.resolve().then(()=>(lZ(),cZ)),"load"),configure:i(e=>{e.description("Analyze resource usage vs configured limits, recommend changes").option("--collect <MINUTES>","Collect stats over N minutes before analyzing (default: quick snapshot)",t=>Number.parseInt(t,10),0).option("-i, --interval <SECS>","Sampling interval in seconds (default: 10)",t=>Number.parseInt(t,10),10)},"configure"),namespace:i((e,t)=>({collect:t.collect,interval:t.interval}),"namespace")},{name:"skills",group:"Agent context:",help:eB,load:i(()=>Promise.resolve().then(()=>(fZ(),uZ)),"load"),configure:i(e=>{e.description("Workspace w9r-* skill projection: verify freshness against the werkmeister repo (check) or rewrite it (sync)").addArgument(new Kd("<action>","check: exit 1 if the workspace's .claude/skills/w9r-* lag the repo; sync: refresh them").choices(["check","sync"]))},"configure"),namespace:i(([e])=>({action:e}),"namespace")},{name:"standards",group:"Agent context:",help:tB,load:i(()=>Promise.resolve().then(()=>(pZ(),dZ)),"load"),configure:i(e=>{e.description("Validate the configured standards tree (structural regression gate)").addArgument(new Kd("<action>","check: exit 1 if any standard module is structurally malformed").choices(["check"]))},"configure"),namespace:i(([e])=>({action:e}),"namespace")},{name:"hooks",deprecated:i(e=>`internal ${e.action}`,"deprecated"),group:"Internal:",help:J2,load:i(()=>Promise.resolve().then(()=>(OI(),$I)),"load"),configure:i(e=>{e.description("Claude Code hook entrypoints: the standards gate, the PR guard and the agent state").addArgument(new Kd("<action>","gate: deny or allow an Edit/Write per the standards gate; pr-guard: deny opening a PR except via `werkmeister pr open`; agent-state: record working / needs-you / done for the workspace pane and dashboard").choices(["gate","pr-guard","agent-state"]))},"configure"),namespace:i(([e])=>({action:e}),"namespace")},{name:"notes",group:"Agent context:",help:U9,load:i(()=>Promise.resolve().then(()=>(NO(),pW)),"load"),configure:i(e=>{e.description("Workspace notes (.werkmeister/notes/). `context` prints the latest handoff + open decisions for session-start injection (hook target); `graduate` scaffolds an open decision note into the standards tree.").addArgument(new Kd("<action>","context: print notes context for the enclosing workspace (silent if none); graduate: scaffold an open decision note into the standards tree").choices(["context","graduate"])).argument("[note_num]","graduate: note number to graduate (omit to pick interactively)").option("--domain <domain>","graduate: target <domain> in the standards tree (omit to infer from refs, or prompt)").addOption(new ss("--kind <kind>","graduate: content kind to scaffold (omit to prompt)").choices(["rule","example","anti-pattern"])).option("--slug <slug>","graduate: override the derived reference-file slug")},"configure"),namespace:i(([e,t],r)=>({action:e,note_num:t==null?null:Number.parseInt(t,10),domain:r.domain??null,kind:r.kind??null,slug:r.slug??null}),"namespace")},{name:"workspace new",group:"Workspaces:",help:lB,load:i(()=>Promise.resolve().then(()=>(kZ(),xZ)),"load"),configure:i(e=>{e.description("Create a new workspace under $WERKMEISTER_WORKSPACES_ROOT (git worktrees on a <user>/<workspace> branch) and run init-workspace inside it.").argument("[feature]","Feature name (lower-cased). Combined with --issue-id to form the workspace dir name, e.g. an issue + feature -> <issue-slug>-feature. If omitted, resolved from ./.werkmeister/workspace.yml, then interactively (TTY).").option("--issue-id <ref>","Issue ID in this machine's issue tracker (see `werkmeister machine setup`). Its slug is prefixed to the workspace dir name; passed through to init-workspace.").option("--project <name>","The project (projects: in ~/.werkmeister/config.yaml) whose tracker holds the issue. Default: the one whose scope holds --issue-id, else the default project.").option("-s, --services <list>","Comma-separated services to run locally. Their owning repos are added as worktrees, and the list is passed through to init-workspace.").option("-r, --repos <list>","Comma-separated repos to create worktrees for (union with the repos derived from --services). Interactive multi-select if neither --repos nor --services is given.").option("--labels <list>","Comma-separated free-form tags for filtering workspaces in the dashboard search; passed through to init-workspace.").option("--group <keys>","Comma-separated member issue keys of a grouped PR led by --issue-id (one PR, one commit per ticket); passed through to init-workspace.").option("-t, --task <title>","Task title for the workspace CLAUDE.md; passed through to init-workspace.").option("--test-path <path>","URL path for feature testing; passed through to init-workspace.").option("--description <text>","Free-form description for the CLAUDE.md header; passed through to init-workspace.").option("--starting-prompt <text>","First instruction for the agent; passed through to init-workspace.").addOption(new ss("--work-type <type>","Kind of work; selects the ICM stages and seeds the JIT first-phase handoff note. Passed through to init-workspace.").choices(["feature","bugfix","refactor","spike","incident"])).addOption(new ss("--context-strategy <id>","Context layer to generate: jit (skills, hooks, notes) or icm (staged folders). (env: WERKMEISTER_CONTEXT_STRATEGY; config: context_strategy).").choices([...kn])).addOption(new ss("--harness <id>","Agent harness that reads the workspace: claude (CLAUDE.md, .claude/, hooks), mcp (AGENTS.md, .agents/skills, no hooks), codex (AGENTS.md, .agents/skills, .codex/hooks.json, .codex/config.toml) or opencode (AGENTS.md, .agents/skills, opencode.json, hooks plugin) (env: WERKMEISTER_HARNESS; config: harness).").choices([...fr])).option("--autonomous","Run an icm workspace stage-to-PR with no human checks, and allow the Bash calls a headless session needs (env: WERKMEISTER_AUTONOMOUS; config: autonomous).").option("--model <tier|model>","Model tier (small, mid, frontier, advanced_frontier) or an explicit model; blank = models.default_tier in ~/.werkmeister/config.yaml (frontier) (env: WERKMEISTER_MODEL; config: model).").option("--auto-stop","Stop this workspace's feature containers when a Claude session in it ends and no other is open (a SessionEnd hook; env: WERKMEISTER_AUTO_STOP; config: auto_stop).").option("--browser-form","Collect inputs through the Werkmeister-branded browser form (the same form the Desktop MCP App renders), pre-filled from every flag given, then create the workspace. Opens a localhost page in the default browser and blocks until submit/cancel.").option("--no-distill","Store the issue but don't have a model rewrite it into description/starting_prompt.").option("--open","With --browser-form: launch VS Code on the new workspace after creating.").option("--force","Delete a <user>/<workspace> branch an earlier workspace of the same name left on origin, instead of aborting (that branch's work is gone; see the abort message for how to continue it instead).")},"configure"),namespace:i(([e],t)=>({feature:e??null,issue_id:t.issueId??null,project:t.project??null,services:t.services??null,repos:t.repos??null,labels:t.labels??null,group:t.group??null,task:t.task??null,test_path:t.testPath??null,description:t.description??null,starting_prompt:t.startingPrompt??null,work_type:t.workType??null,context_strategy:t.contextStrategy??null,harness:t.harness??null,autonomous:t.autonomous??null,model:t.model??null,auto_stop:t.autoStop??null,browser_form:!!t.browserForm,open_vscode:!!t.open,no_distill:t.distill===!1,force:!!t.force}),"namespace")},{name:"workspace list",old:"list-workspaces",group:"Workspaces:",help:D9,load:i(()=>Promise.resolve().then(()=>(vZ(),bZ)),"load"),configure:i(e=>{e.description("List the workspaces under the workspaces root with their issue and labels")},"configure"),namespace:i(()=>({}),"namespace")},{name:"remove-workspace",deprecated:i(()=>"workspace abandon <reason>","deprecated"),group:"Workspaces:",help:z9,load:i(()=>Promise.resolve().then(()=>(_Z(),SZ)),"load"),configure:i(e=>{e.description("Deprecated: use `werkmeister workspace abandon <reason>`. Hand off (commit + push) and delete a workspace").argument("<name>","Workspace directory name, as `werkmeister workspace list` reports it").option("-y, --yes","Skip the confirmation prompt").option("--abandon <reason>","Remove despite unshipped work; records the reason in closeout.md and the PR files")},"configure"),namespace:i(([e],t)=>({name:e,yes:!!t.yes,abandon:t.abandon??null}),"namespace")},{name:"close-out",deprecated:i(e=>e.abandon?"workspace abandon <reason>":"workspace close","deprecated"),group:"Workspaces:",help:z2,load:i(()=>Promise.resolve().then(()=>(aS(),iS)),"load"),configure:i(e=>{e.description("End a workspace. After every PR shipped: close the issue, write closeout.md, remove the workspace, delete merged branches. With --abandon: record the reason, push every branch and keep them, remove the workspace. Refuses without postmortem.md (run the post-mortem first) unless --skip-postmortem gives a reason").argument("[name]","Workspace directory name; defaults to the workspace you are in").option("-y, --yes","Skip the confirmation prompt").option("--abandon <reason>","Close out without shipping; the reason goes in closeout.md and the PR files").option("--skip-postmortem <reason>","Close out without a post-mortem; the reason goes in closeout.md").option("--no-pr <reason>","Close out as done although there are no PR files: the work changed no repo (clean worktrees, no commits ahead). Needs postmortem.md; the reason goes in closeout.md and on the issue")},"configure"),namespace:i(([e],t)=>({name:e??null,yes:!!t.yes,abandon:t.abandon??null,skipPostmortem:t.skipPostmortem??null,noPr:typeof t.pr=="string"?t.pr:null}),"namespace")},{name:"workspace code",old:"code",group:"Workspaces:",help:O9,load:i(()=>Promise.resolve().then(()=>($Z(),EZ)),"load"),configure:i(e=>{e.description("Open a workspace in VS Code").argument("[feature]","Workspace name, as `werkmeister workspace list` reports it. If omitted, read from FEATURE in a .env file.")},"configure"),namespace:i(([e])=>({feature:e??null}),"namespace")},{name:"machine setup",old:"setup",group:"Machine:",help:Z9,load:i(()=>Promise.resolve().then(()=>(AZ(),RZ)),"load"),configure:i(e=>{e.description("Guided machine setup: walks through paths, ingress domains and the ~/.werkmeister service registry, then converges the plugins, the sandbox-workspace checkout, the TLS certificate and the optional issue tracker, Telepresence and VS Code YAML-schema prerequisites").option("--check","Report prerequisite state without prompting or running any install/update commands").option("--yes","Non-interactive: accept every default and skip optional installs")},"configure"),namespace:i((e,t)=>({check:!!t.check,yes:!!t.yes}),"namespace")},{name:"machine config",old:"config",group:"Machine:",help:T9,load:i(()=>Promise.resolve().then(()=>(NZ(),IZ)),"load"),configure:i(e=>{e.description("Set up and maintain the machine-global werkmeister config (~/.werkmeister/config.yaml \u2014 the single source of truth); regenerates env.sh and wires up ~/.zshenv and the Desktop MCP config").option("--write","Write config.yaml (prompting on a TTY for unset values), regenerate env.sh, and wire up ~/.zshenv and the Desktop MCP config. Without it (or a value to set) the command only prints the config.").option("--repos-root <path>","Absolute path to the canonical source-repo clones (non-interactive set).").option("--workspaces-root <path>","Absolute path to the per-feature worktree workspaces (non-interactive set).").option("--show","Print the resolved config and each value's origin (the default).").option("--check","Validate config + derived files; nonzero exit on drift.")},"configure"),namespace:i((e,t)=>({write:!!t.write,repos_root:t.reposRoot??null,workspaces_root:t.workspacesRoot??null,show:!!t.show,check:!!t.check}),"namespace")},{name:"cache",group:"Machine:",help:E9,load:i(()=>Promise.resolve().then(()=>(LZ(),jZ)),"load"),configure:i(e=>{e.description("Prune the shared build and package caches (`caches:` in the registry) by each one's age or prune rule").argument("<action>","prune \u2014 the only action").argument("[name]","One cache; every cache when omitted").option("--reset","Empty the cache(s) instead of applying the rule.").option("--force","Prune a cache even while a running container mounts it.").option("--dry-run","Report what would be deleted; change nothing.")},"configure"),namespace:i(([e,t],r)=>({action:e,name:t??null,reset:!!r.reset,force:!!r.force,dry_run:!!r.dryRun}),"namespace")},{name:"registry",group:"Machine:",help:V9,load:i(()=>Promise.resolve().then(()=>(FZ(),DZ)),"load"),configure:i(e=>{e.description("Regenerate ~/.werkmeister/services.yaml from every <repo>/.werkmeister/services.yaml under paths.repos_root (merged under ~/.werkmeister/services.local.yaml)").argument("[action]","sync \u2014 the default and only action").option("--check","Report drift without writing; nonzero exit when stale.").option("--from <worktree>","Use this checkout's .werkmeister/services.yaml for its repo (needs --out).").option("--out <file>","Write the registry here instead of ~/.werkmeister/services.yaml.")},"configure"),namespace:i(([e],t)=>({action:e??"sync",check:!!t.check,from:t.from??null,out:t.out??null}),"namespace")},{name:"machine migrate",old:"migrate",group:"Machine:",help:B9,load:i(()=>Promise.resolve().then(()=>(GZ(),KZ)),"load"),configure:i(e=>{e.description("Move ~/.sandbox to ~/.werkmeister and repoint everything that names it: config.yaml, env.sh, the ~/.zshenv block, services.yaml, the pr-watch schedule and workspace compose files; then rewrite workspace hooks, permission rules and with-temp-home, secrets.env and Claude Desktop's args to the noun-group spellings. Safe to re-run; refuses while affected containers are running.").option("--workspaces","Also rename each workspace's .sandbox/ to .werkmeister/.").option("--check","Report what would change without writing.")},"configure"),namespace:i((e,t)=>({check:!!t.check,workspaces:!!t.workspaces}),"namespace")},{name:"workspace init",old:"init-workspace",group:"Workspaces:",help:N9,load:i(()=>Promise.resolve().then(()=>(TI(),mZ)),"load"),configure:i(e=>{e.description(`Reconcile a workspace from .werkmeister/workspace.yml: create/remove repo worktrees to match the \`repos\`/\`services\` fields, then (re)generate CLAUDE.md / .env / ${be}. Idempotent \u2014 edit workspace.yml and rerun. Inputs resolve as CLI flag > env (WERKMEISTER_*) > workspace.yml.`).option("-t, --task <title>","Task description / title (env: WERKMEISTER_TASK; config: task).").option("--feature <name>","Feature name for workspace slot routing (config: feature).").option("--services <list>","Comma-separated list of local services (env: WERKMEISTER_SERVICES; config: services). Their owning repos are added to the reconciled worktree set.").option("-r, --repos <list>","Comma-separated repos to keep as git worktrees (union with the repos owning --services). Persisted to workspace.yml; the worktree set is reconciled to match on every run (env: WERKMEISTER_REPOS; config: repos).").option("--force","When reconciling, delete repo worktrees dropped from workspace.yml even if they have uncommitted changes, and delete a <user>/<workspace> branch an earlier workspace left on origin instead of aborting (default: abort without changes).").option("--no-build","Write compose.yml and the context files but skip the image build (`docker compose up --build --no-start`), so no docker call is made.").option("--issue-id <ref>","Issue ID in this machine's issue tracker (see `werkmeister machine setup`) (env: WERKMEISTER_ISSUE_ID; config: issue_id).").option("--project <name>","The project (projects: in ~/.werkmeister/config.yaml) whose tracker holds the issue (env: WERKMEISTER_PROJECT; config: project).").option("--labels <list>","Comma-separated free-form tags for filtering workspaces in the dashboard search (env: WERKMEISTER_LABELS; config: labels).").option("--group <keys>","Comma-separated member issue keys of a grouped PR led by issue_id: one PR, one commit per ticket (env: WERKMEISTER_GROUP; config: group).").option("--test-path <path>","URL path for feature testing (env: WERKMEISTER_TEST_PATH; config: test_path).").option("--description <text>","Free-form description for the CLAUDE.md header (env: WERKMEISTER_DESCRIPTION; config: description).").option("--starting-prompt <text>","First instruction for the agent; persisted to .werkmeister/workspace.yml (env: WERKMEISTER_STARTING_PROMPT; config: starting_prompt).").addOption(new ss("--work-type <type>","Kind of work; selects the ICM stages and seeds the JIT first-phase handoff note (env: WERKMEISTER_WORK_TYPE; config: work_type).").choices(["feature","bugfix","refactor","spike","incident"])).addOption(new ss("--context-strategy <id>","Context layer to generate: jit (skills, hooks, notes) or icm (staged folders). (env: WERKMEISTER_CONTEXT_STRATEGY; config: context_strategy).").choices([...kn])).addOption(new ss("--harness <id>","Agent harness that reads the workspace: claude (CLAUDE.md, .claude/, hooks), mcp (AGENTS.md, .agents/skills, no hooks), codex (AGENTS.md, .agents/skills, .codex/hooks.json, .codex/config.toml) or opencode (AGENTS.md, .agents/skills, opencode.json, hooks plugin) (env: WERKMEISTER_HARNESS; config: harness).").choices([...fr])).option("--autonomous","Run an icm workspace stage-to-PR with no human checks, and allow the Bash calls a headless session needs (env: WERKMEISTER_AUTONOMOUS; config: autonomous).").option("--model <tier|model>","Model tier (small, mid, frontier, advanced_frontier) or an explicit model; blank = models.default_tier in ~/.werkmeister/config.yaml (frontier) (env: WERKMEISTER_MODEL; config: model).").option("--auto-stop","Stop this workspace's feature containers when a Claude session in it ends and no other is open (a SessionEnd hook; env: WERKMEISTER_AUTO_STOP; config: auto_stop).").option("--config <path>","Path to a YAML config file (JSONC/JSON also accepted). Defaults to <workspace>/.werkmeister/workspace.yml; legacy workspace.yaml / workspace.jsonc / workspace.json are migrated on next write (env: WERKMEISTER_WORKSPACE_CONFIG).").option("--prune-context","After a context_strategy change, delete the previous strategy's files that git tracks unmodified (anything else is kept and reported).").option("--refresh-issue","Re-fetch the workspace's issue into .werkmeister/issue.md (BRIEF.md is not rewritten, except an untouched placeholder brief).")},"configure"),namespace:i((e,t)=>({task:t.task??null,feature:t.feature??null,services:t.services??null,repos:t.repos??null,force:!!t.force,issue_id:t.issueId??null,project:t.project??null,labels:t.labels??null,group:t.group??null,test_path:t.testPath??null,description:t.description??null,starting_prompt:t.startingPrompt??null,work_type:t.workType??null,context_strategy:t.contextStrategy??null,harness:t.harness??null,autonomous:t.autonomous??null,model:t.model??null,auto_stop:t.autoStop??null,config_file:t.config??null,prune_context:!!t.pruneContext,refresh_issue:!!t.refreshIssue,build:t.build!==!1}),"namespace")},{name:"budget status",group:"Machine:",help:"",load:i(()=>Promise.resolve().then(()=>(zZ(),YZ)),"load"),configure:i(e=>{e.description("Show the budget, the slots held and the features Waiting for room").option("--json","Print JSON")},"configure"),namespace:i((e,t)=>({json:!!t.json}),"namespace")},...[["status","Say whether the daemon is serving and its launchd agent is current"],["install","Install or refresh the launchd agent (macOS)"],["uninstall","Remove the launchd agent; `infra connect` starts the daemon again"],["restart","Restart the daemon, through launchd when launchd owns it"]].map(([e,t])=>({name:`daemon ${e}`,group:"Machine:",help:"",load:i(()=>Promise.resolve().then(()=>(XZ(),JZ)),"load"),configure:i(r=>{r.description(t),e==="status"&&r.option("--json","Print JSON")},"configure"),namespace:i((r,n)=>({action:e,json:!!n.json}),"namespace")})),{name:"feature stop",group:"Features:",help:Q2,load:i(()=>Promise.resolve().then(()=>(pd(),dd)),"load"),configure:i(e=>{e.description("Stop containers without removing them or releasing the slot").argument("[feature]","Feature name. If omitted, read from FEATURE in a .env file.").addOption(new ss("--via-daemon").hideHelp())},"configure"),namespace:i(([e],t)=>({feature:e??null,if_idle:!1,idle:null,via_daemon:!!t.viaDaemon}),"namespace")},{name:"feature status",group:"Features:",help:X2,load:i(()=>Promise.resolve().then(()=>(Rb(),Tb)),"load"),configure:i(e=>{e.description("Show all features, services, resource usage").option("-v, --verbose","Show individual container details").option("--intercepts","Show Telepresence intercept state only (per feature service; cheap \u2014 skips docker and k8s probes).").option("--json","Output structured JSON (useful for agent-driven diagnosis)")},"configure"),namespace:i((e,t)=>({verbose:!!t.verbose,k8s:!1,intercepts:!!t.intercepts,json:!!t.json}),"namespace")},...["up","down","restart","stop"].map(e=>({name:`infra ${e}`,group:"Services and infra:",help:"",load:{up:i(()=>Promise.resolve().then(()=>(IO(),PO)),"up"),down:i(()=>Promise.resolve().then(()=>(DO(),LO)),"down"),restart:i(()=>Promise.resolve().then(()=>(MO(),FO)),"restart"),stop:i(()=>Promise.resolve().then(()=>(pd(),dd)),"stop")}[e],configure:i(t=>{t.description(`${e[0].toUpperCase()}${e.slice(1)} the shared infrastructure (Caddy, k8s port-forwards)`),e==="down"&&t.option("-v, --volumes","Also remove Docker volumes")},"configure"),namespace:i((t,r)=>({up:{feature:"infra",workspace:null,dev:!1},down:{feature:"infra",volumes:!!r.volumes,all_features:!1},restart:{feature:"infra"},stop:{feature:"infra",if_idle:!1,idle:null,via_daemon:!1}})[e],"namespace")})),{name:"infra status",group:"Services and infra:",help:"",load:i(()=>Promise.resolve().then(()=>(Rb(),Tb)),"load"),configure:i(e=>{e.description("Show k8s port-forward health").option("--json","Output structured JSON (useful for agent-driven diagnosis)")},"configure"),namespace:i((e,t)=>({verbose:!1,k8s:!0,intercepts:!1,json:!!t.json}),"namespace")},{name:"workspace close",group:"Workspaces:",help:z2,load:i(()=>Promise.resolve().then(()=>(aS(),iS)),"load"),configure:i(e=>{e.description("End a workspace after every PR shipped: close the issue, write closeout.md, remove the workspace, delete merged branches. Refuses without postmortem.md (run the post-mortem first) unless --skip-postmortem gives a reason").argument("[name]","Workspace directory name; defaults to the workspace you are in").option("-y, --yes","Skip the confirmation prompt").option("--skip-postmortem <reason>","Close out without a post-mortem; the reason goes in closeout.md").option("--no-pr <reason>","Close out as done although there are no PR files: the work changed no repo (clean worktrees, no commits ahead). Needs postmortem.md; the reason goes in closeout.md and on the issue")},"configure"),namespace:i(([e],t)=>({name:e??null,yes:!!t.yes,abandon:null,skipPostmortem:t.skipPostmortem??null,noPr:typeof t.pr=="string"?t.pr:null}),"namespace")},{name:"workspace abandon",group:"Workspaces:",help:S9,load:i(()=>Promise.resolve().then(()=>(aS(),iS)),"load"),configure:i(e=>{e.description("End a workspace without shipping: record the reason in closeout.md and the PR files, push every branch and keep them, remove the workspace").argument("<reason>","Why the work is abandoned").argument("[name]","Workspace directory name; defaults to the workspace you are in").option("-y, --yes","Skip the confirmation prompt").option("--skip-postmortem <reason>","Close out without a post-mortem; the reason goes in closeout.md")},"configure"),namespace:i(([e,t],r)=>({name:t??null,yes:!!r.yes,abandon:e,skipPostmortem:r.skipPostmortem??null,noPr:null}),"namespace")},...[["gate","Deny or allow an Edit/Write per the standards gate"],["pr-guard","Deny opening a PR except via `werkmeister pr open`"],["agent-state","Record working / needs-you / done for the workspace pane and dashboard"]].map(([e,t])=>({name:`internal ${e}`,group:"Internal:",help:e==="gate"?J2:"",load:i(()=>Promise.resolve().then(()=>(OI(),$I)),"load"),configure:i(r=>{r.description(`Claude Code hook: ${t}`)},"configure"),namespace:i(()=>({action:e}),"namespace")})),{name:"internal session-end",group:"Internal:",help:"",load:i(()=>Promise.resolve().then(()=>(pd(),dd)),"load"),configure:i(e=>{e.description("SessionEnd hook: stop the workspace's own feature unless another Claude session is open there; silent, always exits 0, never stops infra").addOption(new ss("--via-daemon").hideHelp())},"configure"),namespace:i((e,t)=>({feature:null,if_idle:!0,idle:null,via_daemon:!!t.viaDaemon}),"namespace")},{name:"internal reap",group:"Internal:",help:"",load:i(()=>Promise.resolve().then(()=>(pd(),dd)),"load"),configure:i(e=>{e.description("Stop every workspace's feature containers nothing has used for <minutes> (a busy or recently active session, a gate exec or a fresh start all count as use)").argument("<minutes>","Idle minutes before a feature is stopped").argument("[feature]","Only this feature")},"configure"),namespace:i(([e,t])=>({feature:t??null,if_idle:!1,idle:e,via_daemon:!1}),"namespace")},...[["gate","Run the pre-PR gate",["[repo]"],["wait","tests","json"]],["open","Gate, push and open each approved PR file",["[repo]"],["wait","json"]],["status","Record merged, shipped or closed for each PR file",["[repo]"],["json"]],["adopt","Record a PR opened outside the workspace",["[pr]","[repo]"],["no-pr","json"]],["watch","Resume each opening session once its PR merges, ships or closes (any workspace)",[],["install","json"]],["new","Start a follow-up PR file and branch for a worktree whose PRs have merged",["[worktree]"],["slug","json"]]].map(([e,t,r,n])=>({name:`pr ${e}`,group:"PRs and issues:",help:"",load:i(()=>Promise.resolve().then(()=>(ZZ(),QZ)),"load"),configure:i(s=>{s.description(t);let o={"[repo]":"Only this code worktree's PR files, or one PR file by its name (`werkmeister-why-page`)","[pr]":"The PR number or URL","[worktree]":"The code worktree the follow-up is for"};for(let c of r)s.argument(c,o[c]);let a=i(c=>n.includes(c),"has");a("slug")&&s.option("--slug <slug>","The follow-up's name, in its PR file and branch"),a("no-pr")&&s.option("--no-pr <reason>","No PR \u2014 the fix is already on base"),a("wait")&&s.addOption(new ss("--no-wait").hideHelp()),a("tests")&&s.option("--tests","Only the lint and test rows, on the uncommitted tree, before a PR file exists"),a("install")&&s.option("--install","Install a schedule (launchd on macOS, else crontab) that runs `pr watch` every 10 minutes").option("--uninstall","Remove that schedule"),s.option("--json","Print the result as JSON")},"configure"),namespace:i((s,o)=>{let a=s.filter(u=>u!=null),c=typeof o.pr=="string"?o.pr:null,l=e==="adopt"&&c===null?a[0]??null:null;return{action:e,pr:l,noPr:c,repo:a[l?1:0]??null,slug:o.slug??null,wait:o.wait!==!1,tests:!!o.tests,json:!!o.json,install:!!o.install,uninstall:!!o.uninstall}},"namespace")})),...[["view","Print the issue",["json"]],["update","Change the issue's status and/or add a comment",["status","comment"]],["create","File a new issue and print its URL (Jira)",["project","type","title","body-file","relates"]],["start","Move the workspace's issue to in progress and fast-forward its worktrees",[]],["ready","List a project's open work in priority order",["project","json"]]].map(([e,t,r])=>({name:`issue ${e}`,group:"PRs and issues:",help:"",load:i(()=>Promise.resolve().then(()=>(cee(),aee)),"load"),configure:i(n=>{n.description(t),e!=="create"&&e!=="ready"&&n.argument("[ref]","Issue ID; omit inside a workspace to use its .werkmeister/workspace.yml issue");let s={json:["--json","Print JSON"],status:["--status <name>","Move the issue to this status"],comment:["--comment <text>","Add this comment"],project:["--project <key>",e==="create"?"The Jira project key to file in":"A project from projects: in config.yaml"],type:["--type <type>","bug, feature or task (mapped to the tracker's issue type)"],title:["--title <text>","The issue's summary"],"body-file":["--body-file <path>","The issue's description, from a file (- for stdin)"],relates:["--relates <issue>","Link the new issue 'relates to' this one (repeatable)"]};for(let o of r)o==="relates"?n.option(...s[o],(a,c=[])=>[...c,a]):n.option(...s[o])},"configure"),namespace:i(([n],s)=>({action:e,ref:n??null,json:!!s.json,status:s.status??null,comment:s.comment??null,project:s.project??null,type:s.type??null,title:s.title??null,bodyFile:s.bodyFile??null,relates:s.relates??[]}),"namespace")}))];async function _Ae(e,t){let r=yAe.homedir();e.name!=="machine migrate"&&II.existsSync(Wd.join(r,".sandbox"))&&!II.existsSync(Wd.join(r,".werkmeister"))&&console.error(`${dS}Found ~/.sandbox but no ~/.werkmeister: run 'werkmeister machine migrate' first.${Z0}`);try{let{migrateSlotsJson:s}=await Promise.resolve().then(()=>(zt(),zM));await s()}catch{}let n;try{n=await e.load(t)}catch(s){throw s.code==="ERR_MODULE_NOT_FOUND"&&(console.log(`${dS}Failed to load command '${e.name}': ${s.message}${Z0}`),process.exit(1)),s}try{await n.run(t)}catch(s){if(s instanceof G&&s.code!==Cp?M(s.message):console.log(`${dS}Error: ${s.message}${Z0}`),_e("DEBUG"))throw s;process.exit(1)}}i(_Ae,"dispatch");async function EAe(e){let t=(process.env.COMP_LINE??"").slice(0,Number(process.env.COMP_POINT??0)),r=t.split(/\s+/),n=t.endsWith(" ")?"":r.pop()??"",s=e.commands.find(a=>a.name()===r[1]),o=[];if(!s)o=e.commands.map(a=>a.name());else if(n.startsWith("-"))o=s.options.flatMap(a=>a.long?[a.long]:[]);else if(s.registeredArguments.length){o=["infra"];try{let{listWorkspaces:a}=await Promise.resolve().then(()=>(Sn(),uR)),{workspaces:c}=await a();o.push(...c.map(l=>l.name))}catch{}}console.log(o.filter(a=>a.startsWith(n)).join(`
|
|
2108
2113
|
`))}i(EAe,"completeLine");async function $Ae(){mB(process,()=>console.log(`
|
|
2109
2114
|
${dS}Interrupted${Z0}`));let e=new YI,t=new Map,r=i((u,f,d)=>{t.set(f,d),u.addHelpText("after",`
|
|
2110
2115
|
${d}`)},"withHelp");e.name("werkmeister").description(kAe).version(JSON.parse(II.readFileSync(Wd.join(NI,"package.json"),"utf8")).version).helpOption("-h, --help","show this help message and exit");let n=process.argv[2]==="__parse";n&&process.argv.splice(2,1);let s=new Map,o=i((u,f)=>{let d=s.get(u);if(!d){let p=vAe[u];if(!p)throw new Error(`SPECS names unknown noun '${u}'`);d=e.command(u,{hidden:u==="internal"}).helpGroup(f).description(p.description),p.alias&&d.alias(p.alias),p.help&&r(d,u,p.help),s.set(u,d)}return d},"nounCommand"),a=i((u,f,d,p)=>{let m=u.command(d,{hidden:!!p});u===e&&!p&&m.helpGroup(f.group),f.help&&r(m,p?d:f.name,f.help),f.configure(m),m.action(async(...w)=>{let y=w.at(-1).opts(),k=w.slice(0,-2),S=f.namespace(k,y);if(p&&console.error(SAe(d,p(S))),n){console.log(JSON.stringify({command:f.name,args:S}));return}await ca(Bj,()=>_Ae(f,S))})},"addCommand"),c=[...gee].sort((u,f)=>mee.indexOf(u.group)-mee.indexOf(f.group));for(let u of c){let[f,d]=u.name.split(" ");u.deprecated?a(e,u,u.name,u.deprecated):d?a(o(f,u.group),u,d):a(e,u,u.name);let p=`infra ${d}`,m=gee.some(w=>w.name===p);u.old&&a(e,u,u.old,w=>m&&w.feature==="infra"?p:u.name)}for(let[u,f,d]of[["dashboard","Run the localhost workspaces dashboard in the foreground (checkout only)",C9],["mcp","Launch the stdio proxy to the werkmeister daemon (Claude Desktop, the werkmeister plugin)",M9]])for(let[p,m]of[[o("internal","Internal:"),`internal ${u}`],[e,u]]){let w=p.command(u,{hidden:p===e}).description(f);r(w,m,d),w.action(()=>{console.error(`\`werkmeister ${m}\` launches a sibling app and must be run through the ./werkmeister wrapper, which locates a node runtime and the app's entrypoint.`),process.exit(1)})}if(e.commandsGroup("Internal:").helpCommand(!0),process.argv[2]==="__complete")return EAe(e);if(process.argv[2]==="__reference"){let u=i(p=>!!p._hidden,"isHidden"),f=i((p,m,w,g)=>({name:m,usage:p.usage().replace(/^\[options\] ?/,""),description:p.description(),hidden:g,group:w,help:t.get(m)??"",options:p.options.map(y=>({flags:y.flags,long:y.long,description:y.description,hidden:y.hidden}))}),"entry"),d=e.commands.flatMap(p=>{let m=f(p,p.name(),p.helpGroup(),u(p));if(!p.commands.length)return[m];let w=p.commands.map(g=>f(g,`${p.name()} ${g.name()}`,p.helpGroup(),u(p)||u(g)));return t.has(p.name())?[m,...w]:w});console.log(JSON.stringify(d));return}let l=["internal","hooks"].includes(process.argv[2]??"")||process.argv.includes("--if-idle");if(!n&&!l){let u=hB(pB,Wd.resolve(NI,"../.."));u&&console.error(u),mL(()=>vy(Ex(or)))}if(process.argv[2]==="internal"&&process.argv[3]==="fixture"){await(await Promise.resolve().then(()=>(hee(),pee))).run(process.argv.slice(4));return}process.argv.length<=2&&(e.outputHelp(),process.exit(0)),await e.parseAsync(process.argv)}i($Ae,"main");await $Ae();export{$Ae as main};
|