@workit-dev/pi 2.11.0 → 2.12.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/worker.js +1 -72
- package/dist/workit.js +92 -76
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -7405,6 +7405,7 @@ var workspaceConfigSchema = object({
|
|
|
7405
7405
|
releaseNotes: unknown().optional().describe("The release notes `workit release finish` publishes on the forge release: `auto` (default: the draft when there is one, else the notes built from the version's changelog section), `off` (no forge release) or `review` (finish refuses until `workit release notes approve`). A release track overrides it."),
|
|
7406
7406
|
trailers: boolean2().optional().describe("Whether commits get the `Workit-Session:` trailer (default true). With false, authorship lives in the ledger only."),
|
|
7407
7407
|
deleteBranch: boolean2().optional().describe("Whether `workit pr merge` deletes the head branch after a merge (default true); `--keep-branch` opts out for one merge."),
|
|
7408
|
+
cleanup: unknown().optional().describe("What happens when work finishes: `auto` (default) removes the delivered branch's clean Workit worktree and local branch, switches a clean checkout on it back to the trunk, and stops the processes registered inside them; `keep` removes and stops nothing. A value Workit does not know reads as `keep`."),
|
|
7408
7409
|
liveSessionGuard: boolean2().optional().describe("Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
|
|
7409
7410
|
fanout: object({
|
|
7410
7411
|
tierModels: unknown().optional().describe("The model per slice TIER (mundane, standard, hard), as one name or per host.")
|
|
@@ -9783,78 +9784,6 @@ var MUTATING_REMOTE = new Set([
|
|
|
9783
9784
|
"set-branches",
|
|
9784
9785
|
"prune"
|
|
9785
9786
|
]);
|
|
9786
|
-
var GIT_VERBS = {
|
|
9787
|
-
log: "@d@l|@d @l",
|
|
9788
|
-
show: "@d@l|@d @l",
|
|
9789
|
-
diff: "@d|@d cached staged merge-base no-index",
|
|
9790
|
-
"diff-tree": "@drtcm|@d root stdin no-commit-id",
|
|
9791
|
-
"diff-index": "@dm|@d cached merge-base",
|
|
9792
|
-
status: "sbu?zv|short branch porcelain? long untracked-files? ignored? ignore-submodules? show-stash ahead-behind no-ahead-behind renames no-renames find-renames? column? no-column null verbose",
|
|
9793
|
-
"rev-parse": "q|verify short? abbrev-ref? symbolic symbolic-full-name show-toplevel show-prefix git-dir git-common-dir absolute-git-dir is-inside-work-tree is-inside-git-dir is-bare-repository show-cdup quiet all branches? tags? remotes? since= until= default= path-format= sq-quote",
|
|
9794
|
-
"rev-list": "@l|@l count objects? left-only right-only",
|
|
9795
|
-
"ls-files": "cdmoiskuvtzfx:X:|cached deleted modified others ignored stage unmerged killed directory no-empty-directory exclude-standard exclude= exclude-from= full-name abbrev? error-unmatch with-tree= eol deduplicate format= recurse-submodules sparse",
|
|
9796
|
-
"ls-tree": "rdtlz|long name-only name-status object-only full-name full-tree abbrev? format=",
|
|
9797
|
-
"cat-file": "tsepz|batch? batch-check? batch-all-objects follow-symlinks unordered buffer allow-unknown-type mailmap use-mailmap",
|
|
9798
|
-
blame: "L:lstfnepwbcM?C?|porcelain line-porcelain incremental root show-stats show-name show-number show-email abbrev= reverse= first-parent date= ignore-rev= ignore-revs-file= minimal contents=",
|
|
9799
|
-
describe: "|tags all long abbrev= contains always dirty? broken? match= exclude= first-parent exact-match candidates= debug",
|
|
9800
|
-
"merge-base": "a|all octopus independent is-ancestor fork-point",
|
|
9801
|
-
"for-each-ref": "|count= sort= format= color? shell perl python tcl points-at= merged? no-merged? contains? no-contains? ignore-case omit-empty exclude=",
|
|
9802
|
-
shortlog: "@lsnec|@l summary numbered email committer group= format=",
|
|
9803
|
-
"show-ref": "dsq|head verify heads tags branches hash? abbrev? quiet dereference exists",
|
|
9804
|
-
"name-rev": "|tags refs= exclude= all annotate-stdin name-only no-undefined always",
|
|
9805
|
-
grep: "aiIvnhHcEGFPlLzoWqwe:A:B:C:m:f:|cached untracked no-index no-exclude-standard exclude-standard recurse-submodules text ignore-case word-regexp invert-match line-number column count full-name extended-regexp basic-regexp fixed-strings perl-regexp files-with-matches name-only files-without-match null only-matching heading break show-function function-context max-depth= threads= and or not all-match quiet after-context= before-context= context= max-count= color? no-color",
|
|
9806
|
-
"format-patch": "@do:nNks|@d stdout output-directory= numbered no-numbered start-number= subject-prefix= root cover-letter thread? signoff attach? inline? suffix= base=",
|
|
9807
|
-
reflog: "@l|@l all expire= expire-unreachable= rewrite updateref stale-fix dry-run verbose",
|
|
9808
|
-
"count-objects": "vH|verbose human-readable",
|
|
9809
|
-
"check-ignore": "qvnz|quiet verbose stdin non-matching no-index",
|
|
9810
|
-
var: "l|",
|
|
9811
|
-
version: "|build-options",
|
|
9812
|
-
"ls-remote": "htbq|heads tags branches refs quiet exit-code get-url symref sort=",
|
|
9813
|
-
remote: "v|verbose",
|
|
9814
|
-
config: "lz|get get-all get-regexp list local name-only null type= default=",
|
|
9815
|
-
worktree: "fdqvzb:B:|force detach lock reason= orphan no-checkout checkout quiet track no-track guess-remote porcelain expire= verbose",
|
|
9816
|
-
branch: "dDmMcCfvraliu:|delete move copy force list all remotes verbose contains? merged? no-merged? points-at= show-current set-upstream-to= unset-upstream track? no-track sort= format= color? column? ignore-case create-reflog",
|
|
9817
|
-
tag: "lam:dfF:n?|list annotate message= file= delete force sort= format= contains? merged? no-merged? points-at= column? create-reflog ignore-case",
|
|
9818
|
-
init: "+qb:|quiet bare initial-branch= object-format= ref-format= shared? separate-git-dir=",
|
|
9819
|
-
add: "+AunNvf|all update intent-to-add force dry-run verbose ignore-errors ignore-removal no-all renormalize chmod= sparse",
|
|
9820
|
-
commit: "+m:aqsnF:C:ouv|message= all amend no-edit allow-empty allow-empty-message author= date= signoff no-verify quiet file= reuse-message= fixup= squash= only include dry-run no-gpg-sign untracked-files? cleanup= reset-author verbose",
|
|
9821
|
-
checkout: "+b:B:fqm|detach force orphan= quiet track? no-track merge ours theirs",
|
|
9822
|
-
switch: "+c:C:dfqm|create= force-create= detach discard-changes force orphan= quiet track? no-track merge",
|
|
9823
|
-
restore: "+s:SWq|source= staged worktree ours theirs merge quiet overlay no-overlay",
|
|
9824
|
-
reset: "+qN|soft mixed hard merge keep quiet no-refresh",
|
|
9825
|
-
rm: "+rfnq|cached force dry-run quiet ignore-unmatch",
|
|
9826
|
-
mv: "+fnkv|force dry-run verbose",
|
|
9827
|
-
merge: "+m:qvnX:|no-ff ff ff-only squash no-squash commit no-commit message= no-edit abort continue quit allow-unrelated-histories stat no-stat quiet verbose no-verify signoff strategy-option=",
|
|
9828
|
-
stash: "+m:ukqa|message= include-untracked keep-index quiet all index staged",
|
|
9829
|
-
apply: "+p:C:R3qv|check stat numstat summary index cached 3way reverse reject allow-empty exclude= include= verbose quiet whitespace= recount",
|
|
9830
|
-
am: "+skq3|signoff keep 3way quiet abort continue skip quit whitespace= reject",
|
|
9831
|
-
fetch: "+fqvptn|all depth= deepen= shallow-since= unshallow tags no-tags prune force quiet verbose dry-run update-shallow refmap=",
|
|
9832
|
-
clone: "+nqlsb:o:|bare no-checkout depth= branch= origin= single-branch no-single-branch no-tags quiet shared local no-local filter= separate-git-dir=",
|
|
9833
|
-
"cherry-pick": "+nm:sxX:|no-commit mainline= signoff abort continue skip quit allow-empty keep-redundant-commits ff strategy-option=",
|
|
9834
|
-
revert: "+nm:sX:|no-commit mainline= signoff abort continue skip quit strategy-option= no-edit",
|
|
9835
|
-
rebase: "+qvfnX:|onto= root abort continue skip quit keep-base no-ff force-rebase autosquash no-autosquash autostash no-autostash update-refs signoff quiet verbose stat no-stat committer-date-is-author-date reset-author-date rebase-merges? no-rebase-merges empty= strategy-option= apply merge",
|
|
9836
|
-
clean: "+dfnqxXe:|dry-run force quiet exclude=",
|
|
9837
|
-
bisect: "+|term-old= term-new= no-checkout first-parent"
|
|
9838
|
-
};
|
|
9839
|
-
var JUDGE_GIT = `a judge runs git ${Object.keys(GIT_VERBS).join(" ")} with the options each documents (no abbreviations), writing only in a scratch repo; no -c, no wrapper but timeout, nice, time, command, no env but PAGER=cat, GIT_PAGER=cat, GIT_OPTIONAL_LOCKS=0, LC_*, LANG, TZ; status outside scratch needs --no-optional-locks`;
|
|
9840
|
-
var JUDGE_VERBS = {
|
|
9841
|
-
check: true,
|
|
9842
|
-
dir: true,
|
|
9843
|
-
help: true,
|
|
9844
|
-
"test-audit": true,
|
|
9845
|
-
ledger: ["verdict", "list", "check", "ruling", "show"],
|
|
9846
|
-
finding: ["record", "list"],
|
|
9847
|
-
pr: ["status"],
|
|
9848
|
-
ci: ["wait", "logs"],
|
|
9849
|
-
fanout: ["status", "brief"],
|
|
9850
|
-
models: ["show"],
|
|
9851
|
-
lock: ["status"],
|
|
9852
|
-
lease: ["status"],
|
|
9853
|
-
grant: ["show"],
|
|
9854
|
-
task: ["show", "list"],
|
|
9855
|
-
doctor: ["--json"]
|
|
9856
|
-
};
|
|
9857
|
-
var JUDGE_JOB = Object.entries(JUDGE_VERBS).map(([verb, subs]) => `workit ${verb}${subs === true ? "" : ` ${subs.join("|")}`}`).join(", ");
|
|
9858
9787
|
|
|
9859
9788
|
// packages/workit-core/src/hooks/steering.ts
|
|
9860
9789
|
var ROLES = {
|
package/dist/workit.js
CHANGED
|
@@ -9166,6 +9166,7 @@ var workspaceConfigSchema = object({
|
|
|
9166
9166
|
releaseNotes: unknown().optional().describe("The release notes `workit release finish` publishes on the forge release: `auto` (default: the draft when there is one, else the notes built from the version's changelog section), `off` (no forge release) or `review` (finish refuses until `workit release notes approve`). A release track overrides it."),
|
|
9167
9167
|
trailers: boolean2().optional().describe("Whether commits get the `Workit-Session:` trailer (default true). With false, authorship lives in the ledger only."),
|
|
9168
9168
|
deleteBranch: boolean2().optional().describe("Whether `workit pr merge` deletes the head branch after a merge (default true); `--keep-branch` opts out for one merge."),
|
|
9169
|
+
cleanup: unknown().optional().describe("What happens when work finishes: `auto` (default) removes the delivered branch's clean Workit worktree and local branch, switches a clean checkout on it back to the trunk, and stops the processes registered inside them; `keep` removes and stops nothing. A value Workit does not know reads as `keep`."),
|
|
9169
9170
|
liveSessionGuard: boolean2().optional().describe("Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
|
|
9170
9171
|
fanout: object({
|
|
9171
9172
|
tierModels: unknown().optional().describe("The model per slice TIER (mundane, standard, hard), as one name or per host.")
|
|
@@ -26439,8 +26440,10 @@ var opaqueWrites = (input, scriptOf = (index) => input[index], fed) => {
|
|
|
26439
26440
|
return curlOutputs(args);
|
|
26440
26441
|
if (name === "perl")
|
|
26441
26442
|
return inline(/^-[a-zA-Z]*[eE]$/);
|
|
26443
|
+
if (name.startsWith("python") && args.some((arg, at) => arg === "-m" && args[at + 1] !== "json.tool"))
|
|
26444
|
+
return [".", ...args.flatMap(pathsIn)];
|
|
26442
26445
|
if (/^(?:python[\d.]*|node|bun|deno|ruby|php)$/.test(name))
|
|
26443
|
-
return inline(/^-[a-zA-Z]*[
|
|
26446
|
+
return inline(/^-[a-zA-Z]*[cep]$|^--(?:eval|print)$/);
|
|
26444
26447
|
return shellScript2(words) === null ? null : ["."];
|
|
26445
26448
|
};
|
|
26446
26449
|
var CURL_LONG = [
|
|
@@ -27173,7 +27176,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
27173
27176
|
shells.push(...read(named));
|
|
27174
27177
|
shells.push(...preloads.flatMap(read));
|
|
27175
27178
|
} else if (INTERPRETERS.test(verb)) {
|
|
27176
|
-
const code = args.findIndex((arg) => /^-[a-zA-Z]*[
|
|
27179
|
+
const code = args.findIndex((arg) => /^-[a-zA-Z]*[cep]$|^--(?:eval|print)$/.test(arg));
|
|
27177
27180
|
if (code >= 0)
|
|
27178
27181
|
others.push(...expansions(args[code + 1] ?? "", vars, loops));
|
|
27179
27182
|
others.push(...named === undefined ? [...segment.stdin ?? [], ...inputs.flatMap(read), ...piped] : read(named), ...preloads.flatMap(read));
|
|
@@ -29171,50 +29174,38 @@ var shown = (target) => {
|
|
|
29171
29174
|
const named = /^\.workit-(?:live-target$|runs-)/.test(path47.basename(target)) ? path47.dirname(target) : target;
|
|
29172
29175
|
return path47.sep === "\\" ? named.replaceAll("/", "\\") : named;
|
|
29173
29176
|
};
|
|
29174
|
-
var
|
|
29175
|
-
|
|
29176
|
-
|
|
29177
|
-
|
|
29178
|
-
|
|
29179
|
-
|
|
29180
|
-
|
|
29181
|
-
};
|
|
29182
|
-
var outsideDeny = (input, worktree, target) => {
|
|
29177
|
+
var runFrom = (dir, command) => `cd ${dir} && ${command.replace(/^\s*cd\s+\S+\s*(?:&&|;)\s*/, "")}`;
|
|
29178
|
+
var deny2 = (what, unblock) => ({
|
|
29179
|
+
kind: "deny",
|
|
29180
|
+
reason: `${what}.
|
|
29181
|
+
${unblock}`,
|
|
29182
|
+
unblock
|
|
29183
|
+
});
|
|
29184
|
+
var unboundDeny = (input, target) => deny2(`workit worktree confinement: implementer ${input.session.agentId} is not working in a Workit worktree yet, and ${shown(target)} is outside every one`, "Why: work only in your brief's worktree (`workit fanout worktree create <slice>`); with none, tell the lead.");
|
|
29185
|
+
var outsideDeny = (input, worktree, target, command) => {
|
|
29183
29186
|
const runner = runnerAt(target);
|
|
29184
|
-
|
|
29185
|
-
return {
|
|
29186
|
-
kind: "deny",
|
|
29187
|
-
reason: `workit worktree confinement: implementer ${input.session.agentId} is bound to the worktree ${worktree}, and ${runner === null ? `${shown(target)} is` : `\`${runner}\` runs in ${shown(target)},`} outside it. ${unblock}`,
|
|
29188
|
-
unblock
|
|
29189
|
-
};
|
|
29190
|
-
};
|
|
29191
|
-
var unknownDirDeny = (input, worktree) => {
|
|
29192
|
-
const wt = worktree ?? "<worktree>";
|
|
29193
|
-
const unblock = `Workit cannot resolve \`cd -\`, \`cd "$X"\` or \`popd\`: write by absolute path, \`git -C ${wt}\` or \`workit <verb> --cwd ${wt}\`.`;
|
|
29194
|
-
return {
|
|
29195
|
-
kind: "deny",
|
|
29196
|
-
reason: `workit worktree confinement: implementer ${input.session.agentId} writes after an unknown directory change. ${unblock}`,
|
|
29197
|
-
unblock
|
|
29198
|
-
};
|
|
29187
|
+
return deny2(`workit worktree confinement: implementer ${input.session.agentId} is bound to the worktree ${worktree}, and ${runner === null ? `${shown(target)} is` : `\`${runner}\` runs in ${shown(target)},`} outside it`, runner !== null && command ? `Retry as: ${runFrom(worktree, command)}` : `Why: edit only under ${worktree}, git one verb per call (\`workit git --cwd ${worktree} commit -m … -- <paths>\`); the rest is a follow-up.`);
|
|
29199
29188
|
};
|
|
29189
|
+
var unknownDirDeny = (input, worktree) => deny2(`workit worktree confinement: implementer ${input.session.agentId} writes after a directory change Workit cannot resolve (\`cd -\`, \`cd "$X"\`, \`popd\`)`, `Why: write by absolute path, \`git -C ${worktree ?? "<worktree>"}\` or \`workit <verb> --cwd\`.`);
|
|
29190
|
+
var refsOf = (targets) => [
|
|
29191
|
+
...new Set(targets.flatMap((target) => path47.relative(UNKNOWN_VAR, path47.resolve(target)).split(path47.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
|
|
29192
|
+
];
|
|
29200
29193
|
var literalForm = (command, refs) => {
|
|
29201
29194
|
let text = command;
|
|
29202
|
-
for (const ref of refs) {
|
|
29195
|
+
for (const ref of refs.filter((one) => /^[$`]/.test(one))) {
|
|
29203
29196
|
const placeholder = `<absolute path of ${ref}>`;
|
|
29204
29197
|
const name = /^\$(\w+)$/.exec(ref)?.[1];
|
|
29205
29198
|
text = name ? text.replace(new RegExp(`\\$\\{${name}[^}]*\\}|\\$${name}(?!\\w)`, "g"), placeholder) : text.replaceAll(ref, placeholder);
|
|
29206
29199
|
}
|
|
29207
29200
|
return text.length > 600 ? `${text.slice(0, 600)}…` : text;
|
|
29208
29201
|
};
|
|
29209
|
-
var unknownVarDeny = (input,
|
|
29210
|
-
const refs =
|
|
29211
|
-
...new Set(targets.flatMap((target) => path47.relative(UNKNOWN_VAR, path47.resolve(target)).split(path47.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
|
|
29212
|
-
];
|
|
29202
|
+
var unknownVarDeny = (input, targets, command) => {
|
|
29203
|
+
const refs = refsOf(targets);
|
|
29213
29204
|
let text = command ?? "";
|
|
29214
29205
|
const first = [];
|
|
29215
29206
|
const named = refs.map((ref) => {
|
|
29216
29207
|
const name = /^\$(\w+)$/.exec(ref)?.[1];
|
|
29217
|
-
const set = name ? new RegExp(`(^|[\\s;&|(])${name}=("?)(\\$\\([^()]*\\)|\`[^\`]*\`)\\2[ \\t]*(?:&&|;|\\n)
|
|
29208
|
+
const set = name ? new RegExp(`(^|[\\s;&|(])${name}=("?)(\\$\\([^()]*\\)|\`[^\`]*\`)\\2[ \\t]*(?:&&|;|\\n|$)[ \\t]*`).exec(text) : null;
|
|
29218
29209
|
const sub = set?.[3] ?? (/^(?:\$\(|`)/.test(ref) ? ref : null);
|
|
29219
29210
|
if (sub === null)
|
|
29220
29211
|
return ref;
|
|
@@ -29223,15 +29214,8 @@ var unknownVarDeny = (input, worktree, targets, command) => {
|
|
|
29223
29214
|
first.push(`Run \`${sub.slice(sub.startsWith("`") ? 1 : 2, -1).trim()}\` first, then`);
|
|
29224
29215
|
return sub === ref ? ref : `${ref} (set by \`${sub}\`)`;
|
|
29225
29216
|
});
|
|
29226
|
-
const
|
|
29227
|
-
|
|
29228
|
-
const retry = command === undefined || literal === command ? "" : ` ${first.length ? `${first.join(" ")} retry` : "Retry"} as: \`${literal}\`.`;
|
|
29229
|
-
const unblock = `Spell the path out instead of ${refs.join(", ")}: Workit follows only \`NAME=<literal>\`, \`$(mktemp …)\`, \`$(pwd)\`, \`$PWD\` after a literal \`cd\` and a \`for\` over literal words.${retry} Write under ${wt} or a temp dir.`;
|
|
29230
|
-
return {
|
|
29231
|
-
kind: "deny",
|
|
29232
|
-
reason: `workit worktree confinement: implementer ${input.session.agentId} writes to a path built from ${named.join(", ")}, which Workit cannot resolve, so it cannot tell whether the write stays in its worktree. ${unblock}`,
|
|
29233
|
-
unblock
|
|
29234
|
-
};
|
|
29217
|
+
const literal = literalForm(text, refs);
|
|
29218
|
+
return deny2(`workit worktree confinement: implementer ${input.session.agentId} writes to a path built from ${named.join(", ")}, which Workit cannot resolve`, command === undefined || literal === command ? `Why: spell the path out; Workit follows only \`NAME=<literal>\`, \`$(pwd)\` and literal \`for\` words.` : first.length ? `${first.join(" ")} retry as: \`${literal}\`` : `Retry as: ${literal}`);
|
|
29235
29219
|
};
|
|
29236
29220
|
function confineImplementer(input, targets, command) {
|
|
29237
29221
|
try {
|
|
@@ -29239,7 +29223,7 @@ function confineImplementer(input, targets, command) {
|
|
|
29239
29223
|
return NONE5;
|
|
29240
29224
|
const unresolved = targets.filter((target) => within(path47.resolve(target), UNKNOWN_VAR));
|
|
29241
29225
|
if (unresolved.length > 0)
|
|
29242
|
-
return unknownVarDeny(input,
|
|
29226
|
+
return unknownVarDeny(input, unresolved, command);
|
|
29243
29227
|
if (targets.some((target) => within(path47.resolve(target), UNKNOWN_DIR)))
|
|
29244
29228
|
return unknownDirDeny(input, boundWorktree(input));
|
|
29245
29229
|
const bindings = canonical5(bindingDir());
|
|
@@ -29259,7 +29243,7 @@ function confineImplementer(input, targets, command) {
|
|
|
29259
29243
|
}
|
|
29260
29244
|
const root = canonical5(worktree);
|
|
29261
29245
|
const outside = judged.find(({ real }) => !within(real, root) || within(real, bindings));
|
|
29262
|
-
return outside ? outsideDeny(input, worktree, outside.named) : NONE5;
|
|
29246
|
+
return outside ? outsideDeny(input, worktree, outside.named, command) : NONE5;
|
|
29263
29247
|
} catch {
|
|
29264
29248
|
return NONE5;
|
|
29265
29249
|
}
|
|
@@ -29324,14 +29308,7 @@ var leadOwnedWorkit = (args) => !args.includes("--help") && args.some((_, start)
|
|
|
29324
29308
|
const [verb, sub] = skipWorkitGlobals(args.slice(start)).rest;
|
|
29325
29309
|
return verb === "fanout" && /^(?:plan|worktree)$/.test(sub ?? "");
|
|
29326
29310
|
});
|
|
29327
|
-
var leadOwnedDeny = (input, command) => {
|
|
29328
|
-
const unblock = "Worktrees, branches other than your own, refs, tags, remotes, git config, the shared stash and the fan-out plan belong to the lead: report what you need changed as a follow-up instead.";
|
|
29329
|
-
return {
|
|
29330
|
-
kind: "deny",
|
|
29331
|
-
reason: `workit worktree confinement: implementer ${input.session.agentId} may not run \`${command.slice(0, 160)}\`. ${unblock}`,
|
|
29332
|
-
unblock
|
|
29333
|
-
};
|
|
29334
|
-
};
|
|
29311
|
+
var leadOwnedDeny = (input, command) => deny2(`workit worktree confinement: implementer ${input.session.agentId} may not run \`${command.slice(0, 160)}\``, "Why: worktrees, other branches, refs, remotes, git config, the stash and the fan-out plan belong to the lead: a follow-up.");
|
|
29335
29312
|
function confineImplementerShell(input, command, dialect = "posix") {
|
|
29336
29313
|
try {
|
|
29337
29314
|
if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
|
|
@@ -29341,6 +29318,9 @@ function confineImplementerShell(input, command, dialect = "posix") {
|
|
|
29341
29318
|
} catch {}
|
|
29342
29319
|
return confineImplementer(input, shellMutationTargets(input.cwd, command, dialect, true), command);
|
|
29343
29320
|
}
|
|
29321
|
+
var LITERAL_SET = /^\s*([A-Za-z_]\w*)=(['"]?)((?:[\w@%+=:./\\-]|(?<=[^\s:=])~)*)\2[ \t]*(?:;|&&|\n)\s*/;
|
|
29322
|
+
var SPELLED = /^(?:[A-Za-z]|wt|wd|dir|repo|root|base|sha|ref|branch|file|out|scratch|worktree|WT|WD|DIR|REPO|ROOT|BASE|SHA|REF|BRANCH|FILE|OUT|SCRATCH|WORKTREE)$/;
|
|
29323
|
+
var ENV_READ = /^(?:GIT_|LD_|DYLD_|NODE_|PYTHON|PERL|RUBY|BASH|EPOCH|(?:ENV|IFS|CDPATH|PS\d|PWD|OLDPWD|REPLY|OPTARG|OPTIND|MAPFILE|S?RANDOM|SECONDS|LINENO|E?UID|PPID|_|HOSTNAME|HISTCMD)$)/;
|
|
29344
29324
|
var SCRATCH = ".workit-scratch";
|
|
29345
29325
|
var SHELL_NAMES = /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/;
|
|
29346
29326
|
var INTERPRETERS2 = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php)$/;
|
|
@@ -29458,7 +29438,8 @@ var GIT_VERBS = {
|
|
|
29458
29438
|
var: "l|",
|
|
29459
29439
|
version: "|build-options",
|
|
29460
29440
|
"ls-remote": "htbq|heads tags branches refs quiet exit-code get-url symref sort=",
|
|
29461
|
-
remote: "v|verbose",
|
|
29441
|
+
remote: "v|verbose push all",
|
|
29442
|
+
"range-diff": "@d|@d creation-factor= no-dual-color left-only right-only",
|
|
29462
29443
|
config: "lz|get get-all get-regexp list local name-only null type= default=",
|
|
29463
29444
|
worktree: "fdqvzb:B:|force detach lock reason= orphan no-checkout checkout quiet track no-track guess-remote porcelain expire= verbose",
|
|
29464
29445
|
branch: "dDmMcCfvraliu:|delete move copy force list all remotes verbose contains? merged? no-merged? points-at= show-current set-upstream-to= unset-upstream track? no-track sort= format= color? column? ignore-case create-reflog",
|
|
@@ -29544,7 +29525,7 @@ var gitKind = (args, local = () => true) => {
|
|
|
29544
29525
|
case "worktree":
|
|
29545
29526
|
return first === "list" ? "read" : /^(?:add|remove)$/.test(first) ? "write" : null;
|
|
29546
29527
|
case "remote":
|
|
29547
|
-
return !first || first === "show" && named.length === 2 && local(second, true) ? "read" : null;
|
|
29528
|
+
return !first || first === "get-url" || first === "show" && named.length === 2 && local(second, true) ? "read" : null;
|
|
29548
29529
|
case "ls-remote":
|
|
29549
29530
|
return local(first || "origin", true) ? "read" : null;
|
|
29550
29531
|
case "bisect":
|
|
@@ -29561,7 +29542,6 @@ var gitKind = (args, local = () => true) => {
|
|
|
29561
29542
|
}
|
|
29562
29543
|
return GIT_VERBS[verb].startsWith("+") ? "write" : "read";
|
|
29563
29544
|
};
|
|
29564
|
-
var JUDGE_GIT = `a judge runs git ${Object.keys(GIT_VERBS).join(" ")} with the options each documents (no abbreviations), writing only in a scratch repo; no -c, no wrapper but timeout, nice, time, command, no env but PAGER=cat, GIT_PAGER=cat, GIT_OPTIONAL_LOCKS=0, LC_*, LANG, TZ; status outside scratch needs --no-optional-locks`;
|
|
29565
29545
|
var remoteIn = (dir, name, repo) => {
|
|
29566
29546
|
const shared = path47.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo, false)?.[1] : undefined;
|
|
29567
29547
|
if (!shared)
|
|
@@ -29604,14 +29584,12 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
|
|
|
29604
29584
|
why ??= `\`${word}\` is not allowed`;
|
|
29605
29585
|
let index = start < 0 ? words.length : start + 1;
|
|
29606
29586
|
let dir = "";
|
|
29607
|
-
let unlocked = lead.includes("GIT_OPTIONAL_LOCKS=0");
|
|
29608
29587
|
for (;!why && words[index]?.startsWith("-") && words[index] !== "--version"; index++) {
|
|
29609
29588
|
const word = words[index];
|
|
29610
29589
|
const flag = /^--(git-dir|work-tree)(?:=([\s\S]*))?$/.exec(word);
|
|
29611
29590
|
const value = flag?.[2] ?? (/^(?:-C|--git-dir|--work-tree)$/.test(word) ? words[++index] : "");
|
|
29612
29591
|
if (word === "-C")
|
|
29613
29592
|
dir = value;
|
|
29614
|
-
unlocked ||= word === "--no-optional-locks";
|
|
29615
29593
|
if (flag ? !literalIn(value, repo) : !/^(?:-C|-P|--no-pager|--no-optional-locks)$/.test(word))
|
|
29616
29594
|
why = `\`${word}\` is not allowed`;
|
|
29617
29595
|
}
|
|
@@ -29623,11 +29601,6 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
|
|
|
29623
29601
|
const fetches = args[0] === "fetch" && plainFetch(args.slice(1)) && home && (home.workit || commonDir(home.root) === repo) && !words.some((word) => /^--[gw]/.test(word));
|
|
29624
29602
|
if (!fetches && !gitKind(args, local))
|
|
29625
29603
|
why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
|
|
29626
|
-
else if (args[0] === "status" && !unlocked) {
|
|
29627
|
-
const dirs = path47.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo) : null;
|
|
29628
|
-
if (!dirs?.length || !dirs.every((gitDir) => inScratch(gitDir, repo)))
|
|
29629
|
-
why = "`git status` refreshes the index outside scratch: add --no-optional-locks";
|
|
29630
|
-
}
|
|
29631
29604
|
}
|
|
29632
29605
|
const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path47.basename(word)));
|
|
29633
29606
|
const scripts = [
|
|
@@ -29693,7 +29666,6 @@ var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : co
|
|
|
29693
29666
|
at++;
|
|
29694
29667
|
return [words.slice(at + 1)];
|
|
29695
29668
|
});
|
|
29696
|
-
var JUDGE_JOB = Object.entries(JUDGE_VERBS).map(([verb, subs]) => `workit ${verb}${subs === true ? "" : ` ${subs.join("|")}`}`).join(", ");
|
|
29697
29669
|
var judgeRefusal = (command, fed, depth = 0) => {
|
|
29698
29670
|
let moved = false;
|
|
29699
29671
|
for (const segment of segmentsOf(command)) {
|
|
@@ -29715,6 +29687,9 @@ var judgeRefusal = (command, fed, depth = 0) => {
|
|
|
29715
29687
|
moved = true;
|
|
29716
29688
|
if (name === "eval" || (name === "source" || name === ".") && FED.test(args[0] ?? ""))
|
|
29717
29689
|
return unseen;
|
|
29690
|
+
const set = words.find((word) => /^(?:NODE_OPTIONS|PYTHON(?:STARTUP|PATH|HOME)|PERL5(?:OPT|LIB)|RUBY(?:OPT|LIB)|LD_\w+|DYLD_\w+|REPLY|OPTARG|OPTIND|MAPFILE|READLINE_\w+|S?RANDOM|SECONDS|LINENO|E?UID|PPID|OLDPWD|_|HOSTNAME|HISTCMD|EPOCH\w*)=/.test(word));
|
|
29691
|
+
if (set)
|
|
29692
|
+
return `\`${set.slice(0, 80)}\` sets a loader or shell-set name`;
|
|
29718
29693
|
if (SHELL_NAMES.test(name)) {
|
|
29719
29694
|
let operand;
|
|
29720
29695
|
let stdin = false;
|
|
@@ -29761,7 +29736,7 @@ var judgeRefusal = (command, fed, depth = 0) => {
|
|
|
29761
29736
|
for (const args of workitCalls(command)) {
|
|
29762
29737
|
const call = judgeVerbRefused(args);
|
|
29763
29738
|
if (call)
|
|
29764
|
-
return `\`${call}\` is not a judge's job: a judge runs only
|
|
29739
|
+
return `\`${call}\` is not a judge's job: a judge runs only read-only workit verbs`;
|
|
29765
29740
|
}
|
|
29766
29741
|
return null;
|
|
29767
29742
|
};
|
|
@@ -29783,20 +29758,31 @@ var substitutingHeredoc = (command) => {
|
|
|
29783
29758
|
}
|
|
29784
29759
|
return false;
|
|
29785
29760
|
};
|
|
29786
|
-
var judgeDeny = (input, what, target) => {
|
|
29761
|
+
var judgeDeny = (input, what, target, retry) => {
|
|
29787
29762
|
const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
|
|
29788
29763
|
const root = checkoutOf2(input.cwd)?.root;
|
|
29789
29764
|
const candidate = target ? checkoutOf2(target)?.root : undefined;
|
|
29790
|
-
const
|
|
29791
|
-
const scratch = root ? `${path47.join(root, SCRATCH)}${
|
|
29792
|
-
const
|
|
29765
|
+
const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? path47.join(candidate, SCRATCH) : undefined;
|
|
29766
|
+
const scratch = root ? `${path47.join(root, SCRATCH)}${other ? ` or ${other}` : ""}` : `${SCRATCH}/ at the root of the checkout you judge`;
|
|
29767
|
+
const call = root ? retry?.((other ?? path47.join(root, SCRATCH)).replaceAll("\\", "/")) : null;
|
|
29768
|
+
const unblock = call ? `Retry as: ${call}` : "Why: write only there (mkdir -p it); a fix the candidate needs is a finding (`workit finding record`).";
|
|
29793
29769
|
return {
|
|
29794
29770
|
kind: "deny",
|
|
29795
|
-
reason: `workit scratch confinement: ${role} ${input.session.agentId} may write only in its scratch dir ${scratch}, and ${what}.
|
|
29771
|
+
reason: `workit scratch confinement: ${role} ${input.session.agentId} may write only in its scratch dir ${scratch}, and ${what}.
|
|
29772
|
+
${unblock}`,
|
|
29796
29773
|
unblock
|
|
29797
29774
|
};
|
|
29798
29775
|
};
|
|
29799
|
-
|
|
29776
|
+
var movedInto = (command, cwd, target, dir) => {
|
|
29777
|
+
for (const { words, redirects } of segmentsOf(command))
|
|
29778
|
+
for (const word of [...redirects, ...path47.basename(words[0] ?? "") === "tee" ? words : []])
|
|
29779
|
+
if (path47.resolve(cwd, word) === path47.resolve(cwd, target)) {
|
|
29780
|
+
const moved = command.replace(new RegExp(`((?:>>?\\|?|\\btee(?:\\s+-a)?)\\s*)(['"]?)${word.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}\\2(?![^\\s;&|)])`), (_, lead) => `${lead}${dir}/${path47.basename(word)}`);
|
|
29781
|
+
return moved === command ? null : moved;
|
|
29782
|
+
}
|
|
29783
|
+
return null;
|
|
29784
|
+
};
|
|
29785
|
+
function confineJudge(input, targets, placeholders = placeholdersOf(targets), command) {
|
|
29800
29786
|
try {
|
|
29801
29787
|
if (!input.session.agentId)
|
|
29802
29788
|
return NONE5;
|
|
@@ -29809,7 +29795,10 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
|
|
|
29809
29795
|
for (const target of targets) {
|
|
29810
29796
|
const resolved = path47.resolve(target);
|
|
29811
29797
|
if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
|
|
29812
|
-
return judgeDeny(input, "it writes to a path Workit cannot resolve
|
|
29798
|
+
return judgeDeny(input, "it writes to a path Workit cannot resolve", undefined, () => {
|
|
29799
|
+
const literal = command && literalForm(command, refsOf([target]));
|
|
29800
|
+
return literal === command ? null : literal;
|
|
29801
|
+
});
|
|
29813
29802
|
const real = canonical5(target);
|
|
29814
29803
|
const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path47.basename(target));
|
|
29815
29804
|
const gitDirs = runsGit ? gitDirsAt(path47.dirname(real), repo) : [];
|
|
@@ -29818,17 +29807,43 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
|
|
|
29818
29807
|
if (runsGit ? gitDirs.length > 0 ? gitDirs.every(scratch) : scratch(real) : scratch(real) && !inGitDir(real))
|
|
29819
29808
|
continue;
|
|
29820
29809
|
const runner = runnerAt(target);
|
|
29821
|
-
return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`, target);
|
|
29810
|
+
return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`, target, (dir) => !command || runsGit ? null : runner === null ? movedInto(command, input.cwd, target, dir) : runFrom(dir, command));
|
|
29822
29811
|
}
|
|
29823
29812
|
return NONE5;
|
|
29824
29813
|
} catch {
|
|
29825
29814
|
return NONE5;
|
|
29826
29815
|
}
|
|
29827
29816
|
}
|
|
29817
|
+
var spelledIn = (text, name, value) => text.replace(new RegExp(`\\$(?:${name}(?!\\w)|\\{${name}\\})`, "g"), () => value);
|
|
29818
|
+
var variableRefusal = (command) => {
|
|
29819
|
+
let rest = command;
|
|
29820
|
+
const sets = [];
|
|
29821
|
+
for (let set;set = LITERAL_SET.exec(rest); rest = rest.slice(set[0].length))
|
|
29822
|
+
sets.push([set[1], set[3]]);
|
|
29823
|
+
const loop = /^\s*for\s+(\w+)\s+in\s+([\w@%+=:./ \t-]*?)\s*[;\n]\s*do\s([\s\S]*?);?\s*done\s*$/.exec(rest);
|
|
29824
|
+
for (const name of [...sets.map(([one]) => one), ...loop ? [loop[1]] : []])
|
|
29825
|
+
if (new RegExp(`\\$(?:${name}(?!\\w)|\\{${name}(?![\\w}])|\\{${name}\\})(?![\\s/";&|)]|$)`).test(rest))
|
|
29826
|
+
return { why: `\`$${name}\` has a modifier, subscript or suffix Workit does not spell in` };
|
|
29827
|
+
const odd = [...sets.map(([one]) => one), ...loop ? [loop[1]] : []].find((name) => !SPELLED.test(name) || process.env[name] !== undefined || ENV_READ.test(name));
|
|
29828
|
+
const used = sets.filter(([name]) => name === odd || new RegExp(`\\$\\{?${name}(?!\\w)`).test(rest));
|
|
29829
|
+
if (used.length)
|
|
29830
|
+
return {
|
|
29831
|
+
why: odd ? `\`${odd}=\` sets a name the shell, zsh or git reads itself` : `\`$${used[0][0]}\` is a path from a variable, which Workit does not follow for a judge`,
|
|
29832
|
+
retry: used.reduce((text, [name, value]) => spelledIn(text, name, value), rest)
|
|
29833
|
+
};
|
|
29834
|
+
const items = loop?.[2].split(/\s+/).filter(Boolean) ?? [];
|
|
29835
|
+
return loop && (loop[1] === odd || new RegExp(`\\$\\{?${loop[1]}(?!\\w)`).test(loop[3])) ? {
|
|
29836
|
+
why: `\`$${loop[1]}\` is a loop variable, which Workit does not follow for a judge`,
|
|
29837
|
+
retry: items.length > 16 ? undefined : items.map((item) => spelledIn(loop[3].trim(), loop[1], item)).join("; ")
|
|
29838
|
+
} : null;
|
|
29839
|
+
};
|
|
29828
29840
|
function confineJudgeShell(input, command, dialect = "posix") {
|
|
29829
29841
|
try {
|
|
29830
29842
|
if (!input.session.agentId)
|
|
29831
29843
|
return NONE5;
|
|
29844
|
+
const variable = dialect === "posix" ? variableRefusal(command) : null;
|
|
29845
|
+
if (variable)
|
|
29846
|
+
return judgeDeny(input, variable.why, undefined, () => variable.retry);
|
|
29832
29847
|
const fed = [];
|
|
29833
29848
|
let refused;
|
|
29834
29849
|
try {
|
|
@@ -29840,8 +29855,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
|
|
|
29840
29855
|
const judged = checkoutOf2(input.cwd);
|
|
29841
29856
|
try {
|
|
29842
29857
|
const why = judgeGit(command, judged ? commonDir(judged.root) : null, /\b(?:cd|chdir|pushd|popd)\b/.test(command) ? null : input.cwd);
|
|
29843
|
-
|
|
29844
|
-
refused = `${why}: ${JUDGE_GIT}`;
|
|
29858
|
+
refused = why;
|
|
29845
29859
|
} catch {
|
|
29846
29860
|
refused = "Workit cannot read this command: split it into simpler ones";
|
|
29847
29861
|
}
|
|
@@ -29849,7 +29863,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
|
|
|
29849
29863
|
if (refused)
|
|
29850
29864
|
return judgeDeny(input, refused);
|
|
29851
29865
|
if (dialect === "posix" && substitutingHeredoc(command.replaceAll("\\\n", "")))
|
|
29852
|
-
return judgeDeny(input, "an unquoted heredoc runs the `$(…)` or backtick command in its body: quote the delimiter (<<'EOF')");
|
|
29866
|
+
return judgeDeny(input, "an unquoted heredoc runs the `$(…)` or backtick command in its body: quote the delimiter (<<'EOF')", undefined, () => command.replace(/<<(-?)[ \t]*(\w+)/g, "<<$1'$2'"));
|
|
29853
29867
|
let git = [];
|
|
29854
29868
|
try {
|
|
29855
29869
|
git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args) || gitKind(args) === "write" && !/^(?:init|clone)$/.test(args[0]) && !(args[0] === "fetch" && plainFetch(args.slice(1)))) ? [
|
|
@@ -29860,7 +29874,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
|
|
|
29860
29874
|
shellMutationTargets(input.cwd, command, dialect, true),
|
|
29861
29875
|
...fed.map((body) => shellMutationTargets(input.cwd, body, "posix", true))
|
|
29862
29876
|
];
|
|
29863
|
-
return confineJudge(input, [...lists.flat(), ...git], new Set([...git, ...lists.flatMap((list) => [...placeholdersOf(list)])]));
|
|
29877
|
+
return confineJudge(input, [...lists.flat(), ...git], new Set([...git, ...lists.flatMap((list) => [...placeholdersOf(list)])]), command);
|
|
29864
29878
|
} catch {
|
|
29865
29879
|
return NONE5;
|
|
29866
29880
|
}
|
|
@@ -30984,9 +30998,11 @@ var ytrackGate = (cwd, command, dialect, ask) => {
|
|
|
30984
30998
|
const run = calls.length ? ` Run ${calls.join(", then ")} instead, each as its own plain call: it asks the user first.` : "";
|
|
30985
30999
|
const user = bare.length ? ask ? ` For ${bare.join(", ")}, run it as its own plain call: the host asks the user.` : ` For ${bare.join(", ")}, the user decides: ask the user, and if they agree they run it in their own terminal.` : "";
|
|
30986
31000
|
const rerun = writes.some((write) => write.gap === NOT_PLAIN.gap) ? " To get the named workit youtrack call instead, rerun the ytrack call as one plain command, with no wrapper, loop, substitution or script around it." : "";
|
|
31001
|
+
const retry = writes.find((write) => write.workit)?.workit ?? (rerun ? writes.find((write) => write.gap === NOT_PLAIN.gap)?.command : undefined);
|
|
30987
31002
|
return {
|
|
30988
31003
|
kind: "deny",
|
|
30989
|
-
reason: `${why}${run}${user}${rerun}
|
|
31004
|
+
reason: `${why}${run}${user}${rerun}${retry ? `
|
|
31005
|
+
Retry as: ${retry}` : ""}`,
|
|
30990
31006
|
unblock: writes[0]?.workit ?? null
|
|
30991
31007
|
};
|
|
30992
31008
|
};
|