@tablation/crew 0.157.2 → 0.158.3
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 +291 -68
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6769,6 +6769,15 @@ function agentLogRefusedItem(route2, role, status2, request2, nowIso = (/* @__PU
|
|
|
6769
6769
|
message: `${route2}: the tracker refused ${what} (${status2}) for the ${role} seat \u2014 runs and ticket spend are not being recorded; update crew if a newer version exists, otherwise report this`
|
|
6770
6770
|
};
|
|
6771
6771
|
}
|
|
6772
|
+
var listTruncatedKey = (route2, what) => `list_truncated:${route2}:${what}`;
|
|
6773
|
+
function listTruncatedItem(route2, what, limit, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
6774
|
+
return {
|
|
6775
|
+
kind: "list_truncated",
|
|
6776
|
+
key: listTruncatedKey(route2, what),
|
|
6777
|
+
since: nowIso,
|
|
6778
|
+
message: `${route2}: the ${what} list came back full at ${limit} rows and may be missing more \u2014 decisions made from it can skip tickets; report this`
|
|
6779
|
+
};
|
|
6780
|
+
}
|
|
6772
6781
|
var workspaceAuthKey = (role) => `workspace_auth:${role}`;
|
|
6773
6782
|
var workspaceAllowanceKey = (role) => `workspace_allowance:${role}`;
|
|
6774
6783
|
function workspaceAllowanceItem(route2, role, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
@@ -9260,16 +9269,6 @@ function isAutomatic(t, wm) {
|
|
|
9260
9269
|
if (!wm || wm.modes.size === 0) return true;
|
|
9261
9270
|
return modeOf(t, wm) === "automatic";
|
|
9262
9271
|
}
|
|
9263
|
-
function skippedByMode(tickets, wm) {
|
|
9264
|
-
const out = { manual: 0, hybrid: 0 };
|
|
9265
|
-
if (!wm || wm.modes.size === 0) return out;
|
|
9266
|
-
const kept = new Set(withinWorkMode(tickets, wm));
|
|
9267
|
-
for (const t of tickets) {
|
|
9268
|
-
if (kept.has(t)) continue;
|
|
9269
|
-
out[modeOf(t, wm) === "manual" ? "manual" : "hybrid"]++;
|
|
9270
|
-
}
|
|
9271
|
-
return out;
|
|
9272
|
-
}
|
|
9273
9272
|
function withoutManualVerified(tickets, verifiedStatus, wm) {
|
|
9274
9273
|
if (!wm || wm.modes.size === 0) return tickets;
|
|
9275
9274
|
return tickets.filter((t) => t.status !== verifiedStatus || modeOf(t, wm) !== "manual");
|
|
@@ -9387,7 +9386,42 @@ function referenceKeys(t) {
|
|
|
9387
9386
|
}
|
|
9388
9387
|
var RESOLVED_STATUSES = new Set(DEFAULT_CONTRACT.statuses.resolved);
|
|
9389
9388
|
var encodeFilters = (f) => JSON.stringify(f);
|
|
9390
|
-
var
|
|
9389
|
+
var encodeSort = (s) => JSON.stringify(s);
|
|
9390
|
+
var LIST_PAGE_SIZE = 500;
|
|
9391
|
+
var LIST_MAX_PAGES = 200;
|
|
9392
|
+
var LIST_SORT = encodeSort([{ columnName: "id", direction: "asc" }]);
|
|
9393
|
+
function actionableStatuses(c) {
|
|
9394
|
+
const s = c.statuses;
|
|
9395
|
+
const named = [s.approved, s.parked, s.building, s.handoff, s.verifying, s.verified, s.needsHuman, ...s.reviewing ? [s.reviewing] : []];
|
|
9396
|
+
return [...new Set(named.filter((x) => c.statuses.open.includes(x)))];
|
|
9397
|
+
}
|
|
9398
|
+
function scopedTicketQueries(c, scope) {
|
|
9399
|
+
const status2 = c.columns.status;
|
|
9400
|
+
const project = c.columns.slice;
|
|
9401
|
+
const assignee = c.columns.assignee;
|
|
9402
|
+
const manual = [...scope.modes].filter(([, m]) => m === "manual").map(([id]) => id);
|
|
9403
|
+
const hybrid = [...scope.modes].filter(([, m]) => m === "hybrid").map(([id]) => id);
|
|
9404
|
+
const actionable = actionableStatuses(c);
|
|
9405
|
+
const pre = c.statuses.open.filter((x) => !actionable.includes(x));
|
|
9406
|
+
const automatic = [{ columnName: project, operator: "IS_NOT_NULL" }];
|
|
9407
|
+
if (manual.length + hybrid.length > 0) automatic.push({ columnName: project, operator: "NOT_IN", value: [...manual, ...hybrid] });
|
|
9408
|
+
const out = [[...automatic, { columnName: status2, operator: "IN", value: actionable }]];
|
|
9409
|
+
if (scope.triageSeat && pre.length > 0) {
|
|
9410
|
+
out.push([...automatic, { columnName: status2, operator: "IN", value: pre }, { columnName: assignee, operator: "EQ", value: scope.triageSeat }]);
|
|
9411
|
+
}
|
|
9412
|
+
if (hybrid.length > 0) {
|
|
9413
|
+
if (scope.agentAssignees.size > 0) {
|
|
9414
|
+
out.push([
|
|
9415
|
+
{ columnName: project, operator: "IN", value: hybrid },
|
|
9416
|
+
{ columnName: status2, operator: "IN", value: actionable },
|
|
9417
|
+
{ columnName: assignee, operator: "IN", value: [...scope.agentAssignees] }
|
|
9418
|
+
]);
|
|
9419
|
+
}
|
|
9420
|
+
out.push([{ columnName: project, operator: "IN", value: hybrid }, { columnName: status2, operator: "EQ", value: c.statuses.verified }]);
|
|
9421
|
+
}
|
|
9422
|
+
return out;
|
|
9423
|
+
}
|
|
9424
|
+
var Tracker = class _Tracker {
|
|
9391
9425
|
// NB: explicit fields, not TypeScript parameter properties — node's
|
|
9392
9426
|
// --experimental-strip-types cannot transform those, and the test runner
|
|
9393
9427
|
// uses it. The same rule applies everywhere in src/.
|
|
@@ -9433,25 +9467,83 @@ var Tracker = class {
|
|
|
9433
9467
|
});
|
|
9434
9468
|
}
|
|
9435
9469
|
/**
|
|
9436
|
-
* Every non-terminal ticket for this route's area,
|
|
9470
|
+
* Every non-terminal ticket for this route's area, paged to the end
|
|
9471
|
+
* (CREW-3453: one `limit: 500` request silently dropped everything past the
|
|
9472
|
+
* newest 500 once a bulk import filled the board with `new` tickets).
|
|
9437
9473
|
*
|
|
9438
9474
|
* The area filter is what keeps two routes on one tracker out of each
|
|
9439
9475
|
* other's queue: a ship working `synthesis` and `tablation-js` from the same
|
|
9440
9476
|
* Issues project must not have either seat pick up the other's tickets. A
|
|
9441
9477
|
* route with no area sees everything, which is right for a tracker
|
|
9442
9478
|
* nobody has sliced yet.
|
|
9479
|
+
*
|
|
9480
|
+
* With a `scope` (the poll's), only what a lane can act on is asked for; see
|
|
9481
|
+
* `TicketScope`. Without one, every open ticket comes back, which is what the
|
|
9482
|
+
* operator-facing views (`status`, `inbox`, `doctor`) want.
|
|
9443
9483
|
*/
|
|
9444
|
-
async openTickets() {
|
|
9484
|
+
async openTickets(scope) {
|
|
9445
9485
|
const c = this.contract;
|
|
9446
|
-
const
|
|
9447
|
-
{ columnName: c.columns.status, operator: "IN", value: c.statuses.open }
|
|
9448
|
-
];
|
|
9486
|
+
const base = [];
|
|
9449
9487
|
const areaId = this.route.resolved?.areaId;
|
|
9450
|
-
if (areaId)
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9488
|
+
if (areaId) base.push({ columnName: c.columns.slice, operator: "EQ", value: areaId });
|
|
9489
|
+
const queries = scope && scope.modes.size > 0 ? scopedTicketQueries(c, scope) : [[{ columnName: c.columns.status, operator: "IN", value: c.statuses.open }]];
|
|
9490
|
+
const seen = /* @__PURE__ */ new Map();
|
|
9491
|
+
for (const q2 of queries) {
|
|
9492
|
+
for (const t of await this.listAll(this.models.issues, "open tickets", encodeFilters([...base, ...q2]))) seen.set(t.id, t);
|
|
9493
|
+
}
|
|
9494
|
+
return [...seen.values()];
|
|
9495
|
+
}
|
|
9496
|
+
/**
|
|
9497
|
+
* How many open tickets match `extra` (a `crew status` number or the sweep
|
|
9498
|
+
* summary's skipped-by-mode count), from the count endpoint rather than
|
|
9499
|
+
* downloaded rows. `undefined` when the count cannot be read.
|
|
9500
|
+
*/
|
|
9501
|
+
async countOpenTickets(extra) {
|
|
9502
|
+
const c = this.contract;
|
|
9503
|
+
const conds = [{ columnName: c.columns.status, operator: "IN", value: c.statuses.open }, ...extra];
|
|
9504
|
+
const areaId = this.route.resolved?.areaId;
|
|
9505
|
+
if (areaId) conds.push({ columnName: c.columns.slice, operator: "EQ", value: areaId });
|
|
9506
|
+
try {
|
|
9507
|
+
const res = await this.eventsFetch("GET", `/records/count?filters=${encodeURIComponent(encodeFilters(conds))}`);
|
|
9508
|
+
if (!res.ok) return void 0;
|
|
9509
|
+
const body = await res.json();
|
|
9510
|
+
return typeof body.count === "number" ? body.count : void 0;
|
|
9511
|
+
} catch {
|
|
9512
|
+
return void 0;
|
|
9513
|
+
}
|
|
9514
|
+
}
|
|
9515
|
+
/**
|
|
9516
|
+
* Lists the tracker has handed back full and this process had no way to
|
|
9517
|
+
* read past, by what they were (CREW-3453). A decision made from a cut-off
|
|
9518
|
+
* list is wrong without saying so, so every reader that can be cut off calls
|
|
9519
|
+
* `noteTruncated`, and the poll turns what is here into an attention item.
|
|
9520
|
+
*/
|
|
9521
|
+
truncated = /* @__PURE__ */ new Map();
|
|
9522
|
+
/** The page backstop `listAll` stops at; a variable only so a test can reach it without a hundred thousand rows. */
|
|
9523
|
+
static maxPages = LIST_MAX_PAGES;
|
|
9524
|
+
/** Records that the list `what` hit `limit` rows and may be missing more. */
|
|
9525
|
+
noteTruncated(what, limit) {
|
|
9526
|
+
this.truncated.set(what, limit);
|
|
9527
|
+
}
|
|
9528
|
+
/**
|
|
9529
|
+
* Every row of `model` matching `filters`, paged until a short page. Sorted by
|
|
9530
|
+
* `id` so the offset windows neither skip nor repeat a row while the table
|
|
9531
|
+
* changes under the read.
|
|
9532
|
+
*/
|
|
9533
|
+
async listAll(model, what, filters) {
|
|
9534
|
+
const out = [];
|
|
9535
|
+
for (let page = 0; page < _Tracker.maxPages; page++) {
|
|
9536
|
+
const rows = await this.client.records.list(model, {
|
|
9537
|
+
...filters ? { filters } : {},
|
|
9538
|
+
limit: LIST_PAGE_SIZE,
|
|
9539
|
+
offset: page * LIST_PAGE_SIZE,
|
|
9540
|
+
sort: LIST_SORT
|
|
9541
|
+
});
|
|
9542
|
+
out.push(...rows);
|
|
9543
|
+
if (rows.length < LIST_PAGE_SIZE) return out;
|
|
9544
|
+
}
|
|
9545
|
+
this.noteTruncated(what, LIST_PAGE_SIZE * _Tracker.maxPages);
|
|
9546
|
+
return out;
|
|
9455
9547
|
}
|
|
9456
9548
|
/**
|
|
9457
9549
|
* Tickets at the hand-off status whose row changed at or after `since`,
|
|
@@ -9459,10 +9551,11 @@ var Tracker = class {
|
|
|
9459
9551
|
*/
|
|
9460
9552
|
async handedOffSince(since2, exceptId) {
|
|
9461
9553
|
const c = this.contract;
|
|
9462
|
-
const rows = await this.
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9554
|
+
const rows = await this.listAll(
|
|
9555
|
+
this.models.issues,
|
|
9556
|
+
"handed-off tickets",
|
|
9557
|
+
encodeFilters([{ columnName: c.columns.status, operator: "EQ", value: c.statuses.handoff }])
|
|
9558
|
+
);
|
|
9466
9559
|
const from = Date.parse(since2);
|
|
9467
9560
|
return rows.filter((t) => t.id !== exceptId && Date.parse(t.updated_at) >= from);
|
|
9468
9561
|
}
|
|
@@ -9508,23 +9601,44 @@ var Tracker = class {
|
|
|
9508
9601
|
* from the open set. Bounded to the ids actually referenced.
|
|
9509
9602
|
*/
|
|
9510
9603
|
async ticketsByIds(ids) {
|
|
9511
|
-
|
|
9512
|
-
return this.client.records.list(this.models.issues, {
|
|
9513
|
-
filters: encodeFilters([{ columnName: "id", operator: "IN", value: ids }]),
|
|
9514
|
-
limit: 500
|
|
9515
|
-
});
|
|
9604
|
+
return this.ticketsByIn("id", ids);
|
|
9516
9605
|
}
|
|
9517
9606
|
/** Tickets by `issue_id` (CREW-3323: resolving a run's key to its display tag). */
|
|
9518
9607
|
async ticketsByKeys(keys) {
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9608
|
+
return this.ticketsByIn(this.contract.columns.key, keys);
|
|
9609
|
+
}
|
|
9610
|
+
/** IN lists go in the URL, so each request carries at most 100 values; every request is paged. */
|
|
9611
|
+
async ticketsByIn(column, values) {
|
|
9612
|
+
const out = [];
|
|
9613
|
+
for (let i = 0; i < values.length; i += 100) {
|
|
9614
|
+
out.push(...await this.listAll(
|
|
9615
|
+
this.models.issues,
|
|
9616
|
+
"tickets by lookup",
|
|
9617
|
+
encodeFilters([{ columnName: column, operator: "IN", value: values.slice(i, i + 100) }])
|
|
9618
|
+
));
|
|
9619
|
+
}
|
|
9620
|
+
return out;
|
|
9524
9621
|
}
|
|
9525
9622
|
async ticket(id) {
|
|
9526
9623
|
return this.client.records.get(this.models.issues, id);
|
|
9527
9624
|
}
|
|
9625
|
+
/**
|
|
9626
|
+
* Every comment on the given tickets, paged (CREW-3453). The poll feeds hold
|
|
9627
|
+
* answers, the new-comment signal and the digest from this, so a fixed window
|
|
9628
|
+
* of the newest rows would drop an older ticket's answer once the board's
|
|
9629
|
+
* comments outgrow it. IN lists carry at most 100 ids per request.
|
|
9630
|
+
*/
|
|
9631
|
+
async commentsForTickets(ticketIds) {
|
|
9632
|
+
const out = [];
|
|
9633
|
+
for (let i = 0; i < ticketIds.length; i += 100) {
|
|
9634
|
+
out.push(...await this.listAll(
|
|
9635
|
+
this.models.comments,
|
|
9636
|
+
"comments",
|
|
9637
|
+
encodeFilters([{ columnName: this.contract.comments.parent, operator: "IN", value: ticketIds.slice(i, i + 100) }])
|
|
9638
|
+
));
|
|
9639
|
+
}
|
|
9640
|
+
return out;
|
|
9641
|
+
}
|
|
9528
9642
|
async comments(limit = 500) {
|
|
9529
9643
|
return this.client.records.list(this.models.comments, { limit });
|
|
9530
9644
|
}
|
|
@@ -9538,7 +9652,7 @@ var Tracker = class {
|
|
|
9538
9652
|
}
|
|
9539
9653
|
}
|
|
9540
9654
|
async crewRows() {
|
|
9541
|
-
return this.
|
|
9655
|
+
return this.listAll(this.models.crew, "Crew rows");
|
|
9542
9656
|
}
|
|
9543
9657
|
/**
|
|
9544
9658
|
* One row of the `Repos` table, for whatever it can tell the crew that
|
|
@@ -9578,7 +9692,7 @@ var Tracker = class {
|
|
|
9578
9692
|
const model = this.route.resolved?.areaModelId;
|
|
9579
9693
|
if (!model) return /* @__PURE__ */ new Map();
|
|
9580
9694
|
try {
|
|
9581
|
-
const rows = await this.
|
|
9695
|
+
const rows = await this.listAll(model, "Projects");
|
|
9582
9696
|
return projectWorkModes(rows, this.contract);
|
|
9583
9697
|
} catch {
|
|
9584
9698
|
return /* @__PURE__ */ new Map();
|
|
@@ -9588,7 +9702,7 @@ var Tracker = class {
|
|
|
9588
9702
|
async projectRows() {
|
|
9589
9703
|
const model = this.route.resolved?.areaModelId;
|
|
9590
9704
|
if (!model) return [];
|
|
9591
|
-
return this.
|
|
9705
|
+
return this.listAll(model, "Projects");
|
|
9592
9706
|
}
|
|
9593
9707
|
/** Create a `Projects` (area) row (CREW-3359). Throws when the workspace has no Projects table. */
|
|
9594
9708
|
async createProjectRow(fields) {
|
|
@@ -9619,13 +9733,13 @@ var Tracker = class {
|
|
|
9619
9733
|
async repoRows() {
|
|
9620
9734
|
const model = this.route.resolved?.reposModelId;
|
|
9621
9735
|
if (!model) return [];
|
|
9622
|
-
return this.
|
|
9736
|
+
return this.listAll(model, "Repos");
|
|
9623
9737
|
}
|
|
9624
9738
|
/** Every `Repos` row with the columns the resolved file mirrors (CREW-2885). */
|
|
9625
9739
|
async repoRowsForMap() {
|
|
9626
9740
|
const model = this.route.resolved?.reposModelId;
|
|
9627
9741
|
if (!model) return [];
|
|
9628
|
-
return this.
|
|
9742
|
+
return this.listAll(model, "Repos");
|
|
9629
9743
|
}
|
|
9630
9744
|
/** Delete a `Repos` row (`crew sample-ticket --remove`). */
|
|
9631
9745
|
async deleteRepoRow(id) {
|
|
@@ -9635,10 +9749,11 @@ var Tracker = class {
|
|
|
9635
9749
|
}
|
|
9636
9750
|
/** Every ticket filed against one `Repos` row, any status. */
|
|
9637
9751
|
async ticketsForRepo(repoId) {
|
|
9638
|
-
return this.
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9752
|
+
return this.listAll(
|
|
9753
|
+
this.models.issues,
|
|
9754
|
+
"tickets of a repo",
|
|
9755
|
+
encodeFilters([{ columnName: this.contract.columns.repo, operator: "EQ", value: repoId }])
|
|
9756
|
+
);
|
|
9642
9757
|
}
|
|
9643
9758
|
/**
|
|
9644
9759
|
* The Ships rows of this workspace, if it has a Ships table.
|
|
@@ -9650,7 +9765,7 @@ var Tracker = class {
|
|
|
9650
9765
|
const model = this.route.resolved?.shipsModelId;
|
|
9651
9766
|
if (!model) return [];
|
|
9652
9767
|
try {
|
|
9653
|
-
return await this.
|
|
9768
|
+
return await this.listAll(model, "Ships");
|
|
9654
9769
|
} catch {
|
|
9655
9770
|
return [];
|
|
9656
9771
|
}
|
|
@@ -9840,7 +9955,7 @@ var Tracker = class {
|
|
|
9840
9955
|
const model = this.route.resolved?.epicsModelId;
|
|
9841
9956
|
if (!model) return [];
|
|
9842
9957
|
try {
|
|
9843
|
-
return await this.
|
|
9958
|
+
return await this.listAll(model, "Epics");
|
|
9844
9959
|
} catch {
|
|
9845
9960
|
return [];
|
|
9846
9961
|
}
|
|
@@ -16686,6 +16801,15 @@ function versionRequest(argv2) {
|
|
|
16686
16801
|
function helpRequest(argv2) {
|
|
16687
16802
|
return argv2[0] === "--help" || argv2[0] === "-h" || argv2[0] === "help";
|
|
16688
16803
|
}
|
|
16804
|
+
function commandHelpRequest(argv2) {
|
|
16805
|
+
for (let i = 1; i < argv2.length; i++) {
|
|
16806
|
+
const a = argv2[i];
|
|
16807
|
+
if (a === "--") return false;
|
|
16808
|
+
if (a === "--help" || a === "-h") return true;
|
|
16809
|
+
if (a.startsWith("--") && !a.includes("=") && VALUE_FLAGS.has(a.slice(2))) i++;
|
|
16810
|
+
}
|
|
16811
|
+
return false;
|
|
16812
|
+
}
|
|
16689
16813
|
|
|
16690
16814
|
// src/roster.ts
|
|
16691
16815
|
function memberByIdentity(roster, identityId) {
|
|
@@ -19460,15 +19584,23 @@ async function decideCycle(o) {
|
|
|
19460
19584
|
return fallback;
|
|
19461
19585
|
}
|
|
19462
19586
|
};
|
|
19463
|
-
const [
|
|
19464
|
-
tracker.openTickets(),
|
|
19465
|
-
tracker.comments(200),
|
|
19587
|
+
const [crewRows, projectModes] = await Promise.all([
|
|
19466
19588
|
tracker.crewRows(),
|
|
19589
|
+
optional("project work modes", tracker.projectWorkModes(), /* @__PURE__ */ new Map())
|
|
19590
|
+
]);
|
|
19591
|
+
const scopeHolds = new Set(holdIds(buildRoster(configuredMembers(route2), crewRows)));
|
|
19592
|
+
const scope = {
|
|
19593
|
+
modes: projectModes,
|
|
19594
|
+
agentAssignees: agentAssigneeIds(crewRows, (id) => scopeHolds.has(id)),
|
|
19595
|
+
triageSeat: route2.resolved?.seats.triage
|
|
19596
|
+
};
|
|
19597
|
+
const [tickets, epicRows, ships, stalledEvents] = await Promise.all([
|
|
19598
|
+
tracker.openTickets(scope),
|
|
19467
19599
|
optional("epics", tracker.epicRows(), []),
|
|
19468
19600
|
optional("ships", tracker.shipRows(), []),
|
|
19469
|
-
optional("project work modes", tracker.projectWorkModes(), /* @__PURE__ */ new Map()),
|
|
19470
19601
|
tracker.events("stalled")
|
|
19471
19602
|
]);
|
|
19603
|
+
const comments = await tracker.commentsForTickets(tickets.map((t) => t.id));
|
|
19472
19604
|
const directionEvents = (await Promise.all([...DIRECTION_EVENT_TYPES, ...STATUS_EVENT_TYPES, "pushed"].map((t) => tracker.events(t)))).flat();
|
|
19473
19605
|
const statusChanges = await tracker.statusChanges();
|
|
19474
19606
|
emit.note(`${tickets.length} open ticket(s), ${comments.length} comment(s)`, {
|
|
@@ -19501,6 +19633,7 @@ async function decideCycle(o) {
|
|
|
19501
19633
|
}
|
|
19502
19634
|
const extra = await tracker.ticketsByIds(missingBlockerIds(tickets));
|
|
19503
19635
|
const info = blockerInfoMap(tickets, extra);
|
|
19636
|
+
await reportTruncated(tracker, route2.route, state, emit);
|
|
19504
19637
|
const blocked = computeBlockedIds(tickets, info);
|
|
19505
19638
|
const footprintEvents = await optional("footprint events", readFootprintEvents(tracker), { declared: /* @__PURE__ */ new Map(), pushed: /* @__PURE__ */ new Map() });
|
|
19506
19639
|
const footprintPlan = planFootprintsFor(route2, tickets, footprintEvents, new Set(blocked));
|
|
@@ -19517,7 +19650,7 @@ async function decideCycle(o) {
|
|
|
19517
19650
|
const sweep = planSweep(tickets, info, blocked, workModes, footprintPlan.waits);
|
|
19518
19651
|
const holdReleases = planHoldReleases(tickets, tracker.contract);
|
|
19519
19652
|
const stalled = planStalled(tickets, comments, ships, tracker.contract, holds2, Date.now(), workModes, stalledEvents);
|
|
19520
|
-
const skipped =
|
|
19653
|
+
const skipped = await skippedCounts(tracker, tickets, projectModes);
|
|
19521
19654
|
if (skipped.manual || skipped.hybrid) {
|
|
19522
19655
|
emit.note(`sweeps skipped ${skipped.manual} manual/project-less and ${skipped.hybrid} unassigned hybrid ticket(s)`, {
|
|
19523
19656
|
data: { sweepSkipped: skipped }
|
|
@@ -19771,6 +19904,33 @@ ${body}` : body;
|
|
|
19771
19904
|
function rosterFor(d, route2, role) {
|
|
19772
19905
|
return rosterMarkdown(d.roster, route2.resolved.seats[role] ?? null);
|
|
19773
19906
|
}
|
|
19907
|
+
async function skippedCounts(tracker, tickets, modes) {
|
|
19908
|
+
if (modes.size === 0) return { manual: 0, hybrid: 0 };
|
|
19909
|
+
const c = tracker.contract;
|
|
19910
|
+
const idsOf = (m) => [...modes].filter(([, v]) => v === m).map(([id]) => id);
|
|
19911
|
+
const manualIds = idsOf("manual");
|
|
19912
|
+
const hybridIds = idsOf("hybrid");
|
|
19913
|
+
const col = c.columns.slice;
|
|
19914
|
+
const [none, manual, hybrid] = await Promise.all([
|
|
19915
|
+
tracker.countOpenTickets([{ columnName: col, operator: "IS_NULL" }]),
|
|
19916
|
+
manualIds.length ? tracker.countOpenTickets([{ columnName: col, operator: "IN", value: manualIds }]) : Promise.resolve(0),
|
|
19917
|
+
hybridIds.length ? tracker.countOpenTickets([{ columnName: col, operator: "IN", value: hybridIds }]) : Promise.resolve(0)
|
|
19918
|
+
]);
|
|
19919
|
+
const hybridFetched = tickets.filter((t) => t.project_id && hybridIds.includes(t.project_id)).length;
|
|
19920
|
+
return { manual: (none ?? 0) + (manual ?? 0), hybrid: Math.max(0, (hybrid ?? 0) - hybridFetched) };
|
|
19921
|
+
}
|
|
19922
|
+
async function reportTruncated(tracker, route2, state, emit) {
|
|
19923
|
+
const prefix = listTruncatedKey(route2, "");
|
|
19924
|
+
const live2 = /* @__PURE__ */ new Set();
|
|
19925
|
+
for (const [what, limit] of tracker.truncated) {
|
|
19926
|
+
const item = listTruncatedItem(route2, what, limit);
|
|
19927
|
+
live2.add(item.key);
|
|
19928
|
+
await raiseShipAttention({ state, emit }, item);
|
|
19929
|
+
}
|
|
19930
|
+
for (const i of openShipAttention(state)) {
|
|
19931
|
+
if (i.kind === "list_truncated" && i.key.startsWith(prefix) && !live2.has(i.key)) clearShipAttention(state, i.key);
|
|
19932
|
+
}
|
|
19933
|
+
}
|
|
19774
19934
|
|
|
19775
19935
|
// src/claim.ts
|
|
19776
19936
|
import { StaleWriteError as StaleWriteError6 } from "@tablation/client";
|
|
@@ -26657,13 +26817,16 @@ async function discover(o) {
|
|
|
26657
26817
|
}
|
|
26658
26818
|
if (shipRowId) {
|
|
26659
26819
|
const releaseId = stored?.releaseSeat && scoped.some((r) => r.id === stored.releaseSeat) ? stored.releaseSeat : void 0;
|
|
26660
|
-
if (releaseId)
|
|
26661
|
-
|
|
26820
|
+
if (releaseId) {
|
|
26821
|
+
out.releaseSeat = releaseId;
|
|
26822
|
+
out.releaseSeatAction = "matched";
|
|
26823
|
+
} else {
|
|
26662
26824
|
const created = await post2(o, `/data-models/${out.models.crew}/records`, {
|
|
26663
26825
|
name: "Release agent",
|
|
26664
26826
|
ship_id: shipRowId
|
|
26665
26827
|
});
|
|
26666
26828
|
out.releaseSeat = created.id;
|
|
26829
|
+
out.releaseSeatAction = "created";
|
|
26667
26830
|
provisioning.push("created Crew row for the release seat");
|
|
26668
26831
|
}
|
|
26669
26832
|
}
|
|
@@ -26770,12 +26933,11 @@ async function createOperatorRow(o, found) {
|
|
|
26770
26933
|
}
|
|
26771
26934
|
}
|
|
26772
26935
|
function renderConnection(d, route2, dir, opts = {}) {
|
|
26773
|
-
const apiKeyFileLine = opts.keychainBacked
|
|
26774
|
-
const apiKeyVarLine = opts.keychainBacked
|
|
26775
|
-
apiKeyVar: ${opts.apiKeyVar}` :
|
|
26776
|
-
|
|
26777
|
-
|
|
26778
|
-
` : ' baseUrl: "REPLACE \u2014 the same baseUrl as your other routes"\n';
|
|
26936
|
+
const apiKeyFileLine = !opts.keychainBacked && opts.apiKeyFile ? ` apiKeyFile: "${opts.apiKeyFile}"` : "";
|
|
26937
|
+
const apiKeyVarLine = !opts.keychainBacked && opts.apiKeyFile && opts.apiKeyVar ? `
|
|
26938
|
+
apiKeyVar: ${opts.apiKeyVar}` : "";
|
|
26939
|
+
const baseUrlLine = opts.baseUrl && opts.baseUrl.replace(/\/+$/, "") !== DEFAULT_BASE_URL ? ` baseUrl: "${opts.baseUrl}"
|
|
26940
|
+
` : "";
|
|
26779
26941
|
const keyLines = [apiKeyFileLine, apiKeyVarLine.replace(/^\n/, "")].filter(Boolean).join("\n");
|
|
26780
26942
|
return ` - route: ${route2}
|
|
26781
26943
|
enabled: false # set to true once \`crew doctor\` is green
|
|
@@ -26783,6 +26945,27 @@ ${opts.area ? ` area: "${opts.area}"
|
|
|
26783
26945
|
` : ""}${dir === null ? "" : ` dir: "${dir}"
|
|
26784
26946
|
`}${baseUrlLine}${opts.hostPassengers ? " hostPassengers: true\n" : ""}${keyLines ? keyLines + "\n" : ""}`;
|
|
26785
26947
|
}
|
|
26948
|
+
function renderExistingRouteReport(o) {
|
|
26949
|
+
const seatRows = new Map((o.found.seatRows ?? []).map((r) => [r.role, r]));
|
|
26950
|
+
const keyOf = (role) => o.keys?.find((k) => k.role === role)?.action;
|
|
26951
|
+
const lines2 = [];
|
|
26952
|
+
for (const role of ["dev", "design", "qa", "triage"]) {
|
|
26953
|
+
const row = seatRows.get(role);
|
|
26954
|
+
lines2.push(row ? { role, ...row.id ? { id: row.id } : {}, outcome: row.action, key: keyOf(role) } : o.found.seats[role] ? { role, id: o.found.seats[role], outcome: "matched", key: keyOf(role) } : { role, outcome: "unresolved" });
|
|
26955
|
+
}
|
|
26956
|
+
lines2.push(o.found.seats.pair ? { role: "pair", id: o.found.seats.pair, outcome: "matched" } : { role: "pair", outcome: "unresolved" });
|
|
26957
|
+
lines2.push(o.found.releaseSeat ? { role: "release", id: o.found.releaseSeat, outcome: o.found.releaseSeatAction ?? "matched" } : { role: "release", outcome: "unresolved" });
|
|
26958
|
+
const out = [
|
|
26959
|
+
`${o.configFile} already has the route "${o.route}"; it was not changed.`,
|
|
26960
|
+
o.resolvedPath ? `${o.dryRun ? "(dry run) would write" : "Resolved ids written to"} ${o.resolvedPath}` : "",
|
|
26961
|
+
"Seats:",
|
|
26962
|
+
...lines2.map((l) => ` ${l.role.padEnd(8)} ${l.id ? `Crew row ${l.id}` : "no Crew row"} \u2014 ${l.outcome}${l.key && l.key !== "none" ? `; key ${l.key}` : ""}`),
|
|
26963
|
+
"",
|
|
26964
|
+
`Next: crew doctor ${o.route}`
|
|
26965
|
+
].filter((l, i, a) => l !== "" || i === a.length - 2);
|
|
26966
|
+
return `${out.join("\n")}
|
|
26967
|
+
`;
|
|
26968
|
+
}
|
|
26786
26969
|
|
|
26787
26970
|
// src/cli.ts
|
|
26788
26971
|
import {
|
|
@@ -28366,7 +28549,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
28366
28549
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
28367
28550
|
import { join as join60 } from "path";
|
|
28368
28551
|
function builtVersion() {
|
|
28369
|
-
return true ? "0.
|
|
28552
|
+
return true ? "0.158.3" : null;
|
|
28370
28553
|
}
|
|
28371
28554
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
28372
28555
|
function newestMtime(path) {
|
|
@@ -30733,6 +30916,7 @@ var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
30733
30916
|
"worktree"
|
|
30734
30917
|
]);
|
|
30735
30918
|
if (!KNOWN_COMMANDS.has(command)) usage(`unknown command "${command}"`);
|
|
30919
|
+
if (commandHelpRequest(argv)) usage(void 0, true);
|
|
30736
30920
|
if (command === "shell-init") {
|
|
30737
30921
|
const asked = value("shell");
|
|
30738
30922
|
if (asked !== void 0 && !SHELLS.includes(asked)) {
|
|
@@ -34470,10 +34654,36 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
34470
34654
|
emit.error(`crew connect: ${msg}`);
|
|
34471
34655
|
stopWithProblem(msg, "wizard");
|
|
34472
34656
|
}
|
|
34473
|
-
|
|
34657
|
+
const storeLabel = () => {
|
|
34658
|
+
const r = describeSecretStore();
|
|
34659
|
+
return r.kind === "file" && r.dir ? `the key store under ${r.dir}` : "the OS keychain";
|
|
34660
|
+
};
|
|
34661
|
+
const keyFromFlag = givenKeySource === "flag" && !mintedFromDevice && !!apiKey;
|
|
34662
|
+
if (keyFromFlag && !keychainBacked && store) {
|
|
34663
|
+
if (dryRun) {
|
|
34664
|
+
keychainBacked = true;
|
|
34665
|
+
routineLine(`(dry run) would store the key in ${storeLabel()} for ${hostFromUrl4(baseUrl)}/${found.workspaceSlug}`);
|
|
34666
|
+
} else {
|
|
34667
|
+
try {
|
|
34668
|
+
await store.set(hostFromUrl4(baseUrl), found.workspaceSlug, {
|
|
34669
|
+
apiKey,
|
|
34670
|
+
workspaceId: found.workspaceId,
|
|
34671
|
+
identityId: found.meId ?? "",
|
|
34672
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
34673
|
+
});
|
|
34674
|
+
keychainBacked = true;
|
|
34675
|
+
sessionAddress = found.workspaceSlug;
|
|
34676
|
+
rememberSession(cfg.ship.stateDir, hostFromUrl4(baseUrl), found.workspaceSlug);
|
|
34677
|
+
routineLine(`API key stored in ${storeLabel()} for ${hostFromUrl4(baseUrl)}/${found.workspaceSlug}.`);
|
|
34678
|
+
} catch (e) {
|
|
34679
|
+
emit.warn(withFix(`could not store the key in ${storeLabel()} \u2014 ${e.message} \u2014 falling back to a key file`, "`crew doctor`"));
|
|
34680
|
+
}
|
|
34681
|
+
}
|
|
34682
|
+
}
|
|
34683
|
+
if ((mintedFromDevice || firstRunFromFlags || keyFromFlag) && !keychainBacked) {
|
|
34474
34684
|
apiKeyFile = apiKeyPathFor(cfg.ship.stateDir, route3);
|
|
34475
34685
|
if (dryRun) {
|
|
34476
|
-
process.stderr.write(`(dry run) would write the
|
|
34686
|
+
process.stderr.write(`(dry run) would write the API key to ${apiKeyFile}
|
|
34477
34687
|
`);
|
|
34478
34688
|
} else {
|
|
34479
34689
|
mkdirSync43(dirname38(apiKeyFile), { recursive: true });
|
|
@@ -34489,13 +34699,14 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
34489
34699
|
const routeBlock = renderConnection(
|
|
34490
34700
|
found,
|
|
34491
34701
|
route3,
|
|
34492
|
-
routeDir ??
|
|
34702
|
+
routeDir ?? null,
|
|
34493
34703
|
{
|
|
34494
34704
|
area: value("area"),
|
|
34495
34705
|
apiKeyFile,
|
|
34496
34706
|
apiKeyVar: apiKeyFile ? apiKeyVar : void 0,
|
|
34497
34707
|
keychainBacked,
|
|
34498
|
-
|
|
34708
|
+
baseUrl,
|
|
34709
|
+
...writeFirstRun ? { hostPassengers: wizard.answers.hostPassengers } : {}
|
|
34499
34710
|
}
|
|
34500
34711
|
);
|
|
34501
34712
|
let wroteConfig = false;
|
|
@@ -34514,7 +34725,17 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
34514
34725
|
connectEvents.emit("config", `${cfg.configFile} already exists; left alone`, { written: false, path: cfg.configFile, reason: "exists" });
|
|
34515
34726
|
}
|
|
34516
34727
|
}
|
|
34517
|
-
|
|
34728
|
+
const routeInConfig = cfg.routes.some((r) => r.route === route3);
|
|
34729
|
+
const existingReport = routeInConfig ? renderExistingRouteReport({
|
|
34730
|
+
route: route3,
|
|
34731
|
+
configFile: cfg.configFile,
|
|
34732
|
+
resolvedPath,
|
|
34733
|
+
dryRun,
|
|
34734
|
+
found,
|
|
34735
|
+
keys: mintOutcomes.map((m) => ({ role: m.role, action: m.action }))
|
|
34736
|
+
}) : "";
|
|
34737
|
+
if (routeInConfig) (connectEvents.json ? process.stderr : process.stdout).write(existingReport);
|
|
34738
|
+
else if (!wroteConfig) (connectEvents.json ? process.stderr : process.stdout).write(routeBlock);
|
|
34518
34739
|
if (!flag("no-mcp") && apiKey) {
|
|
34519
34740
|
const replace = value("mcp") === "replace";
|
|
34520
34741
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -34564,17 +34785,19 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
|
34564
34785
|
}));
|
|
34565
34786
|
if (!operator) process.stderr.write(` Also set operator in ${resolvedPath} before arming it.
|
|
34566
34787
|
`);
|
|
34788
|
+
} else if (routeInConfig) {
|
|
34789
|
+
if (!operator) emit.warn(`no operator resolved: set it in ${resolvedPath} before arming this route`);
|
|
34567
34790
|
} else if (operator) {
|
|
34568
34791
|
process.stderr.write(
|
|
34569
34792
|
`
|
|
34570
|
-
Paste the block above under routes: in crew.yaml
|
|
34793
|
+
Paste the block above under routes: in crew.yaml, then: crew doctor ${route3}
|
|
34571
34794
|
`
|
|
34572
34795
|
);
|
|
34573
34796
|
} else {
|
|
34574
34797
|
process.stderr.write(
|
|
34575
34798
|
`
|
|
34576
|
-
Paste the block above under routes: in crew.yaml
|
|
34577
|
-
|
|
34799
|
+
Paste the block above under routes: in crew.yaml, set operator in
|
|
34800
|
+
${resolvedPath}, then: crew doctor ${route3}
|
|
34578
34801
|
`
|
|
34579
34802
|
);
|
|
34580
34803
|
}
|
package/package.json
CHANGED