@workit-dev/pi 2.27.5 → 2.27.6
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/workit.js +24 -16
- package/package.json +1 -1
package/dist/workit.js
CHANGED
|
@@ -33723,8 +33723,12 @@ var dropAgentStamps = (env, session, toolUseId, command) => {
|
|
|
33723
33723
|
|
|
33724
33724
|
// packages/workit-core/src/hooks/identity-env.ts
|
|
33725
33725
|
var NAMES = "WORKIT_(?:AGENT_ID|HOST|SESSION_ID|SESSION_TOKEN)";
|
|
33726
|
+
var HOST_NAMES = "(?:OPENCODE_SESSION_ID|PI_SESSION_ID|CODEX_THREAD_ID|CLAUDECODE|CLAUDE_CODE_ENTRYPOINT)";
|
|
33726
33727
|
var IDENTITY = new RegExp(`^${NAMES}$`, "u");
|
|
33727
|
-
var
|
|
33728
|
+
var HOST_VARIABLE = new RegExp(`^${HOST_NAMES}$`, "u");
|
|
33729
|
+
var powershell = (names) => new RegExp(`\\$env:${names}\\b|env:[\\\\/]?${names}\\b|EnvironmentVariable\\(\\s*['"]${names}\\b`, "iu");
|
|
33730
|
+
var POWERSHELL = powershell(NAMES);
|
|
33731
|
+
var POWERSHELL_HOST = powershell(HOST_NAMES);
|
|
33728
33732
|
var DECLARES = new Set(["export", "unset", "declare", "typeset", "local", "readonly"]);
|
|
33729
33733
|
var OPAQUE = new Set([
|
|
33730
33734
|
"watch",
|
|
@@ -33742,14 +33746,21 @@ var ENV_FLAGS = new Set(["i", "0", "v"]);
|
|
|
33742
33746
|
var ENV_LONG_VALUED = new Set(["--unset", "--chdir", "--split-string", "--argv0"]);
|
|
33743
33747
|
var ENV_LONG_FLAGS = /^--(?:ignore-environment|null|debug|(?:block|default|ignore)-signal(?:=.*)?)$/u;
|
|
33744
33748
|
var base3 = (word) => (word?.split(/[\\/]/u).at(-1) ?? "").replace(/\.exe$/iu, "");
|
|
33745
|
-
var
|
|
33749
|
+
var nameOf = (word) => word?.split("=")[0] ?? "";
|
|
33750
|
+
var named = (word) => IDENTITY.test(nameOf(word)) || HOST_VARIABLE.test(nameOf(word));
|
|
33746
33751
|
var isWorkit = (word) => /^workit(?:-cli)?$/u.test(base3(word));
|
|
33747
33752
|
var UNREADABLE = "env/unset arguments Workit cannot read";
|
|
33753
|
+
var mark = (scan, word) => {
|
|
33754
|
+
const name = nameOf(word);
|
|
33755
|
+
if (IDENTITY.test(name))
|
|
33756
|
+
scan.hit ??= name;
|
|
33757
|
+
else if (HOST_VARIABLE.test(name))
|
|
33758
|
+
scan.hostHit ??= name;
|
|
33759
|
+
};
|
|
33748
33760
|
var scanEnv = (words, at, expands, scan, depth) => {
|
|
33749
33761
|
const risky = (what) => void (scan.risky ??= what);
|
|
33750
33762
|
const unset = (name) => {
|
|
33751
|
-
|
|
33752
|
-
scan.hit ??= name ?? null;
|
|
33763
|
+
mark(scan, name);
|
|
33753
33764
|
};
|
|
33754
33765
|
const split = (line, rest, built) => {
|
|
33755
33766
|
if (line === undefined || depth >= 4)
|
|
@@ -33836,8 +33847,7 @@ var commandAt = (words, scan, expands = new Set, from = 0) => {
|
|
|
33836
33847
|
let index = from;
|
|
33837
33848
|
while (index < words.length) {
|
|
33838
33849
|
while (/^[A-Za-z_]\w*=/u.test(words[index] ?? "")) {
|
|
33839
|
-
|
|
33840
|
-
scan.hit ??= words[index]?.split("=")[0] ?? null;
|
|
33850
|
+
mark(scan, words[index]);
|
|
33841
33851
|
index += 1;
|
|
33842
33852
|
}
|
|
33843
33853
|
const name = base3(words[index]).toLowerCase();
|
|
@@ -33868,7 +33878,7 @@ var opaque = (rest, scan, assigns) => {
|
|
|
33868
33878
|
scan.risky ??= UNREADABLE;
|
|
33869
33879
|
const hit = rest.find(named);
|
|
33870
33880
|
if (hit && rest.some((word) => base3(word).toLowerCase() === "env"))
|
|
33871
|
-
scan
|
|
33881
|
+
mark(scan, hit);
|
|
33872
33882
|
};
|
|
33873
33883
|
var LOGIN_VALUED = {
|
|
33874
33884
|
su: /[sgGwc]/u,
|
|
@@ -33905,8 +33915,7 @@ var scanCommand = (command, dialect, depth, scan) => {
|
|
|
33905
33915
|
const expanded = new Set(expands);
|
|
33906
33916
|
let at = 0;
|
|
33907
33917
|
while (/^[A-Za-z_]\w*=/u.test(words[at] ?? "")) {
|
|
33908
|
-
|
|
33909
|
-
scan.hit ??= words[at]?.split("=")[0] ?? null;
|
|
33918
|
+
mark(scan, words[at]);
|
|
33910
33919
|
at += 1;
|
|
33911
33920
|
}
|
|
33912
33921
|
let declare = at;
|
|
@@ -33914,8 +33923,7 @@ var scanCommand = (command, dialect, depth, scan) => {
|
|
|
33914
33923
|
declare += 1;
|
|
33915
33924
|
if (DECLARES.has(words[declare] ?? "")) {
|
|
33916
33925
|
for (let index = declare + 1;index < words.length; index += 1) {
|
|
33917
|
-
|
|
33918
|
-
scan.hit ??= words[index]?.split("=")[0] ?? null;
|
|
33926
|
+
mark(scan, words[index]);
|
|
33919
33927
|
if (expanded.has(index))
|
|
33920
33928
|
scan.risky ??= UNREADABLE;
|
|
33921
33929
|
}
|
|
@@ -33928,15 +33936,15 @@ var scanCommand = (command, dialect, depth, scan) => {
|
|
|
33928
33936
|
}
|
|
33929
33937
|
};
|
|
33930
33938
|
var identityEnvChange = (command, dialect = "posix") => {
|
|
33931
|
-
if (!/WORKIT_|\b(?:env|unset|export|declare|typeset|local|readonly)\b/u.test(command))
|
|
33939
|
+
if (!/WORKIT_|OPENCODE_SESSION_ID|PI_SESSION_ID|CODEX_THREAD_ID|CLAUDE|\b(?:env|unset|export|declare|typeset|local|readonly)\b/u.test(command))
|
|
33932
33940
|
return null;
|
|
33933
33941
|
if (dialect === "powershell")
|
|
33934
|
-
return POWERSHELL.exec(command)?.[0] ?? null;
|
|
33935
|
-
const scan = { hit: null, risky: null, runs: false };
|
|
33942
|
+
return POWERSHELL.exec(command)?.[0] ?? (/\bworkit\b/iu.test(command) ? POWERSHELL_HOST.exec(command)?.[0] ?? null : null);
|
|
33943
|
+
const scan = { hit: null, hostHit: null, risky: null, runs: false };
|
|
33936
33944
|
scanCommand(command, dialect, 0, scan);
|
|
33937
|
-
return scan.hit ?? (scan.runs ? scan.risky : null);
|
|
33945
|
+
return scan.hit ?? (scan.runs ? scan.hostHit ?? scan.risky : null);
|
|
33938
33946
|
};
|
|
33939
|
-
var identityEnvDeny = (change) => `workit identity: ${change === UNREADABLE ? `this command runs workit with ${UNREADABLE}` : `this command changes ${change}`}. The host sets WORKIT_HOST, WORKIT_SESSION_ID and
|
|
33947
|
+
var identityEnvDeny = (change) => `workit identity: ${change === UNREADABLE ? `this command runs workit with ${UNREADABLE}` : `this command changes ${change}`}. The host sets WORKIT_HOST, WORKIT_SESSION_ID, WORKIT_AGENT_ID and its own session variables, and Workit acts as who they name; run it without changing them (a verifier or reviewer passes the --session and --token its start text names).`;
|
|
33940
33948
|
|
|
33941
33949
|
// packages/workit-core/src/hooks/handle.ts
|
|
33942
33950
|
var usable2 = (value) => value === "native" || value === "partial";
|