werkmeister 0.44.0 → 0.44.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/gate.js +2 -2
- package/dist/main.js +436 -436
- package/dist/mcp.js +312 -312
- package/dist/werkmeister-workspaces.vsix +0 -0
- package/package.json +2 -2
package/dist/lib/gate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
var P=Object.defineProperty;var a=(t,e)=>P(t,"name",{value:e,configurable:!0});import*as
|
|
4
|
-
`):null}a(z,"decide");function
|
|
3
|
+
var P=Object.defineProperty;var a=(t,e)=>P(t,"name",{value:e,configurable:!0});import*as u from"node:fs";import*as i from"node:path";import*as $ from"node:path";var k=".werkmeister";function w(t){return $.join(t,k)}a(w,"dotDir");var O="Precedence: these standards' rules win over conflicting task framing \u2014 if a rule and the task clash, follow the rule and say so (invariant: apply it and write a `decision` note; rule: surface the conflict in one line, then apply). This gate fires once; your retry will proceed.",A="Standards gate: invoke `w9r-implement` before coding \u2014 it loads the universal base (ponytail + comments + engineering) and the workspace notes. Then retry this edit.";function R(t){let e="",n=0,r=t.length;for(;n<r;){let o=t[n];if(n+=1,o==="*")e+=".*";else if(o==="?")e+=".";else if(o==="["){let s=n;for(s<r&&t[s]==="!"&&(s+=1),s<r&&t[s]==="]"&&(s+=1);s<r&&t[s]!=="]";)s+=1;if(s>=r)e+="\\[";else{let c=t.slice(n,s).replace(/\\/g,"\\\\");n=s+1,c.startsWith("!")?c="^"+c.slice(1):c.startsWith("^")&&(c="\\"+c),e+=`[${c}]`}}else e+=o.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return`^(?:${e})$`}a(R,"_translate");function F(t,e){return new RegExp(R(e),"s").test(t)}a(F,"fnmatch");function W(t,e){let n=i.resolve(t);for(let r of e){let o=i.relative(r,n);if(!(o===""||o===".."||o.startsWith(".."+i.sep)||i.isAbsolute(o)))return i.join(r,o.split(i.sep)[0])}return null}a(W,"workspaceUnder");function J(t,e){if(e){let r=W(t,e);return r!==null&&T(w(r))?r:null}let n=i.resolve(t);for(;;){if(T(w(n)))return n;let r=i.dirname(n);if(r===n)return null;n=r}}a(J,"findWorkspaceRoot");function T(t){try{return u.statSync(t).isDirectory()}catch{return!1}}a(T,"_isDir");function E(t){try{return u.statSync(t).isFile()}catch{return!1}}a(E,"_isFile");function d(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}a(d,"_isDict");function C(t){let e=i.join(w(t),"standards.json");if(!E(e))return null;let n;try{n=JSON.parse(u.readFileSync(e,"utf8"))}catch{return null}return d(n)?n:null}a(C,"loadManifest");function N(t,e){return i.join(w(t),".gate",`${e}.json`)}a(N,"_statePath");function G(t,e){let n=N(t,e);if(!E(n))return{};let r;try{r=JSON.parse(u.readFileSync(n,"utf8"))}catch{return null}return d(r)?r:null}a(G,"_loadState");function L(t,e,n){try{let r=N(t,e);return u.mkdirSync(i.dirname(r),{recursive:!0}),u.writeFileSync(r,JSON.stringify(n)),!0}catch{return!1}}a(L,"_saveState");function x(t){return[...t].sort()}a(x,"_sorted");function U(t){let e=/^---\r?\n([\s\S]*?)\r?\n---/.exec(t);if(!e)return;let n=/^status:\s*["']?([^\s"'#]+)/m.exec(e[1]);return n?n[1].toLowerCase():null}a(U,"_noteStatus");function X(t,e){let n=String(e.note??"");if(!/^[a-z]+$/.test(n))return!0;let r=e.status?String(e.status).toLowerCase():null,o=i.join(w(t),"notes"),s;try{s=u.readdirSync(o)}catch(l){return l.code!=="ENOENT"}let c=new RegExp(`^\\d{3}-${n}-.+\\.md$`);for(let l of s){if(!c.test(l))continue;let p;try{p=u.readFileSync(i.join(o,l),"utf8")}catch{return!0}let h=U(p);if(h===void 0)return!0;if(!(h==="superseded"||h==="graduated")&&(r===null||h===r))return!0}return!1}a(X,"_phaseGateSatisfied");function Y(t){let e=String(t.note);if(t.status){let n=String(t.status);return`Phase gate: no \`${e}\` note in \`.werkmeister/notes/\` has \`status: ${n}\`, so source edits wait for an approved design. Invoke \`w9r-research\`, present the design to the user, and when they approve write \`NNN-${e}-<slug>.md\` with \`status: ${n}\` recording what was approved. Then retry this edit. Edits under \`.werkmeister/\` are not gated.`}return`Phase gate: no \`${e}\` note in \`.werkmeister/notes/\` names the root cause yet. Invoke \`w9r-research\`, reproduce the problem, and write \`NNN-${e}-<slug>.md\` stating the root cause. Then retry this edit. Edits under \`.werkmeister/\` are not gated.`}a(Y,"_phaseGateText");function z(t,e,n){if(!e||e.includes("/")||e.includes(".."))return null;let r=J(t);if(r===null)return null;let o=C(r);if(o===null)return null;let s=G(r,e);if(s===null)return null;let c=n?i.relative(r,n):"",l=o.phase_gate;if(d(l)&&c&&c!==".."&&!c.startsWith(".."+i.sep)&&!i.isAbsolute(c)&&!c.startsWith(k+i.sep)&&!X(r,l))return Y(l);let p=new Set(Array.isArray(s.delivered)?s.delivered:[]),h=!s.phase_entry_delivered,f=null,g=d(o.domains)?o.domains:{};for(let m of x(Object.keys(g))){let y=g[m];if(p.has(m)||!d(y))continue;if((Array.isArray(y.applies_to)?y.applies_to:[]).some(D=>F(c,String(D)))){f=m;break}}if(!h&&f===null)return null;let S=[];if(h&&S.push(A),f!==null){let m=g[f],y=String(d(m)&&m.summary||"").trim(),_=`Standards gate: you are editing a path governed by the \`${f}\` standard, which has not been loaded this session. Invoke the \`w9r-${f}-standard\` skill, then retry this edit.`;y&&(_+=` Summary: ${y}.`),S.push(_)}S.push(O);let j={phase_entry_delivered:!0,delivered:x(f?new Set([...p,f]):p)};return L(r,e,j)?S.join(`
|
|
4
|
+
`):null}a(z,"decide");function b(){let t;try{let c=process.stdin.isTTY?"":u.readFileSync(0,"utf8"),l=c.trim()?JSON.parse(c):{};t=d(l)?l:{}}catch{t={}}let e=String(t.session_id||""),n=t.tool_input,r=String(d(n)&&n.file_path||""),o=String(t.cwd||process.cwd()),s;try{s=z(o,e,r)}catch{s=null}s&&console.log(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:s}}))}a(b,"main");b();
|
|
5
5
|
//# sourceMappingURL=gate.js.map
|