@tablation/crew 0.165.1 → 0.165.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.
package/dist/cli.js CHANGED
@@ -22022,9 +22022,29 @@ async function applyMergeStamp(tracker, merged, tickets, emit, dryRun, cwd) {
22022
22022
  }
22023
22023
  return stamped;
22024
22024
  }
22025
- async function applyStamp(tracker, plan, version, contract, emit, dryRun, cwd) {
22025
+ var RELEASE_CLAIMED_EVENT = "release_claimed";
22026
+ async function priorAssignees(tracker, plan, seat, contract, emit) {
22027
+ const out = /* @__PURE__ */ new Map();
22028
+ if (!plan.length) return out;
22029
+ try {
22030
+ const fresh = await tracker.ticketsByIds(plan.map((p) => p.ticket.id));
22031
+ const held = fresh.filter((t) => t[contract.columns.assignee] === seat);
22032
+ if (!held.length) return out;
22033
+ const events = await tracker.events(RELEASE_CLAIMED_EVENT);
22034
+ for (const t of held) {
22035
+ const e = events.find((x) => x.record_id === t.id);
22036
+ const prior = e?.metadata?.prior_assignee;
22037
+ out.set(t.id, typeof prior === "string" && prior !== seat ? prior : null);
22038
+ }
22039
+ } catch (e) {
22040
+ emit.warn(`could not read who held the tickets before the release: ${e.message}`);
22041
+ }
22042
+ return out;
22043
+ }
22044
+ async function applyStamp(tracker, plan, version, contract, emit, dryRun, cwd, seat) {
22026
22045
  let stamped = 0;
22027
22046
  const at = (/* @__PURE__ */ new Date()).toISOString();
22047
+ const priorAssignee = !dryRun && seat ? await priorAssignees(tracker, plan, seat, contract, emit) : /* @__PURE__ */ new Map();
22028
22048
  for (const { ticket, sha } of plan) {
22029
22049
  const shaNote = sha ? `, commit_sha ${sha.slice(0, 8)}` : "";
22030
22050
  if (dryRun) {
@@ -22038,6 +22058,7 @@ async function applyStamp(tracker, plan, version, contract, emit, dryRun, cwd) {
22038
22058
  try {
22039
22059
  await tracker.updateTicket(ticket.id, {
22040
22060
  status: contract.statuses.deployed,
22061
+ ...priorAssignee.has(ticket.id) ? { [contract.columns.assignee]: priorAssignee.get(ticket.id) ?? null } : {},
22041
22062
  // `released_at` is always a real release moment here; only the version is optional (versioning: none).
22042
22063
  released_at: at,
22043
22064
  ...version ? { released_version: version } : {},
@@ -23308,7 +23329,21 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
23308
23329
  }
23309
23330
  continue;
23310
23331
  }
23332
+ if (o.onClaim && !o.dryRun) {
23333
+ try {
23334
+ await o.onClaim(c.ticket);
23335
+ } catch (e) {
23336
+ o.emit.warn(`could not assign the ticket to the release seat: ${e.message}`, { ticket: c.ticket.issue_id });
23337
+ }
23338
+ }
23311
23339
  const r = mergeOne(o, c);
23340
+ if (o.onUnclaim && !o.dryRun && typeof r === "object" && ("conflict" in r || "error" in r)) {
23341
+ try {
23342
+ await o.onUnclaim(c.ticket);
23343
+ } catch (e) {
23344
+ o.emit.warn(`could not hand the ticket back from the release seat: ${e.message}`, { ticket: c.ticket.issue_id });
23345
+ }
23346
+ }
23312
23347
  if (typeof r === "object" && "conflict" in r) {
23313
23348
  conflicts.push(r.conflict);
23314
23349
  continue;
@@ -28023,8 +28058,9 @@ import { existsSync as existsSync52, readFileSync as readFileSync50 } from "fs";
28023
28058
  import { join as join56 } from "path";
28024
28059
  var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
28025
28060
  function personaAvatarFile(promptsDir, role) {
28061
+ const stem = role === "release" ? "release-agent" : `lane-${role}`;
28026
28062
  for (const ext of ["png", "svg"]) {
28027
- const name = `lane-${role}.${ext}`;
28063
+ const name = `${stem}.${ext}`;
28028
28064
  const path = join56(promptsDir, "personas", name);
28029
28065
  if (existsSync52(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
28030
28066
  }
@@ -28034,9 +28070,12 @@ async function syncPersonaAvatars(route2, agentPersonas, opts) {
28034
28070
  if (!route2.resolved) return [];
28035
28071
  const base = `${route2.baseUrl.replace(/\/+$/, "")}/api/workspaces/${route2.resolved.workspaceId}/agents/personas`;
28036
28072
  const outcomes = [];
28037
- for (const role of ROLE_NAMES) {
28073
+ const targets = [
28074
+ ...ROLE_NAMES.map((role) => ({ role, agentId: agentPersonas[role]?.agentId })),
28075
+ { role: "release", agentId: opts.releaseAgentId }
28076
+ ];
28077
+ for (const { role, agentId } of targets) {
28038
28078
  const file = personaAvatarFile(route2.promptsDir, role);
28039
- const agentId = agentPersonas[role]?.agentId;
28040
28079
  if (!file || !agentId) continue;
28041
28080
  try {
28042
28081
  const form = new FormData();
@@ -28124,8 +28163,8 @@ async function runAgentsSync(target, o) {
28124
28163
  for (const w of skillResult?.warnings ?? []) o.warn(`warning: ${w}`);
28125
28164
  const avatarFailures2 = {};
28126
28165
  if (!readOnly2 && !dryRun) {
28127
- for (const a of await syncPersonaAvatars(target, personaResult.agentPersonas, { userAgent: o.userAgent })) {
28128
- const line = describeAvatarOutcome(a, PERSONA_NAME[a.role]);
28166
+ for (const a of await syncPersonaAvatars(target, personaResult.agentPersonas, { userAgent: o.userAgent, releaseAgentId: personaResult.releaseAgentId })) {
28167
+ const line = describeAvatarOutcome(a, a.role === "release" ? RELEASE_AGENT_NAME : PERSONA_NAME[a.role]);
28129
28168
  if (a.status === "failed") {
28130
28169
  o.warn(`warning: ${line}`);
28131
28170
  avatarFailures2[a.role] = a.detail ?? "unknown error";
@@ -29548,7 +29587,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
29548
29587
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
29549
29588
  import { join as join61 } from "path";
29550
29589
  function builtVersion() {
29551
- return true ? "0.165.1" : null;
29590
+ return true ? "0.165.2" : null;
29552
29591
  }
29553
29592
  var REBUILD_HINT = "rebuild with npm run build";
29554
29593
  function newestMtime(path) {
@@ -33327,6 +33366,7 @@ ${changed2.map((c) => ` - ${c}
33327
33366
  remit.warn(`could not read hand-back events; not deferring any branch: ${e.message}`);
33328
33367
  }
33329
33368
  }
33369
+ const claimed = /* @__PURE__ */ new Map();
33330
33370
  const outcome = await runRelease({
33331
33371
  cwd: target.dir,
33332
33372
  repo,
@@ -33368,6 +33408,20 @@ ${changed2.map((c) => ` - ${c}
33368
33408
  mergeOnly: command === "merge",
33369
33409
  // ci_* modes: record the merge on the board when it lands on base,
33370
33410
  // not only once CI confirms the release live (CREW-2820).
33411
+ // CREW-3811: the release seat holds a ticket while it merges and ships it.
33412
+ onClaim: async (ticket) => {
33413
+ const seat = releaseSeat(c);
33414
+ if (!seat || ticket.assignee_id === seat) return;
33415
+ const prior = ticket.assignee_id ?? null;
33416
+ await tracker.postEvent(ticket.id, "release took the ticket while it merges and ships it", seat, RELEASE_CLAIMED_EVENT, { prior_assignee: prior });
33417
+ claimed.set(ticket.id, prior);
33418
+ await tracker.updateTicket(ticket.id, { [tracker.contract.columns.assignee]: seat });
33419
+ },
33420
+ onUnclaim: async (ticket) => {
33421
+ if (!claimed.has(ticket.id)) return;
33422
+ await tracker.updateTicket(ticket.id, { [tracker.contract.columns.assignee]: claimed.get(ticket.id) ?? null });
33423
+ claimed.delete(ticket.id);
33424
+ },
33371
33425
  onBasePushed: async (merged) => {
33372
33426
  remit.enter("reconcile");
33373
33427
  await applyMergeStamp(
@@ -33406,7 +33460,7 @@ ${changed2.map((c) => ` - ${c}
33406
33460
  ...outcome.merged.map((m) => [m.ticket.issue_id, m.sha])
33407
33461
  ])
33408
33462
  );
33409
- if (plan.length) await applyStamp(tracker, plan, outcome.version, tracker.contract, remit, dryRun, target.dir);
33463
+ if (plan.length) await applyStamp(tracker, plan, outcome.version, tracker.contract, remit, dryRun, target.dir, releaseSeat(c));
33410
33464
  } else if (outcome.stopped) {
33411
33465
  remit.emit(`nothing stamped \u2014 ${outcome.stopped}`);
33412
33466
  }
@@ -33422,7 +33476,8 @@ ${changed2.map((c) => ` - ${c}
33422
33476
  tracker.contract,
33423
33477
  remit,
33424
33478
  dryRun,
33425
- target.dir
33479
+ target.dir,
33480
+ releaseSeat(c)
33426
33481
  );
33427
33482
  }
33428
33483
  for (const r of planReleasedBranches(
@@ -33441,7 +33496,8 @@ ${changed2.map((c) => ` - ${c}
33441
33496
  tracker.contract,
33442
33497
  remit,
33443
33498
  dryRun,
33444
- target.dir
33499
+ target.dir,
33500
+ releaseSeat(c)
33445
33501
  );
33446
33502
  }
33447
33503
  if (outcome.gateRed && !dryRun) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.165.1",
3
+ "version": "0.165.2",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",