@tablation/crew 0.147.0 → 0.149.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.
package/crew.example.yaml CHANGED
@@ -132,6 +132,11 @@ routes:
132
132
  # dev/design/QA policy this repo ships with) when omitted. See
133
133
  # prompts/default/ for the shape a custom set needs to have.
134
134
  # promptSet: "dev-qa"
135
+ # Roles whose run start marks the ticket's optional `crew_assisted` Yes/No
136
+ # column true (CREW-3258): a record that the crew's building or verifying
137
+ # lane worked it. Defaults to [dev, qa]; [] turns the marking off for this
138
+ # route. Ignored on a workspace whose Issues table lacks the column.
139
+ # assistedRoles: [dev, qa]
135
140
  # What a host must be to build a repo lives in THAT repo's own .crew.yaml
136
141
  # (any | unix | macos | linux | windows) — never here. A route can span
137
142
  # repos with different needs; the ship refuses a route only when it can
package/dist/cli.js CHANGED
@@ -1185,6 +1185,11 @@ function render(e) {
1185
1185
  const level = e.level === "info" ? "" : `${e.level.toUpperCase()}: `;
1186
1186
  return `${e.at} ${scope}:${ticket} ${level}${e.message}`;
1187
1187
  }
1188
+ function renderPlain(e) {
1189
+ const level = e.level === "info" ? "" : `${e.level === "warn" ? "warning" : e.level}: `;
1190
+ const ticket = e.ticket ? `${e.ticket}: ` : "";
1191
+ return `${level}${ticket}${e.message}`;
1192
+ }
1188
1193
  var DEFAULT_EVENTS_ROTATE_BYTES = 64 * 1024 * 1024;
1189
1194
  var ROTATED_EVENTS_RE = /^events\.\d{8}T\d{6}Z(?:-\d+)?\.jsonl$/;
1190
1195
  var ROTATE_LOCK_STALE_MS = 6e4;
@@ -1254,7 +1259,8 @@ var Emitter = class _Emitter {
1254
1259
  message,
1255
1260
  ...extra.role ?? this.role ? { role: extra.role ?? this.role } : {},
1256
1261
  ...extra.ticket ? { ticket: extra.ticket } : {},
1257
- ...extra.data ? { data: extra.data } : {}
1262
+ ...extra.data ? { data: extra.data } : {},
1263
+ ...extra.routine ? { routine: true } : {}
1258
1264
  };
1259
1265
  const line = render(e);
1260
1266
  try {
@@ -1271,13 +1277,19 @@ var Emitter = class _Emitter {
1271
1277
  `);
1272
1278
  } catch {
1273
1279
  }
1274
- try {
1275
- (this.opts.console ?? ((l) => process.stderr.write(`${l}
1276
- `)))(line);
1277
- } catch {
1280
+ if (!e.routine || this.opts.verbose) {
1281
+ try {
1282
+ (this.opts.console ?? ((l) => process.stderr.write(`${l}
1283
+ `)))(this.opts.plain ? renderPlain(e) : line);
1284
+ } catch {
1285
+ }
1278
1286
  }
1279
1287
  return e;
1280
1288
  }
1289
+ /** Routine progress: logged, but shown on the console only under `--verbose`. */
1290
+ note(message, extra = {}) {
1291
+ return this.emit(message, { ...extra, routine: true });
1292
+ }
1281
1293
  warn(message, extra = {}) {
1282
1294
  return this.emit(message, { ...extra, level: "warn" });
1283
1295
  }
@@ -4020,6 +4032,7 @@ var ROLE_LABEL = {
4020
4032
  triage: "Triage",
4021
4033
  pair: "Pair"
4022
4034
  };
4035
+ var DEFAULT_ASSISTED_ROLES = ["dev", "qa"];
4023
4036
  var ConfigError = class extends Error {
4024
4037
  };
4025
4038
  var DEFAULT_MAX_PERISCOPES = 3;
@@ -4150,7 +4163,8 @@ var ROUTE_KEYS = /* @__PURE__ */ new Set([
4150
4163
  "hostPassengers",
4151
4164
  "hostPeriscopes",
4152
4165
  "toolchain",
4153
- "maxRunMinutes"
4166
+ "maxRunMinutes",
4167
+ "assistedRoles"
4154
4168
  ]);
4155
4169
  function parseWorktreeName(v, where, file) {
4156
4170
  const problem = typeof v === "string" ? worktreeNameProblem(v) : "must be a string";
@@ -4602,6 +4616,22 @@ function parseMaxRunMinutes(raw, where, missing) {
4602
4616
  }
4603
4617
  return n;
4604
4618
  }
4619
+ function parseAssistedRoles(raw, where, missing) {
4620
+ if (raw === void 0) return void 0;
4621
+ if (!Array.isArray(raw)) {
4622
+ missing.add(`${where} must be a list of roles (expected any of ${ROLE_NAMES.join(", ")}), [] to turn the marking off`);
4623
+ return void 0;
4624
+ }
4625
+ const out = [];
4626
+ for (const r of raw) {
4627
+ if (!ROLE_NAMES.includes(String(r))) {
4628
+ missing.add(`${where} has "${String(r)}", which is not a role (expected any of ${ROLE_NAMES.join(", ")})`);
4629
+ continue;
4630
+ }
4631
+ if (!out.includes(r)) out.push(r);
4632
+ }
4633
+ return out;
4634
+ }
4605
4635
  function parsePair(raw, missing) {
4606
4636
  if (raw === void 0) return void 0;
4607
4637
  if (!Array.isArray(raw)) {
@@ -4690,6 +4720,7 @@ function parseOneRoute(c, where, file, base, stateDir, raw, missing, crewHome, t
4690
4720
  rejectUnknownKeys(c, ROUTE_KEYS, `${where}`, file);
4691
4721
  const toolchain = c?.toolchain === void 0 ? void 0 : String(c.toolchain);
4692
4722
  const maxRunMinutes = parseMaxRunMinutes(c?.maxRunMinutes, `${where}.maxRunMinutes`, missing);
4723
+ const assistedRoles = parseAssistedRoles(c?.assistedRoles, `${where}.assistedRoles`, missing);
4693
4724
  if (toolchain !== void 0 && !toolchainNames.has(toolchain)) {
4694
4725
  missing.add(`${where}.toolchain "${toolchain}" is not defined in ship.toolchains (have: ${[...toolchainNames].join(", ")})`);
4695
4726
  }
@@ -4754,6 +4785,7 @@ function parseOneRoute(c, where, file, base, stateDir, raw, missing, crewHome, t
4754
4785
  worktreePrefix: c?.worktreePrefix ? String(c.worktreePrefix) : void 0,
4755
4786
  ...toolchain !== void 0 ? { toolchain } : {},
4756
4787
  ...maxRunMinutes !== void 0 ? { maxRunMinutes } : {},
4788
+ ...assistedRoles !== void 0 ? { assistedRoles } : {},
4757
4789
  promptsDir: resolvePromptsDir(c?.promptSet ? String(c.promptSet) : void 0, crewHome, base),
4758
4790
  weight,
4759
4791
  baseUrl: String(c?.baseUrl ?? raw.ship?.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, ""),
@@ -8776,7 +8808,8 @@ var DEFAULT_CONTRACT = {
8776
8808
  tokensOut: "tokens_out",
8777
8809
  cacheReadTokens: "cache_read_tokens",
8778
8810
  cacheWriteTokens: "cache_write_tokens",
8779
- costUsd: "cost_usd"
8811
+ costUsd: "cost_usd",
8812
+ crewAssisted: "crew_assisted"
8780
8813
  },
8781
8814
  comments: {
8782
8815
  parent: "ticket_id",
@@ -9171,6 +9204,7 @@ var Tracker = class {
9171
9204
  * so concurrent first writes share one round of field-metadata reads.
9172
9205
  */
9173
9206
  authorship;
9207
+ crewAssistedColumn;
9174
9208
  attachments;
9175
9209
  stateDir;
9176
9210
  /**
@@ -9817,6 +9851,11 @@ var Tracker = class {
9817
9851
  shipId: auth.shipId
9818
9852
  };
9819
9853
  }
9854
+ /** Whether Issues carries the optional `crew_assisted` column (CREW-3258). */
9855
+ async hasCrewAssistedColumn() {
9856
+ this.crewAssistedColumn ??= this.columnNames(this.models.issues).then((f) => f.has(this.contract.columns.crewAssisted));
9857
+ return this.crewAssistedColumn;
9858
+ }
9820
9859
  /**
9821
9860
  * Which of the optional review columns (`verified_sha`, `pr_ref`) the Issues
9822
9861
  * table carries. A table without them has not adopted the review hand-off:
@@ -19154,6 +19193,27 @@ async function claimStillHeld(tracker, t, buildingStatus, affinity) {
19154
19193
  return null;
19155
19194
  }
19156
19195
 
19196
+ // src/crew-assisted.ts
19197
+ function countsAsAssisted(route2, role) {
19198
+ return (route2.assistedRoles ?? DEFAULT_ASSISTED_ROLES).includes(role);
19199
+ }
19200
+ async function markCrewAssisted(tracker, route2, role, ticket) {
19201
+ if (!countsAsAssisted(route2, role)) return false;
19202
+ const column = tracker.contract.columns.crewAssisted;
19203
+ if (ticket[column] === true) return false;
19204
+ if (!await tracker.hasCrewAssistedColumn()) return false;
19205
+ await tracker.updateTicket(ticket.id, { [column]: true });
19206
+ return true;
19207
+ }
19208
+ async function markCrewAssistedAtLaunch(tracker, route2, role, ticketId, ticket, warn) {
19209
+ if (!ticketId || !countsAsAssisted(route2, role)) return;
19210
+ try {
19211
+ await markCrewAssisted(tracker, route2, role, ticket ?? await tracker.ticket(ticketId));
19212
+ } catch (e) {
19213
+ warn(`could not mark the ticket crew-assisted: ${e.message}`);
19214
+ }
19215
+ }
19216
+
19157
19217
  // src/repo-refresh.ts
19158
19218
  import { existsSync as existsSync40, mkdirSync as mkdirSync28, readFileSync as readFileSync40, writeFileSync as writeFileSync32 } from "fs";
19159
19219
  import { dirname as dirname22 } from "path";
@@ -23849,6 +23909,7 @@ async function runRoleAgentLocked(role, decision, ctx, hooks, held) {
23849
23909
  if (workingId) {
23850
23910
  try {
23851
23911
  const before = await tracker.ticket(workingId);
23912
+ await markCrewAssistedAtLaunch(tracker, route2, role, workingId, before, (m) => emit.warn(m, { step: "agent" }));
23852
23913
  const col = tracker.contract.columns;
23853
23914
  const tipBefore = branchProgress(route2, before);
23854
23915
  if (role === "dev" || role === "design") {
@@ -26727,7 +26788,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
26727
26788
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
26728
26789
  import { join as join58 } from "path";
26729
26790
  function builtVersion() {
26730
- return true ? "0.147.0" : null;
26791
+ return true ? "0.149.0" : null;
26731
26792
  }
26732
26793
  var REBUILD_HINT = "rebuild with npm run build";
26733
26794
  function newestMtime(path) {
@@ -29487,7 +29548,12 @@ if (command === "passenger-sync-daemon") {
29487
29548
  rotateBytes: cfg.ship.eventsRotateBytes,
29488
29549
  logFile: dryRun ? void 0 : cfg.ship.logFile,
29489
29550
  console: (l) => process.stderr.write(`${l}
29490
- `)
29551
+ `),
29552
+ // CREW-3266: a person at a terminal gets terse, untimestamped lines and routine
29553
+ // progress only under --verbose. The daemon and timer units are not a TTY and
29554
+ // keep the full log form.
29555
+ verbose: flag("verbose"),
29556
+ plain: !!process.stderr.isTTY
29491
29557
  });
29492
29558
  async function materializePassengerMirrors(emit2) {
29493
29559
  const specs = passengerCheckoutSyncSpecs(cfg).filter((s) => s.mirror);
@@ -30905,6 +30971,7 @@ ${f.tail.trimEnd()}
30905
30971
  }
30906
30972
  try {
30907
30973
  const runStart = (/* @__PURE__ */ new Date()).toISOString();
30974
+ await markCrewAssistedAtLaunch(fleetTracker, w.route, w.role, fleetWorkingId ?? null, void 0, (m) => wemit.warn(m, { step: "agent" }));
30908
30975
  await spawnAgent(fleetPlan, wemit);
30909
30976
  await guardRunHandoff(w.route, cfg.ship, fleetTracker, w.role, fleetWorkingId, wemit, runStart);
30910
30977
  } finally {
@@ -31147,6 +31214,7 @@ ${f.tail.trimEnd()}
31147
31214
  }
31148
31215
  try {
31149
31216
  const runStart = (/* @__PURE__ */ new Date()).toISOString();
31217
+ await markCrewAssistedAtLaunch(tracker2, route2, current, workingId ?? null, void 0, (m) => emit.warn(m, { step: "agent" }));
31150
31218
  await spawnAgent(plan, emit);
31151
31219
  await guardRunHandoff(route2, cfg.ship, tracker2, current, workingId, emit, runStart);
31152
31220
  } finally {
@@ -33401,7 +33469,8 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33401
33469
  break;
33402
33470
  }
33403
33471
  const pathWt = applyRunWorktree(repoWt.dir, repoWt.config, planWt);
33404
- emit.emit(describeRunWorktreePlan(planWt));
33472
+ if (planIsUsable(planWt)) emit.note(describeRunWorktreePlan(planWt));
33473
+ else emit.warn(describeRunWorktreePlan(planWt));
33405
33474
  if (pathWt && planIsUsable(planWt) && wantsCodeBridge(repoWt.config.hooks.intel)) {
33406
33475
  const shellWt = resolveShell(repoWt.config.shell ?? cfg.ship.shell);
33407
33476
  const paragraph = await startWorktreeIntel({
@@ -33436,7 +33505,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
33436
33505
  return script ? runScript(script, { cwd, env, shell: shellWt, timeoutMs: name === "intel" ? 6e4 : void 0 }) : null;
33437
33506
  }
33438
33507
  });
33439
- emit.emit(paragraph);
33508
+ emit.note(paragraph);
33440
33509
  }
33441
33510
  if (pathWt) process.stdout.write(`${pathWt}
33442
33511
  `);
@@ -33925,6 +33994,8 @@ ${where.join("\n")}`);
33925
33994
  let baseChecked = 0;
33926
33995
  let baseActed = 0;
33927
33996
  let baseUnsafe = 0;
33997
+ let fastForwarded = 0;
33998
+ const prunable = [];
33928
33999
  for (const r of await resolvedRepos(route2)) {
33929
34000
  const base = refreshBaseBranch(r.dir, r.config.branch.remote, r.config.branch.base, dryRun);
33930
34001
  const att = dryRun ? null : baseAttention(r.name, base, r.config.branch.remote, r.config.branch.base);
@@ -33946,7 +34017,8 @@ ${where.join("\n")}`);
33946
34017
  for (const w of worktrees(r.dir)) {
33947
34018
  if (!w.branch) continue;
33948
34019
  if (w.prunable) {
33949
- emit.warn(`${w.branch}: worktree at ${w.path} no longer exists \u2014 skipping (run \`git worktree prune\` in ${r.dir} to clear it)`);
34020
+ emit.note(`${w.branch}: worktree at ${w.path} no longer exists \u2014 skipping`);
34021
+ prunable.push(r.dir);
33950
34022
  continue;
33951
34023
  }
33952
34024
  let s2;
@@ -33961,8 +34033,13 @@ ${where.join("\n")}`);
33961
34033
  tracked2++;
33962
34034
  if (s2.canFastForward) {
33963
34035
  acted++;
33964
- if (dryRun) emit.emit(`would fast-forward ${w.branch}: ${s2.detail}`);
33965
- else emit.emit(fastForward(w.path, w.branch) ? `fast-forwarded ${w.branch}` : `could not fast-forward ${w.branch}`);
34036
+ if (dryRun) {
34037
+ emit.note(`would fast-forward ${w.branch}: ${s2.detail}`);
34038
+ fastForwarded++;
34039
+ } else if (fastForward(w.path, w.branch)) {
34040
+ emit.note(`fast-forwarded ${w.branch}`);
34041
+ fastForwarded++;
34042
+ } else emit.warn(`could not fast-forward ${w.branch}`);
33966
34043
  } else if (s2.behind > 0 || s2.ahead > 0) {
33967
34044
  acted++;
33968
34045
  emit.warn(`${w.branch}: ${s2.detail}`);
@@ -33970,8 +34047,12 @@ ${where.join("\n")}`);
33970
34047
  }
33971
34048
  }
33972
34049
  if (baseUnsafe > 0) process.exitCode = 1;
33973
- if (baseChecked > 0 && baseActed === 0) emit.emit(`${baseChecked} base branch(es) checked, all level with the remote`);
34050
+ if (baseChecked > 0 && baseActed === 0) emit.note(`${baseChecked} base branch(es) checked, all level with the remote`);
34051
+ if (prunable.length > 0) {
34052
+ emit.warn(`${prunable.length} worktree(s) no longer exist on disk and were skipped \u2014 run \`git worktree prune\` in ${[...new Set(prunable)].join(", ")} to clear them`);
34053
+ }
33974
34054
  if (tracked2 === 0) emit.emit("no worktree tracks a remote branch \u2014 nothing to sync");
34055
+ else if (fastForwarded > 0) emit.emit(`${dryRun ? "would fast-forward" : "fast-forwarded"} ${fastForwarded} of ${tracked2} worktree(s)${acted > fastForwarded ? `; ${acted - fastForwarded} need attention` : ""}`);
33975
34056
  else if (acted === 0) emit.emit(`${tracked2} worktree(s) tracking a remote, all level with it`);
33976
34057
  break;
33977
34058
  }
@@ -34998,6 +35079,11 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
34998
35079
  process.stdout.write(
34999
35080
  await tracker.hasPublicReplyColumn() ? `public replies: Comments.${tracker.contract.comments.publicReply} present \u2014 public reporters are labelled in the digest
35000
35081
  ` : `public replies: Comments.${tracker.contract.comments.publicReply} absent \u2014 no public intake form, nothing to guard
35082
+ `
35083
+ );
35084
+ process.stdout.write(
35085
+ await tracker.hasCrewAssistedColumn() ? `crew assisted: Issues.${tracker.contract.columns.crewAssisted} present \u2014 Dev/QA runs mark the ticket
35086
+ ` : `crew assisted: Issues.${tracker.contract.columns.crewAssisted} absent \u2014 tickets are not marked; update the Issues template to adopt it
35001
35087
  `
35002
35088
  );
35003
35089
  const periscopes = await tracker.periscopesStatus();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.147.0",
3
+ "version": "0.149.0",
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",