werkmeister 0.41.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONVENTIONS.md +2 -2
- package/README.md +8 -8
- package/bin/generate-certs.sh +12 -12
- package/dist/NOTICE +1 -1
- package/dist/lib/agent_state.js +4 -4
- package/dist/lib/gate.js +2 -2
- package/dist/lib/pr_guard.js +1 -1
- package/dist/main.js +558 -551
- package/dist/mcp.js +406 -404
- package/dist/werkmeister-workspaces.vsix +0 -0
- package/infra/compose/k8s-port-forward/Dockerfile +1 -1
- package/infra/compose/k8s-port-forward/entrypoint.sh +2 -2
- package/infra/compose/redisinsight/databases.json +1 -1
- package/infra/compose/scripts/werkmeister-install-startup.sh +9 -9
- package/infra/compose/shared-infra.yml +17 -28
- package/infra/proxy/ui/index.html +4 -4
- package/infra/schemas/services-fragment.schema.json +5 -5
- package/infra/schemas/workspace.schema.json +9 -9
- package/infra/skills/{sb-author → w9r-author}/SKILL.md +6 -6
- package/infra/skills/{sb-handoff → w9r-handoff}/SKILL.md +8 -8
- package/infra/skills/{sb-implement → w9r-implement}/SKILL.md +12 -12
- package/infra/skills/{sb-pr → w9r-pr}/SKILL.md +12 -12
- package/infra/skills/{sb-research → w9r-research}/SKILL.md +10 -10
- package/infra/skills/{sb-review → w9r-review}/SKILL.md +12 -12
- package/infra/skills/{sb-test → w9r-test}/SKILL.md +9 -9
- package/infra/templates/Caddyfile.njk +5 -6
- package/infra/templates/docker-compose.feature.yml.njk +8 -9
- package/infra/templates/env.njk +7 -6
- package/infra/templates/supergraph-config.yml.njk +4 -4
- package/package.json +4 -6
- package/w9r +1 -1
- package/werkmeister +21 -29
- package/dist/sandbox-workspaces.vsix +0 -0
- package/sandbox +0 -4
package/CONVENTIONS.md
CHANGED
|
@@ -14,7 +14,7 @@ by other tooling, so they are not free to drift.
|
|
|
14
14
|
| `src/lib/<name>.ts` | shared library modules |
|
|
15
15
|
|
|
16
16
|
Runtime data dirs live alongside the source: `infra/`, `bin/`.
|
|
17
|
-
Path resolution: package root = `WERKMEISTER_ROOT` / `
|
|
17
|
+
Path resolution: package root = `WERKMEISTER_ROOT` / `WERKMEISTER_ROOT` env, else the first
|
|
18
18
|
ancestor holding `apps/cli` (`sandboxRoot()` / `infraRoot()` in
|
|
19
19
|
`packages/werkmeister-core/src/config.ts`, re-exported by `src/lib/config.ts` as
|
|
20
20
|
`getSandboxRoot()` / `getInfraRoot()`).
|
|
@@ -43,7 +43,7 @@ ancestor holding `apps/cli` (`sandboxRoot()` / `infraRoot()` in
|
|
|
43
43
|
- ANSI colors come from `packages/werkmeister-core/src/colors.ts` — the single definition site.
|
|
44
44
|
- `console.error` for stderr, `console.log` for stdout.
|
|
45
45
|
- `process.exit(n)` for exit codes. Thrown errors reach `main`, which prints
|
|
46
|
-
`Error: <msg>` in red and exits 1; `
|
|
46
|
+
`Error: <msg>` in red and exits 1; `WERKMEISTER_DEBUG` re-raises with a stack.
|
|
47
47
|
- Interactive prompts use `node:readline/promises`, which makes the enclosing
|
|
48
48
|
function `async` — command `run()` signatures are `async (args) => Promise<void>`.
|
|
49
49
|
- No new npm dependencies beyond: commander, nunjucks, yaml.
|
package/README.md
CHANGED
|
@@ -12,26 +12,26 @@ pnpm run build
|
|
|
12
12
|
./werkmeister --help
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
`./werkmeister` (alias `./w9r
|
|
16
|
-
(WERKMEISTER_NODE →
|
|
17
|
-
`dist/main.js`. `
|
|
15
|
+
`./werkmeister` (alias `./w9r`) resolves a node runtime
|
|
16
|
+
(WERKMEISTER_NODE → PATH → newest nvm) and execs
|
|
17
|
+
`dist/main.js`. `werkmeister hooks gate` bypasses the CLI import chain via
|
|
18
18
|
`dist/lib/gate.js` for a fast PreToolUse cold start.
|
|
19
19
|
|
|
20
20
|
## Tab completion
|
|
21
21
|
|
|
22
|
-
`
|
|
22
|
+
`werkmeister __complete` answers bash's `complete -C` protocol (COMP_LINE/COMP_POINT
|
|
23
23
|
in, candidates on stdout), so both shells share one code path and there is no
|
|
24
24
|
generated completion script to keep in sync — candidates come off the commander
|
|
25
25
|
program itself.
|
|
26
26
|
|
|
27
|
-
`
|
|
27
|
+
`werkmeister setup` installs it into `~/.zshrc` as a managed block (idempotent;
|
|
28
28
|
re-running replaces its own block and nothing else). To wire it up by hand, or
|
|
29
29
|
in bash, which setup does not touch:
|
|
30
30
|
|
|
31
31
|
```sh
|
|
32
32
|
autoload -Uz compinit && compinit # zsh only; skip if your rc runs it
|
|
33
33
|
autoload -Uz +X bashcompinit && bashcompinit
|
|
34
|
-
complete -C '
|
|
34
|
+
complete -C 'werkmeister __complete' werkmeister
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
Completes subcommand names, a command's long flags, and any positional as a
|
|
@@ -50,9 +50,9 @@ feature name (`infra` plus the workspaces under the workspaces root).
|
|
|
50
50
|
- CLI parsing is commander; templates in `infra/templates/*.njk` render through
|
|
51
51
|
nunjucks with a small compat layer (`{% do %}`, dict truthiness,
|
|
52
52
|
`map(attribute=…)`) so they stay shared verbatim with other consumers
|
|
53
|
-
- `
|
|
53
|
+
- `werkmeister mcp` runs the one MCP server over stdio. Its source is
|
|
54
54
|
`apps/werkmeister-mcp`, bundled into `dist/mcp.js` by `esbuild.mjs` so it ships in the npm
|
|
55
|
-
package. `
|
|
55
|
+
package. `werkmeister dashboard` runs the localhost workspaces dashboard from
|
|
56
56
|
`apps/werkmeister-dashboard`, which is checkout-only
|
|
57
57
|
- interactive prompts and process-spawn edges are async (`run()` is
|
|
58
58
|
`async` throughout); core logic stays synchronous
|
package/bin/generate-certs.sh
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# Generate the self-signed TLS certificate the
|
|
2
|
+
# Generate the self-signed TLS certificate the werkmeister ingress terminates.
|
|
3
3
|
#
|
|
4
|
-
# The hostnames are NOT hardcoded here. They come from the
|
|
4
|
+
# The hostnames are NOT hardcoded here. They come from the werkmeister ingress
|
|
5
5
|
# config (`ingress.local_domain` / `ingress.remote_domain` in
|
|
6
6
|
# ~/.werkmeister/config.yaml, crossed with the routed services in
|
|
7
|
-
# ~/.werkmeister/services.yaml) and are passed in by `
|
|
7
|
+
# ~/.werkmeister/services.yaml) and are passed in by `werkmeister setup` via --domain.
|
|
8
8
|
# That way the certificate SANs, the /etc/hosts entries and the Caddy site
|
|
9
9
|
# blocks all derive from one list instead of three hand-synced copies.
|
|
10
10
|
#
|
|
11
11
|
# Standalone use (no CLI): pass --domain yourself, or set WERKMEISTER_INGRESS_HOSTS
|
|
12
|
-
# to a comma/space-separated list. `
|
|
13
|
-
# WERKMEISTER_HOSTS_FILE overrides /etc/hosts (tests).
|
|
12
|
+
# to a comma/space-separated list. `werkmeister setup` is the normal entry point.
|
|
13
|
+
# WERKMEISTER_HOSTS_FILE overrides /etc/hosts (tests).
|
|
14
14
|
#
|
|
15
15
|
# Usage:
|
|
16
16
|
# generate-certs.sh [--domain HOST]... [--certs-dir DIR]
|
|
17
17
|
# [--no-trust] [--no-hosts] [--force] [--check]
|
|
18
18
|
#
|
|
19
19
|
# --domain HOST Hostname to cover (repeatable). Also seeds /etc/hosts.
|
|
20
|
-
# --certs-dir DIR Output directory [$
|
|
20
|
+
# --certs-dir DIR Output directory [$WERKMEISTER_CERTS_DIR, else ~/.docker/certs]
|
|
21
21
|
# --no-trust Skip adding the cert to the macOS System keychain (no sudo)
|
|
22
22
|
# --no-hosts Skip the /etc/hosts update (no sudo)
|
|
23
23
|
# --force Regenerate even if a certificate already exists
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
|
|
28
28
|
set -euo pipefail
|
|
29
29
|
|
|
30
|
-
CERTS_DIR="${WERKMEISTER_CERTS_DIR:-$
|
|
31
|
-
HOSTS_FILE="${WERKMEISTER_HOSTS_FILE
|
|
32
|
-
HOSTS_BEGIN="# BEGIN sandbox ingress"
|
|
33
|
-
HOSTS_END="# END sandbox ingress"
|
|
30
|
+
CERTS_DIR="${WERKMEISTER_CERTS_DIR:-$HOME/.docker/certs}"
|
|
31
|
+
HOSTS_FILE="${WERKMEISTER_HOSTS_FILE:-/etc/hosts}"
|
|
32
|
+
HOSTS_BEGIN="# BEGIN sandbox ingress" # name-check: ignore
|
|
33
|
+
HOSTS_END="# END sandbox ingress" # name-check: ignore
|
|
34
34
|
DO_TRUST=true
|
|
35
35
|
DO_HOSTS=true
|
|
36
36
|
FORCE=false
|
|
@@ -39,7 +39,7 @@ DOMAINS=()
|
|
|
39
39
|
|
|
40
40
|
# Seed from the env fallback (comma or whitespace separated) before parsing
|
|
41
41
|
# flags, so an explicit --domain adds to it rather than being overridden.
|
|
42
|
-
INGRESS_HOSTS="${WERKMEISTER_INGRESS_HOSTS
|
|
42
|
+
INGRESS_HOSTS="${WERKMEISTER_INGRESS_HOSTS:-}"
|
|
43
43
|
if [ -n "$INGRESS_HOSTS" ]; then
|
|
44
44
|
IFS=', ' read -r -a DOMAINS <<< "$INGRESS_HOSTS"
|
|
45
45
|
fi
|
|
@@ -207,7 +207,7 @@ if [ "$FORCE" != "skip_generate" ]; then
|
|
|
207
207
|
echo " Certificate: $CRT"
|
|
208
208
|
echo " Private Key: $KEY"
|
|
209
209
|
echo ""
|
|
210
|
-
echo "Note: Docker Compose mounts these into Caddy via \$
|
|
210
|
+
echo "Note: Docker Compose mounts these into Caddy via \$WERKMEISTER_CERTS_DIR."
|
|
211
211
|
|
|
212
212
|
# Trust the certificate on macOS.
|
|
213
213
|
if [ "$DO_TRUST" = true ] && [[ "$OSTYPE" == "darwin"* ]]; then
|
package/dist/NOTICE
CHANGED
|
@@ -5,7 +5,7 @@ This product includes software developed by Jay Boyer.
|
|
|
5
5
|
The werkmeister npm package bundles third-party packages into dist/*.js under
|
|
6
6
|
the MIT, ISC, BSD-2-Clause and BSD-3-Clause licences. Their names, versions and
|
|
7
7
|
licence texts are in dist/THIRD-PARTY-LICENSES.txt. The bundled VS Code
|
|
8
|
-
extension (dist/
|
|
8
|
+
extension (dist/werkmeister-workspaces.vsix) carries its own LICENSE, NOTICE and
|
|
9
9
|
THIRD-PARTY-LICENSES.txt. It also contains Apache-2.0, BSD-3-Clause, ISC, MIT
|
|
10
10
|
and Unlicense code. None of these packages carries an Apache NOTICE file.
|
|
11
11
|
|
package/dist/lib/agent_state.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
var
|
|
4
|
-
`);for(let s=
|
|
5
|
-
`)}return null}i(
|
|
6
|
-
`),
|
|
3
|
+
var P=Object.defineProperty;var i=(t,e)=>P(t,"name",{value:e,configurable:!0});import*as r from"node:fs";import*as d from"node:path";import*as g from"node:path";var S=".werkmeister";function p(t){return g.join(t,S)}i(p,"dotDir");import*as l from"node:fs";import*as u from"node:path";function y(t){let e=u.resolve(t);for(;;){if(l.existsSync(u.join(p(e),"workspace.yml")))return e;let n=u.dirname(e);if(n===e)return null;e=n}}i(y,"findRecordRoot");var R=new Set(["working","needs-you","done","idle"]),O=new Set(["AskUserQuestion","ExitPlanMode"]),_="mcp__ccd_turn__wrap_up",A=new Set(["permission_prompt","elicitation_dialog"]),x=i(t=>d.join(p(t),"agent-state.json"),"stateFile");function N(t){try{let e=JSON.parse(r.readFileSync(x(t),"utf8"));if(!R.has(e?.state)||typeof e.at!="string")return null;let n={state:e.state,at:e.at};return typeof e.question=="string"&&(n.question=e.question),e.via==="wrap_up"&&(n.via="wrap_up"),n}catch{return null}}i(N,"readAgentState");function v(t){return/\?[\s*_`'")\]]*$/.test(t)}i(v,"asksQuestion");function T(t){let e=t.trim().split(/\n\s*\n/);return e[e.length-1].trim().slice(0,200)}i(T,"questionOf");function D(t){let e=r.openSync(t,"r"),n;try{let s=r.fstatSync(e).size,a=Math.min(s,65536),c=Buffer.alloc(a);r.readSync(e,c,0,a,s-a),n=c.toString("utf8")}finally{r.closeSync(e)}let o=n.split(`
|
|
4
|
+
`);for(let s=o.length-1;s>=0;s--){let a;try{a=JSON.parse(o[s])}catch{continue}if(a.type!=="assistant")continue;let c=a.message?.content;if(typeof c=="string")return c;if(!Array.isArray(c))continue;let h=c.filter(f=>f?.type==="text"&&typeof f.text=="string");if(h.length)return h.map(f=>f.text).join(`
|
|
5
|
+
`)}return null}i(D,"lastAssistantText");function E(t,e){switch(t.hook_event_name){case"UserPromptSubmit":return{state:"working"};case"PostToolUse":return t.tool_name===_&&e?.via==="wrap_up"?null:{state:"working"};case"PreToolUse":{let n=String(t.tool_name??""),o=t.tool_input?.ask;if(n===_&&typeof o=="string"&&o.trim())return{state:"needs-you",question:o.trim(),via:"wrap_up"};if(!O.has(n))return{state:"working"};let s=t.tool_input?.questions?.[0]?.question;return{state:"needs-you",question:typeof s=="string"?s:"Approve the plan?"}}case"Notification":{let n=t.notification_type,o=String(t.message??"");return!(typeof n=="string"?A.has(n):!/waiting for your input/i.test(o))||e?.state==="needs-you"&&e.question?null:{state:"needs-you",question:o||void 0}}case"Stop":{let n=null;return typeof t.last_assistant_message=="string"?n=t.last_assistant_message:typeof t.transcript_path=="string"&&(n=D(t.transcript_path)),n&&v(n)?{state:"needs-you",question:T(n)}:e?.via==="wrap_up"?null:{state:"done"}}case"SessionEnd":return e?.state==="working"?{state:"idle"}:null;default:return null}}i(E,"nextState");var w="Workspace paused by the person from its card. End your turn now; it continues when they press Resume.";var $=i(t=>d.join(p(t),"paused.json"),"pausedPath"),q=i(t=>d.join(p(t),"resume-nudge.json"),"nudgePath");function U(t,e){let n=`${t}.${process.pid}.tmp`;r.writeFileSync(n,`${JSON.stringify(e)}
|
|
6
|
+
`),r.renameSync(n,t)}i(U,"writeAtomic");function b(t,e){if(!r.existsSync($(e)))return null;switch(t.hook_event_name){case"PreToolUse":return{continue:!1,stopReason:w,hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:w}};case"UserPromptSubmit":return{decision:"block",reason:"This workspace is paused. Press \u25B6 Resume on its card first."};default:return null}}i(b,"pauseGate");function j(t,e=new Date){let n=y(String(t.cwd||process.cwd()));if(!n)return null;let o=N(n),s=E(t,o);if(!s||o&&o.state===s.state&&o.question===s.question&&o.via===s.via)return null;let a={state:s.state,at:e.toISOString()};s.question&&(a.question=s.question),s.via&&(a.via=s.via);let c=x(n);return U(c,a),c}i(j,"record");function k(){try{let t=process.stdin.isTTY?"":r.readFileSync(0,"utf8"),e=t.trim()?JSON.parse(t):{};if(typeof e!="object"||e===null||Array.isArray(e))return;let n=y(String(e.cwd||process.cwd())),o=n?b(e,n):null;if(o){console.log(JSON.stringify(o));return}n&&e.hook_event_name==="UserPromptSubmit"&&r.rmSync(q(n),{force:!0}),j(e)}catch{}}i(k,"main");k();
|
|
7
7
|
//# sourceMappingURL=agent_state.js.map
|
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
|
|
4
|
-
`):null}
|
|
3
|
+
var P=Object.defineProperty;var a=(t,e)=>P(t,"name",{value:e,configurable:!0});import*as c from"node:fs";import*as o from"node:path";import*as $ from"node:path";var k=".werkmeister";function S(t){return $.join(t,k)}a(S,"dotDir");var j="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.",O="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 A(t){let e="",n=0,s=t.length;for(;n<s;){let u=t[n];if(n+=1,u==="*")e+=".*";else if(u==="?")e+=".";else if(u==="["){let r=n;for(r<s&&t[r]==="!"&&(r+=1),r<s&&t[r]==="]"&&(r+=1);r<s&&t[r]!=="]";)r+=1;if(r>=s)e+="\\[";else{let i=t.slice(n,r).replace(/\\/g,"\\\\");n=r+1,i.startsWith("!")?i="^"+i.slice(1):i.startsWith("^")&&(i="\\"+i),e+=`[${i}]`}}else e+=u.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return`^(?:${e})$`}a(A,"_translate");function R(t,e){return new RegExp(A(e),"s").test(t)}a(R,"fnmatch");function F(t){let e=o.resolve(t);for(;;){if(J(S(e)))return e;let n=o.dirname(e);if(n===e)return null;e=n}}a(F,"findWorkspaceRoot");function J(t){try{return c.statSync(t).isDirectory()}catch{return!1}}a(J,"_isDir");function E(t){try{return c.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 W(t){let e=o.join(S(t),"standards.json");if(!E(e))return null;let n;try{n=JSON.parse(c.readFileSync(e,"utf8"))}catch{return null}return d(n)?n:null}a(W,"loadManifest");function N(t,e){return o.join(S(t),".gate",`${e}.json`)}a(N,"_statePath");function C(t,e){let n=N(t,e);if(!E(n))return{};let s;try{s=JSON.parse(c.readFileSync(n,"utf8"))}catch{return null}return d(s)?s:null}a(C,"_loadState");function G(t,e,n){try{let s=N(t,e);return c.mkdirSync(o.dirname(s),{recursive:!0}),c.writeFileSync(s,JSON.stringify(n)),!0}catch{return!1}}a(G,"_saveState");function T(t){return[...t].sort()}a(T,"_sorted");function L(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(L,"_noteStatus");function X(t,e){let n=String(e.note??"");if(!/^[a-z]+$/.test(n))return!0;let s=e.status?String(e.status).toLowerCase():null,u=o.join(S(t),"notes"),r;try{r=c.readdirSync(u)}catch(l){return l.code!=="ENOENT"}let i=new RegExp(`^\\d{3}-${n}-.+\\.md$`);for(let l of r){if(!i.test(l))continue;let p;try{p=c.readFileSync(o.join(u,l),"utf8")}catch{return!0}let h=L(p);if(h===void 0)return!0;if(!(h==="superseded"||h==="graduated")&&(s===null||h===s))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 s=F(t);if(s===null)return null;let u=W(s);if(u===null)return null;let r=C(s,e);if(r===null)return null;let i=n?o.relative(s,n):"",l=u.phase_gate;if(d(l)&&i&&i!==".."&&!i.startsWith(".."+o.sep)&&!o.isAbsolute(i)&&!i.startsWith(k+o.sep)&&!X(s,l))return Y(l);let p=new Set(Array.isArray(r.delivered)?r.delivered:[]),h=!r.phase_entry_delivered,f=null,w=d(u.domains)?u.domains:{};for(let m of T(Object.keys(w))){let y=w[m];if(p.has(m)||!d(y))continue;if((Array.isArray(y.applies_to)?y.applies_to:[]).some(D=>R(i,String(D)))){f=m;break}}if(!h&&f===null)return null;let g=[];if(h&&g.push(O),f!==null){let m=w[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}.`),g.push(_)}g.push(j);let b={phase_entry_delivered:!0,delivered:T(f?new Set([...p,f]):p)};return G(s,e,b)?g.join(`
|
|
4
|
+
`):null}a(z,"decide");function x(){let t;try{let i=process.stdin.isTTY?"":c.readFileSync(0,"utf8"),l=i.trim()?JSON.parse(i):{};t=d(l)?l:{}}catch{t={}}let e=String(t.session_id||""),n=t.tool_input,s=String(d(n)&&n.file_path||""),u=String(t.cwd||process.cwd()),r;try{r=z(u,e,s)}catch{r=null}r&&console.log(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:r}}))}a(x,"main");x();
|
|
5
5
|
//# sourceMappingURL=gate.js.map
|
package/dist/lib/pr_guard.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
var m=Object.defineProperty;var
|
|
3
|
+
var m=Object.defineProperty;var s=(e,t)=>m(e,"name",{value:t,configurable:!0});import*as i from"node:fs";import*as n from"node:path";import*as l from"node:path";var a=".werkmeister";function p(e){return l.join(e,a)}s(p,"dotDir");function f(e){let t=n.resolve(e);for(;;){if(i.existsSync(n.join(p(t),"workspace.yml")))return t;let r=n.dirname(t);if(r===t)return null;t=r}}s(f,"findRecordRoot");function h(e){try{let t=i.readdirSync(n.join(e,"stages")).filter(o=>/^\d+_/.test(o)).sort(),r=t.find(o=>/^\d+_propose$/.test(o))??t.find(o=>/^\d+_ship$/.test(o))??t.at(-1);return r?`stages/${r}/output/`:"the last stage's output/"}catch{return`${n.basename(p(e))}/notes/`}}s(h,"prFileDirName");var R=/(?<!<)<<(?!<)-?\s*(['"]?)(\w+)\1([^\n]*)(?:\n(?:[\s\S]*?\n)?\t*\2(?=\n|$)|[\s\S]*$)/g,_=/'[^']*(?:'|$)|"(?:[^"\\]|\\[\s\S])*(?:"|$)/g,y=/(?:^|[;&|({\n`])\s*(?:(?:\w+=\S*|command|exec|env|then|do|else)\s+)*gh\s+pr\s+create\b/,S=/create_pull_request$/;function $(e){return y.test(e.replace(R,"$3").replace(_,"_"))}s($,"opensPr");function g(e){return["_shared/pr-rules.md",`${a}/pr-rules.md`].find(t=>i.existsSync(n.join(e,t)))??"docs/workspace-lifecycle.md in the werkmeister repo"}s(g,"prRulesPath");function w(e){let t=f(String(e.cwd||process.cwd()));if(!t)return null;let r=String(e.tool_name||""),o=String(e.tool_input?.command||"");if(!(r==="Bash"&&$(o)||S.test(r)))return null;let d=g(t);return`Inside workspace \`${n.basename(t)}\`, PRs open only through \`werkmeister pr open\`: it runs the pre-PR gate and records the URL. Write the PR file in \`${h(t)}\`, have the person set \`status: approved\`, then run \`werkmeister pr open\`. Rules: \`${d}\`.`}s(w,"decide");function u(){let e=null;try{let t=process.stdin.isTTY?"":i.readFileSync(0,"utf8"),r=t.trim()?JSON.parse(t):{};typeof r=="object"&&r!==null&&!Array.isArray(r)&&(e=w(r))}catch{e=null}e&&console.log(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:e}}))}s(u,"main");u();
|
|
4
4
|
//# sourceMappingURL=pr_guard.js.map
|