@brainervirus/workit-cli 8.5.2 → 8.6.1

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/index.js +37 -12
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -65,7 +65,7 @@ var package_default;
65
65
  var init_package = __esm(() => {
66
66
  package_default = {
67
67
  name: "@brainervirus/workit-cli",
68
- version: "8.5.2",
68
+ version: "8.6.1",
69
69
  private: false,
70
70
  description: "Workit CLI — setup wizard, doctor, and task control for agentic coding workflows",
71
71
  keywords: [
@@ -103,9 +103,9 @@ var init_package = __esm(() => {
103
103
  },
104
104
  dependencies: {
105
105
  "@babel/parser": "7.29.9",
106
- "@brainervirus/workit-core": "^8.5.2",
107
- "@brainervirus/workit-cursor": "^8.5.2",
108
- "@brainervirus/workit-opencode": "^8.5.2",
106
+ "@brainervirus/workit-core": "^8.6.1",
107
+ "@brainervirus/workit-cursor": "^8.6.1",
108
+ "@brainervirus/workit-opencode": "^8.6.1",
109
109
  "@inkjs/ui": "2.0.0",
110
110
  ink: "7.1.1",
111
111
  react: "19.2.8"
@@ -15016,7 +15016,9 @@ function clearStanding(context, input) {
15016
15016
  target: input.target
15017
15017
  }, { now: context.now });
15018
15018
  }
15019
- function dirtyElsewhere(cwd, branch) {
15019
+ function dirtyElsewhere(cwd, branch, head) {
15020
+ if (headSha(cwd) === head)
15021
+ return worktreeTree(cwd)?.dirty !== false;
15020
15022
  const list = git4(cwd, ["worktree", "list", "--porcelain"]);
15021
15023
  let worktree = null;
15022
15024
  for (const line of (list ?? "").split(`
@@ -15051,7 +15053,7 @@ function recordVerdict(context, input) {
15051
15053
  const key = codeKey(context.cwd, { branch, base: context.base });
15052
15054
  if (!key.head)
15053
15055
  return err("not_found", `branch "${branch}" has no commit to judge`);
15054
- if (key.dirty === true || key.dirty === null && dirtyElsewhere(context.cwd, branch))
15056
+ if (key.dirty === true || key.dirty === null && dirtyElsewhere(context.cwd, branch, key.head))
15055
15057
  return err("blocked", `dirty_worktree: ${branch} has uncommitted changes, so its head is not what was judged`, "commit or stash the changes, re-check, then record the verdict");
15056
15058
  const session = context.actor.session;
15057
15059
  const selfReason = input.self === true ? "flag" : session && input.derivedFrom !== null ? null : "no_session";
@@ -72429,6 +72431,23 @@ function patchEquivalent(cwd, branch, tip) {
72429
72431
  `).filter(Boolean) : [];
72430
72432
  return lines.length > 0 && lines.every((line) => line.startsWith("-"));
72431
72433
  }
72434
+ function resolveExpectPrefix(prefix, tips, label) {
72435
+ const known = [...new Set(tips.filter((tip) => typeof tip === "string"))];
72436
+ if (!SHA_PREFIX.test(prefix))
72437
+ return {
72438
+ ok: false,
72439
+ code: "invalid_input",
72440
+ error: "--expect must be a commit sha (full, or an abbreviation of at least 7 hex digits)"
72441
+ };
72442
+ const matches = known.filter((tip) => tip.startsWith(prefix));
72443
+ if (matches.length === 1)
72444
+ return { ok: true, sha: matches[0] };
72445
+ return {
72446
+ ok: false,
72447
+ code: "invalid_input",
72448
+ error: matches.length > 1 ? `--expect ${prefix} is ambiguous for ${label}; choose one of: ${matches.join(", ")}` : `--expect ${prefix} matches no known tip of ${label}${known.length ? `; known: ${known.join(", ")}` : ""}; pass the full sha`
72449
+ };
72450
+ }
72432
72451
  function executePush(cwd, plan, input) {
72433
72452
  const before = remoteRefTip(cwd, plan.rawUrl, `refs/heads/${plan.branch}`);
72434
72453
  if (!before.ok)
@@ -72439,10 +72458,15 @@ function executePush(cwd, plan, input) {
72439
72458
  const args = ["push", "--porcelain", "--no-follow-tags", "--recurse-submodules=no"];
72440
72459
  if (input.forceWithLease) {
72441
72460
  const explicit = input.expect !== undefined && input.expect !== null;
72442
- if (explicit && !SHA.test(input.expect))
72443
- return failure3("invalid_input", "--expect must be a full commit sha");
72461
+ let expectSha = input.expect ?? null;
72462
+ if (explicit && !SHA.test(expectSha)) {
72463
+ const resolved = resolveExpectPrefix(expectSha, [before.sha, recordedRemoteTip(cwd, plan)], `${plan.remote}/${plan.branch}`);
72464
+ if (!resolved.ok)
72465
+ return failure3(resolved.code, resolved.error);
72466
+ expectSha = resolved.sha;
72467
+ }
72444
72468
  const integrate = `git fetch ${plan.remote} ${plan.branch} && git rebase ${plan.remote}/${plan.branch} # or merge it; then: workit git push`;
72445
- const recorded = explicit ? input.expect : recordedRemoteTip(cwd, plan);
72469
+ const recorded = explicit ? expectSha : recordedRemoteTip(cwd, plan);
72446
72470
  if (recorded === undefined && before.sha !== null)
72447
72471
  return failure3("blocked", `lease_unknown: workit has no recorded push of ${plan.branch}, so it cannot tell whose commits ${plan.remote}/${plan.branch} (${before.sha.slice(0, 12)}) holds`, `${integrate} # or, after reviewing that tip: workit git push --force-with-lease --expect <sha you reviewed> (--overwrite-unintegrated only to drop commits you never had)`);
72448
72472
  const expected = recorded ?? null;
@@ -72574,7 +72598,7 @@ ${run.stdout ?? ""}`).split(/\r?\n/u).map((value) => value.trimEnd()).filter((va
72574
72598
  ...lines.slice(-half)
72575
72599
  ].join(`
72576
72600
  `);
72577
- }, validRefName = (cwd, name) => !name.startsWith("-") && git5(cwd, ["check-ref-format", "--branch", name]).ok, nulList = (text) => text.split("\x00").filter(Boolean), SESSION_SAFE, TRAILER_CONFIG, nothingToCommit = (what) => failure3("failed", `nothing_to_commit: ${what}`, "workit git commit --allow-empty -m '<msg>' # only to record an empty commit on purpose"), SHA;
72601
+ }, validRefName = (cwd, name) => !name.startsWith("-") && git5(cwd, ["check-ref-format", "--branch", name]).ok, nulList = (text) => text.split("\x00").filter(Boolean), SESSION_SAFE, TRAILER_CONFIG, nothingToCommit = (what) => failure3("failed", `nothing_to_commit: ${what}`, "workit git commit --allow-empty -m '<msg>' # only to record an empty commit on purpose"), SHA, SHA_PREFIX;
72578
72602
  var init_ops = __esm(() => {
72579
72603
  init_branch();
72580
72604
  init_commit_flavors();
@@ -72588,6 +72612,7 @@ var init_ops = __esm(() => {
72588
72612
  SESSION_SAFE = /^[\w.:@/+-]{1,128}$/u;
72589
72613
  TRAILER_CONFIG = ["-c", "trailer.separators=:", "-c", "trailer.where=end"];
72590
72614
  SHA = /^[0-9a-f]{40,64}$/u;
72615
+ SHA_PREFIX = /^[0-9a-f]{7,39}$/u;
72591
72616
  });
72592
72617
 
72593
72618
  // packages/workit-core/src/forge/reruns.ts
@@ -76894,8 +76919,8 @@ async function push(argv, io) {
76894
76919
  const expect = flags.values.expect ?? null;
76895
76920
  if ((expect !== null || flags.booleans.has("overwrite-unintegrated")) && !flags.booleans.has("force-with-lease"))
76896
76921
  return usage3(io, "--expect and --overwrite-unintegrated only apply with --force-with-lease", PUSH_USAGE);
76897
- if (expect !== null && !/^[0-9a-f]{40,64}$/u.test(expect))
76898
- return usage3(io, "--expect must be a full commit sha", PUSH_USAGE);
76922
+ if (expect !== null && !/^[0-9a-f]{7,64}$/u.test(expect))
76923
+ return usage3(io, "--expect must be a commit sha (at least 7 hex digits)", PUSH_USAGE);
76899
76924
  const plan = pushPreflight(io.cwd);
76900
76925
  if (!plan.ok)
76901
76926
  return forgeFail(io, plan);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainervirus/workit-cli",
3
- "version": "8.5.2",
3
+ "version": "8.6.1",
4
4
  "private": false,
5
5
  "description": "Workit CLI — setup wizard, doctor, and task control for agentic coding workflows",
6
6
  "keywords": [
@@ -38,9 +38,9 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@babel/parser": "7.29.9",
41
- "@brainervirus/workit-core": "^8.5.2",
42
- "@brainervirus/workit-cursor": "^8.5.2",
43
- "@brainervirus/workit-opencode": "^8.5.2",
41
+ "@brainervirus/workit-core": "^8.6.1",
42
+ "@brainervirus/workit-cursor": "^8.6.1",
43
+ "@brainervirus/workit-opencode": "^8.6.1",
44
44
  "@inkjs/ui": "2.0.0",
45
45
  "ink": "7.1.1",
46
46
  "react": "19.2.8"