@brainervirus/workit-opencode 8.22.1 → 8.22.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 +53 -18
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -16773,9 +16773,17 @@ var sessionMarkerFile = (input, session, store) => {
16773
16773
  return path18.join(dir, "hooks", `skills-${name}.json`);
16774
16774
  };
16775
16775
  var list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
16776
- var readSessionMarker = (file) => {
16776
+ var EMPTY = { nudged: [], loaded: [], raw: [], stops: [], judges: [] };
16777
+ var readRaw = (file) => {
16777
16778
  try {
16778
- const value = JSON.parse(fs15.readFileSync(file, "utf8"));
16779
+ return fs15.readFileSync(file, "utf8");
16780
+ } catch {
16781
+ return "";
16782
+ }
16783
+ };
16784
+ var parseMarker = (text) => {
16785
+ try {
16786
+ const value = JSON.parse(text);
16779
16787
  return {
16780
16788
  nudged: list2(value.nudged),
16781
16789
  loaded: list2(value.loaded),
@@ -16784,13 +16792,36 @@ var readSessionMarker = (file) => {
16784
16792
  judges: list2(value.judges)
16785
16793
  };
16786
16794
  } catch {
16787
- return { nudged: [], loaded: [], raw: [], stops: [], judges: [] };
16795
+ return { ...EMPTY };
16796
+ }
16797
+ };
16798
+ var readSessionMarker = (file) => parseMarker(readRaw(file));
16799
+ var writeAtomic = (file, marker) => {
16800
+ fs15.mkdirSync(path18.dirname(file), { recursive: true });
16801
+ const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
16802
+ try {
16803
+ fs15.writeFileSync(temp, JSON.stringify(marker));
16804
+ fs15.renameSync(temp, file);
16805
+ } catch (error) {
16806
+ fs15.rmSync(temp, { force: true });
16807
+ throw error;
16788
16808
  }
16789
16809
  };
16790
16810
  var writeSessionMarker = (file, marker) => {
16791
16811
  try {
16792
- fs15.mkdirSync(path18.dirname(file), { recursive: true });
16793
- fs15.writeFileSync(file, JSON.stringify(marker));
16812
+ writeAtomic(file, marker);
16813
+ } catch {}
16814
+ };
16815
+ var updateSessionMarker = (file, change) => {
16816
+ try {
16817
+ for (let attempt = 0;attempt < 2; attempt++) {
16818
+ const before = readRaw(file);
16819
+ const next = change(parseMarker(before));
16820
+ if (attempt === 0 && readRaw(file) !== before)
16821
+ continue;
16822
+ writeAtomic(file, next);
16823
+ return;
16824
+ }
16794
16825
  } catch {}
16795
16826
  };
16796
16827
 
@@ -18440,8 +18471,8 @@ var offPolicyPush = (action, repo, facts, remote) => {
18440
18471
  var nudgeFor = (action, host, session) => {
18441
18472
  switch (action.kind) {
18442
18473
  case "commit": {
18443
- const prefix = host === "cursor" && session ? `WORKIT_SESSION_ID=${session} ` : "";
18444
- return action.amend ? `workit: raw ${quote("git commit --amend")} is recorded for this session; for new commits prefer ${quote(`${prefix}workit git commit -m '<msg>'`)} (adds the Workit-Session trailer and checks branch and commit policy).` : `workit: prefer ${quote(`${prefix}workit git commit -m '<msg>' [--all | -- <paths>]`)}: it adds the Workit-Session trailer and checks branch and commit policy.`;
18474
+ const workit = host === "cursor" && session ? `workit --session ${session}` : "workit";
18475
+ return action.amend ? `workit: raw ${quote("git commit --amend")} is recorded for this session; for new commits prefer ${quote(`${workit} git commit -m '<msg>'`)} (adds the Workit-Session trailer and checks branch and commit policy).` : `workit: prefer ${quote(`${workit} git commit -m '<msg>' [--all | -- <paths>]`)}: it adds the Workit-Session trailer and checks branch and commit policy.`;
18445
18476
  }
18446
18477
  case "push":
18447
18478
  return action.blindForce ? `workit: ${quote("git push --force")} overwrites without a lease; use ${quote("workit git push --force-with-lease")}.` : `workit: prefer ${quote("workit git push")}: it refuses protected branches and verifies the remote tip.`;
@@ -22162,7 +22193,7 @@ var shellPolicy = (cwd, command, dialect = "posix") => {
22162
22193
  import fs19 from "node:fs";
22163
22194
  import os6 from "node:os";
22164
22195
  import path27 from "node:path";
22165
- var EMPTY = () => ({ deny: [], allow: [] });
22196
+ var EMPTY2 = () => ({ deny: [], allow: [] });
22166
22197
  var readText2 = (file) => {
22167
22198
  try {
22168
22199
  return fs19.readFileSync(file, "utf8");
@@ -22239,7 +22270,7 @@ var bashPattern = (entry) => {
22239
22270
  return match ? match[1] ?? "" : null;
22240
22271
  };
22241
22272
  function claudeRules(cwd, env = process.env) {
22242
- const rules = EMPTY();
22273
+ const rules = EMPTY2();
22243
22274
  try {
22244
22275
  for (const file of claudeSettingsFiles(cwd, env)) {
22245
22276
  const text = readText2(file);
@@ -22319,7 +22350,7 @@ var opencodeConfig = (value, rules) => {
22319
22350
  return Object.values(value.agent).every((agent) => isRecord4(agent) && opencodePermission(agent.permission, rules));
22320
22351
  };
22321
22352
  function opencodeRules(cwd, env = process.env) {
22322
- const rules = EMPTY();
22353
+ const rules = EMPTY2();
22323
22354
  try {
22324
22355
  const config = env.XDG_CONFIG_HOME || path27.join(homeOf(env), ".config");
22325
22356
  const files = [
@@ -22366,7 +22397,7 @@ var codexRule = (body) => {
22366
22397
  return { pattern: words.join(" "), decision };
22367
22398
  };
22368
22399
  function codexRules(cwd, env = process.env) {
22369
- const rules = EMPTY();
22400
+ const rules = EMPTY2();
22370
22401
  try {
22371
22402
  const home = env.CODEX_HOME || path27.join(homeOf(env), ".codex");
22372
22403
  const top = gitTop(cwd) ?? cwd;
@@ -22395,7 +22426,7 @@ function codexRules(cwd, env = process.env) {
22395
22426
  return rules;
22396
22427
  }
22397
22428
  function cursorRules(cwd, env = process.env) {
22398
- const rules = EMPTY();
22429
+ const rules = EMPTY2();
22399
22430
  try {
22400
22431
  const top = gitTop(cwd) ?? cwd;
22401
22432
  for (const file of [
@@ -23712,25 +23743,29 @@ var redChecks = (rows, pr, head, endpoint) => {
23712
23743
  reason: `PR #${pr}'s checks were last seen ${state} at ${short(head)}, and this workspace's endpoint is \`${endpoint}\`: run \`workit ci wait --pr ${pr}\`${state === "failing" ? " after fixing the failures `workit pr status` lists (then push)" : ""}.`
23713
23744
  };
23714
23745
  };
23715
- var highRisk = (cwd) => {
23746
+ var taskJudgment = (cwd) => {
23716
23747
  try {
23717
23748
  const store = new TaskStore(cwd);
23718
23749
  const listed = store.listTaskIndex();
23719
23750
  const key = store.currentKey();
23720
23751
  if (!listed.ok || !key.ok)
23721
- return false;
23752
+ return null;
23722
23753
  const entry = listed.data.filter((item) => item.key === key.data.key && item.status !== "closed").toSorted((left, right) => right.updatedAt.localeCompare(left.updatedAt))[0];
23723
23754
  const task = entry ? store.readTask(entry.id) : null;
23724
- return task?.ok === true && latestJudgment(task.data)?.riskTier === "high";
23755
+ return task?.ok === true ? latestJudgment(task.data) : null;
23725
23756
  } catch {
23726
- return false;
23757
+ return null;
23727
23758
  }
23728
23759
  };
23729
23760
  var unverified = (cwd, branch, all, descriptor, verification) => {
23730
23761
  const check = checkVerdicts(cwd, branch, all);
23731
23762
  if (check.accepted.accepted || check.accepted.reasons.includes("failing_verdict"))
23732
23763
  return null;
23733
- const independent = verification === "independent" || highRisk(cwd);
23764
+ const judgment = taskJudgment(cwd);
23765
+ const high = judgment?.riskTier === "high";
23766
+ if (judgment && !judgment.behaviorChange && !high)
23767
+ return null;
23768
+ const independent = verification === "independent" || high;
23734
23769
  if (!independent && check.review === "self-reviewed")
23735
23770
  return null;
23736
23771
  const has = check.review === "self-reviewed" ? "only a self verdict" : "no current verdict";
@@ -23801,7 +23836,7 @@ function stopDecision(input, descriptor) {
23801
23836
  if (file && marker) {
23802
23837
  if (marker.stops.includes(key))
23803
23838
  return NONE4;
23804
- writeSessionMarker(file, { ...marker, stops: [...marker.stops, key] });
23839
+ updateSessionMarker(file, (fresh) => ({ ...fresh, stops: [...fresh.stops, key] }));
23805
23840
  }
23806
23841
  return {
23807
23842
  kind: "continue",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainervirus/workit-opencode",
3
- "version": "8.22.1",
3
+ "version": "8.22.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.22.1",
42
+ "@brainervirus/workit-core": "^8.22.2",
43
43
  "@opencode/plugin": "2.0.18"
44
44
  },
45
45
  "engines": {