@brainervirus/workit-pi 8.19.1 → 8.20.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/workit.js +48 -3
- package/package.json +1 -1
package/dist/workit.js
CHANGED
|
@@ -23095,7 +23095,7 @@ var canonical2 = (file) => {
|
|
|
23095
23095
|
let rest = "";
|
|
23096
23096
|
for (let dir = path30.resolve(file);; dir = path30.dirname(dir)) {
|
|
23097
23097
|
try {
|
|
23098
|
-
return path30.join(realpathSync6(dir), rest);
|
|
23098
|
+
return path30.join(realpathSync6.native(dir), rest);
|
|
23099
23099
|
} catch {
|
|
23100
23100
|
if (path30.dirname(dir) === dir)
|
|
23101
23101
|
return path30.resolve(file);
|
|
@@ -23315,18 +23315,26 @@ var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
|
|
|
23315
23315
|
var PUSHD2 = new Set(["pushd", "push-location"]);
|
|
23316
23316
|
var POPD2 = new Set(["popd", "pop-location"]);
|
|
23317
23317
|
var cdInto = (dir, words) => {
|
|
23318
|
-
const
|
|
23318
|
+
const named = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
|
|
23319
|
+
const target = named === undefined ? undefined : homeExpanded(named);
|
|
23319
23320
|
if (dir === undefined || target === "-" || target && /^~|[$`*?]/.test(target))
|
|
23320
23321
|
return;
|
|
23321
23322
|
return target === undefined ? os10.homedir() : path30.resolve(dir, target);
|
|
23322
23323
|
};
|
|
23323
23324
|
var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
23325
|
+
var homeExpanded = (file) => {
|
|
23326
|
+
const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
|
|
23327
|
+
return match ? (process.env.HOME || os10.homedir()) + file.slice(match[0].length) : file;
|
|
23328
|
+
};
|
|
23324
23329
|
var segmentTargets = (cwd, command, dialect, depth = 0) => {
|
|
23325
23330
|
const targets = [];
|
|
23326
23331
|
let dir = cwd;
|
|
23327
23332
|
let stack = [];
|
|
23328
23333
|
const groups = [];
|
|
23329
|
-
const at = (file) =>
|
|
23334
|
+
const at = (file) => {
|
|
23335
|
+
const home = homeExpanded(file);
|
|
23336
|
+
return path30.isAbsolute(home) ? home : dir === undefined ? null : path30.resolve(dir, home);
|
|
23337
|
+
};
|
|
23330
23338
|
for (const segment of segmentsOf(command, dialect)) {
|
|
23331
23339
|
if (segment.group === "open") {
|
|
23332
23340
|
groups.push({ dir, stack: [...stack] });
|
|
@@ -23431,7 +23439,39 @@ var claimAll = (owner, targets, deps) => {
|
|
|
23431
23439
|
claimLiveSession(target, owner, deps);
|
|
23432
23440
|
};
|
|
23433
23441
|
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path30.resolve(cwd, file)) : [path30.join(cwd, DIR_TARGET)];
|
|
23442
|
+
var issuedTarget = (cwd, targets) => {
|
|
23443
|
+
const state = resolveStateDir();
|
|
23444
|
+
const found = targets.find((target) => underIssued(state, cwd, homeExpanded(target), process.platform, canonical2));
|
|
23445
|
+
return found ?? null;
|
|
23446
|
+
};
|
|
23447
|
+
var underIssued = (state, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
23448
|
+
const win = platform === "win32";
|
|
23449
|
+
const p = win ? path30.win32 : path30.posix;
|
|
23450
|
+
const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
|
|
23451
|
+
const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
|
|
23452
|
+
const relative = p.relative(fold(real(p.resolve(state))), fold(real(p.resolve(cwd, named))));
|
|
23453
|
+
if (relative.startsWith("..") || p.isAbsolute(relative))
|
|
23454
|
+
return false;
|
|
23455
|
+
return relative.split(p.sep)[0].startsWith("issued");
|
|
23456
|
+
};
|
|
23457
|
+
var unquotedWindowsIssued = (command) => {
|
|
23458
|
+
if (process.platform !== "win32" || !command.includes("\\"))
|
|
23459
|
+
return false;
|
|
23460
|
+
const flat = (value) => value.replaceAll("\\", "/").toLowerCase();
|
|
23461
|
+
return flat(command).includes(`${flat(resolveStateDir())}/issued`) && shellWrites(command).writes;
|
|
23462
|
+
};
|
|
23463
|
+
var issuedDeny = (file) => {
|
|
23464
|
+
const unblock = "Issued ids and tokens are written only by Workit's SubagentStart hook. Run the verifier or reviewer agent so the host issues its own session; never edit the issued registries by hand.";
|
|
23465
|
+
return {
|
|
23466
|
+
kind: "deny",
|
|
23467
|
+
reason: `workit issued-registry guard: ${file} is under Workit's issued-session state. ${unblock}`,
|
|
23468
|
+
unblock
|
|
23469
|
+
};
|
|
23470
|
+
};
|
|
23434
23471
|
function writeGate(cwd, paths, owner, deps) {
|
|
23472
|
+
const forged = paths?.length ? issuedTarget(cwd, paths) : null;
|
|
23473
|
+
if (forged)
|
|
23474
|
+
return issuedDeny(forged);
|
|
23435
23475
|
if (!owner)
|
|
23436
23476
|
return beforeWriteGate(cwd, paths);
|
|
23437
23477
|
const targets = liveTargets(cwd, paths);
|
|
@@ -23444,6 +23484,11 @@ function writeGate(cwd, paths, owner, deps) {
|
|
|
23444
23484
|
return decision;
|
|
23445
23485
|
}
|
|
23446
23486
|
function shellGate(cwd, command, owner, dialect = "posix", deps) {
|
|
23487
|
+
try {
|
|
23488
|
+
const forged = issuedTarget(cwd, segmentTargets(cwd, command, dialect)) ?? (unquotedWindowsIssued(command) ? "the issued registry" : null);
|
|
23489
|
+
if (forged)
|
|
23490
|
+
return issuedDeny(forged);
|
|
23491
|
+
} catch {}
|
|
23447
23492
|
const writes = shellWrites(command);
|
|
23448
23493
|
let targets = [];
|
|
23449
23494
|
if (owner) {
|