@brainervirus/workit-opencode 8.19.1 → 8.19.2

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/plugin.js +48 -3
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -23082,7 +23082,7 @@ var canonical2 = (file) => {
23082
23082
  let rest = "";
23083
23083
  for (let dir = path30.resolve(file);; dir = path30.dirname(dir)) {
23084
23084
  try {
23085
- return path30.join(realpathSync6(dir), rest);
23085
+ return path30.join(realpathSync6.native(dir), rest);
23086
23086
  } catch {
23087
23087
  if (path30.dirname(dir) === dir)
23088
23088
  return path30.resolve(file);
@@ -23302,18 +23302,26 @@ var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
23302
23302
  var PUSHD2 = new Set(["pushd", "push-location"]);
23303
23303
  var POPD2 = new Set(["popd", "pop-location"]);
23304
23304
  var cdInto = (dir, words) => {
23305
- const target = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
23305
+ const named = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
23306
+ const target = named === undefined ? undefined : homeExpanded(named);
23306
23307
  if (dir === undefined || target === "-" || target && /^~|[$`*?]/.test(target))
23307
23308
  return;
23308
23309
  return target === undefined ? os10.homedir() : path30.resolve(dir, target);
23309
23310
  };
23310
23311
  var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
23312
+ var homeExpanded = (file) => {
23313
+ const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
23314
+ return match ? (process.env.HOME || os10.homedir()) + file.slice(match[0].length) : file;
23315
+ };
23311
23316
  var segmentTargets = (cwd, command, dialect, depth = 0) => {
23312
23317
  const targets = [];
23313
23318
  let dir = cwd;
23314
23319
  let stack = [];
23315
23320
  const groups = [];
23316
- const at = (file) => path30.isAbsolute(file) ? file : dir === undefined ? null : path30.resolve(dir, file);
23321
+ const at = (file) => {
23322
+ const home = homeExpanded(file);
23323
+ return path30.isAbsolute(home) ? home : dir === undefined ? null : path30.resolve(dir, home);
23324
+ };
23317
23325
  for (const segment of segmentsOf(command, dialect)) {
23318
23326
  if (segment.group === "open") {
23319
23327
  groups.push({ dir, stack: [...stack] });
@@ -23418,7 +23426,39 @@ var claimAll = (owner, targets, deps) => {
23418
23426
  claimLiveSession(target, owner, deps);
23419
23427
  };
23420
23428
  var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path30.resolve(cwd, file)) : [path30.join(cwd, DIR_TARGET)];
23429
+ var issuedTarget = (cwd, targets) => {
23430
+ const state = resolveStateDir();
23431
+ const found = targets.find((target) => underIssued(state, cwd, homeExpanded(target), process.platform, canonical2));
23432
+ return found ?? null;
23433
+ };
23434
+ var underIssued = (state, cwd, target, platform = process.platform, real = (file) => file) => {
23435
+ const win = platform === "win32";
23436
+ const p = win ? path30.win32 : path30.posix;
23437
+ const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
23438
+ const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
23439
+ const relative = p.relative(fold(real(p.resolve(state))), fold(real(p.resolve(cwd, named))));
23440
+ if (relative.startsWith("..") || p.isAbsolute(relative))
23441
+ return false;
23442
+ return relative.split(p.sep)[0].startsWith("issued");
23443
+ };
23444
+ var unquotedWindowsIssued = (command) => {
23445
+ if (process.platform !== "win32" || !command.includes("\\"))
23446
+ return false;
23447
+ const flat = (value) => value.replaceAll("\\", "/").toLowerCase();
23448
+ return flat(command).includes(`${flat(resolveStateDir())}/issued`) && shellWrites(command).writes;
23449
+ };
23450
+ var issuedDeny = (file) => {
23451
+ 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.";
23452
+ return {
23453
+ kind: "deny",
23454
+ reason: `workit issued-registry guard: ${file} is under Workit's issued-session state. ${unblock}`,
23455
+ unblock
23456
+ };
23457
+ };
23421
23458
  function writeGate(cwd, paths, owner, deps) {
23459
+ const forged = paths?.length ? issuedTarget(cwd, paths) : null;
23460
+ if (forged)
23461
+ return issuedDeny(forged);
23422
23462
  if (!owner)
23423
23463
  return beforeWriteGate(cwd, paths);
23424
23464
  const targets = liveTargets(cwd, paths);
@@ -23431,6 +23471,11 @@ function writeGate(cwd, paths, owner, deps) {
23431
23471
  return decision;
23432
23472
  }
23433
23473
  function shellGate(cwd, command, owner, dialect = "posix", deps) {
23474
+ try {
23475
+ const forged = issuedTarget(cwd, segmentTargets(cwd, command, dialect)) ?? (unquotedWindowsIssued(command) ? "the issued registry" : null);
23476
+ if (forged)
23477
+ return issuedDeny(forged);
23478
+ } catch {}
23434
23479
  const writes = shellWrites(command);
23435
23480
  let targets = [];
23436
23481
  if (owner) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainervirus/workit-opencode",
3
- "version": "8.19.1",
3
+ "version": "8.19.2",
4
4
  "private": false,
5
5
  "description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
6
6
  "keywords": [
@@ -39,7 +39,7 @@
39
39
  "typecheck": "tsc --noEmit"
40
40
  },
41
41
  "devDependencies": {
42
- "@brainervirus/workit-core": "^8.19.1",
42
+ "@brainervirus/workit-core": "^8.19.2",
43
43
  "@opencode/plugin": "2.0.18"
44
44
  },
45
45
  "engines": {