@srobroek/pi-worktrunk-merge-policy 1.0.0 → 1.0.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## worktrunk [1.0.1](https://github.com/srobroek/harness-plugins/compare/worktrunk--v1.0.0...worktrunk--v1.0.1) (2026-12-04)
2
+
3
+ ### Bug Fixes
4
+
5
+ * retire beads, worktrunk, trunk-dev and chezmoi gates (guidance only) ([#294](https://github.com/srobroek/harness-plugins/issues/294)) ([19eab97](https://github.com/srobroek/harness-plugins/commit/19eab97fee1e3eb8719838e4ba2a9a8d87c3ea9e))
6
+
1
7
  ## worktrunk [1.0.0](https://github.com/srobroek/harness-plugins/compare/worktrunk--v0.8.0...worktrunk--v1.0.0) (2026-12-04)
2
8
 
3
9
  ### ⚠ BREAKING CHANGES
package/README.md CHANGED
@@ -4,10 +4,10 @@
4
4
  omp-plugins `worktrunk` package. The omp isolation precheck is not ported: OpenCode has no native
5
5
  checkout-cloning isolation to refuse.
6
6
 
7
- It does three things:
7
+ It does three things, and refuses no shell call:
8
8
 
9
9
  - Registers `wt` as OpenCode's worktree strategy.
10
- - Gates `wt merge` shell calls so worker-to-epic merges keep their history.
10
+ - Raises the timeout of a short `wt switch` call so foreground hooks finish.
11
11
  - Ships two skills: `worktrunk-preflight` and `worktrunk-worktrees`.
12
12
 
13
13
  ## Install
@@ -29,7 +29,7 @@ claude plugin install worktrunk@harness-plugins
29
29
 
30
30
  ```
31
31
 
32
- Claude Code get the two skills only; the worktree strategy and merge gate are OpenCode code.
32
+ Claude Code get the two skills only; the worktree strategy and the `wt switch` timeout are OpenCode code.
33
33
 
34
34
  Needs `wt` and `git` on `PATH`. The preflight skill also needs `python3` (3.11 or later).
35
35
 
@@ -37,7 +37,7 @@ Needs `wt` and `git` on `PATH`. The preflight skill also needs `python3` (3.11 o
37
37
 
38
38
  | Option | Default | Effect |
39
39
  | --- | --- | --- |
40
- | `strategy` | `true` | `false` keeps OpenCode's bundled Git strategy. The merge gate and the skills stay on. |
40
+ | `strategy` | `true` | `false` keeps OpenCode's bundled Git strategy. The `wt switch` timeout and the skills stay on. |
41
41
 
42
42
  ```jsonc
43
43
  { "plugins": [{ "package": "...", "options": { "strategy": false } }] }
@@ -66,22 +66,11 @@ restores the previous one. Worktrees created before the plugin loaded keep their
66
66
  Removing a directory that no longer exists does nothing.
67
67
  - `list` reports the main worktree as `root` and every linked worktree as `worktree`.
68
68
 
69
- ## Merge policy gate
69
+ ## Merge guidance
70
70
 
71
- `execute.before` on the `shell` tool. It refuses:
72
-
73
- - `wt merge <target>` to a target other than the default branch without both `--no-squash` and
74
- `--no-ff`;
75
- - such a merge run from the target worktree, or from a detached `HEAD`, because `wt merge`
76
- merges the current branch;
77
- - a merge it cannot check: the default branch cannot be resolved, a probe times out, or the
78
- command is unterminated or runs a merge stored in a variable (`cmd="wt merge x"; eval "$cmd"`).
79
-
80
- `wt merge` with no target and merges to the default branch pass. The gate reads the default branch
81
- from `wt config state default-branch`, then `origin/HEAD`, in the call's directory: the shell
82
- `workdir` (resolved against the session directory), a leading `cd DIR &&`, or `wt -C DIR`. It
83
- finds merges behind wrappers (`env`, `sudo`, `timeout`, ...), in `$(...)`, backticks, process
84
- substitutions, `eval` and `sh -c`. `git merge` and `gh pr merge` are not gated.
71
+ The plugin no longer checks `wt merge` calls. The `worktrunk-worktrees` skill carries the rule as
72
+ guidance: a worker-to-epic merge passes `--no-squash --no-ff` to keep per-commit history, and
73
+ `wt merge` runs from the source worktree.
85
74
 
86
75
  ## Skills
87
76
 
@@ -99,19 +88,18 @@ resolve it as `../skills`. A skill with the same id that the host already has wi
99
88
 
100
89
  ## pi
101
90
 
102
- One extension, `pi/extensions/worktrunk.js` (source `pi-src/worktrunk.ts`). The merge gate and the
103
- `wt switch` timeout share `shared/merge-gate.ts` and `shared/switch-timeout.ts` with OpenCode.
91
+ One extension, `pi/extensions/worktrunk.js` (source `pi-src/worktrunk.ts`). The
92
+ `wt switch` timeout shares `shared/switch-timeout.ts` with OpenCode.
104
93
 
105
94
  | Feature | pi hook | Behavior |
106
95
  | --- | --- | --- |
107
- | Merge policy gate | `tool_call` on `bash` | Returns `{ block: true, reason }` for every merge the OpenCode gate refuses, checked in `ctx.cwd`. A handler error blocks the call, as pi treats a throwing `tool_call` handler. |
108
96
  | `wt switch` timeout | `tool_call` on `bash` | Raises a `timeout` shorter than 600 s to 600 s on a `wt switch` call, so foreground hooks are not killed mid-provisioning. pi's bash tool has no default timeout, so a call without one is left alone. |
109
97
  | `worktrunk_preflight` tool | `registerTool` | The checks of `preflight.py`, ported to TypeScript in `shared/preflight.ts` with the same ids, statuses and `{ ok, summary, checks }` JSON. Parameters: `path` (default: the session directory), `only` (check ids), `apply`. `apply` writes `.config/wt.toml` under pi's file-mutation queue. |
110
98
 
111
99
  The worktree strategy has no pi counterpart: pi has no worktree-strategy hook. pi-subagents allocates
112
100
  its child worktrees itself, running `wt -C <root> switch --create <branch> --base <commit> --no-cd
113
101
  --no-hooks --format json` with `spawnSync` from its extension process, not through the bash tool.
114
- pi fires `tool_call` only for tool calls, so neither gate sees that allocation.
102
+ pi fires `tool_call` only for tool calls, so the timeout hook does not see that allocation.
115
103
 
116
104
  pi-subagents' foreground children do not load the parent's extensions ([required host extensions](https://github.com/nicobailon/pi-subagents/blob/main/docs/agents.md#required-host-extensions)). List this extension for every child in `~/.pi/agent/settings.json`, with the path where pi installed this repository:
117
105
 
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  // Generated by scripts/build.ts. Do not edit.
3
3
  // plugins/worktrunk/pi-src/worktrunk.ts
4
- import { isAbsolute as isAbsolute2, resolve as resolve3 } from "path";
4
+ import { isAbsolute as isAbsolute2, resolve as resolve2 } from "path";
5
5
  import { StringEnum } from "@earendil-works/pi-ai";
6
6
  import {
7
7
  isToolCallEventType,
@@ -9,6 +9,11 @@ import {
9
9
  } from "@earendil-works/pi-coding-agent";
10
10
  import { Type } from "typebox";
11
11
 
12
+ // plugins/worktrunk/shared/preflight.ts
13
+ import { accessSync, constants as constants2, existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from "fs";
14
+ import { homedir } from "os";
15
+ import { dirname, isAbsolute, join, resolve } from "path";
16
+
12
17
  // lib/src/agent-tools.ts
13
18
  var MCP_TOOL_AGENTS = new Set([
14
19
  "adversarial-challenger",
@@ -1400,18 +1405,6 @@ var HAS_WELLFORMED = !!"".isWellFormed;
1400
1405
  // lib/src/patterns.ts
1401
1406
  var compiled = new Map;
1402
1407
  // lib/src/shell-command.ts
1403
- import { resolve } from "path";
1404
- var LITERAL_CD = /^\s*cd[ \t]+([A-Za-z0-9_@%+=:,./-]+)[ \t]*(?:&&|$)/;
1405
- var STARTS_WITH_CD = /^\s*(?:cd|pushd|popd)(?=\s|$|[;&|<>()])/;
1406
- function leadingCd(command, cwd) {
1407
- if (!STARTS_WITH_CD.test(command))
1408
- return { kind: "none" };
1409
- const match = LITERAL_CD.exec(command);
1410
- const dir = match?.[1];
1411
- if (match === null || dir === undefined || dir.startsWith("-") || dir.split("/").includes(".."))
1412
- return { kind: "rejected" };
1413
- return { kind: "dir", dir: resolve(cwd, dir), length: match[0].length };
1414
- }
1415
1408
  function scanShell(source, options = {}) {
1416
1409
  const items = [];
1417
1410
  const substitutions = [];
@@ -1940,296 +1933,7 @@ var WRITE_TOOLS = new Set(["edit", "write", "patch"]);
1940
1933
  var READ_TOOLS = new Set(["read"]);
1941
1934
  var SHELL_ALIASES = new Set(["bash", "Bash"]);
1942
1935
  var SHELL_EXECUTABLES = new Set(["bash", "sh", "zsh", "dash", "ksh"]);
1943
- // lib/src/safe-git.ts
1944
- import { devNull } from "os";
1945
- var SAFE_GIT_CONFIG = [
1946
- ["core.fsmonitor", "false"],
1947
- ["core.hooksPath", devNull]
1948
- ];
1949
- var SAFE_GIT_ARGS = [...SAFE_GIT_CONFIG.flatMap(([key, value]) => ["-c", `${key}=${value}`]), "--no-optional-locks"];
1950
- var HARDENED_GIT_CONFIG = [
1951
- ...SAFE_GIT_CONFIG,
1952
- ["core.attributesFile", devNull],
1953
- ["log.showSignature", "false"],
1954
- ["gpg.program", devNull],
1955
- ["gpg.ssh.program", devNull],
1956
- ["gpg.x509.program", devNull],
1957
- ["commit.gpgSign", "false"],
1958
- ["tag.gpgSign", "false"],
1959
- ["gpg.ssh.defaultKeyCommand", ""],
1960
- ["core.sshCommand", ""],
1961
- ["credential.helper", ""],
1962
- ["diff.external", ""]
1963
- ];
1964
- var EMPTY_TREE = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
1965
- var INHERITED_GIT_VARIABLES = [
1966
- "GIT_DIR",
1967
- "GIT_WORK_TREE",
1968
- "GIT_COMMON_DIR",
1969
- "GIT_INDEX_FILE",
1970
- "GIT_OBJECT_DIRECTORY",
1971
- "GIT_ALTERNATE_OBJECT_DIRECTORIES",
1972
- "GIT_PREFIX",
1973
- "GIT_NAMESPACE",
1974
- "GIT_REPLACE_REF_BASE",
1975
- "GIT_GRAFT_FILE",
1976
- "GIT_SHALLOW_FILE",
1977
- "GIT_CONFIG",
1978
- "GIT_EXEC_PATH",
1979
- "GIT_EXTERNAL_DIFF",
1980
- "GIT_PAGER",
1981
- "GIT_EDITOR",
1982
- "GIT_SEQUENCE_EDITOR",
1983
- "GIT_SSH",
1984
- "GIT_SSH_COMMAND",
1985
- "GIT_ASKPASS",
1986
- "GIT_PROXY_COMMAND",
1987
- "GIT_LITERAL_PATHSPECS",
1988
- "GIT_GLOB_PATHSPECS",
1989
- "GIT_NOGLOB_PATHSPECS",
1990
- "GIT_ICASE_PATHSPECS"
1991
- ];
1992
- var PROGRAM_VARIABLES = ["PAGER", "EDITOR", "VISUAL", "SSH_ASKPASS"];
1993
- function hardenedGitEnv(base) {
1994
- const env = {};
1995
- const dropped = new Set([...INHERITED_GIT_VARIABLES, ...PROGRAM_VARIABLES]);
1996
- for (const [key, value] of Object.entries(base)) {
1997
- if (value === undefined || dropped.has(key) || key.startsWith("GIT_TRACE"))
1998
- continue;
1999
- if (key === "GIT_CONFIG_PARAMETERS" || key === "GIT_CONFIG_COUNT" || /^GIT_CONFIG_(KEY|VALUE)_\d+$/.test(key))
2000
- continue;
2001
- env[key] = value;
2002
- }
2003
- let count = 0;
2004
- for (const [key, value] of HARDENED_GIT_CONFIG) {
2005
- env[`GIT_CONFIG_KEY_${count}`] = key;
2006
- env[`GIT_CONFIG_VALUE_${count}`] = value;
2007
- count += 1;
2008
- }
2009
- env.GIT_CONFIG_COUNT = String(count);
2010
- env.GIT_ATTR_SOURCE = EMPTY_TREE;
2011
- env.GIT_OPTIONAL_LOCKS = "0";
2012
- env.GIT_NO_LAZY_FETCH = "1";
2013
- env.GIT_ALLOW_PROTOCOL = "";
2014
- return env;
2015
- }
2016
-
2017
- // plugins/worktrunk/shared/merge-gate.ts
2018
- var MERGE_RETRY = "wt merge <target> --no-squash --no-ff";
2019
- var SOURCE_WORKTREE_RETRY = `${MERGE_RETRY} from the source worktree`;
2020
- var MERGE_POLICY_REFUSAL = `worker-to-epic merges must preserve history; retry with ${MERGE_RETRY}`;
2021
- var OPAQUE_DYNAMIC_MERGE_REFUSAL = "opaque dynamic shell body names a merge or land command; retry with a literal command";
2022
- var UNPARSEABLE_MERGE_REFUSAL = "the command has an unterminated quote, substitution or here-document and names wt merge, so the merge cannot be checked; retry with a complete literal command";
2023
- var UNKNOWN_DIRECTORY_MERGE_REFUSAL = "the command starts with a cd this gate cannot read (a quoted, expanded, `..` or redirected directory), so the repository the merge runs in is unknown; retry with `cd <literal path> && wt merge \u2026` or `wt -C <absolute path> merge \u2026`";
2024
- var SHELLS = new Set(["bash", "sh", "zsh", "dash", "ksh"]);
2025
- var GLOBAL_VALUE_OPTIONS = new Set(["-C", "--config", "--config-set"]);
2026
- var MERGE_VALUE_OPTIONS = new Set(["--stage", "--format", "--config", "--config-set", "-C"]);
2027
- var ASSIGNMENT2 = /^([A-Za-z_]\w*)=([\s\S]*)$/;
2028
- var MAX_DEPTH = 8;
2029
- function base(word) {
2030
- return word?.split("/").pop() ?? "";
2031
- }
2032
- function parseMergeInvocation(argv) {
2033
- const wtIndex = argv.findIndex((word) => base(word) === "wt");
2034
- if (wtIndex < 0)
2035
- return null;
2036
- let subIndex = wtIndex + 1;
2037
- let workdir = null;
2038
- while (subIndex < argv.length && argv[subIndex]?.startsWith("-")) {
2039
- const option = argv[subIndex] ?? "";
2040
- if (option === "-C")
2041
- workdir = argv[subIndex + 1] ?? null;
2042
- subIndex += GLOBAL_VALUE_OPTIONS.has(option) ? 2 : 1;
2043
- }
2044
- if (argv[subIndex] !== "merge")
2045
- return null;
2046
- if (argv.includes("--help") || argv.includes("-h"))
2047
- return null;
2048
- let target = null;
2049
- let noSquash = false;
2050
- let noFf = false;
2051
- for (let i = subIndex + 1;i < argv.length; i++) {
2052
- const arg = argv[i];
2053
- if (arg === "--no-squash") {
2054
- noSquash = true;
2055
- continue;
2056
- }
2057
- if (arg === "--no-ff") {
2058
- noFf = true;
2059
- continue;
2060
- }
2061
- if (arg === "--") {
2062
- target = argv[i + 1] ?? null;
2063
- break;
2064
- }
2065
- if (!arg)
2066
- continue;
2067
- if (arg.startsWith("-") || MERGE_VALUE_OPTIONS.has(argv[i - 1] ?? ""))
2068
- continue;
2069
- if (target === null)
2070
- target = arg;
2071
- }
2072
- return { target, noSquash, noFf, workdir };
2073
- }
2074
- function namesMergeCommand(source) {
2075
- for (const item of scanShell(source).items) {
2076
- if (item.kind !== "command")
2077
- continue;
2078
- const argv = commandWords(item.words.map((word) => word.value)).argv;
2079
- const executable = base(argv[0]);
2080
- if (executable === "wt" && parseMergeInvocation(argv) !== null)
2081
- return true;
2082
- if (executable === "git" && argv[1] === "merge")
2083
- return true;
2084
- if (executable === "gh" && argv[1] === "pr" && argv[2] === "merge")
2085
- return true;
2086
- }
2087
- return false;
2088
- }
2089
- function references(text, names) {
2090
- for (const match of text.matchAll(/\$(?:\{([A-Za-z_]\w*)[^}]*\}|([A-Za-z_]\w*))/g)) {
2091
- if (names.has(match[1] ?? match[2] ?? ""))
2092
- return true;
2093
- }
2094
- return false;
2095
- }
2096
- function collectCommands(source) {
2097
- const collected = { commands: [], executed: [], mergeVariables: new Set, complete: true };
2098
- const visit = (text, evaluated, depth) => {
2099
- if (depth > MAX_DEPTH) {
2100
- collected.complete = false;
2101
- return;
2102
- }
2103
- const scan = scanShell(text);
2104
- if (!scan.complete)
2105
- collected.complete = false;
2106
- for (const item of scan.items) {
2107
- if (item.kind !== "command")
2108
- continue;
2109
- const values = item.words.map((word) => word.value);
2110
- for (const value of values) {
2111
- const assignment = ASSIGNMENT2.exec(value);
2112
- if (!assignment)
2113
- break;
2114
- if (namesMergeCommand(assignment[2] ?? ""))
2115
- collected.mergeVariables.add(assignment[1] ?? "");
2116
- }
2117
- const argv = commandWords(values).argv;
2118
- if (argv.length === 0)
2119
- continue;
2120
- collected.commands.push(argv);
2121
- if (evaluated)
2122
- collected.executed.push(...argv);
2123
- else if (argv[0] !== undefined)
2124
- collected.executed.push(argv[0]);
2125
- const executable = base(argv[0]);
2126
- if (SHELLS.has(executable) && argv[1] === "-c" && argv[2])
2127
- visit(argv[2], true, depth + 1);
2128
- if (executable === "eval" && argv.length > 1)
2129
- visit(argv.slice(1).join(" "), true, depth + 1);
2130
- }
2131
- for (const substitution of scan.substitutions)
2132
- visit(substitution, evaluated, depth + 1);
2133
- };
2134
- visit(source, false, 0);
2135
- return collected;
2136
- }
2137
-
2138
- class ProbeTimeout extends Error {
2139
- }
2140
- var PROBE_BOUNDS = { timeoutMs: 8000, budgetMs: 25000 };
2141
- async function spawnProbe(binary, args, cwd, signal) {
2142
- let child;
2143
- try {
2144
- child = Bun.spawn([binary, ...args], {
2145
- cwd,
2146
- stdin: "ignore",
2147
- stdout: "pipe",
2148
- stderr: "ignore",
2149
- signal,
2150
- env: hardenedGitEnv(Bun.env)
2151
- });
2152
- } catch {
2153
- return null;
2154
- }
2155
- const run = await supervise(child, { signal });
2156
- if (signal.aborted || run.kind !== "exited")
2157
- throw new ProbeTimeout(`${binary} ${args.join(" ")}`);
2158
- return run.exitCode === 0 ? run.stdout.trim() : null;
2159
- }
2160
- var defaultProbes = {
2161
- git: (args, cwd, signal) => spawnProbe("git", args, cwd, signal),
2162
- wt: (args, cwd, signal) => spawnProbe("wt", args, cwd, signal)
2163
- };
2164
- async function decideMergePolicy(command, cwd, probes = defaultProbes, bounds = PROBE_BOUNDS) {
2165
- const budget = AbortSignal.timeout(bounds.budgetMs);
2166
- const probe = async (binary, args, dir) => {
2167
- const label = `${binary} ${args.join(" ")}`;
2168
- if (budget.aborted)
2169
- throw new ProbeTimeout(label);
2170
- const signal = AbortSignal.any([budget, AbortSignal.timeout(bounds.timeoutMs)]);
2171
- const aborted = new Promise((_, reject) => {
2172
- signal.addEventListener("abort", () => reject(new ProbeTimeout(label)), { once: true });
2173
- });
2174
- return Promise.race([probes[binary](args, dir, signal), aborted]);
2175
- };
2176
- try {
2177
- return await decideCommands(command, cwd, (args, dir) => probe("git", args, dir), (args, dir) => probe("wt", args, dir));
2178
- } catch (error) {
2179
- if (!(error instanceof ProbeTimeout))
2180
- throw error;
2181
- return {
2182
- block: true,
2183
- reason: `merge policy probe \`${error.message}\` timed out, so the merge cannot be checked; retry once git and wt answer promptly`
2184
- };
2185
- }
2186
- }
2187
- async function decideCommands(command, cwd, git, wt) {
2188
- const collected = collectCommands(command);
2189
- if (!collected.complete && /\bwt\b[\s\S]*\bmerge\b/.test(command))
2190
- return { block: true, reason: UNPARSEABLE_MERGE_REFUSAL };
2191
- if (collected.mergeVariables.size > 0 && collected.executed.some((word) => references(word, collected.mergeVariables)))
2192
- return { block: true, reason: OPAQUE_DYNAMIC_MERGE_REFUSAL };
2193
- const lead = leadingCd(command, cwd);
2194
- const shellCwd = lead.kind === "dir" ? lead.dir : lead.kind === "none" ? cwd : undefined;
2195
- for (const argv of collected.commands) {
2196
- const invocation = parseMergeInvocation(argv);
2197
- if (!invocation || invocation.target === null)
2198
- continue;
2199
- const target = invocation.target;
2200
- const repoCwd = invocation.workdir?.startsWith("/") ? invocation.workdir : shellCwd === undefined ? undefined : invocation.workdir ? `${shellCwd}/${invocation.workdir}` : shellCwd;
2201
- if (repoCwd === undefined)
2202
- return { block: true, reason: UNKNOWN_DIRECTORY_MERGE_REFUSAL };
2203
- const configured = await wt(["config", "state", "default-branch"], repoCwd);
2204
- const symbolic = configured || await git(["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], repoCwd);
2205
- const defaultBranch = symbolic?.replace(/^origin\//, "");
2206
- if (!defaultBranch)
2207
- return { block: true, reason: `cannot determine the repository default branch; ${MERGE_RETRY}` };
2208
- if (target === defaultBranch)
2209
- continue;
2210
- if (!invocation.noSquash || !invocation.noFf)
2211
- return { block: true, reason: MERGE_POLICY_REFUSAL.replace("<target>", target) };
2212
- const currentBranch = await git(["branch", "--show-current"], repoCwd);
2213
- if (currentBranch === null) {
2214
- return {
2215
- block: true,
2216
- reason: `\`git branch --show-current\` failed in ${repoCwd}, so the source branch cannot be checked; ${SOURCE_WORKTREE_RETRY.replace("<target>", target)}`
2217
- };
2218
- }
2219
- if (!currentBranch || currentBranch === target) {
2220
- return {
2221
- block: true,
2222
- reason: `worker-to-epic merges must run from the source worktree; retry with ${SOURCE_WORKTREE_RETRY.replace("<target>", target)}`
2223
- };
2224
- }
2225
- }
2226
- return;
2227
- }
2228
-
2229
1936
  // plugins/worktrunk/shared/preflight.ts
2230
- import { accessSync, constants as constants2, existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from "fs";
2231
- import { homedir } from "os";
2232
- import { dirname, isAbsolute, join, resolve as resolve2 } from "path";
2233
1937
  var APPROVALS_FIX = "wt config approvals add --yes";
2234
1938
  var MERGE_FIX = "wt merge --no-squash --no-ff";
2235
1939
  var WORKTREE_FIX = "wt switch -y --create --no-cd --base <base-commit> --format json <branch>";
@@ -2303,7 +2007,7 @@ function unavailable(command) {
2303
2007
  return command.returncode === null;
2304
2008
  }
2305
2009
  function resolvePath(path) {
2306
- const absolute = resolve2(path);
2010
+ const absolute = resolve(path);
2307
2011
  try {
2308
2012
  return realpathSync(absolute);
2309
2013
  } catch {
@@ -2408,7 +2112,7 @@ function parseJsonObject(text) {
2408
2112
  }
2409
2113
  return;
2410
2114
  }
2411
- var ASSIGNMENT3 = /^[A-Za-z_][A-Za-z0-9_]*=/;
2115
+ var ASSIGNMENT2 = /^[A-Za-z_][A-Za-z0-9_]*=/;
2412
2116
  function isPathToken(token) {
2413
2117
  return /^(?:\/|\.\/|\.\.\/|~\/)/.test(token) || token.includes("/") && !token.startsWith("-");
2414
2118
  }
@@ -2429,7 +2133,7 @@ function commandWords2(command) {
2429
2133
  if (tokens === undefined || tokens.length === 0)
2430
2134
  return;
2431
2135
  let index = 0;
2432
- while (index < tokens.length && ASSIGNMENT3.test(tokens[index]))
2136
+ while (index < tokens.length && ASSIGNMENT2.test(tokens[index]))
2433
2137
  index++;
2434
2138
  return index < tokens.length ? tokens.slice(index) : undefined;
2435
2139
  }
@@ -3052,13 +2756,13 @@ async function runPreflight(options, ctx, checks = CHECKS) {
3052
2756
 
3053
2757
  // plugins/worktrunk/shared/switch-timeout.ts
3054
2758
  var SWITCH_TIMEOUT_MS = 600000;
3055
- var GLOBAL_VALUE_OPTIONS2 = new Set(["-C", "--config", "--config-set"]);
2759
+ var GLOBAL_VALUE_OPTIONS = new Set(["-C", "--config", "--config-set"]);
3056
2760
  function isSwitch(argv) {
3057
2761
  if (argv[0]?.split("/").pop() !== "wt")
3058
2762
  return false;
3059
2763
  let index = 1;
3060
2764
  while (argv[index]?.startsWith("-"))
3061
- index += GLOBAL_VALUE_OPTIONS2.has(argv[index] ?? "") ? 2 : 1;
2765
+ index += GLOBAL_VALUE_OPTIONS.has(argv[index] ?? "") ? 2 : 1;
3062
2766
  return argv[index] === "switch" && !argv.includes("--help") && !argv.includes("-h");
3063
2767
  }
3064
2768
  function namesSwitchCommand(source) {
@@ -3074,17 +2778,11 @@ function switchTimeout(input) {
3074
2778
  return;
3075
2779
  return namesSwitchCommand(input.command) ? SWITCH_TIMEOUT_SECONDS : undefined;
3076
2780
  }
3077
- async function mergeGateBlock(event, cwd, probes) {
3078
- if (!isToolCallEventType("bash", event) || !/merge/.test(event.input.command))
3079
- return;
3080
- const decision = await decideMergePolicy(event.input.command, cwd, probes);
3081
- return decision === undefined ? undefined : { block: true, reason: decision.reason };
3082
- }
3083
2781
  function preflightDirectory(sessionDirectory, path) {
3084
2782
  const raw = path?.replace(/^@/, "");
3085
2783
  if (!raw)
3086
2784
  return sessionDirectory;
3087
- return isAbsolute2(raw) ? raw : resolve3(sessionDirectory, raw);
2785
+ return isAbsolute2(raw) ? raw : resolve2(sessionDirectory, raw);
3088
2786
  }
3089
2787
  var preflightParameters = Type.Object({
3090
2788
  path: Type.Optional(Type.String({ description: "Repository directory; defaults to the session directory" })),
@@ -3097,13 +2795,13 @@ var preflightParameters = Type.Object({
3097
2795
  });
3098
2796
  function createExtension(overrides = {}) {
3099
2797
  return (pi) => {
3100
- pi.on("tool_call", async (event, ctx) => {
2798
+ pi.on("tool_call", async (event) => {
3101
2799
  if (!isToolCallEventType("bash", event))
3102
2800
  return;
3103
2801
  const longer = switchTimeout(event.input);
3104
2802
  if (longer !== undefined)
3105
2803
  event.input.timeout = longer;
3106
- return mergeGateBlock(event, ctx.cwd, overrides.probes);
2804
+ return;
3107
2805
  });
3108
2806
  pi.registerTool({
3109
2807
  name: "worktrunk_preflight",
@@ -3131,7 +2829,6 @@ export {
3131
2829
  SWITCH_TIMEOUT_SECONDS,
3132
2830
  createExtension,
3133
2831
  worktrunk_default as default,
3134
- mergeGateBlock,
3135
2832
  preflightDirectory,
3136
2833
  switchTimeout
3137
2834
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srobroek/pi-worktrunk-merge-policy",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Worktrunk (wt) skills: work in linked worktrees and run deterministic preflight checks before an agent run or merge.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -38,8 +38,8 @@ Python). If an immediate test, typecheck, or dev server fails with missing-modul
38
38
  ## Merging
39
39
 
40
40
  `wt merge <target>` merges the current branch, so run it from the source worktree. A worker-to-epic merge MUST pass
41
- `--no-squash --no-ff` to keep per-commit history; an epic-to-default merge may be plain or squashing. This plugin
42
- blocks shell calls that break either rule.
41
+ `--no-squash --no-ff` to keep per-commit history; an epic-to-default merge may be plain or squashing. This is guidance: nothing
42
+ refuses a merge that breaks either rule, so check the target and flags before you run it.
43
43
 
44
44
  ## Ledger and the canonical checkout
45
45