werkmeister 0.83.0 → 0.83.2
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/lib/agent_state.js +6 -4
- package/dist/main.js +407 -405
- package/dist/mcp.js +3 -3
- package/dist/werkmeister-workspaces.vsix +0 -0
- package/package.json +3 -3
package/dist/mcp.js
CHANGED
|
@@ -389,7 +389,7 @@ status=$?
|
|
|
389
389
|
exit "$status"
|
|
390
390
|
`;s(km,"tempHomeWrapper");s(Oce,"writeTempHomeWrapper")});var so,Ab=A(()=>{"use strict";f();so=["claude","mcp","codex","opencode"]});var ni,$1=A(()=>{"use strict";f();ni=["icm","jit"]});import*as co from"node:fs";import*as B6 from"node:os";import*as ao from"node:path";function K5e(e){try{return co.statSync(e).isDirectory()}catch{return!1}}function G5e(e){let t=[],r=0,i=e.length,n=!1;for(;r<i;){let o=e[r];if(n){if(t.push(o),o==="\\"&&r+1<i){t.push(e[r+1]),r+=2;continue}o==='"'&&(n=!1),r+=1;continue}if(o==='"'){n=!0,t.push(o),r+=1;continue}if(o==="/"&&r+1<i){let a=e[r+1];if(a==="/"){for(r+=2;r<i&&e[r]!==`
|
|
391
391
|
`;)r+=1;continue}if(a==="*"){for(r+=2;r+1<i&&!(e[r]==="*"&&e[r+1]==="/");)r+=1;r+=2;continue}}t.push(o),r+=1}return t.join("")}function T1(e){let t=co.readFileSync(e,"utf8"),r=ao.extname(e);return r===".yaml"||r===".yml"?Ice.parse(t):JSON.parse(G5e(t))}function xi(e){return/^(true|1|yes|on)$/i.test(String(e??"").trim())}function Yu(e){return xi(xl(e,"autonomous"))}function Pb(e){let t=xl(e,"auto_stop");return t==null||t===""?Yu(e):xi(t)}function Ace(e){let t=xl(e,"model");return typeof t=="string"&&t.trim()?t.trim():null}function xl(e,t){let r=Bt("WORKSPACE_CONFIG"),i=[...r?[_m(r)]:[],...$m.map(n=>ao.join(V(e),n))];for(let n of i)if(co.existsSync(n))try{return T1(n)?.[t]}catch{return}}function rn(e,t){let r=[];t&&r.push(_m(t));let i=Bt("WORKSPACE_CONFIG");i&&r.push(_m(i));let n=V(e);for(let o of $m)r.push(ao.join(n,o));for(let o of r){if(!co.existsSync(o))continue;let a;try{a=T1(o)}catch(c){return N(`Config file ${o} unreadable: ${c.message} \u2014 skipping.`),{}}return typeof a!="object"||a===null||Array.isArray(a)?(N(`Config file ${o} must be a mapping \u2014 skipping.`),{}):(I(`Loaded workspace config from ${o}`),a)}return{}}function _m(e){return e==="~"?B6.homedir():e.startsWith("~/")?ao.join(B6.homedir(),e.slice(2)):e}function Pce(e){return/['"$#\\]/.test(e)?`"${e.replace(/[\\"$]/g,"\\$&")}"`:e}function J5e(e){return e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1).replace(/\\([\\"$])/g,"$1"):e}function Y5e(e){let t=ao.join(e,".env");if(!(co.existsSync(t)&&co.statSync(t).isFile()))return{};let r={};for(let[,,n]of Sm)r[n.toUpperCase()]=n;r.JIRA_ID=r.GITHUB_ISSUE="issue_id";let i={};for(let n of co.readFileSync(t,"utf8").split(`
|
|
392
|
-
`)){if(n=n.trim(),!n||n.startsWith("#")||!n.includes("="))continue;let o=n.indexOf("="),a=n.slice(0,o).trim(),c=n.slice(o+1);a in r&&(i[r[a]]=J5e(c.trim()))}return i}function Cb(e,t){let r=rn(t,e.config_file??null),i=Y5e(t),n={};for(let[c,l,u]of Sm){let p=e[c]??null,d=l?Bt(l)??null:null,m=u==="issue_id"?Qu(r)||null:u in r?r[u]:null,h=u in i?i[u]:null;for(let y of[p,d,m,h]){if(y==null)continue;let g;if(Array.isArray(y)?g=y.map(v=>String(v).trim()).filter(v=>v).join(","):g=String(y).trim(),g){n[u]=g;break}}}let o=e.services;!n.services&&o!==null&&o!==void 0&&!String(o).trim()&&(n.services="");let a=s(()=>dt({project:n.project,text:n.issue_id??""}),"tracker");if(n.issue_id&&(n.issue_id=a().parseRef(n.issue_id)??n.issue_id),n.group){let c=a(),l=[...new Set(n.group.split(",").map(u=>c.parseRef(u)??u))].filter(u=>u!==n.issue_id);n.group=l.join(",")}return n.autonomous&&(n.autonomous=String(xi(n.autonomous))),n.auto_stop&&(n.auto_stop=String(xi(n.auto_stop))),n}function X5e(e){let t=e.split("-");return t.length&&t[0].length===4&&[...t[0].toLowerCase()].every(r=>"0123456789abcdef".includes(r))&&(t=t.slice(1)),t.length?t.join("-"):e}function Q5e(e){for(let t of co.readdirSync(e).sort()){let r=ao.join(e,t);if(!K5e(r)||t.startsWith("."))continue;let i;try{i=ne(["git","-C",r,"branch","--show-current"],{capture:!0,timeout:5})}catch(a){if(a instanceof xe&&(a.code==="ENOENT"||a.code==="ETIMEDOUT"))continue;throw a}if(i.status!==0)continue;let n=i.stdout.trim(),o=dt({text:n}).parseRef(n);if(o)return o}return""}function Xu(e){let t=e.trim().toLowerCase();return Object.hasOwn(E1,t)?E1[t]:H6}function Cce(e,t,r,i={}){let n={key:e.key,label:e.label,help:e.help,accept_empty:e.acceptEmpty??!0,multi:e.multi??!1,recommended:e.recommended??!1,default:e.defaultFn&&i.defaults!==!1?e.defaultFn(t):e.default??"",resolved:e.key in r,resolved_value:e.key in r?r[e.key]:null};if(e.multiline&&(n.multiline=!0),e.boolean&&(n.boolean=!0),e.refinable&&(n.refinable=!0,e.refineInstruction&&(n.refine_instruction=e.refineInstruction)),e.pattern&&(n.pattern=e.pattern),e.placeholder&&(n.placeholder=e.placeholder),e.choicesFn&&(n.choices=e.choicesFn()),e.choiceGroupsFn){let o={},a=e.choiceGroupsFn();for(let c of n.choices??Object.keys(a))(o[a[c]??"other"]??=[]).push(c);n.choice_groups=Object.fromEntries(Object.entries(o).sort(([c],[l])=>c.localeCompare(l)))}return n}function tBe(){let e=_a();if(e.length){let r=[...new Set(e.map(i=>jb(i.tracker).refExample))];return Rce.map(i=>i.key==="issue_id"?{...i,placeholder:r.join(" or ")}:i)}let t=dt();return Rce.flatMap(r=>r.key==="project"?[]:r.key==="issue_id"?[{...r,placeholder:t.refExample,...t.refPattern?{pattern:t.refPattern}:{}}]:[r])}function rBe(e,t,r={}){return{workspace_root:e,workspace_name:ao.basename(e),prompts:tBe().map(i=>Cce(i,e,t,r))}}function W6(e){let t=e.split("-");return t.length&&t[0].length===4&&[...t[0].toLowerCase()].every(r=>"0123456789abcdef".includes(r))&&(t=t.slice(1)),t.length?t.map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" "):e}function ki(){try{return[Re(),mi()]}catch{return[{},{}]}}function jce(e,t,r={}){return iBe(t,Cb(e,t),r)}function iBe(e,t,r={}){let i=rBe(e,t,r),n=Cce(nBe,"",t);if(n.choices.length){let o=i.prompts??[],a=o.findIndex(c=>c.key==="services");a===-1&&(a=o.length-1),o.splice(a+1,0,n),i.prompts=o}return i}var Ice,Sm,$m,E1,H6,eBe,Rce,nBe,Dn=A(()=>{"use strict";f();Ice=Ge(wt(),1);di();ye();Ab();lo();or();Wv();ze();$1();s(K5e,"isDir");s(G5e,"stripJsoncComments");s(T1,"loadWorkspaceConfig");Sm=[["feature",null,"feature"],["work_type","WORK_TYPE","work_type"],["context_strategy","CONTEXT_STRATEGY","context_strategy"],["harness","HARNESS","harness"],["repos","REPOS","repos"],["services","SERVICES","services"],["issue_id","ISSUE_ID","issue_id"],["project","PROJECT","project"],["test_path","TEST_PATH","test_path"],["description","DESCRIPTION","description"],["task","TASK","task"],["starting_prompt","STARTING_PROMPT","starting_prompt"],["labels","LABELS","labels"],["group","GROUP","group"],["autonomous","AUTONOMOUS","autonomous"],["model","MODEL","model"],["auto_stop","AUTO_STOP","auto_stop"]];s(xi,"isTrue");s(Yu,"readAutonomous");s(Pb,"readAutoStop");s(Ace,"readModel");s(xl,"readWorkspaceField");$m=["workspace.yml","workspace.yaml","workspace.jsonc","workspace.json"];s(rn,"loadConfigFile");s(_m,"expandUserPath");s(Pce,"quoteEnvValue");s(J5e,"unquoteEnvValue");s(Y5e,"loadExistingEnvMetadata");s(Cb,"resolveInputs");s(X5e,"defaultFeatureFromDir");s(Q5e,"scrapeIssueId");E1={feature:{path:"architectural",phases:["research","implement","test","review","pr"],gate:{note:"decision",status:"decided"},hint:"invoke `w9r-research` first \u2014 it ends in a `decision` note the user approves before any code"},bugfix:{path:"bounded",phases:["research","implement","test","pr"],gate:{note:"finding"},hint:"invoke `w9r-research` first to reproduce and write the root cause to a `finding` note before changing code"},incident:{path:"bounded",phases:["research","implement","test","pr"],gate:{note:"finding"},hint:"invoke `w9r-research` first to diagnose; the `finding` note is the incident record"},refactor:{path:"bounded",phases:["implement","test","review","pr"],gate:null,hint:"invoke `w9r-implement` first \u2014 the scope is known and standards matter most"},spike:{path:"spike",phases:["research"],gate:null,hint:"invoke `w9r-research` first to frame the questions; anything built is throwaway and there is no PR"}},H6={path:"architectural",phases:["research","implement","test","review","pr"],gate:null,hint:"invoke `w9r-research` first"};s(Xu,"planFor");eBe=Object.keys(E1),Rce=[{key:"issue_id",label:"Issue",help:"Issue ID in this machine's issue tracker. The issue is fetched and stored in the workspace; empty fields are filled from it.",defaultFn:s(e=>Q5e(e),"defaultFn")},{key:"project",label:"Project",help:"The project whose tracker holds the issue (projects: in ~/.werkmeister/config.yaml). Blank picks the one whose scope holds the issue, else the default project.",choicesFn:s(()=>_a().map(e=>e.name),"choicesFn"),defaultFn:s(()=>Z6()?.name??"","defaultFn")},{key:"feature",label:"Feature name",help:`Lowercase, hyphen-separated. Drives workspace slot routing via the X-Feature cookie. No feature = no ${Ke} / werkmeister-context.md.`,acceptEmpty:!1,recommended:!0,pattern:"^[a-z0-9]+(-[a-z0-9]+)*$",placeholder:"mdx-blog",defaultFn:s(e=>X5e(ao.basename(e)),"defaultFn")},{key:"work_type",label:"Work type",help:"What kind of work this is; selects the phase sequence and the pre-implementation gate in CLAUDE.md.",acceptEmpty:!1,pattern:"^("+Object.keys(E1).join("|")+")$",default:"feature",choicesFn:s(()=>[...eBe],"choicesFn")},{key:"context_strategy",label:"Workflow",help:"Which context layer init-workspace generates: jit (w9r-* skills, hooks, notes) or icm (staged folders the agent walks by itself).",pattern:"^("+ni.join("|")+")$",default:ni[0],choicesFn:s(()=>[...ni],"choicesFn")},{key:"harness",label:"Harness",help:"Which agent harness reads this workspace: claude (Claude Code: CLAUDE.md, .claude/, hooks), mcp (any harness with MCP and skills: AGENTS.md, .agents/skills, no hooks) or codex (Codex CLI: AGENTS.md, .agents/skills, .codex/hooks.json, .codex/config.toml).",pattern:"^("+so.join("|")+")$",default:so[0],choicesFn:s(()=>[...so],"choicesFn")},{key:"autonomous",label:"Autonomous run",help:"Off by default. On: an icm run goes from stage 01 to `werkmeister pr open` with no human check (each stage self-checks and the agent approves its own PR file), and .claude/settings.json allows the git, werkmeister, docker, gh, node and python3 calls a headless session needs. The person reviews the PR; `werkmeister pr gate` still applies.",boolean:!0},{key:"model",label:"Model",help:"Claude model for this workspace's sessions: an alias (opus, sonnet, haiku) or a full claude-\u2026 id; empty = Claude Code's default. Written to .claude/settings.json and passed as --model to claude-send and claude-resume. A cheaper model suits mechanical jobs (lint passes, renames).",pattern:"^[A-Za-z0-9][A-Za-z0-9._\\[\\]-]*$",placeholder:"sonnet"},{key:"auto_stop",label:"Auto-stop on session end",help:"On by default for autonomous workspaces, off otherwise. On: when a Claude session in the workspace ends and no other one is open there, a SessionEnd hook runs `werkmeister internal session-end`, which stops this feature's containers (slot and volumes kept; `werkmeister feature up` resumes). Shared infra is never stopped.",boolean:!0},{key:"services",label:"Services to run locally",help:"Services to run locally with hot-reload; the rest fall through to k8s port-forwards.",multi:!0,choicesFn:s(()=>Object.keys(ki()[0]).sort(),"choicesFn"),choiceGroupsFn:s(()=>Object.fromEntries(Object.entries(ki()[0]).map(([e,t])=>[e,String(t?.repo??"other")])),"choiceGroupsFn")},{key:"labels",label:"Labels",help:"Comma-separated free-form tags for filtering workspaces in the dashboard search.",multi:!0},{key:"group",label:"Grouped PR members",help:"Comma-separated issue keys this workspace's PR also covers, led by its issue: one PR, one commit per ticket. Blank for a one-ticket PR.",multi:!0},{key:"test_path",label:"Feature test path",help:"URL path for the feature entry point, appended to the routed host.",pattern:"^/\\S*$",placeholder:"/products/foo"},{key:"task",label:"Task title",help:"Short title for the Current Task section. Defaults to the feature name in words.",defaultFn:s(e=>W6(ao.basename(e)),"defaultFn")},{key:"description",label:"Description",help:"1-2 sentences on what the feature does and the user-visible outcome; rendered under Current Task in CLAUDE.md.",placeholder:"Adds an MDX-powered blog index under /blog."},{key:"starting_prompt",label:"Starting prompt",help:"The first instruction to hand the agent in this workspace; persisted to .werkmeister/workspace.yml.",multiline:!0,refinable:!0,refineInstruction:"Rewrite the user's text as a clear, specific, actionable starting instruction for a coding agent beginning a development task, preserving the user's intent. The rewritten instruction must state the goal \u2014 the desired end state and why it matters \u2014 and must include explicit acceptance criteria: a checklist of concrete, verifiable conditions that define when the task is done. Derive the goal and acceptance criteria from the user's text wherever possible; for any that cannot be confidently derived, the rewritten instruction must direct the agent to ask the user to supply them before proceeding, rather than guessing."}];s(Cce,"promptEntry");s(tBe,"wizardPrompts");s(rBe,"buildPromptSpec");s(W6,"slugToTask");s(ki,"loadSandboxServiceConfigs");nBe={key:"repos",label:"Extra repos",help:"Extra repos to create worktrees for. The final set is the union of these and the repos owning the services selected above.",multi:!0,choicesFn:s(()=>Object.keys(mi()).sort(),"choicesFn")};s(jce,"computePromptSpec");s(iBe,"workspacePromptSpec")});var oBe,V6,sBe,kl,Nb,K6=A(()=>{"use strict";f();oBe=["mcp__plugin_werkmeister_werkmeister__"],V6=s(e=>oBe.map(t=>`${t}${e}`),"pluginTool"),sBe=["werkmeister","w9r"],kl=s(e=>sBe.map(t=>`Bash(${t} ${e})`),"cli"),Nb=[...["proxy-reload","down","remove","remove-workspace","clean","setup","registry","connect","intercept","notes graduate","up infra","restart infra","stop infra","infra proxy-reload","feature down","infra down","feature drop","machine clean","machine setup","infra connect","infra intercept","workspace new","ws new","infra up","infra restart","infra stop","daemon install","daemon uninstall","daemon restart"].flatMap(e=>kl(`${e}:*`)),...["stop","kill","rm","rmi","compose down","system prune","volume rm","network rm"].map(e=>`Bash(docker ${e}:*)`),...["npm","pnpm"].flatMap(e=>["publish","link","unlink","install -g","install --global","i -g","i --global","uninstall -g","uninstall --global"].map(t=>`Bash(${e} ${t}:*)`)),...["add -g","add --global","remove -g","remove --global"].map(e=>`Bash(pnpm ${e}:*)`),"Bash(gh pr merge:*)",...["kube-switch","up","stop","restart","down","create-workspace","create-workspace-form","pr-approve","ask-pr-review","claude-send","claude-resume","connect","proxy-reload","remove-service","intercept"].flatMap(V6)]});var O1,G6=A(()=>{"use strict";f();Ta();O1={id:"mcp",instructionsFile:"AGENTS.md",skillsDir:".agents/skills",hooks:{available:!1,reason:"a generic MCP harness has no hooks adapter; use harness: codex for Codex"},agents:!1,notice:s(()=>`
|
|
392
|
+
`)){if(n=n.trim(),!n||n.startsWith("#")||!n.includes("="))continue;let o=n.indexOf("="),a=n.slice(0,o).trim(),c=n.slice(o+1);a in r&&(i[r[a]]=J5e(c.trim()))}return i}function Cb(e,t){let r=rn(t,e.config_file??null),i=Y5e(t),n={};for(let[c,l,u]of Sm){let p=e[c]??null,d=l?Bt(l)??null:null,m=u==="issue_id"?Qu(r)||null:u in r?r[u]:null,h=u in i?i[u]:null;for(let y of[p,d,m,h]){if(y==null)continue;let g;if(Array.isArray(y)?g=y.map(v=>String(v).trim()).filter(v=>v).join(","):g=String(y).trim(),g){n[u]=g;break}}}let o=e.services;!n.services&&o!==null&&o!==void 0&&!String(o).trim()&&(n.services="");let a=s(()=>dt({project:n.project,text:n.issue_id??""}),"tracker");if(n.issue_id&&(n.issue_id=a().parseRef(n.issue_id)??n.issue_id),n.group){let c=a(),l=[...new Set(n.group.split(",").map(u=>c.parseRef(u)??u))].filter(u=>u!==n.issue_id);n.group=l.join(",")}return n.autonomous&&(n.autonomous=String(xi(n.autonomous))),n.auto_stop&&(n.auto_stop=String(xi(n.auto_stop))),n}function X5e(e){let t=e.split("-");return t.length&&t[0].length===4&&[...t[0].toLowerCase()].every(r=>"0123456789abcdef".includes(r))&&(t=t.slice(1)),t.length?t.join("-"):e}function Q5e(e){for(let t of co.readdirSync(e).sort()){let r=ao.join(e,t);if(!K5e(r)||t.startsWith("."))continue;let i;try{i=ne(["git","-C",r,"branch","--show-current"],{capture:!0,timeout:5})}catch(a){if(a instanceof xe&&(a.code==="ENOENT"||a.code==="ETIMEDOUT"))continue;throw a}if(i.status!==0)continue;let n=i.stdout.trim(),o=dt({text:n}).parseRef(n);if(o)return o}return""}function Xu(e){let t=e.trim().toLowerCase();return Object.hasOwn(E1,t)?E1[t]:H6}function Cce(e,t,r,i={}){let n={key:e.key,label:e.label,help:e.help,accept_empty:e.acceptEmpty??!0,multi:e.multi??!1,recommended:e.recommended??!1,default:e.defaultFn&&i.defaults!==!1?e.defaultFn(t):e.default??"",resolved:e.key in r,resolved_value:e.key in r?r[e.key]:null};if(e.multiline&&(n.multiline=!0),e.boolean&&(n.boolean=!0),e.refinable&&(n.refinable=!0,e.refineInstruction&&(n.refine_instruction=e.refineInstruction)),e.pattern&&(n.pattern=e.pattern),e.placeholder&&(n.placeholder=e.placeholder),e.choicesFn&&(n.choices=e.choicesFn()),e.choiceGroupsFn){let o={},a=e.choiceGroupsFn();for(let c of n.choices??Object.keys(a))(o[a[c]??"other"]??=[]).push(c);n.choice_groups=Object.fromEntries(Object.entries(o).sort(([c],[l])=>c.localeCompare(l)))}return n}function tBe(){let e=_a();if(e.length){let r=[...new Set(e.map(i=>jb(i.tracker).refExample))];return Rce.map(i=>i.key==="issue_id"?{...i,placeholder:r.join(" or ")}:i)}let t=dt();return Rce.flatMap(r=>r.key==="project"?[]:r.key==="issue_id"?[{...r,placeholder:t.refExample,...t.refPattern?{pattern:t.refPattern}:{}}]:[r])}function rBe(e,t,r={}){return{workspace_root:e,workspace_name:ao.basename(e),prompts:tBe().map(i=>Cce(i,e,t,r))}}function W6(e){let t=e.split("-");return t.length&&t[0].length===4&&[...t[0].toLowerCase()].every(r=>"0123456789abcdef".includes(r))&&(t=t.slice(1)),t.length?t.map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" "):e}function ki(){try{return[Re(),mi()]}catch{return[{},{}]}}function jce(e,t,r={}){return iBe(t,Cb(e,t),r)}function iBe(e,t,r={}){let i=rBe(e,t,r),n=Cce(nBe,"",t);if(n.choices.length){let o=i.prompts??[],a=o.findIndex(c=>c.key==="services");a===-1&&(a=o.length-1),o.splice(a+1,0,n),i.prompts=o}return i}var Ice,Sm,$m,E1,H6,eBe,Rce,nBe,Dn=A(()=>{"use strict";f();Ice=Ge(wt(),1);di();ye();Ab();lo();or();Wv();ze();$1();s(K5e,"isDir");s(G5e,"stripJsoncComments");s(T1,"loadWorkspaceConfig");Sm=[["feature",null,"feature"],["work_type","WORK_TYPE","work_type"],["context_strategy","CONTEXT_STRATEGY","context_strategy"],["harness","HARNESS","harness"],["repos","REPOS","repos"],["services","SERVICES","services"],["issue_id","ISSUE_ID","issue_id"],["project","PROJECT","project"],["test_path","TEST_PATH","test_path"],["description","DESCRIPTION","description"],["task","TASK","task"],["starting_prompt","STARTING_PROMPT","starting_prompt"],["labels","LABELS","labels"],["group","GROUP","group"],["autonomous","AUTONOMOUS","autonomous"],["model","MODEL","model"],["auto_stop","AUTO_STOP","auto_stop"]];s(xi,"isTrue");s(Yu,"readAutonomous");s(Pb,"readAutoStop");s(Ace,"readModel");s(xl,"readWorkspaceField");$m=["workspace.yml","workspace.yaml","workspace.jsonc","workspace.json"];s(rn,"loadConfigFile");s(_m,"expandUserPath");s(Pce,"quoteEnvValue");s(J5e,"unquoteEnvValue");s(Y5e,"loadExistingEnvMetadata");s(Cb,"resolveInputs");s(X5e,"defaultFeatureFromDir");s(Q5e,"scrapeIssueId");E1={feature:{path:"architectural",phases:["research","implement","test","review","pr"],gate:{note:"decision",status:"decided"},hint:"invoke `w9r-research` first \u2014 it ends in a `decision` note the user approves before any code"},bugfix:{path:"bounded",phases:["research","implement","test","pr"],gate:{note:"finding"},hint:"invoke `w9r-research` first to reproduce and write the root cause to a `finding` note before changing code"},incident:{path:"bounded",phases:["research","implement","test","pr"],gate:{note:"finding"},hint:"invoke `w9r-research` first to diagnose; the `finding` note is the incident record"},refactor:{path:"bounded",phases:["implement","test","review","pr"],gate:null,hint:"invoke `w9r-implement` first \u2014 the scope is known and standards matter most"},spike:{path:"spike",phases:["research"],gate:null,hint:"invoke `w9r-research` first to frame the questions; anything built is throwaway and there is no PR"}},H6={path:"architectural",phases:["research","implement","test","review","pr"],gate:null,hint:"invoke `w9r-research` first"};s(Xu,"planFor");eBe=Object.keys(E1),Rce=[{key:"issue_id",label:"Issue",help:"Issue ID in this machine's issue tracker. The issue is fetched and stored in the workspace; empty fields are filled from it.",defaultFn:s(e=>Q5e(e),"defaultFn")},{key:"project",label:"Project",help:"The project whose tracker holds the issue (projects: in ~/.werkmeister/config.yaml). Blank picks the one whose scope holds the issue, else the default project.",choicesFn:s(()=>_a().map(e=>e.name),"choicesFn"),defaultFn:s(()=>Z6()?.name??"","defaultFn")},{key:"feature",label:"Feature name",help:`Lowercase, hyphen-separated. Drives workspace slot routing via the X-Feature cookie. No feature = no ${Ke} / werkmeister-context.md.`,acceptEmpty:!1,recommended:!0,pattern:"^[a-z0-9]+(-[a-z0-9]+)*$",placeholder:"mdx-blog",defaultFn:s(e=>X5e(ao.basename(e)),"defaultFn")},{key:"work_type",label:"Work type",help:"What kind of work this is; selects the phase sequence and the pre-implementation gate in CLAUDE.md.",acceptEmpty:!1,pattern:"^("+Object.keys(E1).join("|")+")$",default:"feature",choicesFn:s(()=>[...eBe],"choicesFn")},{key:"context_strategy",label:"Workflow",help:"Which context layer init-workspace generates: jit (w9r-* skills, hooks, notes) or icm (staged folders the agent walks by itself).",pattern:"^("+ni.join("|")+")$",default:ni[0],choicesFn:s(()=>[...ni],"choicesFn")},{key:"harness",label:"Harness",help:"Which agent harness reads this workspace: claude (Claude Code: CLAUDE.md, .claude/, hooks), mcp (any harness with MCP and skills: AGENTS.md, .agents/skills, no hooks) or codex (Codex CLI: AGENTS.md, .agents/skills, .codex/hooks.json, .codex/config.toml).",pattern:"^("+so.join("|")+")$",default:so[0],choicesFn:s(()=>[...so],"choicesFn")},{key:"autonomous",label:"Autonomous run",help:"Off by default. On: an icm run goes from stage 01 to `werkmeister pr open` with no human check (each stage self-checks and the agent approves its own PR file), and .claude/settings.json allows the git, werkmeister, docker, gh, node and python3 calls a headless session needs. The person reviews the PR; `werkmeister pr gate` still applies.",boolean:!0},{key:"model",label:"Model",help:"Claude model for this workspace's sessions: an alias (opus, sonnet, haiku) or a full claude-\u2026 id; empty = Claude Code's default. Written to .claude/settings.json and passed as --model to claude-send and claude-resume. A cheaper model suits mechanical jobs (lint passes, renames).",pattern:"^[A-Za-z0-9][A-Za-z0-9._\\[\\]-]*$",placeholder:"sonnet"},{key:"auto_stop",label:"Auto-stop on session end",help:"On by default for autonomous workspaces, off otherwise. On: when a Claude session in the workspace ends and no other one is open there, a SessionEnd hook runs `werkmeister internal session-end`, which stops this feature's containers (slot and volumes kept; `werkmeister feature up` resumes). Shared infra is never stopped.",boolean:!0},{key:"services",label:"Services to run locally",help:"Services to run locally with hot-reload; the rest fall through to k8s port-forwards.",multi:!0,choicesFn:s(()=>Object.keys(ki()[0]).sort(),"choicesFn"),choiceGroupsFn:s(()=>Object.fromEntries(Object.entries(ki()[0]).map(([e,t])=>[e,String(t?.repo??"other")])),"choiceGroupsFn")},{key:"labels",label:"Labels",help:"Comma-separated free-form tags for filtering workspaces in the dashboard search.",multi:!0},{key:"group",label:"Grouped PR members",help:"Comma-separated issue keys this workspace's PR also covers, led by its issue: one PR, one commit per ticket. Blank for a one-ticket PR.",multi:!0},{key:"test_path",label:"Feature test path",help:"URL path for the feature entry point, appended to the routed host.",pattern:"^/\\S*$",placeholder:"/products/foo"},{key:"task",label:"Task title",help:"Short title for the Current Task section. Defaults to the feature name in words.",defaultFn:s(e=>W6(ao.basename(e)),"defaultFn")},{key:"description",label:"Description",help:"1-2 sentences on what the feature does and the user-visible outcome; rendered under Current Task in CLAUDE.md.",placeholder:"Adds an MDX-powered blog index under /blog."},{key:"starting_prompt",label:"Starting prompt",help:"The first instruction to hand the agent in this workspace; persisted to .werkmeister/workspace.yml.",multiline:!0,refinable:!0,refineInstruction:"Rewrite the user's text as a clear, specific, actionable starting instruction for a coding agent beginning a development task, preserving the user's intent. The rewritten instruction must state the goal \u2014 the desired end state and why it matters \u2014 and must include explicit acceptance criteria: a checklist of concrete, verifiable conditions that define when the task is done. Derive the goal and acceptance criteria from the user's text wherever possible; for any that cannot be confidently derived, the rewritten instruction must direct the agent to ask the user to supply them before proceeding, rather than guessing."}];s(Cce,"promptEntry");s(tBe,"wizardPrompts");s(rBe,"buildPromptSpec");s(W6,"slugToTask");s(ki,"loadSandboxServiceConfigs");nBe={key:"repos",label:"Extra repos",help:"Extra repos to create worktrees for. The final set is the union of these and the repos owning the services selected above.",multi:!0,choicesFn:s(()=>Object.keys(mi()).sort(),"choicesFn")};s(jce,"computePromptSpec");s(iBe,"workspacePromptSpec")});var oBe,V6,sBe,kl,Nb,K6=A(()=>{"use strict";f();oBe=["mcp__plugin_werkmeister_werkmeister__"],V6=s(e=>oBe.map(t=>`${t}${e}`),"pluginTool"),sBe=["werkmeister","w9r"],kl=s(e=>sBe.map(t=>`Bash(${t} ${e})`),"cli"),Nb=["Bash(node:*)","Bash(python3:*)",...["proxy-reload","down","remove","remove-workspace","clean","setup","registry","connect","intercept","notes graduate","up infra","restart infra","stop infra","infra proxy-reload","feature down","infra down","feature drop","machine clean","machine setup","infra connect","infra intercept","workspace new","ws new","infra up","infra restart","infra stop","daemon install","daemon uninstall","daemon restart"].flatMap(e=>kl(`${e}:*`)),...["stop","kill","rm","rmi","compose down","system prune","volume rm","network rm"].map(e=>`Bash(docker ${e}:*)`),...["npm","pnpm"].flatMap(e=>["publish","link","unlink","install -g","install --global","i -g","i --global","uninstall -g","uninstall --global"].map(t=>`Bash(${e} ${t}:*)`)),...["add -g","add --global","remove -g","remove --global"].map(e=>`Bash(pnpm ${e}:*)`),"Bash(gh pr merge:*)",...["kube-switch","up","stop","restart","down","create-workspace","create-workspace-form","pr-approve","ask-pr-review","claude-send","claude-resume","connect","proxy-reload","remove-service","intercept"].flatMap(V6)]});var O1,G6=A(()=>{"use strict";f();Ta();O1={id:"mcp",instructionsFile:"AGENTS.md",skillsDir:".agents/skills",hooks:{available:!1,reason:"a generic MCP harness has no hooks adapter; use harness: codex for Codex"},agents:!1,notice:s(()=>`
|
|
393
393
|
## Harness
|
|
394
394
|
|
|
395
395
|
This workspace was generated for the \`mcp\` harness. Werkmeister's tools come from the MCP server \`werkmeister\` at ${FE()}/mcp (how to register it: docs/harnesses.md in the werkmeister repo). Hooks are unavailable on this harness: werkmeister's session-start context, standards gate, PR guard and agent state do not run here (Codex: use \`harness: codex\`). Open PRs only with \`werkmeister pr open\`.
|
|
@@ -532,7 +532,7 @@ export default {
|
|
|
532
532
|
`,CBe=Object.fromEntries(Nb.flatMap(e=>{let t=/^Bash\((.+):\*\)$/.exec(e);return t?[[`${t[1]}*`,"deny"]]:[]}));s(vle,"writeOpencodeHooks")});var jBe,wle,xle=A(()=>{"use strict";f();ble();jBe="session-start context, auto-stop",wle={id:"opencode",instructionsFile:"AGENTS.md",skillsDir:".agents/skills",hooks:{available:"own",write:vle,missing:jBe},agents:!1,questionTool:"question",notice:s(()=>"\n## Harness\n\nThis workspace was generated for OpenCode. Werkmeister's MCP server is registered in `opencode.json`, and `.opencode/plugins/werkmeister.js` runs the standards gate, the PR guard and agent state. Session-start context and auto-stop do not run on OpenCode: nothing injects the notes when a session starts, and quitting does not stop the containers. A `model:` in workspace.yml applies to headless turns only in OpenCode's `provider/model` form. Open PRs only with `werkmeister pr open`.\n","notice")}});function Ub(e){let t=e==null?"":String(e).trim();if(!t)return so[0];if(so.includes(t))return t;throw new te(`Unknown harness '${t}' in workspace.yml \u2014 expected one of: ${so.join(", ")}`,"UNKNOWN_HARNESS")}function ii(e){return LBe[Ub(xl(e,"harness"))]}function N1(e){try{return Ub(xl(e,"harness"))}catch{return so[0]}}function Ua(e){return DBe[N1(e)]}function ep(e){let{id:t,hooks:r}=ii(e);return r.available===!0?!0:(r.available==="own"?(Y(`Wrote ${r.write(e)}`),N(`hooks: partial on ${t} (${r.missing} do not run)`)):N(`hooks: unavailable on ${t} (${r.reason})`),!1)}var NBe,LBe,DBe,qa=A(()=>{"use strict";f();Ht();ze();Dn();gF();ile();Lb();G6();yle();xle();Ab();NBe={id:"claude",instructionsFile:"CLAUDE.md",skillsDir:".claude/skills",hooks:{available:!0},agents:!0,questionTool:"AskUserQuestion",notice:s(()=>"","notice")},LBe={claude:NBe,mcp:O1,codex:Lce,opencode:wle};s(Ub,"parseHarnessId");s(ii,"harnessLayoutFor");DBe={claude:Fb,mcp:Fb,codex:nle,opencode:gle};s(N1,"harnessIdOf");s(Ua,"harnessFor");s(ep,"hooksAvailable")});var Wle={};Ai(Wle,{AGENT_STATE_COMMAND:()=>Ele,AGENT_STATE_EVENTS:()=>Ole,AUTONOMOUS_DENY:()=>Nb,AUTONOMOUS_RULES:()=>bF,CODEX_AGENT_STATE_COMMAND:()=>Tle,CODEX_AGENT_STATE_EVENTS:()=>Rle,PRE_TOOL_USE_GATE_COMMAND:()=>_le,PR_GUARD_COMMAND:()=>Sle,READ_ONLY_GIT_RULES:()=>Lle,SESSION_END_COMMAND:()=>$le,SESSION_START_COMMAND:()=>kle,autonomousRules:()=>Dle,buildAgentStateEntry:()=>Cle,buildAllowRules:()=>zle,buildPrGuardEntry:()=>xF,buildPreToolUseGateEntry:()=>Ale,buildSessionEndEntry:()=>Ple,buildSessionStartEntry:()=>Ile,removeWorkspaceHooks:()=>$F,removeWorkspacePermissions:()=>WBe,workspaceAllowRules:()=>Fle,workspaceAskRules:()=>qle,workspaceDenyRules:()=>Ble,writeAgentStateHooks:()=>qb,writeAutoStopHook:()=>vF,writePrGuardHook:()=>SF,writeWorkspaceHooks:()=>B1,writeWorkspaceModel:()=>Hle,writeWorkspacePermissions:()=>TF,writeWorkspaceSettings:()=>Im});import*as Ar from"node:fs";import*as vn from"node:path";function Ile(){return{hooks:[{type:"command",command:kle}]}}function Ale(e=!1){return{matcher:e?"apply_patch":"Edit|Write",hooks:[{type:"command",command:_le}]}}function xF(){return{matcher:"Bash|mcp__.*create_pull_request",hooks:[{type:"command",command:Sle}]}}function Ple(e=!1){return{hooks:[{type:"command",command:$le,timeout:e?UBe:FBe}]}}function Cle(e=!1){return{hooks:[{type:"command",command:e?Tle:Ele}]}}function jle(e,t=D1){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let r=e.hooks;return Array.isArray(r)?r.some(i=>typeof i=="object"&&i!==null&&!Array.isArray(i)&&qBe(String(i.command??""),t)):!1}function BBe(e,t,r,i){let n=t in e?e[t]:[];if(!Array.isArray(n))return!1;let o=n.filter(a=>!jle(a,i));return o.push(r),e[t]=o,!0}function kF(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Hb(e){return Bb(e)?vn.join(e,Y6):vn.join(e,".claude","settings.json")}function _F(e){if(!Ar.existsSync(e))return{};try{let t=JSON.parse(Ar.readFileSync(e,"utf8"));return kF(t)?t:null}catch{return null}}function U1(e,t){if(Object.keys(t).length){Ar.mkdirSync(vn.dirname(e),{recursive:!0}),Ar.writeFileSync(e,JSON.stringify(t,null,2)+`
|
|
533
533
|
`);return}Ar.rmSync(e,{force:!0});try{Ar.rmdirSync(vn.dirname(e))}catch{}}function q1(e,t){let r=Hb(e),i=_F(r);if(i===null)return r;"hooks"in i||(i.hooks={});let n=i.hooks;if(typeof n!="object"||n===null||Array.isArray(n))return r;for(let[o,a,c]of t)if(!BBe(n,o,a,c))return r;return U1(r,i),r}function B1(e){return q1(e,[["SessionStart",Ile(),D1],["PreToolUse",Ale(Bb(e)),M1],["PreToolUse",xF(),z1]])}function qb(e){let t=Bb(e);return q1(e,(t?Rle:Ole).map(r=>[r,Cle(t),F1]))}function SF(e){return q1(e,[["PreToolUse",xF(),z1]])}function $F(e){return Nle(e,[["SessionStart",D1],["PreToolUse",M1]])}function vF(e,t){return t?q1(e,[["SessionEnd",Ple(Bb(e)),L1]]):(Nle(e,[["SessionEnd",L1]]),Hb(e))}function Nle(e,t){let r=Hb(e),i;try{i=JSON.parse(Ar.readFileSync(r,"utf8"))}catch{return[]}let n=i?.hooks;if(typeof n!="object"||n===null||Array.isArray(n))return[];let o=[];for(let[a,c]of t){let l=n[a];if(!Array.isArray(l))continue;let u=l.filter(p=>!jle(p,c));for(let p of l)u.includes(p)||o.push(...p.hooks.map(d=>String(d.command)));u.length?n[a]=u:delete n[a]}return o.length?(Object.keys(n).length||delete i.hooks,U1(r,i),o):[]}function Dle(e,t){return e?[...bF,...["up","restart","feature up","feature restart"].flatMap(r=>kl(`${r} ${e}`)),...kl(`feature up ${e} --service:*`),...["logs","test","services","feature logs","feature test","feature services"].flatMap(r=>kl(`${r} ${e}:*`)),...t.flatMap(r=>[`Bash(docker exec ${e}-${r}:*)`,`Bash(docker logs ${e}-${r}:*)`,`Bash(docker restart ${e}-${r})`])]:bF}function zle(e,t,r,i,n="",o=[],a=[]){let c=[],l=s(p=>p.split(/\s*&&\s*/).filter(Boolean),"segments");for(let p of[...t,...a]){let d=Es(p,r[p],i);if(!d)continue;let[m=d,...h]=l(d);t.includes(p)&&(c.push(`Bash(${ZE(e,p,d)})`),c.push(...l(d).map(y=>`Bash(${y}:*)`))),n&&c.push(`Bash(${n} ${m}:*)`),n&&c.push(...h.map(y=>`Bash(${y}:*)`))}if(n)for(let p of o)c.push(`Bash(${n} ${p}:*)`);n&&o.length&&c.push(`Bash(${vn.join(vn.dirname(n),"with-fixture-workspace")}:*)`);let u=`Bash(${n} `;return n&&c.push(...c.filter(p=>p.startsWith(u)).map(p=>`${u}--no-wait ${p.slice(u.length)}`)),[...new Set([...c,...Lle])]}function HBe(e){let t;try{t=Ar.readFileSync(vn.join(e,".env"),"utf8")}catch{return{}}let r={};for(let i of t.split(`
|
|
534
534
|
`)){let n=i.indexOf("=");n>0&&(r[i.slice(0,n).trim()]=i.slice(n+1).trim())}return r}function Fle(e,t=Yu(e)){let r=HBe(e),i=r.FEATURE??"",n=(r.SERVICES??"").split(",").map(m=>m.trim()).filter(Boolean),o=km(e),a=Ule(e),c=vr(e).map(m=>vn.basename(m)),l=[];try{c.length&&(l=Ku(c,mi()))}catch{}let u=l.filter(m=>!n.includes(m)),p=n.length>0||u.length>0,d=zle(p?i:"",n,p?Re():{},p?hr():{},o,a,u);return t?[...new Set([...d,...Dle(i,n)])]:d}function Ule(e){return vr(e).map(t=>vn.join(t,"apps","cli","werkmeister")).filter(t=>Ar.existsSync(t))}function qle(e){let t=km(e),r=[`Bash(${t} env WERKMEISTER_ROOT=* node --test:*)`,`Bash(${t} --no-wait env WERKMEISTER_ROOT=* node --test:*)`],i=Ule(e);if(!i.length)return r;let n=vn.join(vn.dirname(t),"with-fixture-workspace");return[`Bash(${n} --exec-runs:*)`,`Bash(${n} --no-wait --exec-runs:*)`,...i.flatMap(o=>[`Bash(${t} ${o} internal fixture --exec-runs:*)`,`Bash(${t} --no-wait ${o} internal fixture --exec-runs:*)`]),...r]}function Ble(e,t=Yu(e)){return t?Nb:[]}function EF(e){try{let t=JSON.parse(Ar.readFileSync(e,"utf8"));return kF(t)?{allow:yF(t.allow),deny:yF(t.deny),ask:yF(t.ask),model:typeof t.model=="string"?t.model:null}:{allow:[],deny:[],ask:[],model:null}}catch{return{allow:[],deny:[],ask:[],model:null}}}function wF(e,t){let r={...t.allow.length?{allow:t.allow}:{},...t.deny.length?{deny:t.deny}:{},...t.ask.length?{ask:t.ask}:{},...t.model?{model:t.model}:{}},i=EF(e);JSON.stringify(t)!==JSON.stringify(i)&&(Object.keys(r).length?(Ar.mkdirSync(vn.dirname(e),{recursive:!0}),Ar.writeFileSync(e,`${JSON.stringify(r,null,2)}
|
|
535
|
-
`)):Ar.rmSync(e,{force:!0}))}function TF(e,t,r=[],i=[]){let n=Hb(e),o=_F(n);if(o===null)return n;let a=o.permissions??{};if(!kF(a))return n;let c={allow:t,deny:r,ask:i},l=["allow","deny","ask"];if(l.some(h=>!Array.isArray(a[h]??[])))return n;let u=Mle(e),p=EF(u),d={...p},m=!1;for(let h of l){let y=a[h]??[],g=new Set(p[h]),v=[...new Set(c[h])],x=y.filter(S=>!(typeof S=="string"&&g.has(S)&&!v.includes(S))),k=v.filter(S=>!x.includes(S));if(d[h]=v.filter(S=>g.has(S)||k.includes(S)),x.length===y.length&&!k.length)continue;m=!0;let _=[...x,...k];_.length?a[h]=_:delete a[h]}return m&&(Object.keys(a).length?o.permissions=a:delete o.permissions,U1(n,o)),wF(u,d),n}function WBe(e){return TF(e,[],[],[])}function Hle(e,t){let r=Hb(e),i=_F(r);if(i===null)return r;let n=Mle(e),o=EF(n),a=i.model;return a!==void 0&&a!==o.model?(wF(n,{...o,model:null}),r):(a!==(t??void 0)&&(t?i.model=t:delete i.model,U1(r,i)),wF(n,{...o,model:t}),r)}function Im(e){if(Bb(e)){vF(e,Pb(e)),qb(e),Dce(e),I(`codex: trust this folder in Codex, approve its hooks with /hooks, and start it as \`${Em}\` (docs/harnesses.md \xA7 Codex)`);return}TF(e,Fle(e),Ble(e),qle(e)),Hle(e,Ace(e)),vF(e,Pb(e)),qb(e)}var D1,M1,z1,L1,F1,MBe,zBe,kle,_le,Sle,$le,Ele,Tle,Ole,Rle,FBe,UBe,Bb,qBe,Lle,bF,Mle,yF,Wb=A(()=>{"use strict";f();Do();ye();ze();wi();Ib();Dn();K6();Lb();qa();D1="werkmeister notes context",M1="werkmeister internal gate",z1="werkmeister internal pr-guard",L1="werkmeister internal session-end",F1="werkmeister internal agent-state",MBe={[M1]:"werkmeister hooks gate",[z1]:"werkmeister hooks pr-guard",[L1]:"werkmeister stop --if-idle",[F1]:"werkmeister hooks agent-state"},zBe="werkmeister skills check >/dev/null 2>&1 || werkmeister skills sync >/dev/null 2>&1",kle=`command -v werkmeister >/dev/null 2>&1 && { ${zBe}; ${D1}; } || true`,_le=`command -v werkmeister >/dev/null 2>&1 && ${M1} || true`,Sle=`command -v werkmeister >/dev/null 2>&1 && ${z1} || true`,$le=`command -v werkmeister >/dev/null 2>&1 && ${L1} >/dev/null 2>&1 || true`,Ele=`command -v werkmeister >/dev/null 2>&1 && ${F1} || true`,Tle=`command -v werkmeister >/dev/null 2>&1 && WERKMEISTER_HOOK_HARNESS=codex ${F1} || true`,Ole=["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","Notification","Stop","SessionEnd","PermissionRequest","PermissionDenied","PostToolUseFailure","SubagentStart","SubagentStop","StopFailure"],Rle=["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","PermissionRequest","Stop","SessionEnd"],FBe=10,UBe=3,Bb=s(e=>ii(e).id==="codex","isCodex");s(Ile,"buildSessionStartEntry");s(Ale,"buildPreToolUseGateEntry");s(xF,"buildPrGuardEntry");s(Ple,"buildSessionEndEntry");s(Cle,"buildAgentStateEntry");qBe=s((e,t)=>[t,MBe[t]].some(r=>r!==void 0&&(e.includes(r)||e.includes(r.replace(/^werkmeister /,"sandbox ")))),"isManagedCommand");s(jle,"_isManaged");s(BBe,"_mergeEvent");s(kF,"_isDict");s(Hb,"_settingsPath");s(_F,"_readSettings");s(U1,"_saveSettings");s(q1,"_writeManaged");s(B1,"writeWorkspaceHooks");s(qb,"writeAgentStateHooks");s(SF,"writePrGuardHook");s($F,"removeWorkspaceHooks");s(vF,"writeAutoStopHook");s(Nle,"_removeManaged");Lle=["Bash(git diff:*)","Bash(git status:*)","Bash(git ls-files:*)"],bF=["Bash(git:*)",...["pr view","pr checks","pr diff","pr list","issue view","run view","run list"].map(e=>`Bash(gh ${e}:*)`),...["up","restart","feature up","feature restart"].flatMap(kl),...kl("feature up --service:*"),...["status","feature status","infra status","pr","issue view","issue start","init-workspace","workspace init","skills","standards","notes context"].flatMap(e=>kl(`${e}:*`)),"Bash(docker ps:*)",...["npm ci","npm run","npm test"
|
|
535
|
+
`)):Ar.rmSync(e,{force:!0}))}function TF(e,t,r=[],i=[]){let n=Hb(e),o=_F(n);if(o===null)return n;let a=o.permissions??{};if(!kF(a))return n;let c={allow:t,deny:r,ask:i},l=["allow","deny","ask"];if(l.some(h=>!Array.isArray(a[h]??[])))return n;let u=Mle(e),p=EF(u),d={...p},m=!1;for(let h of l){let y=a[h]??[],g=new Set(p[h]),v=[...new Set(c[h])],x=y.filter(S=>!(typeof S=="string"&&g.has(S)&&!v.includes(S))),k=v.filter(S=>!x.includes(S));if(d[h]=v.filter(S=>g.has(S)||k.includes(S)),x.length===y.length&&!k.length)continue;m=!0;let _=[...x,...k];_.length?a[h]=_:delete a[h]}return m&&(Object.keys(a).length?o.permissions=a:delete o.permissions,U1(n,o)),wF(u,d),n}function WBe(e){return TF(e,[],[],[])}function Hle(e,t){let r=Hb(e),i=_F(r);if(i===null)return r;let n=Mle(e),o=EF(n),a=i.model;return a!==void 0&&a!==o.model?(wF(n,{...o,model:null}),r):(a!==(t??void 0)&&(t?i.model=t:delete i.model,U1(r,i)),wF(n,{...o,model:t}),r)}function Im(e){if(Bb(e)){vF(e,Pb(e)),qb(e),Dce(e),I(`codex: trust this folder in Codex, approve its hooks with /hooks, and start it as \`${Em}\` (docs/harnesses.md \xA7 Codex)`);return}TF(e,Fle(e),Ble(e),qle(e)),Hle(e,Ace(e)),vF(e,Pb(e)),qb(e)}var D1,M1,z1,L1,F1,MBe,zBe,kle,_le,Sle,$le,Ele,Tle,Ole,Rle,FBe,UBe,Bb,qBe,Lle,bF,Mle,yF,Wb=A(()=>{"use strict";f();Do();ye();ze();wi();Ib();Dn();K6();Lb();qa();D1="werkmeister notes context",M1="werkmeister internal gate",z1="werkmeister internal pr-guard",L1="werkmeister internal session-end",F1="werkmeister internal agent-state",MBe={[M1]:"werkmeister hooks gate",[z1]:"werkmeister hooks pr-guard",[L1]:"werkmeister stop --if-idle",[F1]:"werkmeister hooks agent-state"},zBe="werkmeister skills check >/dev/null 2>&1 || werkmeister skills sync >/dev/null 2>&1",kle=`command -v werkmeister >/dev/null 2>&1 && { ${zBe}; ${D1}; } || true`,_le=`command -v werkmeister >/dev/null 2>&1 && ${M1} || true`,Sle=`command -v werkmeister >/dev/null 2>&1 && ${z1} || true`,$le=`command -v werkmeister >/dev/null 2>&1 && ${L1} >/dev/null 2>&1 || true`,Ele=`command -v werkmeister >/dev/null 2>&1 && ${F1} || true`,Tle=`command -v werkmeister >/dev/null 2>&1 && WERKMEISTER_HOOK_HARNESS=codex ${F1} || true`,Ole=["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","Notification","Stop","SessionEnd","PermissionRequest","PermissionDenied","PostToolUseFailure","SubagentStart","SubagentStop","StopFailure"],Rle=["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","PermissionRequest","Stop","SessionEnd"],FBe=10,UBe=3,Bb=s(e=>ii(e).id==="codex","isCodex");s(Ile,"buildSessionStartEntry");s(Ale,"buildPreToolUseGateEntry");s(xF,"buildPrGuardEntry");s(Ple,"buildSessionEndEntry");s(Cle,"buildAgentStateEntry");qBe=s((e,t)=>[t,MBe[t]].some(r=>r!==void 0&&(e.includes(r)||e.includes(r.replace(/^werkmeister /,"sandbox ")))),"isManagedCommand");s(jle,"_isManaged");s(BBe,"_mergeEvent");s(kF,"_isDict");s(Hb,"_settingsPath");s(_F,"_readSettings");s(U1,"_saveSettings");s(q1,"_writeManaged");s(B1,"writeWorkspaceHooks");s(qb,"writeAgentStateHooks");s(SF,"writePrGuardHook");s($F,"removeWorkspaceHooks");s(vF,"writeAutoStopHook");s(Nle,"_removeManaged");Lle=["Bash(git diff:*)","Bash(git status:*)","Bash(git ls-files:*)"],bF=["Bash(git:*)",...["pr view","pr checks","pr diff","pr list","issue view","run view","run list"].map(e=>`Bash(gh ${e}:*)`),...["up","restart","feature up","feature restart"].flatMap(kl),...kl("feature up --service:*"),...["status","feature status","infra status","pr","issue view","issue start","init-workspace","workspace init","skills","standards","notes context"].flatMap(e=>kl(`${e}:*`)),"Bash(docker ps:*)",...["npm ci","npm run","npm test"].map(e=>`Bash(${e}:*)`),...["install --frozen-lockfile","run","test","turbo"].map(e=>`Bash(pnpm ${e}:*)`),...["ls","cat","grep","find","head","tail","sed","diff","wc","test","mkdir"].map(e=>`Bash(${e}:*)`),"Bash(claude plugin validate:*)","Bash(claude plugin test:*)",...["issue","issue-statuses","status","workspace-prs","kube-context","k8s-forwards-status"].flatMap(V6)];s(Dle,"autonomousRules");Mle=s(e=>vn.join(V(e),"claude-permissions.json"),"permissionsRecord");s(zle,"buildAllowRules");s(HBe,"_readEnv");s(Fle,"workspaceAllowRules");s(Ule,"builtCliWrappers");s(qle,"workspaceAskRules");s(Ble,"workspaceDenyRules");yF=s(e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],"_strings");s(EF,"_readRecord");s(wF,"_writeRecord");s(TF,"writeWorkspacePermissions");s(WBe,"removeWorkspacePermissions");s(Hle,"writeWorkspaceModel");s(Im,"writeWorkspaceSettings")});import ZBe from"node:fs/promises";import VBe from"node:path";function Zle(e,t,r){return y1(e,t,r,bm)}function Vle(e,t,r,i={}){return["-p",...i.allow?.length?["--allowedTools",i.allow.join(",")]:[],...i.deny?.length?["--disallowedTools",i.deny.join(",")]:[],"--permission-mode","acceptEdits",...i.json?["--output-format","json"]:[],...r?["--model",r]:[],...t?["--resume",t]:[],e]}async function Kle(e,t,r,i,n,o={}){let a=await L6(),c=o.unattended,l=c&&await Promise.resolve().then(()=>(Wb(),Wle)),u=Vle(r,i,n,{...c&&l&&{allow:l.workspaceAllowRules(c,!0),deny:l.workspaceDenyRules(c,!0)},json:o.wait}),p=await vm(e,a,u,t,!!o.wait);return p===null?null:{denied:KBe(p)}}function KBe(e){let t;try{t=JSON.parse(e)}catch{return[]}let r=(t.permission_denials??[]).map(i=>{let n=String(i.tool_input?.command??"").split(`
|
|
536
536
|
`)[0].slice(0,120);return n?`${i.tool_name}: ${n}`:String(i.tool_name)});return[...new Set(r)]}function OF(e,t){let r=Date.parse(t.sentAt);return e.some(i=>i.role==="user"&&i.timestamp!==null&&Date.parse(i.timestamp)>r&&i.text.includes(t.text))}async function RF(e,t){let r=t==="codex"?"codex":"claude",i=t==="codex"?/^ (exec|e)( |$)/:/(^| )(-p|--print)( |$)/,o=((await nt("ps",["-axo","pid=,args="]).catch(()=>null))?.stdout??"").split(`
|
|
537
537
|
`).map(l=>l.trim().match(/^(\d+) (\S+)(.*)$/)).filter(l=>l&&VBe.basename(l[2])===r&&!i.test(l[3])).map(l=>l?.[1]);if(!o.length)return!1;let a=await ZBe.realpath(e).catch(()=>e);return((await nt("lsof",["-a","-d","cwd","-Fn","-p",o.join(",")]).catch(()=>null))?.stdout??"").split(`
|
|
538
538
|
`).some(l=>l.startsWith("n")&&(l.slice(1)===a||l.slice(1).startsWith(`${a}/`)))}function IF(e,t,r){return["claude",...t?["--model",gr(t)]:[],...e?["--resume",e]:[],...r?[gr(r)]:[]].join(" ")}var H1=A(()=>{"use strict";f();gn();wb();za();bb();Sb();s(Zle,"sessionSignal");s(Vle,"claudeSendArgs");s(Kle,"startTurn");s(KBe,"deniedIn");s(OF,"relayPickedUp");s(RF,"claudeOpenIn");s(IF,"claudeResumeCommand")});var Fb,gF=A(()=>{"use strict";f();za();bb();H1();Sb();j1();Fb={id:"claude",ask:sce,askJson:ace,askOrThrow:D6,sendTurn:Kle,turnStatus:As,transcript:vce,sessionSource:gce,sessionStartDir:s((e,t)=>yce(t),"sessionStartDir"),listSessions:mce,parseSession:bm,agentSignal:Zle,usage:Mb,resumeCommand:IF,reconcileCommand:cce}});function uo(){return Fb}var W1=A(()=>{"use strict";f();gF();Ab();s(uo,"harness")});function Gle(e,t,r){let i=e.trim();for(;i.endsWith("/");)i=i.slice(0,-1);return!i||!t||!r||Sl(i)||Sl(t)||Sl(r)?null:{baseUrl:i,email:t,token:r}}async function $l(){let e=Gle(process.env.JIRA_BASE_URL??"",process.env.JIRA_EMAIL??"",process.env.JIRA_API_TOKEN??"");if(e)return e;try{let t=Ki().jira??{};return Gle(String(t.base_url??""),String(t.email??""),String(t.api_token??""))}catch{return null}}async function Am(e,t,r){let i=await fetch(`${e.baseUrl}${t}`,{method:r===void 0?"GET":"POST",headers:{Authorization:"Basic "+Buffer.from(`${e.email}:${e.token}`).toString("base64"),Accept:"application/json",...r===void 0?{}:{"Content-Type":"application/json"}},body:r===void 0?void 0:JSON.stringify(r),signal:AbortSignal.timeout(1e4)});if(!i.ok){let n=(await i.text().catch(()=>"")).trim().slice(0,500);throw new Error(`Jira REST ${t} \u2192 HTTP ${i.status}${n?`: ${n}`:""}`)}return i}async function Yle(){let e=await $l();if(!e)return null;let r=await(await Am(e,"/rest/api/3/myself")).json();return{who:r.emailAddress??r.displayName??e.email}}async function tp(e,t){return await(await Am(e,t)).json()}async function Xle(e,t){let r=await $l();if(!r)return t?.push("no Jira REST credentials"),null;try{return await tp(r,`/rest/api/2/issue/${encodeURIComponent(e)}?fields=${GBe}`)}catch(i){return t?.push(JBe(i)),null}}function JBe(e){let t=e;if(t.message?.startsWith("Jira REST "))return t.message;let r=t.cause?.code??t.cause?.message;return`Jira REST: ${t.message}${r?` (${r})`:""}`}async function Qle(e){if(!e.length)return{};let t=await $l();if(!t)return null;let r=encodeURIComponent(`key in (${e.join(",")})`);try{let i=await tp(t,`/rest/api/2/search/jql?jql=${r}&fields=status&maxResults=100`),n={};for(let o of i.issues??[]){let a=o.fields?.status?.name;o.key&&a&&(n[o.key.toUpperCase()]=a)}return n}catch{return null}}async function tue(e){let t=await $l();return t?(await tp(t,`/rest/api/2/search/jql?jql=${encodeURIComponent(e)}&${eue}`)).issues??[]:null}async function rue(e,t){let r=await $l();if(!r)return null;let i=encodeURIComponent(e),{columnConfig:n}=await tp(r,`/rest/agile/1.0/board/${i}/configuration`),o=n?.columns??[],a=o.find(p=>p.name?.toLowerCase()===t.toLowerCase());if(!a)throw new Error(`board ${e} has no "${t}" column (it has: ${o.map(p=>p.name).join(", ")})`);let c=(a.statuses??[]).flatMap(p=>p.id?[p.id]:[]);if(!c.length)return[];let l=encodeURIComponent(`status in (${c.join(",")})`);return(await tp(r,`/rest/agile/1.0/board/${i}/issue?jql=${l}&${eue}`)).issues??[]}async function nue(e){let t=await $l();if(!t)return null;let r=encodeURIComponent(e.project),{issueTypes:i=[]}=await tp(t,`/rest/api/2/issue/createmeta/${r}/issuetypes`),n=s(l=>i.some(u=>u.name?.toLowerCase()===l.toLowerCase()),"has"),o=n(e.issueType)||!n("Task")?e.issueType:"Task",a=await Am(t,"/rest/api/2/issue",{fields:{project:{key:e.project},issuetype:{name:o},summary:e.summary,description:e.description,...o===e.issueType?{}:{labels:[e.fallbackLabel]}}}),{key:c}=await a.json();return{key:c,url:`${t.baseUrl}/browse/${c}`,issueType:o}}async function iue(e,t){let r=await $l();return r?(await Am(r,"/rest/api/2/issueLink",{type:{name:"Relates"},inwardIssue:{key:e},outwardIssue:{key:t}}),!0):null}async function oue(e,t){let r=await $l();if(!r)return null;let i=`/rest/api/2/issue/${encodeURIComponent(e)}`;if(t.status){let n=t.status.trim().toLowerCase(),{transitions:o=[]}=await tp(r,`${i}/transitions`),a=o.find(c=>c.to?.name?.toLowerCase()===n)??o.find(c=>c.name?.toLowerCase()===n);if(!a){let c=o.map(l=>l.to?.name??l.name).filter(Boolean).join(", ");throw new Error(`${e} has no transition to "${t.status}" (available: ${c||"none"})`)}await Am(r,`${i}/transitions`,{transition:{id:a.id}})}return t.comment&&await Am(r,`${i}/comment`,{body:t.comment}),!0}var Jle,Sl,GBe,eue,AF=A(()=>{"use strict";f();ye();Jle=new Set(["PASTE_TOKEN_HERE","<your-atlassian-login-email>","https://your-org.atlassian.net"]),Sl=s(e=>Jle.has(e.trim().replace(/\/+$/,"")),"isJiraPlaceholder");s(Gle,"normalizeCreds");s($l,"jiraCreds");s(Am,"jiraFetch");s(Yle,"jiraMyself");s(tp,"jiraGet");GBe="summary,description,status,issuetype,assignee,comment";s(Xle,"fetchIssueRest");s(JBe,"restFailure");s(Qle,"fetchStatusesRest");eue="fields=summary,status&maxResults=100";s(tue,"searchIssuesRest");s(rue,"boardColumnRest");s(nue,"createIssueRest");s(iue,"linkIssueRest");s(oue,"updateIssueRest")});function Z1(e){let t=(Xf().base_url??"").trim().replace(/\/+$/,"");return!t||Sl(t)?null:`${t.includes("://")?t:`https://${t}`}/browse/${e}`}function uue(){let e=Xf(),t=(e.cloud_id??"").trim();if(t)return t;let r=(e.base_url??"").trim();if(!r||Sl(r))return null;try{return new URL(r.includes("://")?r:`https://${r}`).hostname||null}catch{return null}}function V1(){let e=uue();return e?`(Atlassian cloud id ${e})`:"(find the cloud id with getAccessibleAtlassianResources)"}function sue(e){let t=e.fields??{},r=(t.comment?.comments??[]).flatMap(i=>{let n=i.body?.trim();return n?[{author:i.author?.displayName??"unknown",created:i.created,body:n}]:[]});return{ref:e.key,title:nn(t.summary),status:nn(t.status?.name),statusCategory:pue(t.status?.statusCategory?.key),type:nn(t.issuetype?.name),assignee:nn(t.assignee?.displayName),description:nn(t.description),url:Z1(e.key)??void 0,comments:r}}async function QBe(e){let t=await uo().askJson(`You are a data extractor, not an agent. Do exactly two things and nothing else:
|
|
@@ -736,7 +736,7 @@ document.cookie = "X-Feature=${e}; domain=.${Vt.domain}; path=/; SameSite=Lax";
|
|
|
736
736
|
or visit https://${Vt.host}/__werkmeister and select \`${e}\` \u2014 the selector is served on every routed host and the cookie applies to each host sharing the base domain.
|
|
737
737
|
`:"",kn=l.filter(ue=>!n.includes(ue)).sort(),yt=`## How to validate
|
|
738
738
|
|
|
739
|
-
How to exercise a change to each service in this workspace.${kn.length?` A plain \`werkmeister feature up\` skips the on-demand ones, ${kn.map(ue=>`\`${ue}\``).join(", ")}: start one with \`werkmeister feature up --service <name>\`.`:""}${p?` Each test command runs through \`.werkmeister/bin/with-temp-home\`, which gives it a fresh temporary HOME and deletes it on exit: never hand-roll \`HOME=\u2026\`. Start every exercise command with the script itself, never with env assignments or a \`cd\`, so one permission rule matches it: \`${p} <test command>\`. A command that needs an env var takes it after the script (\`${p} env WERKMEISTER_ROOT=\u2026 <cmd>\`); no rule pre-approves that form, so it asks. Put \`--no-wait\` first (\`${p} --no-wait <cmd>\`) to skip its host-load wait; the allow rules below cover that form too. That wait lasts up to 90 s; if load is still over then, the script exits 75 without running the command (retry later). It prints only on stderr, so a foreground call shows nothing until it ends and its only child is \`werkmeister internal wait-load\`: that is the wait, not a hang. The allow rule that covers them is \`Bash(${p} <test command>:*)\` for each test command below: run those for a test without a prompt. Neither \`node --test\` through the script nor the script alone is allowed, since both run any file (SW-510).`:""}${L?" A test command ending in `&& <lint>` also runs the repo's lint, the same command the PR gate's lint row runs, so a format error fails here and not first at `werkmeister pr open`.":""}
|
|
739
|
+
How to exercise a change to each service in this workspace.${kn.length?` A plain \`werkmeister feature up\` skips the on-demand ones, ${kn.map(ue=>`\`${ue}\``).join(", ")}: start one with \`werkmeister feature up --service <name>\`.`:""}${p?` Each test command runs through \`.werkmeister/bin/with-temp-home\`, which gives it a fresh temporary HOME and deletes it on exit: never hand-roll \`HOME=\u2026\`. Start every exercise command with the script itself, never with env assignments or a \`cd\`, so one permission rule matches it: \`${p} <test command>\`. A command that needs an env var takes it after the script (\`${p} env WERKMEISTER_ROOT=\u2026 <cmd>\`); no rule pre-approves that form, so it asks. Put \`--no-wait\` first (\`${p} --no-wait <cmd>\`) to skip its host-load wait; the allow rules below cover that form too. That wait lasts up to 90 s; if load is still over then, the script exits 75 without running the command (retry later). It prints only on stderr, so a foreground call shows nothing until it ends and its only child is \`werkmeister internal wait-load\`: that is the wait, not a hang. The allow rule that covers them is \`Bash(${p} <test command>:*)\` for each test command below: run those for a test without a prompt. Neither \`node --test\` through the script nor the script alone is allowed, since both run any file (SW-510). The temp HOME only keeps a run from writing to the real one by accident; it is not an isolation boundary. A pre-approved test command or built CLI still runs whatever the worktree holds, a test written in this run included, and that code can reach absolute paths, the caller's env, the network, docker and gh (SW-522).`:""}${L?" A test command ending in `&& <lint>` also runs the repo's lint, the same command the PR gate's lint row runs, so a format error fails here and not first at `werkmeister pr open`.":""}
|
|
740
740
|
|
|
741
741
|
${G}
|
|
742
742
|
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "werkmeister",
|
|
3
|
-
"version": "0.83.
|
|
3
|
+
"version": "0.83.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Multi-feature concurrent development orchestrator CLI tool",
|
|
6
6
|
"type": "module",
|
|
@@ -117,8 +117,8 @@
|
|
|
117
117
|
"typescript": "^5.7.0",
|
|
118
118
|
"vitest": "^3.0.0",
|
|
119
119
|
"yaml": "^2.7.0",
|
|
120
|
-
"werkmeister-
|
|
121
|
-
"werkmeister-
|
|
120
|
+
"werkmeister-mcp": "0.9.2",
|
|
121
|
+
"werkmeister-core": "0.83.2"
|
|
122
122
|
},
|
|
123
123
|
"scripts": {
|
|
124
124
|
"build": "node esbuild.mjs",
|