werkmeister 0.29.0 → 0.31.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 +3 -3
- package/README.md +2 -2
- package/dist/lib/agent_state.js +4 -4
- package/dist/main.js +517 -509
- package/dist/mcp.js +338 -337
- package/dist/sandbox-workspaces.vsix +0 -0
- package/infra/schemas/services-fragment.schema.json +1 -1
- package/package.json +2 -2
- package/werkmeister +2 -2
package/CONVENTIONS.md
CHANGED
|
@@ -16,7 +16,7 @@ by other tooling, so they are not free to drift.
|
|
|
16
16
|
Runtime data dirs live alongside the source: `infra/`, `bin/`.
|
|
17
17
|
Path resolution: package root = `WERKMEISTER_ROOT` / `SANDBOX_ROOT` env, else the first
|
|
18
18
|
ancestor holding `apps/cli` (`sandboxRoot()` / `infraRoot()` in
|
|
19
|
-
`packages/
|
|
19
|
+
`packages/werkmeister-core/src/config.ts`, re-exported by `src/lib/config.ts` as
|
|
20
20
|
`getSandboxRoot()` / `getInfraRoot()`).
|
|
21
21
|
|
|
22
22
|
## Language
|
|
@@ -34,13 +34,13 @@ ancestor holding `apps/cli` (`sandboxRoot()` / `infraRoot()` in
|
|
|
34
34
|
verbatim with other consumers, so the environment options in `generate.ts`
|
|
35
35
|
(autoescape, trim/lstrip) are load-bearing — see the notes there before
|
|
36
36
|
touching them.
|
|
37
|
-
- Subprocesses go through `packages/
|
|
37
|
+
- Subprocesses go through `packages/werkmeister-core/src/proc.ts` (spawnSync-based, synchronous):
|
|
38
38
|
- `run(cmd: string[], opts)` → `{ status, stdout, stderr }`; `check: true` throws `ProcError`.
|
|
39
39
|
- `capture(cmd)` → trimmed stdout, throws on failure.
|
|
40
40
|
- Streaming/inherit-stdio cases: pass `stdio: "inherit"`.
|
|
41
41
|
- `timeout` is in **seconds**, not milliseconds.
|
|
42
42
|
- Filesystem work uses the sync `node:fs` API (`readFileSync` etc.) plus `node:path`.
|
|
43
|
-
- ANSI colors come from `packages/
|
|
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
46
|
`Error: <msg>` in red and exits 1; `SANDBOX_DEBUG` re-raises with a stack.
|
package/README.md
CHANGED
|
@@ -51,8 +51,8 @@ feature name (`infra` plus the workspaces under the workspaces root).
|
|
|
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
|
- `sandbox mcp` runs the one MCP server over stdio. Its source is
|
|
54
|
-
`apps/mcp`, bundled into `dist/mcp.js` by `esbuild.mjs` so it ships in the npm
|
|
54
|
+
`apps/werkmeister-mcp`, bundled into `dist/mcp.js` by `esbuild.mjs` so it ships in the npm
|
|
55
55
|
package. `sandbox dashboard` runs the localhost workspaces dashboard from
|
|
56
|
-
`apps/
|
|
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/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 b=Object.defineProperty;var i=(e,t)=>b(e,"name",{value:t,configurable:!0});import*as
|
|
4
|
-
`);for(let s=
|
|
5
|
-
`)}return null}i(
|
|
6
|
-
`),
|
|
3
|
+
var b=Object.defineProperty;var i=(e,t)=>b(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 g(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(g,"findRecordRoot");var R=new Set(["working","needs-you","done","idle"]),A=new Set(["AskUserQuestion","ExitPlanMode"]),w="mcp__ccd_turn__wrap_up",N=new Set(["permission_prompt","elicitation_dialog"]),k=i(e=>m.join(p(e),"agent-state.json"),"stateFile");function O(e){try{let t=JSON.parse(o.readFileSync(k(e),"utf8"));if(!R.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(O,"readAgentState");function v(e){return/\?[\s*_`'")\]]*$/.test(e)}i(v,"asksQuestion");function T(e){let t=e.trim().split(/\n\s*\n/);return t[t.length-1].trim().slice(0,200)}i(T,"questionOf");function D(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 S=c.filter(f=>f?.type==="text"&&typeof f.text=="string");if(S.length)return S.map(f=>f.text).join(`
|
|
5
|
+
`)}return null}i(D,"lastAssistantText");function q(e,t){switch(e.hook_event_name){case"UserPromptSubmit":return{state:"working"};case"PostToolUse":return e.tool_name===w&&t?.via==="wrap_up"?null:{state:"working"};case"PreToolUse":{let n=String(e.tool_name??""),r=e.tool_input?.ask;if(n===w&&typeof r=="string"&&r.trim())return{state:"needs-you",question:r.trim(),via:"wrap_up"};if(!A.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"?N.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=D(e.transcript_path)),n&&v(n)?{state:"needs-you",question:T(n)}:t?.via==="wrap_up"?null:{state:"done"}}case"SessionEnd":return t?.state==="working"?{state:"idle"}:null;default:return null}}i(q,"nextState");var x="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"),$=i(e=>m.join(p(e),"resume-nudge.json"),"nudgePath");function j(e,t){let n=`${e}.${process.pid}.tmp`;o.writeFileSync(n,`${JSON.stringify(t)}
|
|
6
|
+
`),o.renameSync(n,e)}i(j,"writeAtomic");function U(e,t){if(!o.existsSync(E(t)))return null;switch(e.hook_event_name){case"PreToolUse":return{continue:!1,stopReason:x,hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:x}};case"UserPromptSubmit":return{decision:"block",reason:"This workspace is paused. Press \u25B6 Resume on its card first."};default:return null}}i(U,"pauseGate");function F(e,t=new Date){let n=g(String(e.cwd||process.cwd()));if(!n)return null;let r=O(n),s=q(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 j(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=g(String(t.cwd||process.cwd())),r=n?U(t,n):null;if(r){console.log(JSON.stringify(r));return}n&&t.hook_event_name==="UserPromptSubmit"&&o.rmSync($(n),{force:!0}),F(t)}catch{}}i(P,"main");P();
|
|
7
7
|
//# sourceMappingURL=agent_state.js.map
|