@workit-dev/pi 1.7.3 → 1.7.5
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 +58 -13
- package/package.json +1 -1
package/dist/workit.js
CHANGED
|
@@ -26601,53 +26601,67 @@ var claimAll = (owner, targets, deps) => {
|
|
|
26601
26601
|
claimLiveSession(target, owner, deps);
|
|
26602
26602
|
};
|
|
26603
26603
|
var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path40.resolve(cwd, file)) : [path40.join(cwd, DIR_TARGET)];
|
|
26604
|
+
var configDirs = () => [resolveConfigDir(), grantsDir()];
|
|
26604
26605
|
var registryTarget = (cwd, targets) => {
|
|
26605
26606
|
const state = resolveStateDir();
|
|
26607
|
+
const configs = configDirs();
|
|
26606
26608
|
for (const target of targets) {
|
|
26607
|
-
const
|
|
26609
|
+
const file = homeExpanded(target);
|
|
26610
|
+
const registry = underRegistry(state, cwd, file, process.platform, canonical3) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical3)) ? "grants" : null);
|
|
26608
26611
|
if (registry)
|
|
26609
26612
|
return { file: target, registry };
|
|
26610
26613
|
}
|
|
26611
26614
|
return null;
|
|
26612
26615
|
};
|
|
26613
|
-
var
|
|
26616
|
+
var partsUnder = (dir, cwd, target, platform, real) => {
|
|
26614
26617
|
const win = platform === "win32";
|
|
26615
26618
|
const p = win ? path40.win32 : path40.posix;
|
|
26616
26619
|
const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
|
|
26617
26620
|
const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
|
|
26618
|
-
const relative = p.relative(fold(real(p.resolve(
|
|
26619
|
-
|
|
26620
|
-
|
|
26621
|
-
|
|
26622
|
-
|
|
26621
|
+
const relative = p.relative(fold(real(p.resolve(dir))), fold(real(p.resolve(cwd, named))));
|
|
26622
|
+
return relative.startsWith("..") || p.isAbsolute(relative) ? null : relative.split(p.sep);
|
|
26623
|
+
};
|
|
26624
|
+
var underRegistry = (state, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
26625
|
+
const first = partsUnder(state, cwd, target, platform, real)?.[0];
|
|
26626
|
+
if (first?.startsWith("issued"))
|
|
26623
26627
|
return "issued";
|
|
26624
26628
|
return first === "approvals" ? "approvals" : null;
|
|
26625
26629
|
};
|
|
26626
|
-
var
|
|
26627
|
-
|
|
26630
|
+
var underConfig = (dir, cwd, target, platform = process.platform, real = (file) => file) => {
|
|
26631
|
+
const parts = partsUnder(dir, cwd, target, platform, real);
|
|
26632
|
+
return parts?.length === 1 && (parts[0] === "" || parts[0] === "workspaces.json");
|
|
26633
|
+
};
|
|
26634
|
+
var unquotedWindowsRegistry = (command, platform = process.platform) => {
|
|
26635
|
+
if (platform !== "win32" || !command.includes("\\"))
|
|
26628
26636
|
return null;
|
|
26629
26637
|
const flat = (value) => value.replaceAll("\\", "/").toLowerCase();
|
|
26630
26638
|
const text = flat(command);
|
|
26631
26639
|
const state = flat(resolveStateDir());
|
|
26632
|
-
const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : null;
|
|
26640
|
+
const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : configDirs().some((dir) => text.includes(`${flat(dir)}/workspaces.json`)) ? "grants" : null;
|
|
26633
26641
|
return registry && shellWrites(command).writes ? registry : null;
|
|
26634
26642
|
};
|
|
26635
26643
|
var REGISTRY_DENY = {
|
|
26636
26644
|
issued: {
|
|
26637
26645
|
label: "issued-registry guard",
|
|
26646
|
+
what: "Workit's issued-session state",
|
|
26638
26647
|
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."
|
|
26639
26648
|
},
|
|
26640
26649
|
approvals: {
|
|
26641
26650
|
label: "approvals guard",
|
|
26651
|
+
what: "Workit's host-approval state",
|
|
26642
26652
|
unblock: "Approval requests and the user's yes are written only by Workit: run `workit approve <id>` as its own call so the host asks the user, or ask the user to run it in their own terminal; never edit the approvals registry by hand."
|
|
26653
|
+
},
|
|
26654
|
+
grants: {
|
|
26655
|
+
label: "config guard",
|
|
26656
|
+
what: "the user's Workit config (grants, roles, youtrack.writes)",
|
|
26657
|
+
unblock: "Only the user changes it: ask them to run `workit grant set <ws> <kind>=<value>` or `workit workspace set <ws> <key>=<value>` in a terminal outside this host. `workit grant show` and `workit workspace list` read it."
|
|
26643
26658
|
}
|
|
26644
26659
|
};
|
|
26645
26660
|
var registryDeny = ({ file, registry }) => {
|
|
26646
|
-
const { label, unblock } = REGISTRY_DENY[registry];
|
|
26647
|
-
const what = registry === "issued" ? "issued-session state" : "host-approval state";
|
|
26661
|
+
const { label, what, unblock } = REGISTRY_DENY[registry];
|
|
26648
26662
|
return {
|
|
26649
26663
|
kind: "deny",
|
|
26650
|
-
reason: `workit ${label}: ${file} is under
|
|
26664
|
+
reason: `workit ${label}: ${file} is under ${what}. ${unblock}`,
|
|
26651
26665
|
unblock
|
|
26652
26666
|
};
|
|
26653
26667
|
};
|
|
@@ -28643,6 +28657,15 @@ var verbFirst = (command) => {
|
|
|
28643
28657
|
return null;
|
|
28644
28658
|
return `${lead} ${verb}${globals}${command.slice(whole.length)}`;
|
|
28645
28659
|
};
|
|
28660
|
+
var NPX = new RegExp(String.raw`^(\s*(?:cd\s+(?:${DIR})\s*&&\s*)?)npx(?:\s+(?:-y|--yes))*\s+@workit-dev\/cli(?:@[\w.-]+)?(?=\s|$)`, "u");
|
|
28661
|
+
var npxWorkit = (command) => {
|
|
28662
|
+
const match = NPX.exec(command);
|
|
28663
|
+
if (!match)
|
|
28664
|
+
return null;
|
|
28665
|
+
const call = `${match[1]}workit${command.slice(match[0].length)}`;
|
|
28666
|
+
const left = segmentsOf(call).some((s) => s.unanalyzable || s.words.some((w) => /^(npx|@workit-dev\/cli(@\S*)?)$/u.test(w)));
|
|
28667
|
+
return left ? null : cwdRewrite(call) ?? verbFirst(call) ?? call;
|
|
28668
|
+
};
|
|
28646
28669
|
var MUTATING_GIT2 = /^git( -\S+| -[Cc] \S+)* (commit|push|add|switch|checkout|merge|rebase|reset|cherry-pick|revert|branch .*(-[dDmM]|--delete|--move)\b|tag (?!-l\b|--list)|stash(?! (list|show)\b))/u;
|
|
28647
28670
|
var cdWorkitSplit = (command) => {
|
|
28648
28671
|
const match = COMPOUND2.exec(command);
|
|
@@ -29109,6 +29132,28 @@ function decide(input, deps) {
|
|
|
29109
29132
|
return withContextLine(text ? { kind: "context", text } : NONE6, promptNudge(input, event.prompt));
|
|
29110
29133
|
}
|
|
29111
29134
|
case "shell.pre": {
|
|
29135
|
+
const npx = npxWorkit(event.command);
|
|
29136
|
+
if (npx && workitOnPath2()) {
|
|
29137
|
+
const canDeny = usable2(descriptor.shellPolicy.deny);
|
|
29138
|
+
const approve = approveCallIn(npx, event.dialect);
|
|
29139
|
+
if (approve && canDeny && (input.host === "claude_code" || input.host === "pi")) {
|
|
29140
|
+
const fix = approve.plain ? `workit approve ${approve.ids.join(" ")}` : approve.fix;
|
|
29141
|
+
return { kind: "deny", reason: approveCallDeny(fix), unblock: fix };
|
|
29142
|
+
}
|
|
29143
|
+
const plain = decide({ ...input, event: { ...event, command: npx } }, deps);
|
|
29144
|
+
if (plain.kind !== "none" && plain.kind !== "context")
|
|
29145
|
+
return plain;
|
|
29146
|
+
if (usable2(descriptor.shellPolicy.rewrite))
|
|
29147
|
+
return {
|
|
29148
|
+
kind: "rewrite",
|
|
29149
|
+
command: npx,
|
|
29150
|
+
input: event.toolInput ? { ...event.toolInput, command: npx } : null,
|
|
29151
|
+
text: plain.kind === "context" ? plain.text : null
|
|
29152
|
+
};
|
|
29153
|
+
if (canDeny)
|
|
29154
|
+
return { kind: "deny", reason: `Run \`${npx}\`: workit is on PATH.`, unblock: npx };
|
|
29155
|
+
return plain;
|
|
29156
|
+
}
|
|
29112
29157
|
const skillRead = skillReadIn(event.command, event.dialect);
|
|
29113
29158
|
if (skillRead)
|
|
29114
29159
|
recordSkillLoad(input, skillRead, "read");
|