@workit-dev/opencode 1.14.2 → 1.14.3

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 +49 -1
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -24871,8 +24871,18 @@ var WORKIT_USER_ONLY = [
24871
24871
  ["grant", "set"],
24872
24872
  ["grant", "raise"],
24873
24873
  ["ledger", "void"],
24874
- ["approve"]
24874
+ ["approve"],
24875
+ ["setup"],
24876
+ ["uninstall"],
24877
+ ["install"],
24878
+ ["workspace", "seal"]
24875
24879
  ];
24880
+ var USER_ONLY_WORD = new RegExp(`\\b(?:${[...new Set(WORKIT_USER_ONLY.map((words) => words[0]))].join("|")})\\b`);
24881
+ var mayRunUserOnly = (text) => {
24882
+ const joined = text.replace(/\\\r?\n/g, "");
24883
+ const bare = joined.replace(/['"\\]/g, "");
24884
+ return [bare, bare.replace(/`/g, "")].some((all) => /\bworkit\b/.test(all) && (USER_ONLY_WORD.test(all) || /\$['"]/.test(joined)));
24885
+ };
24876
24886
  var ALLOWED = new Set(WORKIT_ALLOWED_VERBS);
24877
24887
  var hasWordsInOrder = (words, needle) => {
24878
24888
  let at = 0;
@@ -24882,6 +24892,7 @@ var hasWordsInOrder = (words, needle) => {
24882
24892
  return false;
24883
24893
  };
24884
24894
  var isBypass = (word) => WORKIT_BYPASS_FLAGS.some((flag) => word === flag || word.startsWith(`${flag}=`));
24895
+ var isWorkitWord = (word) => /^(?:.*[\\/])?workit(?:-cli)?$/u.test(word);
24885
24896
  var isAllowedWorkitCall = (words, expands = []) => {
24886
24897
  if (words[0] !== "workit")
24887
24898
  return false;
@@ -24911,6 +24922,37 @@ var isAllowedWorkitCall = (words, expands = []) => {
24911
24922
  return false;
24912
24923
  return !words.slice(0, limit).some(isBypass) && !expands.some((index) => index < limit);
24913
24924
  };
24925
+ var userOnlyWorkitCall = (command, dialect = "posix") => {
24926
+ if (!mayRunUserOnly(command))
24927
+ return null;
24928
+ for (const segment of segmentsOf(command, dialect)) {
24929
+ if (segment.unanalyzable)
24930
+ continue;
24931
+ const start = segment.words.findIndex(isWorkitWord);
24932
+ if (start < 0)
24933
+ continue;
24934
+ const words = segment.words.slice(start + 1);
24935
+ const end = words.indexOf("--");
24936
+ const args = end < 0 ? words : words.slice(0, end);
24937
+ let at = 0;
24938
+ for (;; ) {
24939
+ const word = args[at];
24940
+ if (word === "--json")
24941
+ at += 1;
24942
+ else if (word === "--cwd" || word === "--session")
24943
+ at += 2;
24944
+ else if (word?.startsWith("--cwd="))
24945
+ at += 1;
24946
+ else
24947
+ break;
24948
+ }
24949
+ const call = args.slice(at);
24950
+ const found = WORKIT_USER_ONLY.find((needle) => call[0] === needle[0] && hasWordsInOrder(call, needle));
24951
+ if (found)
24952
+ return [...found];
24953
+ }
24954
+ return null;
24955
+ };
24914
24956
  var isAllowedWorkitCommand = (command) => {
24915
24957
  const segments = segmentsOf(command);
24916
24958
  return segments.length > 0 && segments.every((s) => !s.unanalyzable && !s.group && !s.subs?.length && !s.stdin?.length && !s.redirects.length && isAllowedWorkitCall(s.words, s.expands));
@@ -31271,6 +31313,12 @@ var evaluateShellPermission = (root, event, workdirs = new Map) => {
31271
31313
  return deny(plan.reason);
31272
31314
  }
31273
31315
  }
31316
+ const userOnly = resources.map((resource) => userOnlyWorkitCall(resource, "posix")).find(Boolean);
31317
+ if (userOnly) {
31318
+ event.effect = "ask";
31319
+ event.message = `Only the user runs \`workit ${userOnly.join(" ")}\`: the user decides this call.`;
31320
+ return;
31321
+ }
31274
31322
  if (event.effect === "ask" && resources.length > 0 && resources.length === event.resources.length && resources.every(isAllowedWorkitCommand))
31275
31323
  event.effect = "allow";
31276
31324
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "1.14.2",
3
+ "version": "1.14.3",
4
4
  "private": false,
5
5
  "description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
6
6
  "keywords": [
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@opencode/plugin": "2.0.18",
44
- "@workit-dev/core": "^1.14.2"
44
+ "@workit-dev/core": "^1.14.3"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"