@workit-dev/pi 1.1.8 → 1.2.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/dist/worker.js +13 -0
- package/dist/workit.js +319 -25
- package/package.json +1 -1
- package/skills/workit-implement/SKILL.md +9 -10
package/dist/worker.js
CHANGED
|
@@ -9689,6 +9689,19 @@ var MUTATING_REMOTE = new Set([
|
|
|
9689
9689
|
"set-branches",
|
|
9690
9690
|
"prune"
|
|
9691
9691
|
]);
|
|
9692
|
+
var JUDGE_VERBS = {
|
|
9693
|
+
check: true,
|
|
9694
|
+
dir: true,
|
|
9695
|
+
help: true,
|
|
9696
|
+
"test-audit": true,
|
|
9697
|
+
ledger: ["verdict", "finding", "list", "check", "ruling"],
|
|
9698
|
+
pr: ["status"],
|
|
9699
|
+
ci: ["wait", "logs"],
|
|
9700
|
+
fanout: ["status", "brief"],
|
|
9701
|
+
models: ["show"],
|
|
9702
|
+
lock: ["status"]
|
|
9703
|
+
};
|
|
9704
|
+
var JUDGE_JOB = Object.entries(JUDGE_VERBS).map(([verb, subs]) => `workit ${verb}${subs === true ? "" : ` ${subs.join("|")}`}`).join(", ");
|
|
9692
9705
|
|
|
9693
9706
|
// packages/workit-core/src/hooks/steering.ts
|
|
9694
9707
|
var ROLES = {
|
package/dist/workit.js
CHANGED
|
@@ -25450,7 +25450,7 @@ var shellScript2 = (words) => {
|
|
|
25450
25450
|
return null;
|
|
25451
25451
|
for (let index = 1;index < words.length; index++) {
|
|
25452
25452
|
const word = words[index];
|
|
25453
|
-
if (/^-[a-z]*c
|
|
25453
|
+
if (/^-[a-z]*c[a-z]*$/.test(word))
|
|
25454
25454
|
return words[index + 1] ?? null;
|
|
25455
25455
|
if (/^[-+][oO]$/.test(word))
|
|
25456
25456
|
index++;
|
|
@@ -25481,8 +25481,16 @@ var opaqueWrites = (input, scriptOf = (index) => input[index]) => {
|
|
|
25481
25481
|
const files = operands(args);
|
|
25482
25482
|
const has = (pattern) => args.some((arg) => pattern.test(arg));
|
|
25483
25483
|
const listed = (named) => named.length ? named : ["."];
|
|
25484
|
-
if (name === "unlink" || name === "shred")
|
|
25484
|
+
if (name === "unlink" || name === "shred" || name === "mkfifo")
|
|
25485
25485
|
return listed(files);
|
|
25486
|
+
if (name === "wget")
|
|
25487
|
+
return wgetOutputs(args);
|
|
25488
|
+
if (name === "tar")
|
|
25489
|
+
return tarOutputs(args);
|
|
25490
|
+
if (name === "unzip")
|
|
25491
|
+
return has(/^-[a-zA-Z]*[lptvzZ]/) ? null : listed(args.flatMap((arg, at) => arg.startsWith("-d") ? [arg.slice(2) || args[at + 1] || "."] : []));
|
|
25492
|
+
if (name === "git")
|
|
25493
|
+
return gitOutputs(args);
|
|
25486
25494
|
if (/^(?:chmod|chown|chgrp|chattr)$/.test(name))
|
|
25487
25495
|
return listed(has(/^--reference/) ? files : files.slice(1));
|
|
25488
25496
|
if (name === "rsync") {
|
|
@@ -25602,6 +25610,85 @@ var curlOutputs = (args) => {
|
|
|
25602
25610
|
files.push(...dirs.length ? dirs : ["."]);
|
|
25603
25611
|
return files.length > 0 ? files : null;
|
|
25604
25612
|
};
|
|
25613
|
+
var valueOf = (args, option) => {
|
|
25614
|
+
const at = args.findIndex((arg) => option.test(arg));
|
|
25615
|
+
return at < 0 ? undefined : option.exec(args[at])?.[1] || args[at + 1];
|
|
25616
|
+
};
|
|
25617
|
+
var wgetOutputs = (args) => {
|
|
25618
|
+
const named = valueOf(args, /^(?:-[a-zA-Z]*O|--output-document=?)(.*)$/s);
|
|
25619
|
+
const logs = [/^-[a-zA-Z]*[oa](.*)$/s, /^--(?:output-file|append-output)=?(.*)$/s].flatMap((option) => valueOf(args, option) ?? []);
|
|
25620
|
+
if (named === undefined)
|
|
25621
|
+
return [...logs, valueOf(args, /^(?:-[a-zA-Z]*P|--directory-prefix=?)(.*)$/s) ?? "."];
|
|
25622
|
+
return named === "-" ? logs : [...logs, named];
|
|
25623
|
+
};
|
|
25624
|
+
var tarOutputs = (args) => {
|
|
25625
|
+
const letters = args.filter((arg, at) => at === 0 && !arg.startsWith("-") || /^-[a-zA-Z]+$/.test(arg)).join("").replaceAll("C", "");
|
|
25626
|
+
const long = (pattern) => args.some((arg) => pattern.test(arg));
|
|
25627
|
+
const extract = /x/.test(letters) || long(/^--(?:extract|get)$/);
|
|
25628
|
+
const creates = /[cruA]/.test(letters) || long(/^--(?:create|append|update|concatenate|delete)$/);
|
|
25629
|
+
if (!extract && !creates)
|
|
25630
|
+
return null;
|
|
25631
|
+
const files = [];
|
|
25632
|
+
if (extract) {
|
|
25633
|
+
const dirs = args.flatMap((arg, at) => /^-C|^--directory(?:=|$)/.test(arg) ? [arg.replace(/^-C|^--directory=?/, "") || args[at + 1] || "."] : []);
|
|
25634
|
+
files.push(...dirs.length ? dirs : ["."]);
|
|
25635
|
+
}
|
|
25636
|
+
const old = args[0] !== undefined && !args[0].startsWith("-") && args[0].includes("f");
|
|
25637
|
+
const archive = old ? args[1] : valueOf(args, /^(?:-[a-zA-Z]*f|--file=?)(.*)$/s);
|
|
25638
|
+
if (creates && archive !== undefined && archive !== "-")
|
|
25639
|
+
files.push(archive);
|
|
25640
|
+
return files;
|
|
25641
|
+
};
|
|
25642
|
+
var CONFIG_READ = /^(?:--get(?:-all|-regexp|-urlmatch)?|--list|-l|get|list)$/;
|
|
25643
|
+
var CONFIG_WRITE = /^(?:--(?:unset(?:-all)?|add|replace-all|rename-section|remove-section|edit)|-e|set|unset|rename-section|remove-section|edit)$/;
|
|
25644
|
+
var CONFIG_VALUE = /^(?:--file|-f|--blob|--type|--default|--comment)$/;
|
|
25645
|
+
var configWrites = (rest) => {
|
|
25646
|
+
if (rest.some((arg) => CONFIG_READ.test(arg)))
|
|
25647
|
+
return false;
|
|
25648
|
+
if (rest.some((arg) => CONFIG_WRITE.test(arg)))
|
|
25649
|
+
return true;
|
|
25650
|
+
let named = 0;
|
|
25651
|
+
for (let index = 0;index < rest.length; index++)
|
|
25652
|
+
if (CONFIG_VALUE.test(rest[index]))
|
|
25653
|
+
index++;
|
|
25654
|
+
else if (!rest[index].startsWith("-"))
|
|
25655
|
+
named++;
|
|
25656
|
+
return named > 1;
|
|
25657
|
+
};
|
|
25658
|
+
var GIT_VALUE = /^(?:-[Ccbouj]|--(?:git-dir|work-tree|namespace|config-env|branch|origin|config|depth|reference(?:-if-able)?|template|separate-git-dir|upload-pack|jobs|filter|initial-branch|object-format))$/;
|
|
25659
|
+
var gitOutputs = (args) => {
|
|
25660
|
+
let at = 0;
|
|
25661
|
+
let base;
|
|
25662
|
+
for (;args[at]?.startsWith("-"); at += GIT_VALUE.test(args[at]) ? 2 : 1)
|
|
25663
|
+
if (args[at] === "-C")
|
|
25664
|
+
base = args[at + 1];
|
|
25665
|
+
const [sub = "", ...rest] = args.slice(at);
|
|
25666
|
+
if (rest.some((arg) => arg === "--help" || arg === "-h"))
|
|
25667
|
+
return null;
|
|
25668
|
+
const names = rest.filter((arg, index) => !arg.startsWith("-") && !GIT_VALUE.test(rest[index - 1] ?? ""));
|
|
25669
|
+
const has = (pattern) => rest.some((arg) => pattern.test(arg));
|
|
25670
|
+
const files = [];
|
|
25671
|
+
const output = valueOf(rest, sub === "archive" ? /^(?:-o|--output=?)(.*)$/s : /^--output=?(.*)$/s);
|
|
25672
|
+
if (output !== undefined)
|
|
25673
|
+
files.push(output);
|
|
25674
|
+
if (sub === "init")
|
|
25675
|
+
files.push(names[0] ?? ".");
|
|
25676
|
+
if (sub === "clone")
|
|
25677
|
+
files.push(names[1] ?? names[0]?.replace(/(?:\.git)?[\\/]*$/, "").split(/[\\/:]/).at(-1) ?? ".");
|
|
25678
|
+
if (sub === "format-patch" && !has(/^--stdout$/))
|
|
25679
|
+
files.push(valueOf(rest, /^(?:-o|--output-directory=?)(.*)$/s) ?? ".");
|
|
25680
|
+
if (sub === "bundle" && names[0] === "create" && names[1])
|
|
25681
|
+
files.push(names[1]);
|
|
25682
|
+
if (sub === "config" && configWrites(rest))
|
|
25683
|
+
files.push(has(/^--global$/) ? "~/.gitconfig" : has(/^--system$/) ? "/etc/gitconfig" : valueOf(rest, /^(?:-f|--file=?)(.*)$/s) ?? ".");
|
|
25684
|
+
const branchWrite = has(/^-[a-zA-Z]*[dDfmMcCu]|^--(?:delete|force|move|copy|set-upstream|unset-upstream|edit)/) || names.length > 0 && !has(/^-[a-zA-Z]*[lavr]|^--(?:list|all|remotes|verbose|show|contains|no-contains|merged|no-merged|points-at|format|sort)/);
|
|
25685
|
+
if (sub === "fetch" || sub === "gc" || sub === "branch" && branchWrite)
|
|
25686
|
+
files.push(".");
|
|
25687
|
+
if (base === undefined)
|
|
25688
|
+
return files.length ? files : null;
|
|
25689
|
+
const under = (file) => file === "." ? `${base}/${OPAQUE_TARGET}git` : /^[/~$]|^[A-Za-z]:[\\/]/.test(file) ? file : `${base}/${file}`;
|
|
25690
|
+
return files.length ? files.map(under) : null;
|
|
25691
|
+
};
|
|
25605
25692
|
var pathsIn = (text) => [
|
|
25606
25693
|
...text.matchAll(/(?<![\w.~:/$-])(?:~\/|\/|[A-Za-z]:\/|\.\.(?:\/|$))[^\s'"`$),;:*?<>|\\[\]{}]*/g)
|
|
25607
25694
|
].map((match) => match[0]);
|
|
@@ -27558,9 +27645,6 @@ var MUTATING_REMOTE = new Set([
|
|
|
27558
27645
|
"set-branches",
|
|
27559
27646
|
"prune"
|
|
27560
27647
|
]);
|
|
27561
|
-
var CONFIG_READ = /^(?:--get(?:-all|-regexp|-urlmatch)?|--list|-l|get|list)$/;
|
|
27562
|
-
var CONFIG_WRITE = /^(?:--(?:unset(?:-all)?|add|replace-all|rename-section|remove-section|edit)|-e|set|unset|rename-section|remove-section|edit)$/;
|
|
27563
|
-
var CONFIG_VALUE = /^(?:--file|-f|--blob|--type|--default|--comment)$/;
|
|
27564
27648
|
var leadOwnedGit = (args) => {
|
|
27565
27649
|
const [sub = "", ...rest] = args;
|
|
27566
27650
|
if (rest.some((arg) => arg === "--help" || arg === "-h"))
|
|
@@ -27599,19 +27683,8 @@ var leadOwnedGit = (args) => {
|
|
|
27599
27683
|
return names[0] === "drop" || names[0] === "clear";
|
|
27600
27684
|
case "remote":
|
|
27601
27685
|
return MUTATING_REMOTE.has(names[0] ?? "");
|
|
27602
|
-
case "config":
|
|
27603
|
-
|
|
27604
|
-
return false;
|
|
27605
|
-
if (rest.some((arg) => CONFIG_WRITE.test(arg)))
|
|
27606
|
-
return true;
|
|
27607
|
-
let operands = 0;
|
|
27608
|
-
for (let index = 0;index < rest.length; index++)
|
|
27609
|
-
if (CONFIG_VALUE.test(rest[index]))
|
|
27610
|
-
index++;
|
|
27611
|
-
else if (!rest[index].startsWith("-"))
|
|
27612
|
-
operands++;
|
|
27613
|
-
return operands > 1;
|
|
27614
|
-
}
|
|
27686
|
+
case "config":
|
|
27687
|
+
return configWrites(rest);
|
|
27615
27688
|
default:
|
|
27616
27689
|
return false;
|
|
27617
27690
|
}
|
|
@@ -27639,6 +27712,223 @@ function confineImplementerShell(input, command, dialect = "posix") {
|
|
|
27639
27712
|
} catch {}
|
|
27640
27713
|
return confineImplementer(input, shellMutationTargets(input.cwd, command, dialect, true), command);
|
|
27641
27714
|
}
|
|
27715
|
+
var SCRATCH = ".workit-scratch";
|
|
27716
|
+
var SHELL_NAMES = /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/;
|
|
27717
|
+
var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php)$/;
|
|
27718
|
+
var FED = /^(?:-|\/dev\/stdin|\/dev\/fd\/0|\/proc\/self\/fd\/0)$|^<\(/;
|
|
27719
|
+
var LEADS = /^(?:sudo|doas|env|command|builtin|exec|nohup|time|nice|timeout|stdbuf|xargs|busybox|!|\{|if|then|else|elif|do|while|until|\w+=.*|[-\d].*)$/s;
|
|
27720
|
+
var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|perl|php|eval|source|\.|workit)$/;
|
|
27721
|
+
var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/;
|
|
27722
|
+
var VALUED = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
|
|
27723
|
+
var commonDir = (root) => {
|
|
27724
|
+
const dotGit = path39.join(root, ".git");
|
|
27725
|
+
if (!fs28.statSync(dotGit).isFile())
|
|
27726
|
+
return canonical4(dotGit);
|
|
27727
|
+
const admin = path39.resolve(root, /^gitdir:\s*(.+)$/mu.exec(fs28.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "");
|
|
27728
|
+
const common = path39.join(admin, "commondir");
|
|
27729
|
+
return canonical4(fs28.existsSync(common) ? path39.resolve(admin, fs28.readFileSync(common, "utf8").trim()) : admin);
|
|
27730
|
+
};
|
|
27731
|
+
var inScratch = (real, repo) => {
|
|
27732
|
+
const checkout = checkoutOf2(real);
|
|
27733
|
+
return checkout !== null && within(real, path39.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
|
|
27734
|
+
};
|
|
27735
|
+
var JUDGE_VERBS = {
|
|
27736
|
+
check: true,
|
|
27737
|
+
dir: true,
|
|
27738
|
+
help: true,
|
|
27739
|
+
"test-audit": true,
|
|
27740
|
+
ledger: ["verdict", "finding", "list", "check", "ruling"],
|
|
27741
|
+
pr: ["status"],
|
|
27742
|
+
ci: ["wait", "logs"],
|
|
27743
|
+
fanout: ["status", "brief"],
|
|
27744
|
+
models: ["show"],
|
|
27745
|
+
lock: ["status"]
|
|
27746
|
+
};
|
|
27747
|
+
var HELP = /^(?:--help|-h)$/;
|
|
27748
|
+
var judgeVerbRefused = (args) => {
|
|
27749
|
+
const { rest } = skipWorkitGlobals(args);
|
|
27750
|
+
const end = rest.indexOf("--");
|
|
27751
|
+
const call = end < 0 ? rest : rest.slice(0, end);
|
|
27752
|
+
const [verb, sub = ""] = call;
|
|
27753
|
+
if (verb === undefined || verb === "--version" || HELP.test(verb) || HELP.test(sub))
|
|
27754
|
+
return null;
|
|
27755
|
+
const allowed = Object.hasOwn(JUDGE_VERBS, verb) ? JUDGE_VERBS[verb] : [];
|
|
27756
|
+
const ok = allowed === true ? !(verb === "test-audit" && call.some((arg) => /^--mutate(?:=|$)/.test(arg))) : allowed.includes(sub);
|
|
27757
|
+
return ok ? null : `workit ${call.join(" ")}`;
|
|
27758
|
+
};
|
|
27759
|
+
var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
|
|
27760
|
+
var CLI_ENTRY = /(?:^|[=\\/])(?:workit(?:\.(?:exe|cmd|[cm]?js))?|@workit-dev\/cli(?:@\S*)?)$|(?:workit-cli|@workit-dev[\\/]cli)[\\/](?:src[\\/](?:index|main)|dist[\\/]index)\.[cm]?[jt]sx?$/;
|
|
27761
|
+
var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
|
|
27762
|
+
const name = path39.basename(words[0] ?? "").toLowerCase();
|
|
27763
|
+
if (name === "alias")
|
|
27764
|
+
return words.flatMap((word) => {
|
|
27765
|
+
const set = /^([\w-]+)=(.*)$/s.exec(word);
|
|
27766
|
+
if (!set)
|
|
27767
|
+
return [];
|
|
27768
|
+
aliases.set(set[1], set[2]);
|
|
27769
|
+
return workitCalls(set[2], depth + 1, aliases);
|
|
27770
|
+
});
|
|
27771
|
+
const body = aliases.get(words[0] ?? "");
|
|
27772
|
+
if (body !== undefined)
|
|
27773
|
+
return workitCalls([body, ...words.slice(1).map((word) => `'${word.replaceAll("'", `'\\''`)}'`)].join(" "), depth + 1, aliases);
|
|
27774
|
+
let at = /^workit(?:\.exe|\.cmd)?$/.test(name) ? 0 : CLI_RUNNERS.test(name) ? words.findIndex((word, index) => index > 0 && CLI_ENTRY.test(word)) : -1;
|
|
27775
|
+
if (at < 0)
|
|
27776
|
+
return [];
|
|
27777
|
+
while (words[at + 1] === "--" || CLI_ENTRY.test(words[at + 1] ?? ""))
|
|
27778
|
+
at++;
|
|
27779
|
+
return [words.slice(at + 1)];
|
|
27780
|
+
});
|
|
27781
|
+
var JUDGE_JOB = Object.entries(JUDGE_VERBS).map(([verb, subs]) => `workit ${verb}${subs === true ? "" : ` ${subs.join("|")}`}`).join(", ");
|
|
27782
|
+
var judgeRefusal = (command, fed, depth = 0) => {
|
|
27783
|
+
let moved = false;
|
|
27784
|
+
for (const segment of segmentsOf(command)) {
|
|
27785
|
+
const nested = (script) => script !== undefined && depth < 4 ? judgeRefusal(script, fed, depth + 1) : null;
|
|
27786
|
+
for (const sub of segment.subs ?? []) {
|
|
27787
|
+
const why = nested(sub);
|
|
27788
|
+
if (why)
|
|
27789
|
+
return why;
|
|
27790
|
+
}
|
|
27791
|
+
const { words } = segment;
|
|
27792
|
+
const runs = (word = "") => RUNS.test(path39.basename(word).toLowerCase());
|
|
27793
|
+
let at = 0;
|
|
27794
|
+
while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
|
|
27795
|
+
at++;
|
|
27796
|
+
const name = path39.basename(words[at] ?? "").toLowerCase();
|
|
27797
|
+
const args = words.slice(at + 1);
|
|
27798
|
+
const unseen = `\`${words.join(" ").slice(0, 80)}\` runs a script Workit cannot read (piped, on stdin, a process substitution or eval): write the case to a file in ${SCRATCH} and dispatch it from a test instead`;
|
|
27799
|
+
if (/^(?:cd|chdir|pushd|popd)$/.test(name))
|
|
27800
|
+
moved = true;
|
|
27801
|
+
if (name === "eval" || (name === "source" || name === ".") && FED.test(args[0] ?? ""))
|
|
27802
|
+
return unseen;
|
|
27803
|
+
if (SHELL_NAMES.test(name)) {
|
|
27804
|
+
let operand;
|
|
27805
|
+
let stdin = false;
|
|
27806
|
+
let inline;
|
|
27807
|
+
for (let index = 0;index < args.length && inline === undefined; index++) {
|
|
27808
|
+
const arg = args[index];
|
|
27809
|
+
if (/^-[a-zA-Z]*c[a-zA-Z]*$/.test(arg))
|
|
27810
|
+
inline = index + 1;
|
|
27811
|
+
else if (/^[-+][oO]$/.test(arg))
|
|
27812
|
+
index++;
|
|
27813
|
+
else if (arg === "--" || !/^[-+]/.test(arg)) {
|
|
27814
|
+
operand = arg === "--" ? args[index + 1] : arg;
|
|
27815
|
+
break;
|
|
27816
|
+
} else if (/^-[a-zA-Z]*s/.test(arg))
|
|
27817
|
+
stdin = true;
|
|
27818
|
+
}
|
|
27819
|
+
if (inline !== undefined) {
|
|
27820
|
+
const why = nested(args[inline]);
|
|
27821
|
+
if (why)
|
|
27822
|
+
return why;
|
|
27823
|
+
} else if (operand === undefined || stdin || FED.test(operand)) {
|
|
27824
|
+
if (!segment.stdin?.length || moved || operand !== undefined && !stdin)
|
|
27825
|
+
return unseen;
|
|
27826
|
+
fed.push(...segment.stdin);
|
|
27827
|
+
for (const body of segment.stdin) {
|
|
27828
|
+
const why = nested(body);
|
|
27829
|
+
if (why)
|
|
27830
|
+
return why;
|
|
27831
|
+
}
|
|
27832
|
+
}
|
|
27833
|
+
}
|
|
27834
|
+
if (INTERPRETERS.test(name) && !args.some((arg) => INLINE.test(arg))) {
|
|
27835
|
+
const operand = args.find((arg, index) => (arg === "-" || !arg.startsWith("-")) && !VALUED.test(args[index - 1] ?? ""));
|
|
27836
|
+
if (FED.test(operand ?? "") || operand === undefined && !/^(?:bun|deno)$/.test(name))
|
|
27837
|
+
return unseen;
|
|
27838
|
+
}
|
|
27839
|
+
const tail = workitCheckTail(words.slice(at));
|
|
27840
|
+
if (tail) {
|
|
27841
|
+
const why = nested("script" in tail ? tail.script : tail.argv.map((word) => `'${word.replaceAll("'", `'\\''`)}'`).join(" "));
|
|
27842
|
+
if (why)
|
|
27843
|
+
return why;
|
|
27844
|
+
}
|
|
27845
|
+
}
|
|
27846
|
+
for (const args of workitCalls(command)) {
|
|
27847
|
+
const call = judgeVerbRefused(args);
|
|
27848
|
+
if (call)
|
|
27849
|
+
return `\`${call}\` is not a judge's job: a judge runs only ${JUDGE_JOB}`;
|
|
27850
|
+
}
|
|
27851
|
+
return null;
|
|
27852
|
+
};
|
|
27853
|
+
var substitutingHeredoc = (command) => {
|
|
27854
|
+
for (const match of command.matchAll(/(?<!<)<<-?[ \t]*([^\s<>;&|()]+)/g)) {
|
|
27855
|
+
const delimiter = match[1];
|
|
27856
|
+
if (/['"\\]/.test(delimiter))
|
|
27857
|
+
continue;
|
|
27858
|
+
const newline = command.indexOf(`
|
|
27859
|
+
`, match.index + match[0].length);
|
|
27860
|
+
if (newline < 0)
|
|
27861
|
+
continue;
|
|
27862
|
+
const lines = command.slice(newline + 1).split(`
|
|
27863
|
+
`);
|
|
27864
|
+
const end = lines.findIndex((line) => line.trim() === delimiter);
|
|
27865
|
+
if (/\$\((?!\()|`/.test((end < 0 ? lines : lines.slice(0, end)).join(`
|
|
27866
|
+
`)))
|
|
27867
|
+
return true;
|
|
27868
|
+
}
|
|
27869
|
+
return false;
|
|
27870
|
+
};
|
|
27871
|
+
var judgeDeny = (input, what) => {
|
|
27872
|
+
const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
|
|
27873
|
+
const root = checkoutOf2(input.cwd)?.root;
|
|
27874
|
+
const scratch = root ? path39.join(root, SCRATCH) : `${SCRATCH}/ at the root of the checkout you judge`;
|
|
27875
|
+
const unblock = `Write only under ${scratch} (mkdir -p it): put a generated case in a file there with a quoted heredoc (<<'EOF') and never run it in the shell. Reads, \`workit check\` and \`workit ledger verdict|finding\` stay allowed; a change the candidate needs is a finding, not an edit.`;
|
|
27876
|
+
return {
|
|
27877
|
+
kind: "deny",
|
|
27878
|
+
reason: `workit scratch confinement: ${role} ${input.session.agentId} may write only in its scratch dir ${scratch}, and ${what}. ${unblock}`,
|
|
27879
|
+
unblock
|
|
27880
|
+
};
|
|
27881
|
+
};
|
|
27882
|
+
function confineJudge(input, targets) {
|
|
27883
|
+
try {
|
|
27884
|
+
if (!input.session.agentId)
|
|
27885
|
+
return NONE5;
|
|
27886
|
+
const judged = checkoutOf2(input.cwd);
|
|
27887
|
+
const repo = judged ? commonDir(judged.root) : null;
|
|
27888
|
+
for (const target of targets) {
|
|
27889
|
+
const resolved = path39.resolve(target);
|
|
27890
|
+
if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
|
|
27891
|
+
return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
|
|
27892
|
+
if (inScratch(canonical4(target), repo))
|
|
27893
|
+
continue;
|
|
27894
|
+
const runner = runnerAt(target);
|
|
27895
|
+
return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`);
|
|
27896
|
+
}
|
|
27897
|
+
return NONE5;
|
|
27898
|
+
} catch {
|
|
27899
|
+
return NONE5;
|
|
27900
|
+
}
|
|
27901
|
+
}
|
|
27902
|
+
function confineJudgeShell(input, command, dialect = "posix") {
|
|
27903
|
+
try {
|
|
27904
|
+
if (!input.session.agentId)
|
|
27905
|
+
return NONE5;
|
|
27906
|
+
const fed = [];
|
|
27907
|
+
let refused;
|
|
27908
|
+
try {
|
|
27909
|
+
refused = dialect === "posix" ? judgeRefusal(command, fed) : null;
|
|
27910
|
+
} catch {
|
|
27911
|
+
refused = "Workit cannot read this command: split it into simpler ones";
|
|
27912
|
+
}
|
|
27913
|
+
if (refused)
|
|
27914
|
+
return judgeDeny(input, refused);
|
|
27915
|
+
if (dialect === "posix" && substitutingHeredoc(command))
|
|
27916
|
+
return judgeDeny(input, "an unquoted heredoc runs the `$(…)` or backtick command in its body: quote the delimiter (<<'EOF')");
|
|
27917
|
+
let git = [];
|
|
27918
|
+
try {
|
|
27919
|
+
git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args)) ? [
|
|
27920
|
+
path39.join(dir === undefined ? UNKNOWN_DIR : path39.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
|
|
27921
|
+
] : []);
|
|
27922
|
+
} catch {}
|
|
27923
|
+
return confineJudge(input, [
|
|
27924
|
+
...shellMutationTargets(input.cwd, command, dialect, true),
|
|
27925
|
+
...fed.flatMap((body) => shellMutationTargets(input.cwd, body, "posix", true)),
|
|
27926
|
+
...git
|
|
27927
|
+
]);
|
|
27928
|
+
} catch {
|
|
27929
|
+
return NONE5;
|
|
27930
|
+
}
|
|
27931
|
+
}
|
|
27642
27932
|
|
|
27643
27933
|
// packages/workit-core/src/hooks/steering.ts
|
|
27644
27934
|
var ROLES = {
|
|
@@ -28212,7 +28502,7 @@ var usable2 = (value) => value === "native" || value === "partial";
|
|
|
28212
28502
|
var NONE6 = { kind: "none" };
|
|
28213
28503
|
var resendsOnChange = (descriptor) => descriptor.context.turnResend === "on-change" && usable2(descriptor.context.perTurn);
|
|
28214
28504
|
var offered = new Set;
|
|
28215
|
-
var
|
|
28505
|
+
var agentRole = (input, descriptor) => input.session.agentId && input.session.agentType !== null ? workitRole(descriptor, input.session.agentType) : null;
|
|
28216
28506
|
var LIMIT_TEXT_MAX = 1000;
|
|
28217
28507
|
var usageLimitOnStop = (input, agentId, text) => {
|
|
28218
28508
|
try {
|
|
@@ -28326,12 +28616,14 @@ function decide(input, deps) {
|
|
|
28326
28616
|
unblock: null
|
|
28327
28617
|
};
|
|
28328
28618
|
}
|
|
28329
|
-
|
|
28330
|
-
|
|
28619
|
+
const role = canDeny ? agentRole(input, descriptor) : null;
|
|
28620
|
+
if (role) {
|
|
28621
|
+
const confined = (role === "implementer" ? confineImplementerShell : confineJudgeShell)(input, event.command, event.dialect);
|
|
28331
28622
|
if (confined.kind === "deny")
|
|
28332
28623
|
return confined;
|
|
28333
28624
|
}
|
|
28334
|
-
const
|
|
28625
|
+
const owner = role === "judge" ? null : liveOwner(input, descriptor.transport);
|
|
28626
|
+
const gate = usable2(descriptor.events["write.pre"].support) ? shellGate(input.cwd, event.command, owner, event.dialect) : NONE6;
|
|
28335
28627
|
if (gate.kind === "deny")
|
|
28336
28628
|
return gate;
|
|
28337
28629
|
const plan = heavyGate(input.cwd, event.command, {
|
|
@@ -28378,12 +28670,14 @@ function decide(input, deps) {
|
|
|
28378
28670
|
case "write.pre": {
|
|
28379
28671
|
if (!usable2(descriptor.events["write.pre"].support))
|
|
28380
28672
|
return NONE6;
|
|
28381
|
-
|
|
28382
|
-
|
|
28673
|
+
const role = agentRole(input, descriptor);
|
|
28674
|
+
if (role) {
|
|
28675
|
+
const targets = liveTargets(input.cwd, event.paths);
|
|
28676
|
+
const confined = role === "implementer" ? confineImplementer(input, targets) : confineJudge(input, targets);
|
|
28383
28677
|
if (confined.kind === "deny")
|
|
28384
28678
|
return confined;
|
|
28385
28679
|
}
|
|
28386
|
-
return writeGate(input.cwd, event.paths, liveOwner(input, descriptor.transport));
|
|
28680
|
+
return writeGate(input.cwd, event.paths, role === "judge" ? null : liveOwner(input, descriptor.transport));
|
|
28387
28681
|
}
|
|
28388
28682
|
case "subagent.start":
|
|
28389
28683
|
if (workitRole(descriptor, event.agentType) === "judge")
|
package/package.json
CHANGED
|
@@ -16,21 +16,20 @@ description: Build a requested change in small verified steps - follow local pat
|
|
|
16
16
|
judged? Cite the plan with `--ref <path>` or record the decision; don't re-judge.
|
|
17
17
|
3. Small steps that each leave the tree green. Behavior change: write the
|
|
18
18
|
acceptance as Given/When/Then and see a test fail first (read the `workit-bdd` skill's SKILL.md and follow it).
|
|
19
|
-
Mechanical change: the existing checks are enough.
|
|
20
|
-
a
|
|
19
|
+
Mechanical change: the existing checks are enough. A codemod or schematic
|
|
20
|
+
goes one area at a time: run it on one directory, `workit check`, commit
|
|
21
|
+
that directory, then the next; never loop it over all areas. No tautological tests: a test must fail if the behavior breaks, never restate the implementation.
|
|
21
22
|
4. Run the real checks, local-first: the targeted test or check for the file
|
|
22
23
|
you touched while you work, then the full configured set once at the end
|
|
23
|
-
(`workit check test`, plus `lint` and `typecheck` when the repo has them)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
lease waits and names its holder (`workit lock status`). A tool warning is a finding: fix it in this PR in the right layer, or record the false positive with evidence; pre-existing ones get their own PR.
|
|
24
|
+
(`workit check test`, plus `lint` and `typecheck` when the repo has them).
|
|
25
|
+
Heavy work runs under one machine-wide lease: an ad-hoc suite is `workit check --heavy -- <cmd>`, never a hand-made flock; a busy
|
|
26
|
+
lease waits and names its holder (`workit lock status`). A tool warning is a finding: fix it in this PR, or record the false positive with evidence; pre-existing ones get their own PR.
|
|
27
27
|
5. Prove the feature on its real surface with the project's `verify-<app>`
|
|
28
|
-
skill; none yet? Write one (read the `workit-verify-app` skill's SKILL.md and follow it).
|
|
29
|
-
not that the feature works. The report carries what you observed: a UI
|
|
28
|
+
skill; none yet? Write one (read the `workit-verify-app` skill's SKILL.md and follow it). The report carries what you observed: a UI
|
|
30
29
|
change a screenshot or console/network check (chrome devtools or
|
|
31
30
|
agent-browser), an API a quoted real response. App not runnable? Say so
|
|
32
31
|
plainly, never claim success.
|
|
33
|
-
6. Commit: `workit git commit -m "<type>: <what>" -- <paths
|
|
32
|
+
6. Commit: `workit git commit -m "<type>: <what>" -- <paths>`; Co-Authored-By goes in with `--trailer "Co-Authored-By: <name> <email>"`. Host note: a Workit worktree (`workit fanout worktree create`) takes `workit git --cwd <worktree> …`; a Claude Code host-isolated one (`.claude/worktrees/agent-<id>`) takes plain git. One file holding two changes: stage one change's hunks with `workit git stage --patch <file>` (a `git diff -- <file>` cut to them), then `workit git commit -m "<msg>" --staged` (exactly the index); a path staged in part commits only its staged hunks (`--whole` takes the file).
|
|
34
33
|
No endpoint named? Stop here and state the next command. Hand delivery to
|
|
35
34
|
ship, which pushes and opens the PR with its body shape (read the `workit-ship` skill's SKILL.md and follow it), only
|
|
36
35
|
when that was requested, or the request implies delivery and the effective
|
|
@@ -48,7 +47,7 @@ description: Build a requested change in small verified steps - follow local pat
|
|
|
48
47
|
|
|
49
48
|
Independent slices that could run in parallel: fan them out (read the `workit-fanout` skill's SKILL.md and follow it).
|
|
50
49
|
One `implementer` slice: `workit fanout worktree create <slice>` before spawning,
|
|
51
|
-
then `workit fanout brief <slice>`; no host isolation
|
|
50
|
+
then `workit fanout brief <slice>`; no host isolation.
|
|
52
51
|
|
|
53
52
|
Stay inline by default (workspace `delegation: inline-first`). Hand work off
|
|
54
53
|
only past the thresholds: an explorer after about 3 tool calls or 10k tokens
|