@tablation/crew 0.156.1 → 0.157.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.
- package/README.md +2 -2
- package/dist/cli.js +296 -48
- package/package.json +1 -1
- package/prompts/default/skills/crew-lane-agent.md +22 -0
- package/prompts/dev-qa/skills/crew-lane-agent.md +22 -0
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@ and reports back on the board.
|
|
|
10
10
|
|
|
11
11
|
Each **seat** is a row in the board's Crew table that happens to be a robot,
|
|
12
12
|
with a brief (`prompts/<promptSet>/`, see "Prompt sets" below) and a slice
|
|
13
|
-
of the queue. A seat is
|
|
14
|
-
queue digest and in the comments it writes on tickets. Everything the crew
|
|
13
|
+
of the queue. A seat is linked to its Agents row and is found by that link, not its name; it
|
|
14
|
+
answers to the name in that table, in the queue digest and in the comments it writes on tickets. Everything the crew
|
|
15
15
|
knows about a run — what to build, what is blocked, what has shipped — is
|
|
16
16
|
table data, and every step it takes is visible as a status change or a
|
|
17
17
|
comment on the ticket. There is no hidden state and no queue but the board.
|
package/dist/cli.js
CHANGED
|
@@ -4454,6 +4454,18 @@ function readResolvedFile(stateDir, route2) {
|
|
|
4454
4454
|
throw new ConfigError(`${path}: not valid JSON \u2014 ${e.message}`);
|
|
4455
4455
|
}
|
|
4456
4456
|
}
|
|
4457
|
+
function readStoredSeats(stateDir, route2) {
|
|
4458
|
+
let raw;
|
|
4459
|
+
try {
|
|
4460
|
+
raw = readResolvedFile(stateDir, route2);
|
|
4461
|
+
} catch {
|
|
4462
|
+
return void 0;
|
|
4463
|
+
}
|
|
4464
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
4465
|
+
const seats2 = {};
|
|
4466
|
+
for (const role of ROLE_NAMES) if (typeof raw.seats?.[role] === "string" && raw.seats[role]) seats2[role] = raw.seats[role];
|
|
4467
|
+
return { seats: seats2, ...typeof raw.releaseSeat === "string" && raw.releaseSeat ? { releaseSeat: raw.releaseSeat } : {} };
|
|
4468
|
+
}
|
|
4457
4469
|
function parseResolved(raw, m, where) {
|
|
4458
4470
|
if (!raw) return void 0;
|
|
4459
4471
|
const seats2 = {};
|
|
@@ -4484,6 +4496,7 @@ function parseResolved(raw, m, where) {
|
|
|
4484
4496
|
areaId: raw.areaId,
|
|
4485
4497
|
shipsModelId: raw.shipsModelId,
|
|
4486
4498
|
epicsModelId: raw.epicsModelId,
|
|
4499
|
+
mapsModelId: raw.mapsModelId,
|
|
4487
4500
|
periscopesModelId: raw.periscopesModelId,
|
|
4488
4501
|
locksModelId: raw.locksModelId,
|
|
4489
4502
|
recordLinkViewId: raw.recordLinkViewId,
|
|
@@ -8223,6 +8236,7 @@ function forbiddenDetail(e, route2) {
|
|
|
8223
8236
|
[r?.shipsModelId, "Ships"],
|
|
8224
8237
|
[r?.locksModelId, "Locks"],
|
|
8225
8238
|
[r?.epicsModelId, "Epics"],
|
|
8239
|
+
[r?.mapsModelId, "Maps"],
|
|
8226
8240
|
[r?.periscopesModelId, "Periscopes"],
|
|
8227
8241
|
[r?.reposModelId, "Repos"]
|
|
8228
8242
|
];
|
|
@@ -9021,6 +9035,15 @@ var DEFAULT_CONTRACT = {
|
|
|
9021
9035
|
keyColumn: "epic_id",
|
|
9022
9036
|
statuses: { planned: "planned", building: "in_progress", done: "done", cancelled: "cancelled" }
|
|
9023
9037
|
},
|
|
9038
|
+
maps: {
|
|
9039
|
+
epicColumn: "epic_id",
|
|
9040
|
+
titleColumn: "title",
|
|
9041
|
+
contentColumn: "content",
|
|
9042
|
+
conversationColumn: "conversation",
|
|
9043
|
+
statusColumn: "status",
|
|
9044
|
+
versionColumn: "version",
|
|
9045
|
+
activeStatus: "active"
|
|
9046
|
+
},
|
|
9024
9047
|
priorityOrder: ["p0", "p1", "p2", "p3"],
|
|
9025
9048
|
severityOrder: ["s1", "s2", "s3", "s4"],
|
|
9026
9049
|
unknownPriorityRank: 2,
|
|
@@ -9043,6 +9066,7 @@ function resolveContract(override) {
|
|
|
9043
9066
|
...override.epics,
|
|
9044
9067
|
statuses: { ...DEFAULT_CONTRACT.epics.statuses, ...override.epics?.statuses }
|
|
9045
9068
|
},
|
|
9069
|
+
maps: { ...DEFAULT_CONTRACT.maps, ...override.maps },
|
|
9046
9070
|
priorityOrder: override.priorityOrder ?? DEFAULT_CONTRACT.priorityOrder,
|
|
9047
9071
|
severityOrder: override.severityOrder ?? DEFAULT_CONTRACT.severityOrder,
|
|
9048
9072
|
unknownPriorityRank: override.unknownPriorityRank ?? DEFAULT_CONTRACT.unknownPriorityRank,
|
|
@@ -9812,6 +9836,36 @@ var Tracker = class {
|
|
|
9812
9836
|
return [];
|
|
9813
9837
|
}
|
|
9814
9838
|
}
|
|
9839
|
+
/** One Epics row, or `undefined` when the workspace has no Epics table or the row is gone (CREW-3444). */
|
|
9840
|
+
async epicRow(id) {
|
|
9841
|
+
const model = this.route.resolved?.epicsModelId;
|
|
9842
|
+
if (!model) return void 0;
|
|
9843
|
+
try {
|
|
9844
|
+
return await this.client.records.get(model, id);
|
|
9845
|
+
} catch {
|
|
9846
|
+
return void 0;
|
|
9847
|
+
}
|
|
9848
|
+
}
|
|
9849
|
+
/**
|
|
9850
|
+
* Every Maps row of one epic, whatever its status (CREW-3444). **Throws**,
|
|
9851
|
+
* unlike `epicRows()`: a brief must tell "this seat may not read Maps" from
|
|
9852
|
+
* "the epic has none", and swallowing the 403 would turn the first into
|
|
9853
|
+
* the second. Callers classify the error.
|
|
9854
|
+
*/
|
|
9855
|
+
async mapRows(epicId) {
|
|
9856
|
+
const model = this.route.resolved?.mapsModelId;
|
|
9857
|
+
if (!model) return [];
|
|
9858
|
+
return this.client.records.list(model, {
|
|
9859
|
+
filters: encodeFilters([{ columnName: this.contract.maps.epicColumn, operator: "EQ", value: epicId }]),
|
|
9860
|
+
limit: 100
|
|
9861
|
+
});
|
|
9862
|
+
}
|
|
9863
|
+
/** One Maps row in full, for the document's text. Throws like `mapRows`. */
|
|
9864
|
+
async mapRow(id) {
|
|
9865
|
+
const model = this.route.resolved?.mapsModelId;
|
|
9866
|
+
if (!model) throw new ConfigError(`route "${this.route.route}" has no Maps table`);
|
|
9867
|
+
return this.client.records.get(model, id);
|
|
9868
|
+
}
|
|
9815
9869
|
/**
|
|
9816
9870
|
* The tickets of these epics that are closed (`closed: true`) or not
|
|
9817
9871
|
* (`closed: false`), for the epic sync (CREW-1255).
|
|
@@ -9977,23 +10031,23 @@ var Tracker = class {
|
|
|
9977
10031
|
this.onReadFailure?.(`reading status changes failed: ${err3 instanceof Error ? err3.message : String(err3)}`);
|
|
9978
10032
|
return [];
|
|
9979
10033
|
}
|
|
9980
|
-
const
|
|
10034
|
+
const str2 = (v) => typeof v === "string" && v ? v : null;
|
|
9981
10035
|
const out = [];
|
|
9982
10036
|
for (const r of rows) {
|
|
9983
10037
|
if (r.event_type !== "field_changed" || r.field !== this.contract.columns.status) continue;
|
|
9984
10038
|
const meta = r.metadata && typeof r.metadata === "object" ? r.metadata : {};
|
|
9985
|
-
const to =
|
|
9986
|
-
const at =
|
|
9987
|
-
const record =
|
|
10039
|
+
const to = str2(meta.to) ?? str2(r.to_value);
|
|
10040
|
+
const at = str2(r.occurred_at) ?? str2(r.created_at);
|
|
10041
|
+
const record = str2(r.record_id);
|
|
9988
10042
|
if (!to || !at || !record) continue;
|
|
9989
10043
|
out.push({
|
|
9990
10044
|
record_id: record,
|
|
9991
10045
|
to,
|
|
9992
10046
|
occurred_at: at,
|
|
9993
|
-
actor_kind:
|
|
9994
|
-
actor_id:
|
|
9995
|
-
actor_name:
|
|
9996
|
-
actor_record_id:
|
|
10047
|
+
actor_kind: str2(r.actor_kind),
|
|
10048
|
+
actor_id: str2(r.actor_id),
|
|
10049
|
+
actor_name: str2(r.actor_name),
|
|
10050
|
+
actor_record_id: str2(r.actor_record_id)
|
|
9997
10051
|
});
|
|
9998
10052
|
}
|
|
9999
10053
|
return out.sort((a, b) => Date.parse(b.occurred_at) - Date.parse(a.occurred_at));
|
|
@@ -19610,11 +19664,14 @@ function otherRunsRemoved(tickets, own) {
|
|
|
19610
19664
|
function ownRunBanner(own) {
|
|
19611
19665
|
const banner = `**Your ticket for this run: ${own.ticket.issue_id}.** Work this one. Any other ticket a live run on this ship is already working has been left out of this digest: it belongs to that run.`;
|
|
19612
19666
|
const block = acceptanceChecklistBlock(acceptanceLines(own.ticket.description));
|
|
19613
|
-
|
|
19667
|
+
const withBlock = block ? `${banner}
|
|
19614
19668
|
|
|
19615
19669
|
\`\`\`
|
|
19616
19670
|
${block}
|
|
19617
19671
|
\`\`\`` : banner;
|
|
19672
|
+
return own.mapBrief ? `${withBlock}
|
|
19673
|
+
|
|
19674
|
+
${own.mapBrief}` : withBlock;
|
|
19618
19675
|
}
|
|
19619
19676
|
function writeDigest(o, d, role, stateDir, runId, own) {
|
|
19620
19677
|
const me = o.route.resolved?.seats[role];
|
|
@@ -22753,6 +22810,169 @@ import { existsSync as existsSync48, mkdirSync as mkdirSync36, readFileSync as r
|
|
|
22753
22810
|
import { join as join53 } from "path";
|
|
22754
22811
|
import { randomBytes } from "crypto";
|
|
22755
22812
|
|
|
22813
|
+
// src/map-brief.ts
|
|
22814
|
+
var MAP_INLINE_LIMIT = 2e4;
|
|
22815
|
+
var str = (v) => typeof v === "string" ? v : "";
|
|
22816
|
+
function citedSections(...texts) {
|
|
22817
|
+
const out = [];
|
|
22818
|
+
const add = (n) => {
|
|
22819
|
+
if (n && !out.includes(n)) out.push(n);
|
|
22820
|
+
};
|
|
22821
|
+
const re = /§+\s*(\d+(?:\.\d+)*)((?:\s*(?:,|and|&|–|-|to)\s*§?\s*\d+(?:\.\d+)*)*)/g;
|
|
22822
|
+
for (const text2 of texts) {
|
|
22823
|
+
for (const m of (text2 ?? "").matchAll(re)) {
|
|
22824
|
+
const nums = [m[1]];
|
|
22825
|
+
const tail3 = m[2] ?? "";
|
|
22826
|
+
const parts = tail3.split(/\s*(?:,|and|&|–|-|to)\s*/).map((p) => p.replace(/^§\s*/, "").trim()).filter(Boolean);
|
|
22827
|
+
const isRange = /^\s*(?:–|-|to)\s*/.test(tail3) && parts.length === 1;
|
|
22828
|
+
if (isRange && /^\d+$/.test(m[1]) && /^\d+$/.test(parts[0])) {
|
|
22829
|
+
const lo = Number(m[1]), hi = Number(parts[0]);
|
|
22830
|
+
if (hi > lo && hi - lo <= 20) for (let n = lo + 1; n <= hi; n++) nums.push(String(n));
|
|
22831
|
+
} else nums.push(...parts);
|
|
22832
|
+
nums.forEach(add);
|
|
22833
|
+
}
|
|
22834
|
+
}
|
|
22835
|
+
return out;
|
|
22836
|
+
}
|
|
22837
|
+
function headingsOf(doc) {
|
|
22838
|
+
const out = [];
|
|
22839
|
+
let fenced = false;
|
|
22840
|
+
doc.split("\n").forEach((raw, line) => {
|
|
22841
|
+
if (/^\s*(```|~~~)/.test(raw)) {
|
|
22842
|
+
fenced = !fenced;
|
|
22843
|
+
return;
|
|
22844
|
+
}
|
|
22845
|
+
if (fenced) return;
|
|
22846
|
+
const m = /^(#{1,6})\s+(.*?)\s*#*\s*$/.exec(raw);
|
|
22847
|
+
if (!m) return;
|
|
22848
|
+
const num2 = /^§?\s*(\d+(?:\.\d+)*)\.?(?=\s|$)/.exec(m[2]);
|
|
22849
|
+
out.push({ line, level: m[1].length, number: num2 ? num2[1] : null, text: m[2] });
|
|
22850
|
+
});
|
|
22851
|
+
return out;
|
|
22852
|
+
}
|
|
22853
|
+
function sectionText(doc, n) {
|
|
22854
|
+
const hs = headingsOf(doc);
|
|
22855
|
+
const i = hs.findIndex((h) => h.number === n);
|
|
22856
|
+
if (i < 0) return null;
|
|
22857
|
+
const lines2 = doc.split("\n");
|
|
22858
|
+
const end = hs.slice(i + 1).find((h) => h.level <= hs[i].level)?.line ?? lines2.length;
|
|
22859
|
+
return lines2.slice(hs[i].line, end).join("\n").trimEnd();
|
|
22860
|
+
}
|
|
22861
|
+
function activeMap(rows, c) {
|
|
22862
|
+
const m = c.maps;
|
|
22863
|
+
const active = rows.filter((r) => str(r[m.statusColumn]) === m.activeStatus);
|
|
22864
|
+
if (!active.length) return null;
|
|
22865
|
+
const ver = (r) => typeof r[m.versionColumn] === "number" ? r[m.versionColumn] : 0;
|
|
22866
|
+
return [...active].sort((a, b) => ver(b) - ver(a) || str(b.updated_at).localeCompare(str(a.updated_at)))[0];
|
|
22867
|
+
}
|
|
22868
|
+
var fence = (s) => {
|
|
22869
|
+
let ticks = "````";
|
|
22870
|
+
while (s.includes(ticks)) ticks += "`";
|
|
22871
|
+
return `${ticks}markdown
|
|
22872
|
+
${s}
|
|
22873
|
+
${ticks}`;
|
|
22874
|
+
};
|
|
22875
|
+
var NO_SEARCH = "It is not in the repository, so do not search the checkout for it.";
|
|
22876
|
+
function howToRead(modelId, row, c) {
|
|
22877
|
+
return `Read the whole Map with the tracker MCP tool \`records_controller_find_one\` (\`dataModelId\` \`${modelId}\`, \`recordId\` \`${row.id}\`): its \`${c.maps.contentColumn}\` field is the document, and its \`${c.maps.conversationColumn}\` field is the interview record behind the decisions, which you read only when you need the reasoning.`;
|
|
22878
|
+
}
|
|
22879
|
+
var PRECEDENCE = "The Map is the planning decision this ticket was derived from. Where it differs from the ticket's own text or a later comment on the ticket, the ticket and its comments win.";
|
|
22880
|
+
function mapBriefSection(i) {
|
|
22881
|
+
const c = i.contract;
|
|
22882
|
+
const epicId = i.ticket[c.columns.epic];
|
|
22883
|
+
if (typeof epicId !== "string" || !epicId || !i.mapsModelId) return null;
|
|
22884
|
+
const label = i.epic ? str(i.epic.label) || epicLabel(i.epic, c) : String(epicId);
|
|
22885
|
+
const head = `### Map for ${label}`;
|
|
22886
|
+
if ("forbidden" in i.maps) {
|
|
22887
|
+
return `${head}
|
|
22888
|
+
|
|
22889
|
+
This ticket belongs to ${label}, whose Map holds the planning decisions behind it. Your seat is not allowed to read the Maps table, so the Map is not supplied. It lives in the tracker. ${NO_SEARCH} Work from the ticket and its comments; if you need something only the Map would say, ask on the ticket.`;
|
|
22890
|
+
}
|
|
22891
|
+
if ("failed" in i.maps) {
|
|
22892
|
+
return `${head}
|
|
22893
|
+
|
|
22894
|
+
This ticket belongs to ${label}, whose Map holds the planning decisions behind it. Reading it failed this run (${i.maps.failed}), so it is not supplied. It lives in the tracker's Maps table (\`${i.mapsModelId}\`), filtered to the epic's row \`${epicId}\`. ${NO_SEARCH}`;
|
|
22895
|
+
}
|
|
22896
|
+
const row = activeMap(i.maps.rows, c);
|
|
22897
|
+
if (!row) {
|
|
22898
|
+
const others = i.maps.rows.map((r) => `v${r[c.maps.versionColumn] ?? "?"} ${str(r[c.maps.statusColumn]) || "no status"}`);
|
|
22899
|
+
const have = others.length ? ` Its Maps are not active (${others.join(", ")}), and a Map that is not active is not a settled plan, so none is supplied.` : " It has no Map.";
|
|
22900
|
+
return `${head}
|
|
22901
|
+
|
|
22902
|
+
${label} has no active Map.${have} ${NO_SEARCH} Work from the ticket and its comments.`;
|
|
22903
|
+
}
|
|
22904
|
+
const doc = str((i.full ?? row)[c.maps.contentColumn]);
|
|
22905
|
+
const title = str(row[c.maps.titleColumn]);
|
|
22906
|
+
const version = row[c.maps.versionColumn];
|
|
22907
|
+
const intro = `This ticket belongs to ${label}. Its active Map${title ? `, "${title}"` : ""}${version != null ? ` (version ${version})` : ""}, is below. It is a record in the tracker's Maps table, not a file in the repository, so a citation such as "Map v1 \xA711" in the ticket refers to this document. ${PRECEDENCE} The interview record is not included.`;
|
|
22908
|
+
if (!doc.trim()) {
|
|
22909
|
+
return `${head}
|
|
22910
|
+
|
|
22911
|
+
${intro}
|
|
22912
|
+
|
|
22913
|
+
The document is empty. ${howToRead(i.mapsModelId, row, c)}`;
|
|
22914
|
+
}
|
|
22915
|
+
const cited = citedSections(i.ticket.title, i.ticket.description);
|
|
22916
|
+
const hs = headingsOf(doc);
|
|
22917
|
+
const where = cited.map((n) => {
|
|
22918
|
+
const h = hs.find((x) => x.number === n);
|
|
22919
|
+
return h ? `\xA7${n} is the section headed "${h.text}"` : `\xA7${n} has no section of that number in this document`;
|
|
22920
|
+
});
|
|
22921
|
+
const cites = where.length ? `
|
|
22922
|
+
|
|
22923
|
+
The ticket cites: ${where.join("; ")}.` : "";
|
|
22924
|
+
if (doc.length <= MAP_INLINE_LIMIT) {
|
|
22925
|
+
return `${head}
|
|
22926
|
+
|
|
22927
|
+
${intro}${cites}
|
|
22928
|
+
|
|
22929
|
+
${fence(doc)}
|
|
22930
|
+
|
|
22931
|
+
${howToRead(i.mapsModelId, row, c)}`;
|
|
22932
|
+
}
|
|
22933
|
+
const parts = cited.map((n) => ({ n, text: sectionText(doc, n) })).filter((p) => p.text != null);
|
|
22934
|
+
const outline = hs.map((h) => `${" ".repeat(Math.max(0, h.level - 1))}- ${h.text}`).join("\n");
|
|
22935
|
+
const body = parts.length ? parts.map((p) => `#### \xA7${p.n}, in full
|
|
22936
|
+
|
|
22937
|
+
${fence(p.text)}`).join("\n\n") : "The ticket cites no section that could be found, so none is included.";
|
|
22938
|
+
return `${head}
|
|
22939
|
+
|
|
22940
|
+
${intro}${cites}
|
|
22941
|
+
|
|
22942
|
+
The document is ${doc.length.toLocaleString("en-US")} characters, too long to include whole. The sections the ticket cites follow in full; the outline lists every heading.
|
|
22943
|
+
|
|
22944
|
+
${body}
|
|
22945
|
+
|
|
22946
|
+
#### Outline of the whole document
|
|
22947
|
+
|
|
22948
|
+
${outline}
|
|
22949
|
+
|
|
22950
|
+
${howToRead(i.mapsModelId, row, c)}`;
|
|
22951
|
+
}
|
|
22952
|
+
async function briefMapFor(src, ticket, mapsModelId, contract) {
|
|
22953
|
+
const epicId = ticket[contract.columns.epic];
|
|
22954
|
+
if (typeof epicId !== "string" || !epicId || !mapsModelId) return null;
|
|
22955
|
+
const epic = await src.epicRow(epicId).catch(() => void 0);
|
|
22956
|
+
let maps;
|
|
22957
|
+
try {
|
|
22958
|
+
maps = { rows: await src.mapRows(epicId) };
|
|
22959
|
+
} catch (e) {
|
|
22960
|
+
maps = isForbiddenError(e) ? { forbidden: true } : { failed: (e instanceof Error ? e.message : String(e)).split("\n")[0].slice(0, 160) };
|
|
22961
|
+
}
|
|
22962
|
+
let full = null;
|
|
22963
|
+
if ("rows" in maps) {
|
|
22964
|
+
const row = activeMap(maps.rows, contract);
|
|
22965
|
+
if (row) {
|
|
22966
|
+
try {
|
|
22967
|
+
full = await src.mapRow(row.id);
|
|
22968
|
+
} catch (e) {
|
|
22969
|
+
if (isForbiddenError(e)) maps = { forbidden: true };
|
|
22970
|
+
}
|
|
22971
|
+
}
|
|
22972
|
+
}
|
|
22973
|
+
return mapBriefSection({ ticket, epic, mapsModelId, maps, full, contract });
|
|
22974
|
+
}
|
|
22975
|
+
|
|
22756
22976
|
// src/outage.ts
|
|
22757
22977
|
var TRANSIENT_BACKOFF_MS = [15e3, 3e4, 6e4];
|
|
22758
22978
|
var OUTAGE_ESCALATE_AFTER = 5;
|
|
@@ -24645,9 +24865,11 @@ async function runRoleAgentLocked(role, decision, ctx, hooks, held) {
|
|
|
24645
24865
|
if (idx >= 0) decision.tickets[idx] = result.ticket;
|
|
24646
24866
|
writeDigest({ route: route2, ship, state: ctx.state, emit }, decision, role, ship.stateDir);
|
|
24647
24867
|
}
|
|
24868
|
+
const mapBrief = await briefMapFor(tracker, result.ticket, route2.resolved?.mapsModelId, contract).catch(() => null);
|
|
24648
24869
|
writeDigest({ route: route2, ship, state: ctx.state, emit }, decision, role, ship.stateDir, runId, {
|
|
24649
24870
|
ticket: result.ticket,
|
|
24650
|
-
inFlight: (id) => ctx.state.ticketInFlight(id)
|
|
24871
|
+
inFlight: (id) => ctx.state.ticketInFlight(id),
|
|
24872
|
+
mapBrief
|
|
24651
24873
|
});
|
|
24652
24874
|
hooks?.ready(true);
|
|
24653
24875
|
ticketHint = result.ticket.issue_id;
|
|
@@ -25977,12 +26199,13 @@ async function listWorkspaces(o) {
|
|
|
25977
26199
|
return res.workspaces.map((w) => ({ slug: w.path ?? w.slug, name: w.name, role: w.role }));
|
|
25978
26200
|
}
|
|
25979
26201
|
var eq = (a, b) => (a ?? "").trim().toLowerCase() === b.trim().toLowerCase();
|
|
25980
|
-
function
|
|
25981
|
-
const linked = agentId ? rows.
|
|
25982
|
-
if (linked)
|
|
25983
|
-
|
|
25984
|
-
|
|
25985
|
-
|
|
26202
|
+
function pickSeat(rows, agentId, storedId) {
|
|
26203
|
+
const linked = agentId ? rows.filter((x) => x.agent_id === agentId) : [];
|
|
26204
|
+
if (storedId && linked.some((x) => x.id === storedId)) return { id: storedId, via: "agent" };
|
|
26205
|
+
if (linked.length === 1) return { id: linked[0].id, via: "agent" };
|
|
26206
|
+
if (linked.length > 1) return { ambiguous: linked };
|
|
26207
|
+
const kept = storedId ? rows.find((x) => x.id === storedId && (!agentId || !x.agent_id)) : void 0;
|
|
26208
|
+
return kept ? { id: kept.id, via: "stored" } : {};
|
|
25986
26209
|
}
|
|
25987
26210
|
var REQUIRED_TABLES = ["Issues"];
|
|
25988
26211
|
async function missingTables(o, projectId) {
|
|
@@ -26002,7 +26225,8 @@ async function discover(o) {
|
|
|
26002
26225
|
holds: [],
|
|
26003
26226
|
candidates: [],
|
|
26004
26227
|
problems,
|
|
26005
|
-
provisioning
|
|
26228
|
+
provisioning,
|
|
26229
|
+
notes: []
|
|
26006
26230
|
};
|
|
26007
26231
|
try {
|
|
26008
26232
|
const me = await get(o, `/auth/me?workspaceId=${ws.id}`);
|
|
@@ -26102,6 +26326,7 @@ async function discover(o) {
|
|
|
26102
26326
|
out.reposModelId = find("Repos");
|
|
26103
26327
|
out.shipsModelId = find("Ships");
|
|
26104
26328
|
out.epicsModelId = find("Epics");
|
|
26329
|
+
out.mapsModelId = find("Maps");
|
|
26105
26330
|
out.periscopesModelId = find("Periscopes");
|
|
26106
26331
|
out.locksModelId = find("Locks");
|
|
26107
26332
|
try {
|
|
@@ -26258,7 +26483,8 @@ async function discover(o) {
|
|
|
26258
26483
|
}
|
|
26259
26484
|
}
|
|
26260
26485
|
let agentIdFor = () => void 0;
|
|
26261
|
-
|
|
26486
|
+
let agentsGap = () => "the Agents table could not be read with this key";
|
|
26487
|
+
if (out.models.crew) {
|
|
26262
26488
|
try {
|
|
26263
26489
|
const agentsModel = await get(o, `/data-models/agents?workspaceId=${ws.id}`);
|
|
26264
26490
|
const agentRows = await get(
|
|
@@ -26266,6 +26492,7 @@ async function discover(o) {
|
|
|
26266
26492
|
`/data-models/${agentsModel.id}/records?limit=200`
|
|
26267
26493
|
);
|
|
26268
26494
|
agentIdFor = (role) => agentRows.find((r) => r.name === PERSONA_NAME[role])?.id;
|
|
26495
|
+
agentsGap = (role) => `the Agents table has no "${PERSONA_NAME[role]}" row`;
|
|
26269
26496
|
} catch {
|
|
26270
26497
|
}
|
|
26271
26498
|
}
|
|
@@ -26289,46 +26516,64 @@ async function discover(o) {
|
|
|
26289
26516
|
}
|
|
26290
26517
|
const scoped = seatShipId ? rows.filter((r) => r.ship_id === seatShipId) : rows.filter((r) => !r.ship_id);
|
|
26291
26518
|
const unclaimed = seatShipId ? rows.filter((r) => !r.ship_id) : [];
|
|
26519
|
+
const stored = o.storedSeats?.(`${out.workspaceSlug}/${out.projectSlug ?? out.projectId}`);
|
|
26520
|
+
const listRows = (rs) => rs.map((r) => `"${r.name ?? ""}" (${r.id})`).join(", ");
|
|
26292
26521
|
for (const role of ["dev", "design", "qa", "triage"]) {
|
|
26293
|
-
const
|
|
26294
|
-
let
|
|
26522
|
+
const agentId = agentIdFor(role);
|
|
26523
|
+
let pick = pickSeat(scoped, agentId, stored?.seats?.[role]);
|
|
26524
|
+
let id = pick.id;
|
|
26295
26525
|
let seatAction = "matched";
|
|
26296
|
-
if (!id &&
|
|
26297
|
-
const
|
|
26298
|
-
if (
|
|
26299
|
-
|
|
26526
|
+
if (!id && !pick.ambiguous && agentId && seatShipId) {
|
|
26527
|
+
const legacy = pickSeat(unclaimed, agentId);
|
|
26528
|
+
if (legacy.ambiguous) pick = legacy;
|
|
26529
|
+
else if (legacy.id) {
|
|
26530
|
+
id = legacy.id;
|
|
26300
26531
|
seatAction = "claimed";
|
|
26532
|
+
if (shipRowId) {
|
|
26533
|
+
await patch(o, `/data-models/${out.models.crew}/records/${id}`, { ship_id: shipRowId });
|
|
26534
|
+
provisioning.push(`claimed existing Crew row for the ${role} seat`);
|
|
26535
|
+
}
|
|
26301
26536
|
}
|
|
26302
|
-
}
|
|
26303
|
-
|
|
26304
|
-
|
|
26305
|
-
|
|
26306
|
-
|
|
26307
|
-
|
|
26308
|
-
|
|
26309
|
-
} else {
|
|
26537
|
+
}
|
|
26538
|
+
if (pick.ambiguous) {
|
|
26539
|
+
problems.push(`${pick.ambiguous.length} Crew rows on this ship are linked to the ${PERSONA_NAME[role]} agent, so the ${role} seat is ambiguous: ${listRows(pick.ambiguous)} \u2014 unlink all but one`);
|
|
26540
|
+
continue;
|
|
26541
|
+
}
|
|
26542
|
+
if (!id && agentId) {
|
|
26543
|
+
if (shipRowId) {
|
|
26310
26544
|
const created = await post2(o, `/data-models/${out.models.crew}/records`, {
|
|
26311
26545
|
name: `${PERSONA_NAME[role]} agent`,
|
|
26312
26546
|
ship_id: shipRowId,
|
|
26313
|
-
|
|
26547
|
+
agent_id: agentId
|
|
26314
26548
|
});
|
|
26315
26549
|
id = created.id;
|
|
26316
26550
|
seatAction = "created";
|
|
26317
26551
|
provisioning.push(`created Crew row for the ${role} seat`);
|
|
26552
|
+
} else if (o.dryRun && out.shipsModelId) {
|
|
26553
|
+
(out.seatRows ??= []).push({ role, id: "", action: "would-create" });
|
|
26554
|
+
continue;
|
|
26318
26555
|
}
|
|
26319
26556
|
}
|
|
26320
26557
|
if (id) {
|
|
26321
26558
|
out.seats[role] = id;
|
|
26322
26559
|
const rowShip = rows.find((r) => r.id === id)?.ship_id ?? shipRowId ?? void 0;
|
|
26323
26560
|
(out.seatRows ??= []).push({ role, id, action: seatAction, ...rowShip ? { shipId: rowShip } : {} });
|
|
26324
|
-
|
|
26325
|
-
|
|
26326
|
-
|
|
26561
|
+
if (pick.via === "stored") (out.notes ??= []).push(`${role} seat kept by its stored id; it is not linked to its Agent \u2014 run \`crew agents sync\` to link it`);
|
|
26562
|
+
} else if (!agentId) {
|
|
26563
|
+
problems.push(`${role} seat: ${agentsGap(role)}, so no Crew row can be matched or created for it (seats are never matched by name) \u2014 run \`crew agents sync\`, then connect again`);
|
|
26564
|
+
} else problems.push(`no Crew row on this ship is linked to the ${PERSONA_NAME[role]} agent for the ${role} seat \u2014 link one, or omit that role`);
|
|
26565
|
+
}
|
|
26566
|
+
const pairAgent = agentIdFor("pair");
|
|
26567
|
+
let pairPick = pickSeat(scoped, pairAgent, stored?.seats?.pair);
|
|
26568
|
+
if (!pairPick.id && !pairPick.ambiguous && pairAgent && seatShipId) pairPick = pickSeat(unclaimed, pairAgent);
|
|
26569
|
+
if (pairPick.ambiguous) {
|
|
26570
|
+
problems.push(`${pairPick.ambiguous.length} Crew rows are linked to the Pair agent, so the pair seat is ambiguous: ${listRows(pairPick.ambiguous)} \u2014 unlink all but one`);
|
|
26571
|
+
} else if (pairPick.id) {
|
|
26572
|
+
out.seats.pair = pairPick.id;
|
|
26573
|
+
if (pairPick.via === "stored") (out.notes ??= []).push("pair seat kept by its stored id; it is not linked to its Agent \u2014 run `crew agents sync` to link it");
|
|
26327
26574
|
}
|
|
26328
|
-
const pairId = seatFor(scoped, "pair") || (seatShipId ? seatFor(unclaimed, "pair") : void 0);
|
|
26329
|
-
if (pairId) out.seats.pair = pairId;
|
|
26330
26575
|
if (shipRowId) {
|
|
26331
|
-
const releaseId =
|
|
26576
|
+
const releaseId = stored?.releaseSeat && scoped.some((r) => r.id === stored.releaseSeat) ? stored.releaseSeat : void 0;
|
|
26332
26577
|
if (releaseId) out.releaseSeat = releaseId;
|
|
26333
26578
|
else {
|
|
26334
26579
|
const created = await post2(o, `/data-models/${out.models.crew}/records`, {
|
|
@@ -27352,6 +27597,7 @@ var SNAPSHOT_TABLES = [
|
|
|
27352
27597
|
{ key: "periscopesModelId", name: "Periscopes" },
|
|
27353
27598
|
{ key: "shipsModelId", name: "Ships" },
|
|
27354
27599
|
{ key: "epicsModelId", name: "Epics" },
|
|
27600
|
+
{ key: "mapsModelId", name: "Maps" },
|
|
27355
27601
|
{ key: "locksModelId", name: "Locks" },
|
|
27356
27602
|
{ key: "reposModelId", name: "Repos" },
|
|
27357
27603
|
{ key: "areaModelId", name: "Projects" }
|
|
@@ -28037,7 +28283,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
28037
28283
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
28038
28284
|
import { join as join60 } from "path";
|
|
28039
28285
|
function builtVersion() {
|
|
28040
|
-
return true ? "0.
|
|
28286
|
+
return true ? "0.157.1" : null;
|
|
28041
28287
|
}
|
|
28042
28288
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
28043
28289
|
function newestMtime(path) {
|
|
@@ -33871,7 +34117,7 @@ Waiting for approval`
|
|
|
33871
34117
|
lastSyncedName: (r) => readSyncedName(resolvedPathFor(cfg.ship.stateDir, r))
|
|
33872
34118
|
};
|
|
33873
34119
|
const runConnect = async (ws, proj) => {
|
|
33874
|
-
let found = await discover({ ...authOpts, workspace: ws, project: proj, area: value("area"), ship, dryRun, interactive: canAsk || connectEvents.json });
|
|
34120
|
+
let found = await discover({ ...authOpts, workspace: ws, project: proj, area: value("area"), ship, dryRun, interactive: canAsk || connectEvents.json, storedSeats: (r) => readStoredSeats(cfg.ship.stateDir, r) });
|
|
33875
34121
|
if (store && keychainBacked && sessionAddress && sessionAddress !== found.workspaceSlug) {
|
|
33876
34122
|
if (await adoptSessionAddress({
|
|
33877
34123
|
store,
|
|
@@ -33920,7 +34166,7 @@ Waiting for approval`
|
|
|
33920
34166
|
const installedSlug = await offerTemplateInstall(authOpts, found.workspaceId, canAsk ? void 0 : true);
|
|
33921
34167
|
if (installedSlug) {
|
|
33922
34168
|
connectEvents.emit("template_installed", `installed project ${installedSlug}`, { projectSlug: installedSlug });
|
|
33923
|
-
found = await discover({ ...authOpts, workspace: ws, project: installedSlug, area: value("area"), ship, dryRun, interactive: canAsk || connectEvents.json });
|
|
34169
|
+
found = await discover({ ...authOpts, workspace: ws, project: installedSlug, area: value("area"), ship, dryRun, interactive: canAsk || connectEvents.json, storedSeats: (r) => readStoredSeats(cfg.ship.stateDir, r) });
|
|
33924
34170
|
}
|
|
33925
34171
|
}
|
|
33926
34172
|
}
|
|
@@ -34068,6 +34314,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
34068
34314
|
areaId: found.areaId,
|
|
34069
34315
|
shipsModelId: found.shipsModelId,
|
|
34070
34316
|
epicsModelId: found.epicsModelId,
|
|
34317
|
+
mapsModelId: found.mapsModelId,
|
|
34071
34318
|
periscopesModelId: found.periscopesModelId,
|
|
34072
34319
|
locksModelId: found.locksModelId,
|
|
34073
34320
|
recordLinkViewId: found.recordLinkViewId,
|
|
@@ -34214,6 +34461,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
34214
34461
|
emit.note(`Provisioned for this machine (${ship.name}):`);
|
|
34215
34462
|
for (const p of found.provisioning) emit.note(` - ${p}`);
|
|
34216
34463
|
}
|
|
34464
|
+
for (const n of found.notes ?? []) emit.note(`Note: ${n}`);
|
|
34217
34465
|
if (found.problems.length) {
|
|
34218
34466
|
emit.warn(`Unresolved \u2014 fix these before arming it:
|
|
34219
34467
|
${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
@@ -34836,18 +35084,18 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
|
34836
35084
|
const repos = await resolvedRepos(rt);
|
|
34837
35085
|
return (await tr.periscopeRows()).map(({ row, ticket }) => {
|
|
34838
35086
|
const repo = repos.find((r) => r.id && r.id === ticket[tr.contract.columns.repo]) ?? (repos.length === 1 ? repos[0] : void 0);
|
|
34839
|
-
const
|
|
35087
|
+
const str2 = (v) => typeof v === "string" ? v : "";
|
|
34840
35088
|
return {
|
|
34841
35089
|
id: row.id,
|
|
34842
35090
|
ticketRecordId: ticket.id,
|
|
34843
35091
|
ticket: ticket.issue_tag ?? ticket.issue_id,
|
|
34844
35092
|
number: /(\d+)$/.exec(ticket.issue_id)?.[1] ?? "",
|
|
34845
35093
|
repo: repo?.name ?? "?",
|
|
34846
|
-
state:
|
|
34847
|
-
url:
|
|
34848
|
-
worktree:
|
|
34849
|
-
branch:
|
|
34850
|
-
lastActivityAt:
|
|
35094
|
+
state: str2(row.state),
|
|
35095
|
+
url: str2(row.url),
|
|
35096
|
+
worktree: str2(row.worktree),
|
|
35097
|
+
branch: str2(row.branch),
|
|
35098
|
+
lastActivityAt: str2(row.last_activity_at) || null,
|
|
34851
35099
|
localUrl: readPeriscopeSidecars(cfg.ship.stateDir).find((x) => x.ticketRecordId === ticket.id)?.localUrl
|
|
34852
35100
|
};
|
|
34853
35101
|
});
|
package/package.json
CHANGED
|
@@ -137,6 +137,28 @@ fetch the tracker yourself exactly as Steps 1 and 2 describe. Everything below
|
|
|
137
137
|
works either way: the digest changes where the list comes from, never what
|
|
138
138
|
you do with it.
|
|
139
139
|
|
|
140
|
+
## A ticket's Map
|
|
141
|
+
|
|
142
|
+
A ticket filed from an epic's planning document cites it by name and section,
|
|
143
|
+
such as "Map v1 §11". That document is the epic's **Map**: a record in the
|
|
144
|
+
tracker's Maps table, linked to the epic, never a file in any repository. Do
|
|
145
|
+
not search the checkout for it.
|
|
146
|
+
|
|
147
|
+
When the ticket belongs to an epic and the workspace keeps Maps, your brief
|
|
148
|
+
ends its ticket banner with a "Map for <epic>" section. It holds the epic's
|
|
149
|
+
active Map, whole, or, when the document is too long, the sections the ticket
|
|
150
|
+
cites in full, an outline of every heading and the tracker call that reads the
|
|
151
|
+
rest. It may instead say the epic has no active Map, or that your seat may not
|
|
152
|
+
read it; believe that and carry on from the ticket. A draft or superseded Map
|
|
153
|
+
is never supplied in place of the active one.
|
|
154
|
+
|
|
155
|
+
The Map is the planning decision the ticket was derived from, so read the
|
|
156
|
+
sections the ticket cites before you scope the work. **The ticket wins:** where
|
|
157
|
+
the Map differs from the ticket's own text or from a later comment on the
|
|
158
|
+
ticket, follow the ticket and its comments. The Map's interview record is not
|
|
159
|
+
in the brief; read it (the Map's `conversation` field) only when you need the
|
|
160
|
+
reasoning behind a decision.
|
|
161
|
+
|
|
140
162
|
## Step 1 — check your own open tickets first
|
|
141
163
|
|
|
142
164
|
Before picking up anything new, take the digest's "Step 1" table or, absent a
|
|
@@ -138,6 +138,28 @@ fetch the tracker yourself exactly as Steps 1 and 2 describe. Everything below
|
|
|
138
138
|
works either way: the digest changes where the list comes from, never what
|
|
139
139
|
you do with it.
|
|
140
140
|
|
|
141
|
+
## A ticket's Map
|
|
142
|
+
|
|
143
|
+
A ticket filed from an epic's planning document cites it by name and section,
|
|
144
|
+
such as "Map v1 §11". That document is the epic's **Map**: a record in the
|
|
145
|
+
tracker's Maps table, linked to the epic, never a file in any repository. Do
|
|
146
|
+
not search the checkout for it.
|
|
147
|
+
|
|
148
|
+
When the ticket belongs to an epic and the workspace keeps Maps, your brief
|
|
149
|
+
ends its ticket banner with a "Map for <epic>" section. It holds the epic's
|
|
150
|
+
active Map, whole, or, when the document is too long, the sections the ticket
|
|
151
|
+
cites in full, an outline of every heading and the tracker call that reads the
|
|
152
|
+
rest. It may instead say the epic has no active Map, or that your seat may not
|
|
153
|
+
read it; believe that and carry on from the ticket. A draft or superseded Map
|
|
154
|
+
is never supplied in place of the active one.
|
|
155
|
+
|
|
156
|
+
The Map is the planning decision the ticket was derived from, so read the
|
|
157
|
+
sections the ticket cites before you scope the work. **The ticket wins:** where
|
|
158
|
+
the Map differs from the ticket's own text or from a later comment on the
|
|
159
|
+
ticket, follow the ticket and its comments. The Map's interview record is not
|
|
160
|
+
in the brief; read it (the Map's `conversation` field) only when you need the
|
|
161
|
+
reasoning behind a decision.
|
|
162
|
+
|
|
141
163
|
## Step 1 — check your own open tickets first
|
|
142
164
|
|
|
143
165
|
Before picking up anything new, take the digest's "Step 1" table or, absent a
|