werkmeister 0.33.2 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/agent_state.js +4 -4
- package/dist/lib/pr_guard.js +1 -1
- package/dist/main.js +367 -366
- package/dist/mcp.js +334 -333
- package/dist/sandbox-workspaces.vsix +0 -0
- package/infra/compose/scripts/sandbox-install-startup.sh +8 -2
- package/package.json +2 -2
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=r.length-1;s>=0;s--){let a;try{a=JSON.parse(r[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
|
|
5
|
-
`)}return null}i(
|
|
6
|
-
`),o.renameSync(n,e)}i(
|
|
3
|
+
var R=Object.defineProperty;var i=(e,t)=>R(e,"name",{value:t,configurable:!0});import*as o from"node:fs";import*as m from"node:path";import*as _ from"node:fs";import*as l from"node:path";var y=[".werkmeister",".sandbox"];function p(e){let t=y.find(n=>_.existsSync(l.join(e,n)));return l.join(e,t??y[0])}i(p,"dotDir");import*as d from"node:fs";import*as u from"node:path";function S(e){let t=u.resolve(e);for(;;){if(d.existsSync(u.join(p(t),"workspace.yml")))return t;let n=u.dirname(t);if(n===t)return null;t=n}}i(S,"findRecordRoot");var b=new Set(["working","needs-you","done","idle"]),O=new Set(["AskUserQuestion","ExitPlanMode"]),x="mcp__ccd_turn__wrap_up",A=new Set(["permission_prompt","elicitation_dialog"]),k=i(e=>m.join(p(e),"agent-state.json"),"stateFile");function N(e){try{let t=JSON.parse(o.readFileSync(k(e),"utf8"));if(!b.has(t?.state)||typeof t.at!="string")return null;let n={state:t.state,at:t.at};return typeof t.question=="string"&&(n.question=t.question),t.via==="wrap_up"&&(n.via="wrap_up"),n}catch{return null}}i(N,"readAgentState");function v(e){return/\?[\s*_`'")\]]*$/.test(e)}i(v,"asksQuestion");function D(e){let t=e.trim().split(/\n\s*\n/);return t[t.length-1].trim().slice(0,200)}i(D,"questionOf");function T(e){let t=o.openSync(e,"r"),n;try{let s=o.fstatSync(t).size,a=Math.min(s,65536),c=Buffer.alloc(a);o.readSync(t,c,0,a,s-a),n=c.toString("utf8")}finally{o.closeSync(t)}let r=n.split(`
|
|
4
|
+
`);for(let s=r.length-1;s>=0;s--){let a;try{a=JSON.parse(r[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 g=c.filter(f=>f?.type==="text"&&typeof f.text=="string");if(g.length)return g.map(f=>f.text).join(`
|
|
5
|
+
`)}return null}i(T,"lastAssistantText");function $(e,t){switch(e.hook_event_name){case"UserPromptSubmit":return{state:"working"};case"PostToolUse":return e.tool_name===x&&t?.via==="wrap_up"?null:{state:"working"};case"PreToolUse":{let n=String(e.tool_name??""),r=e.tool_input?.ask;if(n===x&&typeof r=="string"&&r.trim())return{state:"needs-you",question:r.trim(),via:"wrap_up"};if(!O.has(n))return{state:"working"};let s=e.tool_input?.questions?.[0]?.question;return{state:"needs-you",question:typeof s=="string"?s:"Approve the plan?"}}case"Notification":{let n=e.notification_type,r=String(e.message??"");return!(typeof n=="string"?A.has(n):!/waiting for your input/i.test(r))||t?.state==="needs-you"&&t.question?null:{state:"needs-you",question:r||void 0}}case"Stop":{let n=null;return typeof e.last_assistant_message=="string"?n=e.last_assistant_message:typeof e.transcript_path=="string"&&(n=T(e.transcript_path)),n&&v(n)?{state:"needs-you",question:D(n)}:t?.via==="wrap_up"?null:{state:"done"}}case"SessionEnd":return t?.state==="working"?{state:"idle"}:null;default:return null}}i($,"nextState");var w="Workspace paused by the person from its card. End your turn now; it continues when they press Resume.";var E=i(e=>m.join(p(e),"paused.json"),"pausedPath"),q=i(e=>m.join(p(e),"resume-nudge.json"),"nudgePath");function U(e,t){let n=`${e}.${process.pid}.tmp`;o.writeFileSync(n,`${JSON.stringify(t)}
|
|
6
|
+
`),o.renameSync(n,e)}i(U,"writeAtomic");function j(e,t){if(!o.existsSync(E(t)))return null;switch(e.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(j,"pauseGate");function F(e,t=new Date){let n=S(String(e.cwd||process.cwd()));if(!n)return null;let r=N(n),s=$(e,r);if(!s||r&&r.state===s.state&&r.question===s.question&&r.via===s.via)return null;let a={state:s.state,at:t.toISOString()};s.question&&(a.question=s.question),s.via&&(a.via=s.via);let c=k(n);return U(c,a),c}i(F,"record");function P(){try{let e=process.stdin.isTTY?"":o.readFileSync(0,"utf8"),t=e.trim()?JSON.parse(e):{};if(typeof t!="object"||t===null||Array.isArray(t))return;let n=S(String(t.cwd||process.cwd())),r=n?j(t,n):null;if(r){console.log(JSON.stringify(r));return}n&&t.hook_event_name==="UserPromptSubmit"&&o.rmSync(q(n),{force:!0}),F(t)}catch{}}i(P,"main");P();
|
|
7
7
|
//# sourceMappingURL=agent_state.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
|
|
3
|
+
var m=Object.defineProperty;var r=(e,t)=>m(e,"name",{value:t,configurable:!0});import*as i from"node:fs";import*as o from"node:path";import*as u from"node:fs";import*as a from"node:path";var p=[".werkmeister",".sandbox"];function c(e){let t=p.find(n=>u.existsSync(a.join(e,n)));return a.join(e,t??p[0])}r(c,"dotDir");function h(e){let t=o.resolve(e);for(;;){if(i.existsSync(o.join(c(t),"workspace.yml")))return t;let n=o.dirname(t);if(n===t)return null;t=n}}r(h,"findRecordRoot");function x(e){try{let t=i.readdirSync(o.join(e,"stages")).filter(s=>/^\d+_/.test(s)).sort(),n=t.find(s=>/^\d+_propose$/.test(s))??t.find(s=>/^\d+_ship$/.test(s))??t.at(-1);return n?`stages/${n}/output/`:"the last stage's output/"}catch{return`${o.basename(c(e))}/notes/`}}r(x,"prFileDirName");var S=/(?<!<)<<(?!<)-?\s*(['"]?)(\w+)\1([^\n]*)(?:\n(?:[\s\S]*?\n)?\t*\2(?=\n|$)|[\s\S]*$)/g,R=/'[^']*(?:'|$)|"(?:[^"\\]|\\[\s\S])*(?:"|$)/g,$=/(?:^|[;&|({\n`])\s*(?:(?:\w+=\S*|command|exec|env|then|do|else)\s+)*gh\s+pr\s+create\b/,y=/create_pull_request$/;function _(e){return $.test(e.replace(S,"$3").replace(R,"_"))}r(_,"opensPr");function g(e){return["_shared/pr-rules.md",...p.map(t=>`${t}/pr-rules.md`)].find(t=>i.existsSync(o.join(e,t)))??"docs/workspace-lifecycle.md in the sandbox repo"}r(g,"prRulesPath");function D(e){let t=h(String(e.cwd||process.cwd()));if(!t)return null;let n=String(e.tool_name||""),s=String(e.tool_input?.command||"");if(!(n==="Bash"&&_(s)||y.test(n)))return null;let l=g(t);return`Inside sandbox workspace \`${o.basename(t)}\`, PRs open only through \`sandbox pr open\`: it runs the pre-PR gate and records the URL. Write the PR file in \`${x(t)}\`, have the person set \`status: approved\`, then run \`sandbox pr open\`. Rules: \`${l}\`.`}r(D,"decide");function f(){let e=null;try{let t=process.stdin.isTTY?"":i.readFileSync(0,"utf8"),n=t.trim()?JSON.parse(t):{};typeof n=="object"&&n!==null&&!Array.isArray(n)&&(e=D(n))}catch{e=null}e&&console.log(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:e}}))}r(f,"main");f();
|
|
4
4
|
//# sourceMappingURL=pr_guard.js.map
|