@workit-dev/pi 1.7.4 → 1.8.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.
Files changed (2) hide show
  1. package/dist/workit.js +27 -13
  2. 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 registry = underRegistry(state, cwd, homeExpanded(target), process.platform, canonical3);
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 underRegistry = (state, cwd, target, platform = process.platform, real = (file) => file) => {
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(state))), fold(real(p.resolve(cwd, named))));
26619
- if (relative.startsWith("..") || p.isAbsolute(relative))
26620
- return null;
26621
- const first = relative.split(p.sep)[0];
26622
- if (first.startsWith("issued"))
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 unquotedWindowsRegistry = (command) => {
26627
- if (process.platform !== "win32" || !command.includes("\\"))
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 Workit's ${what}. ${unblock}`,
26664
+ reason: `workit ${label}: ${file} is under ${what}. ${unblock}`,
26651
26665
  unblock
26652
26666
  };
26653
26667
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "1.7.4",
3
+ "version": "1.8.0",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",