@workit-dev/opencode 1.0.3 → 1.1.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.
@@ -41,7 +41,7 @@ the same check. Fix round and recheck both failed: a decider (call the skill too
41
41
  and the stop point unless merge is granted.
42
42
  3. **Conflicts or a required rebase.** Rewrite only a branch this session or
43
43
  its stack created (yours in `workit ledger list --type commit.recorded` or
44
- `workit stack status`): rebase onto the base, `workit git push
44
+ `workit stack status`): `workit git rebase`, then `workit git push
45
45
  --force-with-lease` (`workit stack sync` in a stack). Anyone else's branch:
46
46
  report that a rebase is needed and stop.
47
47
  4. **Review threads** (`workit pr threads`). Check each claim in the code; fix
package/dist/plugin.js CHANGED
@@ -15407,6 +15407,7 @@ var DOC_EXT = /\.(?:md|mdx|markdown|rst|adoc)$/iu;
15407
15407
  var DOC_NAMES = /^(?:license|licence|notice|authors|changelog|changes|contributors)$/iu;
15408
15408
  var INSTRUCTIONS = /(?:^|\/)(?:AGENTS|CLAUDE|GEMINI|SKILL)\.md$|(?:^|\/)(?:skills|agents|commands|rules|prompts)\/[^/]+/iu;
15409
15409
  var TEST_PATH = /(?:^|\/)(?:test|tests|__tests__)\/|\.(?:test|spec)\.[^/]+$|_test\.[^/]+$/iu;
15410
+ var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
15410
15411
  var basename = (file) => file.slice(file.lastIndexOf("/") + 1);
15411
15412
  var isDoc = (file) => !INSTRUCTIONS.test(file) && (DOC_EXT.test(file) || DOC_NAMES.test(basename(file)));
15412
15413
  function kindOf(file) {
@@ -15465,6 +15466,8 @@ function computeLane(input) {
15465
15466
  const behavior = kinds.filter((entry) => entry.kind === "behavior" || entry.kind === "test" || entry.kind === "lockfile");
15466
15467
  const lines = behavior.filter((entry) => entry.kind !== "lockfile").reduce((sum, entry) => sum + entry.file.added + entry.file.deleted, 0);
15467
15468
  const opaque = behavior.filter((entry) => entry.kind === "lockfile" || entry.file.binary);
15469
+ const diffLines = input.files.reduce((sum, file) => sum + file.added + file.deleted, 0);
15470
+ const counted = diffLines === lines && input.files.length === behavior.length ? "" : ` counted (the whole diff is ${plural(diffLines, "line")} in ${plural(input.files.length, "file")}; docs, comments, formatting, generated copies and lockfile lines are not counted)`;
15468
15471
  const result = (lane, reasons) => ({
15469
15472
  lane,
15470
15473
  reasons,
@@ -15484,9 +15487,9 @@ function computeLane(input) {
15484
15487
  input.files.length ? "only docs, comments, formatting or generated copies changed" : "no changes"
15485
15488
  ]);
15486
15489
  if (lines >= fullMinLines)
15487
- return result("full", [`large diff: ${lines} lines (≥ ${fullMinLines})`]);
15490
+ return result("full", [`large diff: ${lines} lines (≥ ${fullMinLines})${counted}`]);
15488
15491
  if (lines > selfMaxLines)
15489
- return result("focused", [`${lines} lines changed (> ${selfMaxLines})`]);
15492
+ return result("focused", [`${lines} lines changed (> ${selfMaxLines})${counted}`]);
15490
15493
  if (behavior.length > selfMaxFiles)
15491
15494
  return result("focused", [`${behavior.length} behavior files changed (> ${selfMaxFiles})`]);
15492
15495
  if (opaque.length)
@@ -15494,7 +15497,7 @@ function computeLane(input) {
15494
15497
  `a lockfile or binary changed: ${opaque.slice(0, 3).map((entry) => entry.file.path).join(", ")}${opaque.length > 3 ? ", …" : ""}`
15495
15498
  ]);
15496
15499
  return result("self", [
15497
- `small change: ${lines} line${lines === 1 ? "" : "s"} in ${behavior.length} file${behavior.length === 1 ? "" : "s"}, no risk path`
15500
+ `small change: ${plural(lines, "line")} in ${plural(behavior.length, "file")}${counted}, no risk path`
15498
15501
  ]);
15499
15502
  }
15500
15503
  function untrackedStat(cwd, file) {
@@ -27191,36 +27194,50 @@ var DESCRIPTORS = {
27191
27194
  pi: PI_DESCRIPTOR
27192
27195
  };
27193
27196
  var workerOfLead = (input) => input.session.agentType === null || workitRole(DESCRIPTORS[input.host], input.session.agentType) !== null;
27194
- var worksFor = (plan, input, branch) => {
27197
+ var worksFor = (plan, input, branches) => {
27195
27198
  const session = input.session.id;
27196
27199
  if (plan.leads.includes(session) && !input.session.agentId)
27197
- return false;
27200
+ return null;
27201
+ if (branches.some((branch) => plan.branches.includes(branch)))
27202
+ return "slice";
27198
27203
  const lead = leadOf2(input);
27199
27204
  if (lead && plan.leads.includes(lead) && workerOfLead(input))
27200
- return true;
27201
- if (plan.leads.some((each) => session.startsWith(`${each}-w-`)))
27202
- return true;
27203
- const current = branch();
27204
- return current !== null && plan.branches.includes(current);
27205
+ return "lead";
27206
+ return plan.leads.some((each) => session.startsWith(`${each}-w-`)) ? "lead" : null;
27207
+ };
27208
+ var agentBranches = (input, rows) => {
27209
+ const { id, agentId } = input.session;
27210
+ const bound = agentId ? rows.findLast((row) => row.type === "worktree.bound" && row.actor.session === id && row.actor.agentId === agentId && typeof row.worktree === "string")?.worktree : undefined;
27211
+ const dirs = typeof bound === "string" ? [input.cwd, bound] : [input.cwd];
27212
+ return dirs.map((dir) => currentBranch(dir)).filter((branch) => !!branch);
27205
27213
  };
27206
27214
  var standingFor = (input, store, rev) => {
27207
27215
  const orders = new Map;
27208
27216
  const ledger = readLedger(input.cwd);
27209
27217
  const rows = ledger.ok ? ledger.value.rows : [];
27210
- let branch;
27211
- const lazyBranch = () => branch === undefined ? branch = currentBranch(input.cwd) : branch;
27212
- for (const plan of readPlans(store))
27213
- if (worksFor(plan, input, lazyBranch))
27214
- for (const row of activeStanding(rows, plan.name, plan.leads.length ? plan.leads : null))
27215
- orders.set(row.id, row);
27216
- return { rev, orders, rows };
27218
+ const branches = agentBranches(input, rows);
27219
+ const matched = readPlans(store).map((plan) => ({
27220
+ plan,
27221
+ how: worksFor(plan, input, branches)
27222
+ }));
27223
+ const tied = matched.some(({ how }) => how === "slice");
27224
+ const plans = matched.filter(({ how }) => tied ? how === "slice" : how !== null);
27225
+ for (const { plan } of plans)
27226
+ for (const row of activeStanding(rows, plan.name, plan.leads.length ? plan.leads : null))
27227
+ orders.set(row.id, row);
27228
+ return {
27229
+ rev,
27230
+ orders,
27231
+ rows,
27232
+ fanouts: new Set(plans.map(({ plan }) => plan.name))
27233
+ };
27217
27234
  };
27218
27235
  var fanoutOf = (row) => typeof row.fanout === "string" ? row.fanout : "?";
27219
27236
  var changedSince = (now, ids) => {
27220
27237
  const known = new Set(ids);
27221
27238
  const added = [...now.orders.values()].filter((row) => !known.has(row.id));
27222
27239
  const byId = new Map(now.rows.map((row) => [row.id, row]));
27223
- const dropped = ids.filter((id) => !now.orders.has(id)).map((id) => byId.get(id)).filter((row) => row !== undefined);
27240
+ const dropped = ids.filter((id) => !now.orders.has(id)).map((id) => byId.get(id)).filter((row) => row !== undefined && now.fanouts.has(fanoutOf(row)));
27224
27241
  if (!added.length && !dropped.length)
27225
27242
  return null;
27226
27243
  const fanouts = [...new Set([...added, ...dropped].map(fanoutOf))].join(", ");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
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.0.3"
44
+ "@workit-dev/core": "^1.1.0"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"