@tablation/crew 0.160.0 → 0.161.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/dist/cli.js CHANGED
@@ -4589,6 +4589,8 @@ function parseResolved(raw, m, where) {
4589
4589
  epicsModelId: raw.epicsModelId,
4590
4590
  mapsModelId: raw.mapsModelId,
4591
4591
  periscopesModelId: raw.periscopesModelId,
4592
+ questionsModelId: raw.questionsModelId,
4593
+ answersModelId: raw.answersModelId,
4592
4594
  locksModelId: raw.locksModelId,
4593
4595
  recordLinkViewId: raw.recordLinkViewId,
4594
4596
  reposModelId: raw.reposModelId,
@@ -8406,10 +8408,10 @@ var SEAT_WRITE_ISSUE_FIELDS = [
8406
8408
  "cost_usd"
8407
8409
  ];
8408
8410
  var canWrite = (level) => level === "WRITE" || level === "DELETE";
8409
- function refusedIssueFields(body, columns = SEAT_WRITE_ISSUE_FIELDS) {
8411
+ function refusedIssueFields(body, columns2 = SEAT_WRITE_ISSUE_FIELDS) {
8410
8412
  const fields = body?.fields;
8411
8413
  if (!fields || typeof fields !== "object") return [];
8412
- return columns.filter((c) => c in fields && !canWrite(fields[c]));
8414
+ return columns2.filter((c) => c in fields && !canWrite(fields[c]));
8413
8415
  }
8414
8416
  async function getJson(url, apiKey, o) {
8415
8417
  const res = await (o.fetchImpl ?? fetch)(url, {
@@ -9084,7 +9086,9 @@ var TABLE_ENTRIES = [
9084
9086
  { role: "epics", defaultName: "Epics", label: "Epics table", optional: true, whatBreaks: "Without it tickets cannot belong to an epic." },
9085
9087
  { role: "maps", defaultName: "Maps", label: "Maps table", optional: true, whatBreaks: "Without it a ticket cannot cite its epic\u2019s planning document." },
9086
9088
  { role: "periscopes", defaultName: "Periscopes", label: "Periscopes table", optional: true, whatBreaks: "Without it crew cannot host live previews." },
9087
- { role: "locks", defaultName: "Locks", label: "Locks table", optional: true, whatBreaks: "Without it ships cannot take the release lock through the board." }
9089
+ { role: "locks", defaultName: "Locks", label: "Locks table", optional: true, whatBreaks: "Without it ships cannot take the release lock through the board." },
9090
+ { role: "questions", defaultName: "Questions", label: "Questions table", optional: true, whatBreaks: "Without it a seat that parks a ticket for an answer cannot also ask the question as a record with proposed answers; the comment still carries it." },
9091
+ { role: "answers", defaultName: "Answers", label: "Answers table", optional: true, whatBreaks: "Without it a question cannot offer proposed answers." }
9088
9092
  ];
9089
9093
  function f(table2, name, contractPath, defaultColumn, kind, label, whatBreaks, extra = {}) {
9090
9094
  return { role: `${table2}.${name}`, table: table2, contractPath, defaultColumn, kind, label, whatBreaks, ...extra };
@@ -9132,6 +9136,22 @@ var FIELD_ENTRIES = [
9132
9136
  f("comments", "ship", "comments.ship", "ship_id", "link", "Posted from ship", "Without it a comment does not name the machine that posted it.", opt),
9133
9137
  f("comments", "publicReply", "comments.publicReply", "is_public_reply", "boolean", "Public reply", "Without it replies from a public form are read as the team\u2019s.", opt),
9134
9138
  f("comments", "authorName", "comments.authorName", "author_name", "text", "Public author name", "Without it a public reporter\u2019s name is lost.", opt),
9139
+ // The optional questions part (interface 1.1, CREW-3588). The shapes are the
9140
+ // ones the platform's Record choices requirement asks of its questions and
9141
+ // answers tables; `questionsPartMapped` says when a mapping carries enough of
9142
+ // them for crew to write a question. Each role is optional here because the
9143
+ // whole part is: an app that maps none of it still conforms.
9144
+ f("questions", "parent", "questions.parent", "ticket_id", "link", "Question ticket", "Without it a question cannot be tied to the ticket it is about, so crew writes none.", { ...opt, linkTo: "issues" }),
9145
+ f("questions", "text", "questions.text", "question", "text", "Question text", "Without it a question has no words.", opt),
9146
+ f("questions", "status", "questions.status", "status", "choice", "Question status", "Without it crew cannot tell an open question from an answered or withdrawn one.", opt),
9147
+ f("questions", "askedBy", "questions.askedBy", "asked_by_id", "link", "Asked by", "Without it a question does not say which seat asked it, so crew cannot withdraw its own earlier question.", opt),
9148
+ f("questions", "addressedTo", "questions.addressedTo", "addressed_to_id", "link", "Addressed to", "Without it a question does not say who it is waiting on.", opt),
9149
+ f("questions", "answeredBy", "questions.answeredBy", "answered_by_id", "link", "Answered by", "Without it an answered question does not say who answered.", opt),
9150
+ f("questions", "chosenAnswer", "questions.chosenAnswer", "chosen_answer_id", "link", "Chosen answer", "Without it an answered question does not say which answer was chosen.", { ...opt, linkTo: "answers" }),
9151
+ f("answers", "question", "answers.question", "question_id", "link", "Answer question", "Without it an answer cannot be tied to its question, so crew offers none.", { ...opt, linkTo: "questions" }),
9152
+ f("answers", "label", "answers.label", "label", "text", "Answer label", "Without it an answer has no short label to show on a button.", opt),
9153
+ f("answers", "detail", "answers.detail", "detail", "text", "Answer detail", "Without it an answer has no full instruction to act on when chosen.", opt),
9154
+ f("answers", "order", "answers.order", "position", "number", "Answer order", "Without it the answers show in the order they were created, not the order the seat intended.", opt),
9135
9155
  f("epics", "status", "epics.statusColumn", "status", "choice", "Epic status", "Without it crew cannot keep an epic\u2019s status from its tickets.", opt),
9136
9156
  f("epics", "key", "epics.keyColumn", "epic_id", "any", "Epic key", "Without it an epic has no name in the log.", opt),
9137
9157
  f("maps", "epic", "maps.epicColumn", "epic_id", "link", "Map epic", "Without it a Map cannot be matched to its epic.", opt),
@@ -9158,6 +9178,11 @@ var STATUS_MEANINGS = [
9158
9178
  { id: "cantReproduce", label: "Can\u2019t reproduce", defaultValue: "closed_cant_reproduce", open: false, resolved: true, meaning: "Closed as written, unreproducible." },
9159
9179
  { id: "draft", label: "Draft", defaultValue: "draft", contractKey: "draft", open: false, resolved: false, optional: true, meaning: "Held back; never polled." }
9160
9180
  ];
9181
+ var QUESTION_STATUS_MEANINGS = [
9182
+ { id: "open", label: "Open", defaultValue: "open", meaning: "Waiting for a person to answer." },
9183
+ { id: "answered", label: "Answered", defaultValue: "answered", meaning: "A person chose an answer or replied in writing." },
9184
+ { id: "withdrawn", label: "Withdrawn", defaultValue: "withdrawn", meaning: "The asker took it back, usually because it asked again on the same ticket." }
9185
+ ];
9161
9186
  function defaultGroup(group) {
9162
9187
  const out = {};
9163
9188
  for (const e of FIELD_ENTRIES) {
@@ -9166,6 +9191,10 @@ function defaultGroup(group) {
9166
9191
  }
9167
9192
  return out;
9168
9193
  }
9194
+ function defaultQuestionStatuses() {
9195
+ const v = (id) => QUESTION_STATUS_MEANINGS.find((q2) => q2.id === id).defaultValue;
9196
+ return { open: v("open"), answered: v("answered"), withdrawn: v("withdrawn") };
9197
+ }
9169
9198
  function defaultStatusValues() {
9170
9199
  const open2 = STATUS_MEANINGS.filter((s) => s.open && s.defaultValue).map((s) => s.defaultValue);
9171
9200
  const resolved = STATUS_MEANINGS.filter((s) => s.resolved && s.defaultValue).map((s) => s.defaultValue);
@@ -9187,11 +9216,21 @@ function sideToUpdate(v) {
9187
9216
  }
9188
9217
  function contractFromMapping(base, mapping) {
9189
9218
  const next = structuredClone(base);
9190
- const groups = { columns: next.columns, comments: next.comments, epics: next.epics, maps: next.maps };
9219
+ const groups = {
9220
+ columns: next.columns,
9221
+ comments: next.comments,
9222
+ epics: next.epics,
9223
+ maps: next.maps,
9224
+ questions: next.questions,
9225
+ answers: next.answers
9226
+ };
9191
9227
  for (const e of FIELD_ENTRIES) {
9192
9228
  const col = mapping.fields[e.role];
9193
- if (!col) continue;
9194
9229
  const [group, key] = e.contractPath.split(".");
9230
+ if (!col) {
9231
+ if (group === "questions" || group === "answers") Object.assign(groups[group], { [key]: "" });
9232
+ continue;
9233
+ }
9195
9234
  Object.assign(groups[group], { [key]: col });
9196
9235
  }
9197
9236
  const mapped = mapping.values?.["status"] ?? {};
@@ -9206,11 +9245,27 @@ function contractFromMapping(base, mapping) {
9206
9245
  }
9207
9246
  next.statuses.open = open2;
9208
9247
  next.statuses.resolved = resolved;
9248
+ const questionValues = mapping.values?.["questionStatus"] ?? {};
9249
+ for (const q2 of QUESTION_STATUS_MEANINGS) {
9250
+ Object.assign(next.questionStatuses, { [q2.id]: questionValues[q2.id] ?? q2.defaultValue });
9251
+ }
9209
9252
  return next;
9210
9253
  }
9211
9254
  function mappedTableName(mapping, role) {
9212
9255
  return mapping.tables?.[role];
9213
9256
  }
9257
+ var QUESTIONS_PART_ROLES = [
9258
+ "questions.parent",
9259
+ "questions.text",
9260
+ "questions.status",
9261
+ "questions.askedBy",
9262
+ "answers.question",
9263
+ "answers.label",
9264
+ "answers.detail"
9265
+ ];
9266
+ function questionsPartMapped(mapping) {
9267
+ return !!mapping.tables?.["questions"] && !!mapping.tables?.["answers"] && QUESTIONS_PART_ROLES.every((r) => !!mapping.fields?.[r]);
9268
+ }
9214
9269
  function describeShape(roleId) {
9215
9270
  const t = TABLE_ENTRIES.find((x) => x.role === roleId);
9216
9271
  if (t) return "a table";
@@ -9252,6 +9307,9 @@ var DEFAULT_CONTRACT = {
9252
9307
  statuses: { planned: "planned", building: "in_progress", done: "done", cancelled: "cancelled" }
9253
9308
  },
9254
9309
  maps: { ...MAP_DEFAULTS, activeStatus: "active" },
9310
+ questions: defaultGroup("questions"),
9311
+ answers: defaultGroup("answers"),
9312
+ questionStatuses: defaultQuestionStatuses(),
9255
9313
  priorityOrder: ["p0", "p1", "p2", "p3"],
9256
9314
  severityOrder: ["s1", "s2", "s3", "s4"],
9257
9315
  unknownPriorityRank: 2,
@@ -9275,6 +9333,9 @@ function resolveContract(override) {
9275
9333
  statuses: { ...DEFAULT_CONTRACT.epics.statuses, ...override.epics?.statuses }
9276
9334
  },
9277
9335
  maps: { ...DEFAULT_CONTRACT.maps, ...override.maps },
9336
+ questions: { ...DEFAULT_CONTRACT.questions, ...override.questions },
9337
+ answers: { ...DEFAULT_CONTRACT.answers, ...override.answers },
9338
+ questionStatuses: { ...DEFAULT_CONTRACT.questionStatuses, ...override.questionStatuses },
9278
9339
  priorityOrder: override.priorityOrder ?? DEFAULT_CONTRACT.priorityOrder,
9279
9340
  severityOrder: override.severityOrder ?? DEFAULT_CONTRACT.severityOrder,
9280
9341
  unknownPriorityRank: override.unknownPriorityRank ?? DEFAULT_CONTRACT.unknownPriorityRank,
@@ -10289,6 +10350,33 @@ var Tracker = class _Tracker {
10289
10350
  if (res.status === 404) throw new ConfigError(EVENT_LOG_MISSING);
10290
10351
  if (!res.ok) throw new Error(`posting a ${type} event failed: HTTP ${res.status}${await refusalReason(res)}`);
10291
10352
  }
10353
+ /**
10354
+ * The questions part's tables when this route's app maps it (interface 1.1,
10355
+ * CREW-3588), else null: an app at 1.0, an undeclared app, or a mapping that
10356
+ * leaves a table out. Nothing is written for a null.
10357
+ */
10358
+ questionsPart() {
10359
+ const r = this.route.resolved;
10360
+ return r?.questionsModelId && r.answersModelId ? { questionsModelId: r.questionsModelId, answersModelId: r.answersModelId } : null;
10361
+ }
10362
+ /** The seat's own open questions on a ticket (its askedBy, never a person's). */
10363
+ async listOpenQuestions(part, ticketId, askedBy) {
10364
+ const q2 = this.contract.questions;
10365
+ return this.client.records.list(part.questionsModelId, {
10366
+ filters: encodeFilters([
10367
+ { columnName: q2.parent, operator: "EQ", value: ticketId },
10368
+ { columnName: q2.status, operator: "EQ", value: this.contract.questionStatuses.open },
10369
+ { columnName: q2.askedBy, operator: "EQ", value: askedBy }
10370
+ ]),
10371
+ limit: 100
10372
+ });
10373
+ }
10374
+ async updateRecord(modelId, id, fields) {
10375
+ await this.client.records.update(modelId, id, fields);
10376
+ }
10377
+ async createRecord(modelId, fields) {
10378
+ return this.client.records.create(modelId, fields);
10379
+ }
10292
10380
  /** A ticket comment under a seat's identity (CREW-2363: the replayed hand-off comment). */
10293
10381
  async postComment(ticketId, body, memberId) {
10294
10382
  const auth = await this.authorshipProbe();
@@ -10649,11 +10737,11 @@ var Tracker = class _Tracker {
10649
10737
  [this.route.resolved?.shipsModelId, "Ships", ["kind", "instance_class", "relay_url"]]
10650
10738
  ];
10651
10739
  const missing = [];
10652
- for (const [modelId, label, columns] of wanted) {
10740
+ for (const [modelId, label, columns2] of wanted) {
10653
10741
  if (!modelId) continue;
10654
10742
  const have = await this.columnNames(modelId);
10655
10743
  if (have.size === 0) continue;
10656
- for (const c of columns) if (!have.has(c)) missing.push(`${label}.${c}`);
10744
+ for (const c of columns2) if (!have.has(c)) missing.push(`${label}.${c}`);
10657
10745
  }
10658
10746
  return missing;
10659
10747
  }
@@ -14546,7 +14634,7 @@ function planAgentRun(o) {
14546
14634
  // resolved yet has nothing to authenticate the MCP connection with either.
14547
14635
  mcp: o.apiKey ? { url: `${o.route.baseUrl}/api/mcp`, keyVar: API_KEY_VAR } : void 0
14548
14636
  });
14549
- const columns = resolveContract(o.route.contract).columns;
14637
+ const columns2 = resolveContract(o.route.contract).columns;
14550
14638
  const agentLog = o.route.resolved && o.apiKey ? {
14551
14639
  baseUrl: o.route.baseUrl,
14552
14640
  workspaceId: o.route.resolved.workspaceId,
@@ -14556,15 +14644,15 @@ function planAgentRun(o) {
14556
14644
  ...o.route.resolved.models?.crew && o.route.resolved.seats?.[o.role] ? { actor: { table: o.route.resolved.models.crew, recordId: o.route.resolved.seats[o.role] } } : {},
14557
14645
  ...o.route.resolved.models?.issues ? { tickets: {
14558
14646
  issuesModelId: o.route.resolved.models.issues,
14559
- keyColumn: columns.key,
14560
- tagColumn: columns.tag,
14647
+ keyColumn: columns2.key,
14648
+ tagColumn: columns2.tag,
14561
14649
  counters: {
14562
- agentRuns: columns.agentRuns,
14563
- tokensIn: columns.tokensIn,
14564
- tokensOut: columns.tokensOut,
14565
- cacheReadTokens: columns.cacheReadTokens,
14566
- cacheWriteTokens: columns.cacheWriteTokens,
14567
- costUsd: columns.costUsd
14650
+ agentRuns: columns2.agentRuns,
14651
+ tokensIn: columns2.tokensIn,
14652
+ tokensOut: columns2.tokensOut,
14653
+ cacheReadTokens: columns2.cacheReadTokens,
14654
+ cacheWriteTokens: columns2.cacheWriteTokens,
14655
+ costUsd: columns2.costUsd
14568
14656
  }
14569
14657
  } } : {}
14570
14658
  } : void 0;
@@ -16952,7 +17040,10 @@ var VALUE_FLAGS = /* @__PURE__ */ new Set([
16952
17040
  "requested-by",
16953
17041
  "issue",
16954
17042
  "shell",
16955
- "resume"
17043
+ "resume",
17044
+ "question",
17045
+ "answer",
17046
+ "to"
16956
17047
  ]);
16957
17048
  function positionalArgs(argv2) {
16958
17049
  const out = [];
@@ -21901,7 +21992,7 @@ async function runReview(r, verified, reviewing) {
21901
21992
  }
21902
21993
  return out;
21903
21994
  }
21904
- async function applyReview(tracker, contract, outcome, remote, emit, seat, columns, dryRun) {
21995
+ async function applyReview(tracker, contract, outcome, remote, emit, seat, columns2, dryRun) {
21905
21996
  const reviewing = contract.statuses.reviewing;
21906
21997
  for (const h of outcome.handoffs) {
21907
21998
  if (!reviewing) break;
@@ -21920,8 +22011,8 @@ ${h.prFailure.tail}
21920
22011
  try {
21921
22012
  await tracker.updateTicket(t.id, {
21922
22013
  [contract.columns.status]: reviewing,
21923
- ...h.prRef && columns.prRef ? { [contract.columns.prRef]: h.prRef } : {},
21924
- ...h.prUrl && columns.prUrl ? { [contract.columns.prUrl]: h.prUrl } : {}
22014
+ ...h.prRef && columns2.prRef ? { [contract.columns.prRef]: h.prRef } : {},
22015
+ ...h.prUrl && columns2.prUrl ? { [contract.columns.prUrl]: h.prUrl } : {}
21925
22016
  }, t.updated_at);
21926
22017
  await tracker.postEvent(t.id, lines2.join("\n\n"), seat, "review");
21927
22018
  emit.emit(`moved to ${reviewing}`, { ticket: t.issue_id });
@@ -26707,6 +26798,58 @@ function renderStatus(v, opts) {
26707
26798
  return out;
26708
26799
  }
26709
26800
 
26801
+ // src/questions.ts
26802
+ var MIN_ANSWERS = 2;
26803
+ var MAX_ANSWERS = 4;
26804
+ function validateAsk(req) {
26805
+ const problems = [];
26806
+ if (!req.question.trim()) problems.push("the question is empty");
26807
+ const n = req.answers.length;
26808
+ if (n === 1) problems.push(`one proposed answer is not a choice \u2014 give ${MIN_ANSWERS} to ${MAX_ANSWERS}, or none for a question that needs a free-form answer`);
26809
+ if (n > MAX_ANSWERS) problems.push(`${n} proposed answers is too many \u2014 give ${MIN_ANSWERS} to ${MAX_ANSWERS}`);
26810
+ req.answers.forEach((a, i) => {
26811
+ if (!a.label.trim()) problems.push(`answer ${i + 1} has no label`);
26812
+ if (!a.detail.trim()) problems.push(`answer ${i + 1} has no detail`);
26813
+ });
26814
+ return problems;
26815
+ }
26816
+ function columns(pairs) {
26817
+ return Object.fromEntries(pairs.filter(([name, value2]) => name && value2 !== void 0));
26818
+ }
26819
+ async function askQuestion(store, part, contract, req) {
26820
+ const q2 = contract.questions;
26821
+ const a = contract.answers;
26822
+ const st = contract.questionStatuses;
26823
+ const earlier = await store.listOpenQuestions(part, req.ticketId, req.askedBy);
26824
+ for (const old of earlier) await store.updateRecord(part.questionsModelId, old.id, { [q2.status]: st.withdrawn });
26825
+ const made = await store.createRecord(part.questionsModelId, columns([
26826
+ [q2.parent, req.ticketId],
26827
+ [q2.text, req.question.trim()],
26828
+ [q2.status, st.open],
26829
+ [q2.askedBy, req.askedBy],
26830
+ [q2.addressedTo, req.addressedTo]
26831
+ ]));
26832
+ const answerIds = [];
26833
+ try {
26834
+ for (const [i, ans] of req.answers.entries()) {
26835
+ const row = await store.createRecord(part.answersModelId, columns([
26836
+ [a.question, made.id],
26837
+ [a.label, ans.label.trim()],
26838
+ [a.detail, ans.detail.trim()],
26839
+ [a.order, i + 1]
26840
+ ]));
26841
+ answerIds.push(row.id);
26842
+ }
26843
+ } catch (e) {
26844
+ try {
26845
+ await store.updateRecord(part.questionsModelId, made.id, { [q2.status]: st.withdrawn });
26846
+ } catch {
26847
+ }
26848
+ throw e;
26849
+ }
26850
+ return { withdrawn: earlier.map((e) => e.id), questionId: made.id, answerIds };
26851
+ }
26852
+
26710
26853
  // src/connect.ts
26711
26854
  var ConnectHttpError = class extends Error {
26712
26855
  status;
@@ -27002,6 +27145,14 @@ async function discover(o) {
27002
27145
  out.epicsModelId = find("epics");
27003
27146
  out.mapsModelId = find("maps");
27004
27147
  out.periscopesModelId = find("periscopes");
27148
+ if (usesMapping && mapping && questionsPartMapped(mapping)) {
27149
+ out.questionsModelId = find("questions");
27150
+ out.answersModelId = find("answers");
27151
+ if (!out.questionsModelId || !out.answersModelId) {
27152
+ out.questionsModelId = void 0;
27153
+ out.answersModelId = void 0;
27154
+ }
27155
+ }
27005
27156
  out.locksModelId = find("locks");
27006
27157
  try {
27007
27158
  const views = await get(o, `/views?workspaceId=${ws.id}`);
@@ -28997,7 +29148,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
28997
29148
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
28998
29149
  import { join as join60 } from "path";
28999
29150
  function builtVersion() {
29000
- return true ? "0.160.0" : null;
29151
+ return true ? "0.161.0" : null;
29001
29152
  }
29002
29153
  var REBUILD_HINT = "rebuild with npm run build";
29003
29154
  function newestMtime(path) {
@@ -31227,6 +31378,8 @@ function usage(problem, requested = false) {
31227
31378
  crew shell-init [--shell zsh|bash|fish] print the periscope shell function (install: eval "$(crew shell-init)")
31228
31379
  crew worktree [route] NNN cut (or refresh) this run's worktree for a ticket from the remote; prints its path
31229
31380
  crew unassign [route] NNN hand back a session's ticket \u2014 clears assignee, next cycle picks it up
31381
+ crew ask [route] NNN --question TEXT [--answer "LABEL :: DETAIL"]... [--to CREW_ROW_ID] [--role dev|design|qa]
31382
+ write a parked ticket's question as a record with 2-4 proposed answers (none for a free-form question); a no-op when the app maps no questions part
31230
31383
  crew footprint [route] NNN [path...] record the files a ticket will change (once), then print PROCEED or YIELD against active work
31231
31384
  crew sandbox cache [--refresh|--prune|--reset] [--json] list the sandbox cache volume's mirrors; --refresh runs the daemon's cache pass once (creates missing mirrors), --prune drops unserved repositories, --reset recreates the volume
31232
31385
  crew sync [route] fast-forward the checkout and its worktrees from the remote
@@ -31358,6 +31511,7 @@ var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
31358
31511
  "sync",
31359
31512
  "unassign",
31360
31513
  "footprint",
31514
+ "ask",
31361
31515
  "uninstall",
31362
31516
  "watch",
31363
31517
  "whoami",
@@ -35109,6 +35263,8 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
35109
35263
  epicsModelId: found.epicsModelId,
35110
35264
  mapsModelId: found.mapsModelId,
35111
35265
  periscopesModelId: found.periscopesModelId,
35266
+ questionsModelId: found.questionsModelId,
35267
+ answersModelId: found.answersModelId,
35112
35268
  locksModelId: found.locksModelId,
35113
35269
  recordLinkViewId: found.recordLinkViewId,
35114
35270
  reposModelId: found.reposModelId,
@@ -36359,6 +36515,59 @@ ${where.join("\n")}`);
36359
36515
  }
36360
36516
  break;
36361
36517
  }
36518
+ case "ask": {
36519
+ const argsA = positional.slice(1);
36520
+ const nA = argsA.map(parseTicketNumber).find((x) => x !== null);
36521
+ const usageA = '`crew ask 326 --question "Which way?" --answer "Option A :: Do A" --answer "Option B :: Do B" --to <crew row id>`';
36522
+ if (!nA) {
36523
+ die("crew ask", "need a ticket number (326, ISSUE-326, or TABL-326)", usageA);
36524
+ }
36525
+ const questionA = value("question");
36526
+ if (!questionA) {
36527
+ die("crew ask", "need --question TEXT", usageA);
36528
+ }
36529
+ const answersA = [];
36530
+ argv.forEach((a, i) => {
36531
+ if (a !== "--answer") return;
36532
+ const raw = argv[i + 1] ?? "";
36533
+ const at = raw.indexOf("::");
36534
+ if (at < 0) {
36535
+ die("crew ask", `--answer "${raw}" needs a label and a detail separated by "::"`, usageA);
36536
+ }
36537
+ answersA.push({ label: raw.slice(0, at).trim(), detail: raw.slice(at + 2).trim() });
36538
+ });
36539
+ const trA = new Tracker(route2, cfg.ship);
36540
+ const partA = trA.questionsPart();
36541
+ if (!partA) {
36542
+ process.stdout.write("no questions part: this app does not map one, so nothing was written \u2014 post the comment as usual\n");
36543
+ break;
36544
+ }
36545
+ const openA = await trA.openTickets();
36546
+ const ticketA = openA.find((t) => t[trA.contract.columns.key] === `ISSUE-${nA}`);
36547
+ if (!ticketA) {
36548
+ die("crew ask", `no open ticket ISSUE-${nA} on ${route2.route}`, "`crew inbox` to list open tickets");
36549
+ }
36550
+ const seatsA = route2.resolved?.seats ?? {};
36551
+ const roleA = value("role") ?? "dev";
36552
+ const holderA = ticketA[trA.contract.columns.assignee];
36553
+ const askedByA = holderA && Object.values(seatsA).includes(holderA) ? holderA : seatsA[roleA];
36554
+ if (!askedByA) {
36555
+ die("crew ask", `no seat for role "${roleA}" on ${route2.route}`, "pass --role dev|design|qa");
36556
+ }
36557
+ const reqA = { ticketId: ticketA.id, question: questionA, answers: answersA, askedBy: askedByA, addressedTo: value("to") };
36558
+ const problemsA = validateAsk(reqA);
36559
+ if (problemsA.length) {
36560
+ die("crew ask", problemsA.join("; "), `${MIN_ANSWERS} to ${MAX_ANSWERS} --answer flags, or none for a free-form question`);
36561
+ }
36562
+ if (dryRun) {
36563
+ emit.emit(`would withdraw this seat's open questions on ${displayKey(ticketA)}, then ask one with ${answersA.length} proposed answer(s)`);
36564
+ break;
36565
+ }
36566
+ const doneA = await askQuestion(trA, partA, trA.contract, reqA);
36567
+ process.stdout.write(`asked on ${displayKey(ticketA)}: question ${doneA.questionId} with ${doneA.answerIds.length} answer(s)${doneA.withdrawn.length ? `, withdrew ${doneA.withdrawn.length} earlier` : ""}
36568
+ `);
36569
+ break;
36570
+ }
36362
36571
  case "footprint": {
36363
36572
  const args = positional.slice(1);
36364
36573
  const at = args.findIndex((a) => parseTicketNumber(a) !== null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.160.0",
3
+ "version": "0.161.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",
@@ -635,6 +635,29 @@ ticket looks:
635
635
  sensible default, state it ("If you just approve this without replying, I
636
636
  will <default>."). Approving with no reply then means that default.
637
637
 
638
+ **Also ask it as a record, when the app takes questions.** Before you post a
639
+ stop comment that asks a person to decide or answer something, run
640
+ `crew ask <ticket number> --question "<the question>" --role <your lane>`, with
641
+ `--to <the park-to Crew row id>` when the park names a person, and one
642
+ `--answer "<label> :: <detail>"` per proposed answer. It writes the question as
643
+ a record the person can answer with one click. It is a no-op that says so when
644
+ the app has no questions part, so run it every time and then post the comment as
645
+ usual; the comment is never skipped, and it still opens with the question. A
646
+ failure of the command is never a reason to hold the park back.
647
+
648
+ - Offer answers only when the choices are genuinely discrete: two to four
649
+ options you could each act on at once. Give the recommended one first, and the
650
+ default you would take on a bare approval is that first one. Each label is a
651
+ few words for a button; each detail is the full instruction you will act on if
652
+ it is chosen.
653
+ - A question that needs a free-form answer (a name, a description, an opinion,
654
+ "what should this say?") is asked with no `--answer` at all. Do not invent
655
+ options to fill the space.
656
+ - Asking again on the same ticket withdraws your earlier open question, so the
657
+ person never sees two. Do not read the question record to learn the answer:
658
+ a chosen answer arrives as a comment from the person, which you already treat
659
+ as direction.
660
+
638
661
  **A parked ticket that comes back unanswered is not an answer.** When a ticket
639
662
  you parked with a question returns to `accepted` (or has `needs_planning`
640
663
  cleared) and no person has commented since your question — a comment from your
@@ -26,6 +26,10 @@ No worktree and no code changes; only an answer.
26
26
  4. Set `status` to `needs_info`, `needs_planning` to true, and `assignee_id`
27
27
  to the Crew row in the ticket's `park to` cell (none: leave it unassigned,
28
28
  no personal address).
29
+ When the closing question is a decision between discrete choices, ask it as
30
+ a record too (`crew ask`, see "Stopping" in the shared policy) with the
31
+ recommended choice first; a question that needs a free-form answer is asked
32
+ with no answers.
29
33
  Close the answer by saying what you need from the person in one plain
30
34
  sentence and asking them to reply in a comment — never to change the
31
35
  status (see "Stopping" in the shared policy). This is the designed ending
@@ -612,6 +612,29 @@ on data. There are two kinds, each written where the operator looks:
612
612
  sensible default, state it ("If you just approve this without replying, I
613
613
  will <default>."). Approving with no reply then means that default.
614
614
 
615
+ **Also ask it as a record, when the app takes questions.** Before you post a
616
+ stop comment that asks a person to decide or answer something, run
617
+ `crew ask <ticket number> --question "<the question>" --role <your lane>`, with
618
+ `--to <the park-to Crew row id>` when the park names a person, and one
619
+ `--answer "<label> :: <detail>"` per proposed answer. It writes the question as
620
+ a record the person can answer with one click. It is a no-op that says so when
621
+ the app has no questions part, so run it every time and then post the comment as
622
+ usual; the comment is never skipped, and it still opens with the question. A
623
+ failure of the command is never a reason to hold the park back.
624
+
625
+ - Offer answers only when the choices are genuinely discrete: two to four
626
+ options you could each act on at once. Give the recommended one first, and the
627
+ default you would take on a bare approval is that first one. Each label is a
628
+ few words for a button; each detail is the full instruction you will act on if
629
+ it is chosen.
630
+ - A question that needs a free-form answer (a name, a description, an opinion,
631
+ "what should this say?") is asked with no `--answer` at all. Do not invent
632
+ options to fill the space.
633
+ - Asking again on the same ticket withdraws your earlier open question, so the
634
+ person never sees two. Do not read the question record to learn the answer:
635
+ a chosen answer arrives as a comment from the person, which you already treat
636
+ as direction.
637
+
615
638
  **A parked ticket that comes back unanswered is not an answer.** When a ticket
616
639
  you parked with a question returns to `accepted` (or has `needs_planning`
617
640
  cleared) and no person has commented since your question — a comment from your
@@ -24,6 +24,10 @@ No worktree and no code changes; only an answer.
24
24
  rests on, the way a closing comment cites what changed.
25
25
  4. Set `status` to `needs_info`, `needs_planning` to true, and `assignee_id`
26
26
  to the operator's Crew row (see the roster).
27
+ When the closing question is a decision between discrete choices, ask it as
28
+ a record too (`crew ask`, see "Stopping" in the shared policy) with the
29
+ recommended choice first; a question that needs a free-form answer is asked
30
+ with no answers.
27
31
  Close the answer by saying what you need from the person in one plain
28
32
  sentence and asking them to reply in a comment — never to change the
29
33
  status (see "Stopping" in the shared policy). This is the designed ending