@drisp/cli 0.7.11 → 0.7.13

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
@@ -141,10 +141,14 @@ import {
141
141
  teamDefaultSchema,
142
142
  teamIdentityPath,
143
143
  todoGlyphSet,
144
+ trackerImportPreviewSchema,
145
+ trackerIssueSchema,
146
+ trackerOperationSchema,
147
+ trackerSnapshotSchema,
144
148
  visualPositionToOffset,
145
149
  wrapText,
146
150
  writeIdentityOnce
147
- } from "./chunk-YHXTTSJE.js";
151
+ } from "./chunk-5TM2ARN3.js";
148
152
  import {
149
153
  generateId as generateId2
150
154
  } from "./chunk-PQIB66SG.js";
@@ -203,7 +207,7 @@ import {
203
207
  workflowRegistryDir,
204
208
  writeGlobalConfig,
205
209
  writeProjectConfig
206
- } from "./chunk-XITT6UQX.js";
210
+ } from "./chunk-SACVOS6T.js";
207
211
  import {
208
212
  __toESM
209
213
  } from "./chunk-G3PMV62Z.js";
@@ -211,10 +215,10 @@ import {
211
215
  // src/app/entry/cli.tsx
212
216
  import { render } from "ink";
213
217
  import meow from "meow";
214
- import fs12 from "fs";
218
+ import fs13 from "fs";
215
219
  import { createRequire } from "module";
216
220
  import os5 from "os";
217
- import path12 from "path";
221
+ import path13 from "path";
218
222
  import { fileURLToPath } from "url";
219
223
 
220
224
  // src/app/shell/sessionUiState.ts
@@ -5333,14 +5337,14 @@ function extractWebSearch(_input, response) {
5333
5337
  return { type: "text", content: extractTextContent(response), maxLines: 10 };
5334
5338
  }
5335
5339
  function extractNotebookEdit(input, _response) {
5336
- const path13 = typeof input["notebook_path"] === "string" ? input["notebook_path"] : "";
5340
+ const path14 = typeof input["notebook_path"] === "string" ? input["notebook_path"] : "";
5337
5341
  const mode = typeof input["edit_mode"] === "string" ? input["edit_mode"] : "replace";
5338
5342
  const source = typeof input["new_source"] === "string" ? input["new_source"] : "";
5339
- if (!source) return { type: "text", content: `${mode} cell in ${path13}` };
5343
+ if (!source) return { type: "text", content: `${mode} cell in ${path14}` };
5340
5344
  return {
5341
5345
  type: "code",
5342
5346
  content: source,
5343
- language: detectLanguage(path13),
5347
+ language: detectLanguage(path14),
5344
5348
  maxLines: 10
5345
5349
  };
5346
5350
  }
@@ -5866,10 +5870,10 @@ function extractToolSubject(toolName, toolInput) {
5866
5870
  const parts = [];
5867
5871
  const pattern = str(input, "pattern");
5868
5872
  const glob = str(input, "glob");
5869
- const path13 = str(input, "path");
5873
+ const path14 = str(input, "path");
5870
5874
  if (pattern) parts.push(`"${pattern}"`);
5871
5875
  if (glob) parts.push(glob);
5872
- if (path13) parts.push(`in ${path13}`);
5876
+ if (path14) parts.push(`in ${path14}`);
5873
5877
  return parts.length > 0 ? parts.join(" ") : void 0;
5874
5878
  }
5875
5879
  case "Skill":
@@ -13100,7 +13104,7 @@ var thisMachine = (installationId) => ({
13100
13104
  os: `${platform()} ${release()}`.slice(0, 64),
13101
13105
  softwareVersion: runnerSoftwareVersion
13102
13106
  });
13103
- var post = (origin, path13, body) => fetch(new URL(path13, origin), {
13107
+ var post = (origin, path14, body) => fetch(new URL(path14, origin), {
13104
13108
  method: "POST",
13105
13109
  headers: { "Content-Type": "application/json" },
13106
13110
  body: JSON.stringify(body)
@@ -13119,8 +13123,8 @@ async function alreadyConnected(existing, { forTeam, ownIdentity }) {
13119
13123
  const problem = own ? await credentialAccepted(own.config) ? void 0 : "lapsed" : forTeam(existing.orgId).length ? "other_runner" : "missing";
13120
13124
  const runner = { orgId: existing.orgId, runnerId: existing.runnerId, name: existing.name };
13121
13125
  if (own && problem === void 0) return { status: "already_connected", ...runner, path: own.path };
13122
- const path13 = (own ?? forTeam(existing.orgId)[0])?.path;
13123
- return { status: "identity_unusable", ...runner, problem, ...path13 ? { path: path13 } : {} };
13126
+ const path14 = (own ?? forTeam(existing.orgId)[0])?.path;
13127
+ return { status: "identity_unusable", ...runner, problem, ...path14 ? { path: path14 } : {} };
13124
13128
  }
13125
13129
  async function connectWithCode({
13126
13130
  code,
@@ -13192,20 +13196,20 @@ async function saveIdentity(origin, credential, { single, forTeam }, directory)
13192
13196
  name: credential.name
13193
13197
  });
13194
13198
  const replaced = [];
13195
- for (const { path: path14 } of forTeam(credential.orgId)) {
13196
- const aside = `${path14}.replaced-${Date.now()}`;
13197
- await rename(path14, aside);
13199
+ for (const { path: path15 } of forTeam(credential.orgId)) {
13200
+ const aside = `${path15}.replaced-${Date.now()}`;
13201
+ await rename(path15, aside);
13198
13202
  replaced.push(aside);
13199
13203
  }
13200
- const path13 = single ?? teamIdentityPath(origin, credential.orgId, directory);
13204
+ const path14 = single ?? teamIdentityPath(origin, credential.orgId, directory);
13201
13205
  try {
13202
- await writeIdentityOnce(path13, JSON.stringify(config, null, 2) + "\n");
13206
+ await writeIdentityOnce(path14, JSON.stringify(config, null, 2) + "\n");
13203
13207
  } catch (error) {
13204
13208
  if (error.code === "EEXIST")
13205
- throw new Error(`Another Connect wrote a Runner identity for this Team at ${path13} meanwhile; it was left unchanged.`);
13209
+ throw new Error(`Another Connect wrote a Runner identity for this Team at ${path14} meanwhile; it was left unchanged.`);
13206
13210
  throw error;
13207
13211
  }
13208
- return { status: "connected", config, path: path13, replaced };
13212
+ return { status: "connected", config, path: path14, replaced };
13209
13213
  }
13210
13214
  function pathSegment(value) {
13211
13215
  const segment = encodeURIComponent(value);
@@ -13245,7 +13249,7 @@ async function refuseExisting(target) {
13245
13249
  throw new Error(`This machine already has a Runner${name ? ` (${name})` : ""} configured at ${target}.`);
13246
13250
  }
13247
13251
  async function disconnectRunner({
13248
- identity: { path: path13, config },
13252
+ identity: { path: path14, config },
13249
13253
  serviceManager,
13250
13254
  othersRemain
13251
13255
  }) {
@@ -13278,7 +13282,7 @@ async function disconnectRunner({
13278
13282
  await restore();
13279
13283
  throw new Error(`The Hub refused to disconnect ${name} (${body.error ?? response.status}); it is still connected.`);
13280
13284
  }
13281
- await forgetRunner(path13);
13285
+ await forgetRunner(path14);
13282
13286
  if (othersRemain) await restore();
13283
13287
  else await serviceManager?.remove();
13284
13288
  return result;
@@ -13431,18 +13435,18 @@ async function runRunnerCommandV2(input, options = {}) {
13431
13435
  `This machine is already connected to this Team as ${outcome.name}, but ${why}. ` + (code ? `The code was not used: connect a new Runner in its place with ${retry}. ` : `Connect a new Runner in its place with a Connect code from Settings \u2192 Runners: ${retry}. `) + `The old ${outcome.name} stays listed in Settings \u2192 Runners, offline.`
13432
13436
  );
13433
13437
  }
13434
- const { config, path: path13, replaced } = outcome;
13438
+ const { config, path: path14, replaced } = outcome;
13435
13439
  for (const aside of replaced)
13436
13440
  process.stdout.write(
13437
13441
  `The Hub no longer recognised this machine's earlier identity for this Team; it was moved aside to ${aside}.
13438
13442
  `
13439
13443
  );
13440
13444
  process.stdout.write(
13441
- `Connected as ${config.name ?? config.runnerId}. Identity saved to ${path13}.
13445
+ `Connected as ${config.name ?? config.runnerId}. Identity saved to ${path14}.
13442
13446
  `
13443
13447
  );
13444
13448
  if (services) {
13445
- const service = await ensureService(services, config, path13);
13449
+ const service = await ensureService(services, config, path14);
13446
13450
  process.stdout.write(`${serviceStarted(service)}
13447
13451
  `);
13448
13452
  return 0;
@@ -13451,7 +13455,7 @@ async function runRunnerCommandV2(input, options = {}) {
13451
13455
  process.stdout.write(
13452
13456
  "No launchd or systemd here to run the Runner as a background service; running it in the foreground instead.\n"
13453
13457
  );
13454
- await runConfiguredRunner(path13, options.signal);
13458
+ await runConfiguredRunner(path14, options.signal);
13455
13459
  return 0;
13456
13460
  }
13457
13461
  case "disconnect": {
@@ -13522,9 +13526,9 @@ async function runRunnerCommandV2(input, options = {}) {
13522
13526
  configured: true,
13523
13527
  // One entry per Team this machine serves; credentials are never printed.
13524
13528
  teams: identities.map(
13525
- ({ path: path13, config: { token: _token, ...config } }) => ({
13529
+ ({ path: path14, config: { token: _token, ...config } }) => ({
13526
13530
  ...config,
13527
- path: path13
13531
+ path: path14
13528
13532
  })
13529
13533
  ),
13530
13534
  service: service ? {
@@ -13873,9 +13877,9 @@ var DrispClient = class _DrispClient {
13873
13877
  if (!match) throw new Error("invalid_hub_url");
13874
13878
  return new _DrispClient(url.origin, decodeURIComponent(match[1]), async () => token);
13875
13879
  }
13876
- async request(path13, body) {
13880
+ async request(path14, body) {
13877
13881
  const response = await fetch(
13878
- `${this.baseUrl}/v2/orgs/${encodeURIComponent(this.orgId)}${path13}`,
13882
+ `${this.baseUrl}/v2/orgs/${encodeURIComponent(this.orgId)}${path14}`,
13879
13883
  {
13880
13884
  method: body === void 0 ? "GET" : "POST",
13881
13885
  headers: {
@@ -13893,6 +13897,24 @@ var DrispClient = class _DrispClient {
13893
13897
  submit(command) {
13894
13898
  return this.request("/commands", commandSchema.parse(command));
13895
13899
  }
13900
+ async tracker() {
13901
+ return trackerSnapshotSchema.parse(await this.request("/tracker"));
13902
+ }
13903
+ async trackerIssue(id) {
13904
+ return trackerIssueSchema.parse(await this.request(`/tracker/issues/${encodeURIComponent(id)}`));
13905
+ }
13906
+ trackerOperation(operation) {
13907
+ return this.request("/tracker", trackerOperationSchema.parse(operation));
13908
+ }
13909
+ async previewLinearImport(input) {
13910
+ return trackerImportPreviewSchema.parse(await this.trackerOperation({ kind: "import.preview", input }));
13911
+ }
13912
+ async commitLinearImport(previewId) {
13913
+ return trackerSnapshotSchema.parse(await this.trackerOperation({ kind: "import.commit", previewId }));
13914
+ }
13915
+ startIssue(id, command) {
13916
+ return this.request(`/tracker/issues/${encodeURIComponent(id)}/start`, commandSchema.parse(command));
13917
+ }
13896
13918
  /** The recent Runs; with a filter, every Run carrying that key or every child of that Run, newest first. */
13897
13919
  async runs(filter) {
13898
13920
  const query = !filter ? "" : "key" in filter ? `?key=${encodeURIComponent(filter.key)}` : `?parent=${encodeURIComponent(filter.parent)}`;
@@ -14207,8 +14229,15 @@ var buildStateSchema = external_exports.strictObject({
14207
14229
  * written before parses.
14208
14230
  */
14209
14231
  done: external_exports.array(external_exports.string()).optional(),
14210
- /** The merged issues the Orchestrator was already asked to repair in Linear, so it is asked once. */
14211
- repaired: external_exports.array(external_exports.string()).optional()
14232
+ /**
14233
+ * The merged issues the Orchestrator was asked to repair in Linear. No longer written since reconcile (DRI-277),
14234
+ * still read so a state written before parses.
14235
+ */
14236
+ repaired: external_exports.array(external_exports.string()).optional(),
14237
+ /** Additive (DRI-277): the `once` keys of the comments reconcile already asked for, so each is asked once. */
14238
+ posted: external_exports.array(external_exports.string()).optional(),
14239
+ /** Additive (DRI-277): reconcile ticks in a row; at `RECONCILE_PASSES` the tick goes on without one. */
14240
+ reconcilePasses: external_exports.number().int().nonnegative().optional()
14212
14241
  });
14213
14242
 
14214
14243
  // src/core/build/childStart.ts
@@ -14266,10 +14295,13 @@ function outcomeOf(view) {
14266
14295
  return "failed";
14267
14296
  }
14268
14297
  function buildLimits(own, delegation) {
14269
- if (!delegation) return own;
14298
+ if (!delegation) return { ...own, maxChildren: own.maxChildren ?? 1 };
14270
14299
  return {
14271
14300
  ...own,
14272
- maxChildren: Math.min(own.maxChildren, delegation.maxChildren),
14301
+ maxChildren: Math.min(
14302
+ own.maxChildren ?? Infinity,
14303
+ delegation.maxChildren ?? own.maxChildren ?? 1
14304
+ ),
14273
14305
  tokenBudget: delegation.tokenBudget
14274
14306
  };
14275
14307
  }
@@ -14327,11 +14359,13 @@ function assessTick(facts) {
14327
14359
  state.needsPerson[entry.id] = BUILD_STRINGS.rebaseFailed(branchOf(entry));
14328
14360
  }
14329
14361
  const pullRequests = /* @__PURE__ */ new Map();
14362
+ const byEntry = /* @__PURE__ */ new Map();
14330
14363
  const prsOf = (entry) => {
14331
14364
  const branch = attemptsOf(entry.id).at(-1)?.branch ?? issues.get(entry.id)?.branchName;
14332
14365
  if (!branch) return void 0;
14333
14366
  if (!pullRequests.has(branch))
14334
14367
  pullRequests.set(branch, facts.pullRequests(branch));
14368
+ byEntry.set(entry.id, pullRequests.get(branch));
14335
14369
  return pullRequests.get(branch);
14336
14370
  };
14337
14371
  const status = /* @__PURE__ */ new Map();
@@ -14339,8 +14373,6 @@ function assessTick(facts) {
14339
14373
  const linear = issues.get(id)?.state.type;
14340
14374
  return linear === "completed" ? "done" : "blocked";
14341
14375
  };
14342
- const repair = [];
14343
- const repaired = new Set(state.repaired ?? []);
14344
14376
  for (const entry of entries) {
14345
14377
  const attempts2 = attemptsOf(entry.id);
14346
14378
  const newest = attempts2.at(-1);
@@ -14349,19 +14381,7 @@ function assessTick(facts) {
14349
14381
  const statusOf = () => {
14350
14382
  if (linear === "completed" || linear === "canceled") return "done";
14351
14383
  const prs = entry.profile === "investigation" ? void 0 : prsOf(entry);
14352
- if (prs?.merged) {
14353
- if (!repaired.has(entry.id) && !(newest && occupies(view))) {
14354
- const prUrl = prs.mergedUrl ?? branchOf(entry);
14355
- repair.push({
14356
- id: entry.id,
14357
- identifier: entry.identifier,
14358
- prUrl,
14359
- comment: BUILD_STRINGS.repairComment(prUrl, orchestratorRunId)
14360
- });
14361
- repaired.add(entry.id);
14362
- }
14363
- return "done";
14364
- }
14384
+ if (prs?.merged) return "done";
14365
14385
  if (newest && (!view || !view.closed)) return "live";
14366
14386
  const current = issues.get(entry.id);
14367
14387
  if (!current || eligibilityReason(current)) {
@@ -14374,7 +14394,7 @@ function assessTick(facts) {
14374
14394
  }
14375
14395
  if (newest?.outcome === "template_mismatch") return "replan";
14376
14396
  if (newest?.outcome === "completed")
14377
- state.needsPerson[entry.id] ??= entry.profile === "investigation" ? "The investigation ended without marking its accepted findings Done in Linear. Review its evidence." : BUILD_STRINGS.completedUnmerged;
14397
+ state.needsPerson[entry.id] ??= entry.profile === "investigation" ? "The investigation ended. Review its findings and evidence on the issue." : BUILD_STRINGS.completedUnmerged;
14378
14398
  if (state.needsPerson[entry.id] || newest && !mayRetry(attempts2))
14379
14399
  return "needs_person";
14380
14400
  const blockers = [
@@ -14399,12 +14419,12 @@ function assessTick(facts) {
14399
14419
  if (status.get(entry.id) === "done" && state.needsPerson[entry.id] === BUILD_STRINGS.completedUnmerged)
14400
14420
  delete state.needsPerson[entry.id];
14401
14421
  }
14402
- if (repaired.size > 0) state.repaired = [...repaired];
14403
14422
  const tokenBudget = facts.limits.tokenBudget;
14404
14423
  const attempts = [
14405
14424
  ...facts.children.map((view) => ({
14406
14425
  tokenCap: view.parent?.tokenCap ?? Number.NaN,
14407
- closed: view.closed
14426
+ closed: view.closed,
14427
+ ...view.usage ? { spent: view.usage.counted } : {}
14408
14428
  })),
14409
14429
  ...Object.values(state.attempts).flat().filter((attempt) => !views.has(attempt.runId)).map((attempt) => ({ tokenCap: attempt.tokenCap, closed: false }))
14410
14430
  ];
@@ -14442,7 +14462,7 @@ function assessTick(facts) {
14442
14462
  return {
14443
14463
  state,
14444
14464
  status,
14445
- repair,
14465
+ pullRequests: byEntry,
14446
14466
  queue,
14447
14467
  slots: Math.max(0, facts.limits.maxChildren - occupying),
14448
14468
  ...park ? { park } : {}
@@ -14450,6 +14470,17 @@ function assessTick(facts) {
14450
14470
  }
14451
14471
  function tickAction(input) {
14452
14472
  const live = input.children.filter((view) => !view.closed);
14473
+ const questions = live.filter(
14474
+ (view) => view.execution?.status === "awaiting_attention" && view.scheduling === "idle" && view.execution.interruption?.kind === "question" && view.execution.interruption.respondent === "orchestrator" && !view.cancellation
14475
+ );
14476
+ if (questions.length)
14477
+ return {
14478
+ action: "supervise",
14479
+ children: questions.map((view) => ({
14480
+ runId: view.runId,
14481
+ message: view.execution.interruption.message
14482
+ }))
14483
+ };
14453
14484
  if (input.started > 0 || live.some((view) => occupies(view)))
14454
14485
  return { action: "wait" };
14455
14486
  const remaining = input.entries.some(
@@ -14472,13 +14503,126 @@ function tickAction(input) {
14472
14503
  };
14473
14504
  }
14474
14505
 
14506
+ // src/core/build/reconcile.ts
14507
+ var RECONCILE_PASSES = 3;
14508
+ var WEB_QA = /* @__PURE__ */ new Set(["web", "both"]);
14509
+ var NOT_HUMAN = "waiting";
14510
+ function teamStatus(status, issue) {
14511
+ const states = issue.teamStates;
14512
+ if (!states) return status;
14513
+ const type = status === "Todo" ? "unstarted" : status === "Released" ? "completed" : "started";
14514
+ const names = status === "Review" || status === "QA" || status === "Ready" ? [status, "In Review", "Review", "In Progress"] : status === "Released" ? [status, "Done"] : [status];
14515
+ for (const name of names) {
14516
+ const match = states.find(
14517
+ (s) => s.type === type && s.name.toLowerCase() === name.toLowerCase()
14518
+ );
14519
+ if (match) return match.name;
14520
+ }
14521
+ if (status === "Needs Input") return void 0;
14522
+ if (issue.state.type === type && states.some((s) => s.name === issue.state.name))
14523
+ return issue.state.name;
14524
+ return states.find((s) => s.type === type)?.name;
14525
+ }
14526
+ function desired(entry, facts, views) {
14527
+ const newest = facts.attempts[entry.id]?.at(-1);
14528
+ const view = newest && views.get(newest.runId);
14529
+ const live = newest !== void 0 && (!view || !view.closed);
14530
+ const prs = facts.pullRequests.get(entry.id);
14531
+ const interruption = view?.execution?.interruption;
14532
+ if (facts.released?.(entry.id)) return { status: "Released", comments: [] };
14533
+ if (live && view?.execution?.status === "awaiting_attention" && interruption && interruption.kind !== NOT_HUMAN && !(interruption.kind === "question" && interruption.respondent === "orchestrator")) {
14534
+ const step = facts.step?.(view.runId);
14535
+ return {
14536
+ status: "Needs Input",
14537
+ comments: [
14538
+ {
14539
+ body: BUILD_STRINGS.askComment({
14540
+ message: interruption.message,
14541
+ runId: view.runId,
14542
+ ...step ? { step } : {}
14543
+ }),
14544
+ once: `ask:${view.runId}:${interruption.interruptionId}`
14545
+ }
14546
+ ]
14547
+ };
14548
+ }
14549
+ if (prs?.merged) {
14550
+ const pr = prComment(prs.mergedUrl);
14551
+ if (!WEB_QA.has(entry.qa)) return { status: "Ready", comments: pr };
14552
+ const results = facts.qa?.(entry.id) ?? [];
14553
+ const last = results.at(-1);
14554
+ if (!last) return { status: "QA", comments: pr };
14555
+ if (last.passed) return { status: "Ready", comments: pr };
14556
+ const failures = results.filter((result) => !result.passed).length;
14557
+ return {
14558
+ status: failures >= 2 ? "Needs Input" : "Todo",
14559
+ comments: [...pr, { body: last.report, once: `qa:${last.runId}` }]
14560
+ };
14561
+ }
14562
+ if (prs?.open) return { status: "Review", comments: prComment(prs.openUrl) };
14563
+ if (live) return { status: "In Progress", comments: [] };
14564
+ if (entry.profile === "investigation" && newest?.outcome === "completed")
14565
+ return { status: "Review", comments: [] };
14566
+ if (newest) return { status: "Todo", comments: [] };
14567
+ return { comments: [] };
14568
+ }
14569
+ function prComment(url) {
14570
+ return url ? [{ body: BUILD_STRINGS.prComment(url), once: `pr:${url}` }] : [];
14571
+ }
14572
+ var closedIssue = (issue) => issue.state.type === "completed" || issue.state.type === "canceled";
14573
+ function projectStatus(facts) {
14574
+ const current = facts.project.status;
14575
+ const issues = facts.issues.filter((issue) => !issue.external);
14576
+ const completed = issues.length > 0 && issues.every(closedIssue);
14577
+ const started = facts.entries.some(
14578
+ (entry) => (facts.attempts[entry.id]?.length ?? 0) > 0
14579
+ );
14580
+ if (current === "Planned" && started) return "In Progress";
14581
+ if (current === "In Progress" && completed) return "Completed";
14582
+ if (current === "Completed" && !completed) return "In Progress";
14583
+ return void 0;
14584
+ }
14585
+ function reconcile(facts) {
14586
+ const views = new Map(facts.children.map((view) => [view.runId, view]));
14587
+ const issues = new Map(facts.issues.map((issue) => [issue.id, issue]));
14588
+ const posted = new Set(facts.posted);
14589
+ const actions = [];
14590
+ const asked = [];
14591
+ for (const entry of facts.entries) {
14592
+ const issue = issues.get(entry.id);
14593
+ if (!issue || issue.external || closedIssue(issue) || issue.labels.includes("ready-for-human"))
14594
+ continue;
14595
+ const implied = desired(entry, facts, views);
14596
+ const { comments } = implied;
14597
+ const status = implied.status ?? (issue.state.name === "In Progress" ? "Todo" : void 0);
14598
+ const target = status && teamStatus(status, issue);
14599
+ if (target && target !== issue.state.name)
14600
+ actions.push({ kind: "issue.state", issue: entry.id, state: target });
14601
+ for (const comment of comments) {
14602
+ if (posted.has(comment.once)) continue;
14603
+ posted.add(comment.once);
14604
+ asked.push(comment.once);
14605
+ actions.push({ kind: "issue.comment", issue: entry.id, ...comment });
14606
+ }
14607
+ }
14608
+ const project = projectStatus(facts);
14609
+ if (project)
14610
+ actions.push({
14611
+ kind: "project.state",
14612
+ project: facts.project.id,
14613
+ state: project
14614
+ });
14615
+ return { actions, posted: asked };
14616
+ }
14617
+
14475
14618
  // src/core/build/tick.ts
14476
14619
  var UNAVAILABLE_RETRY_MS = 2e3;
14477
14620
  var UNAVAILABLE_RETRY_FOR_MS = 3e4;
14478
14621
  var NEVER = (/* @__PURE__ */ new Date(0)).toISOString();
14479
14622
  var notStarted = () => ({
14480
- action: "complete",
14481
- message: BUILD_STRINGS.notStarted
14623
+ action: "park",
14624
+ reason: "attention",
14625
+ message: "This Build has not been started. Review the plan and choose Start; no child work has completed."
14482
14626
  });
14483
14627
  var guidanceFile = (artifacts) => path7.join(artifacts, "input", "guidance.json");
14484
14628
  function replan(artifacts, guidance) {
@@ -14625,10 +14769,6 @@ async function runBuildTick(deps) {
14625
14769
  ))
14626
14770
  push(worktree.path, worktree.branch);
14627
14771
  };
14628
- if (assessment.repair.length > 0) {
14629
- record();
14630
- return { action: "repair", issues: assessment.repair };
14631
- }
14632
14772
  const deferred = [];
14633
14773
  const behind = [];
14634
14774
  let started = 0;
@@ -14744,6 +14884,24 @@ async function runBuildTick(deps) {
14744
14884
  }
14745
14885
  if (installed) removeWorkflow(entry.workflowName);
14746
14886
  }
14887
+ const linear = reconcile({
14888
+ project: input.project,
14889
+ entries,
14890
+ issues: input.issues,
14891
+ attempts: state.attempts,
14892
+ children: children.runs,
14893
+ pullRequests: assessment.pullRequests,
14894
+ posted: state.posted ?? []
14895
+ });
14896
+ const passes = state.reconcilePasses ?? 0;
14897
+ if (linear.actions.length > 0 && passes < RECONCILE_PASSES) {
14898
+ state.reconcilePasses = passes + 1;
14899
+ if (linear.posted.length > 0)
14900
+ state.posted = [...state.posted ?? [], ...linear.posted];
14901
+ record();
14902
+ return { action: "reconcile", actions: linear.actions };
14903
+ }
14904
+ delete state.reconcilePasses;
14747
14905
  record();
14748
14906
  if (behind.length > 0) return { action: "rebase", items: behind };
14749
14907
  return tickAction({
@@ -15103,8 +15261,120 @@ function runBuildCheck(input) {
15103
15261
  return code;
15104
15262
  }
15105
15263
 
15264
+ // src/core/build/supervision.ts
15265
+ import { randomUUID as randomUUID3 } from "crypto";
15266
+ async function superviseChild(input) {
15267
+ const { hub, parentId, operation } = input;
15268
+ if (operation === "children") return hub.runs({ parent: parentId });
15269
+ if (!input.childId) throw new BuildUsageError("A child Run id is required.");
15270
+ const child = await hub.run(input.childId);
15271
+ if (child.parent?.runId !== parentId)
15272
+ throw new BuildUsageError(
15273
+ "Only a direct child of this Build can be inspected or guided."
15274
+ );
15275
+ if (operation === "inspect") {
15276
+ const after = input.after ?? 0;
15277
+ if (!Number.isSafeInteger(after) || after < 0)
15278
+ throw new BuildUsageError(
15279
+ "The history cursor must be a nonnegative integer."
15280
+ );
15281
+ return { child, history: await hub.historyPage(child.runId, after) };
15282
+ }
15283
+ const text = input.text?.trim();
15284
+ if (!text || text.length > 12e4)
15285
+ throw new BuildUsageError("Guidance must contain 1\u2013120000 characters.");
15286
+ if (child.closed || child.cancellation)
15287
+ throw new BuildUsageError("The child is closed or cancelling.");
15288
+ const interruption = child.execution?.interruption;
15289
+ const message = `Orchestrator ${parentId} technical guidance (not a human approval):
15290
+ ${text}`;
15291
+ const { hubEpoch } = await hub.runs({ parent: parentId });
15292
+ const base = {
15293
+ commandId: randomUUID3(),
15294
+ hubEpoch,
15295
+ runId: child.runId,
15296
+ expectedRecordRevision: child.recordRevision
15297
+ };
15298
+ if (child.execution?.status === "awaiting_attention") {
15299
+ if (interruption?.kind !== "question" || interruption.respondent !== "orchestrator" || interruption.requestId)
15300
+ throw new BuildUsageError(
15301
+ "This interruption is reserved for a member. Inspect it and escalate the specific decision."
15302
+ );
15303
+ return hub.submit({
15304
+ ...base,
15305
+ intent: {
15306
+ kind: "answer",
15307
+ interruptionId: interruption.interruptionId,
15308
+ expectedInterruptionRevision: interruption.revision,
15309
+ answer: message
15310
+ }
15311
+ });
15312
+ }
15313
+ if (child.execution?.status !== "running")
15314
+ throw new BuildUsageError(
15315
+ "The child is not running; inspect its scheduling state before retrying."
15316
+ );
15317
+ return hub.submit({ ...base, intent: { kind: "steer", text: message } });
15318
+ }
15319
+
15320
+ // src/core/build/evidenceCopy.ts
15321
+ import fs11 from "fs";
15322
+ import path11 from "path";
15323
+ function copyEvidence(cwd, source, name) {
15324
+ if (!source || !name || !/^[a-zA-Z0-9][a-zA-Z0-9._-]*\.(png|jpe?g|webp)$/i.test(name))
15325
+ throw new BuildUsageError(
15326
+ "Usage: drisp build evidence-copy <screenshot> <filename.png|jpg|webp>"
15327
+ );
15328
+ const root = fs11.realpathSync(cwd);
15329
+ let directory = root;
15330
+ for (const part of [".athena", "evidence"]) {
15331
+ directory = path11.join(directory, part);
15332
+ try {
15333
+ fs11.mkdirSync(directory);
15334
+ } catch (error) {
15335
+ if (error.code !== "EEXIST") throw error;
15336
+ }
15337
+ const stat = fs11.lstatSync(directory);
15338
+ if (stat.isSymbolicLink() || !stat.isDirectory())
15339
+ throw new BuildUsageError(
15340
+ "Evidence directories must be real directories inside this worktree."
15341
+ );
15342
+ }
15343
+ const sourcePath = path11.resolve(root, source);
15344
+ const fd = fs11.openSync(
15345
+ sourcePath,
15346
+ fs11.constants.O_RDONLY | fs11.constants.O_NOFOLLOW
15347
+ );
15348
+ let bytes;
15349
+ try {
15350
+ const stat = fs11.fstatSync(fd);
15351
+ if (!stat.isFile() || stat.size > 25 * 1024 * 1024)
15352
+ throw new BuildUsageError(
15353
+ "A screenshot must be a regular image file of at most 25 MiB."
15354
+ );
15355
+ bytes = fs11.readFileSync(fd);
15356
+ } finally {
15357
+ fs11.closeSync(fd);
15358
+ }
15359
+ const png = bytes.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]));
15360
+ const jpg = bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255;
15361
+ const webp = bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WEBP";
15362
+ const extension = path11.extname(name).toLowerCase();
15363
+ if (!(extension === ".png" && png || [".jpg", ".jpeg"].includes(extension) && jpg || extension === ".webp" && webp))
15364
+ throw new BuildUsageError(
15365
+ "The source must be a PNG, JPEG or WebP screenshot matching the destination extension."
15366
+ );
15367
+ const target = path11.join(directory, name);
15368
+ fs11.writeFileSync(target, bytes, { flag: "wx" });
15369
+ return { path: target };
15370
+ }
15371
+
15106
15372
  // src/app/entry/buildCommand.ts
15107
15373
  var USAGE3 = `Usage: drisp build plan --input <path>
15374
+ drisp build children
15375
+ drisp build inspect <child-run-id> [history-cursor]
15376
+ drisp build guide <child-run-id> "<technical guidance>"
15377
+ drisp build evidence-copy <screenshot> <filename.png|jpg|webp>
15108
15378
  drisp build tick --input <path> [--rebase-failed <IDENTIFIER>]...
15109
15379
  drisp build checks
15110
15380
  drisp build step <n> [--qa none|web|macos|both] [--profile implementation|documentation|investigation]
@@ -15147,10 +15417,12 @@ function githubPullRequests(folder, branch) {
15147
15417
  function parsePullRequests(output) {
15148
15418
  const prs = JSON.parse(output);
15149
15419
  const merged = prs.find((pr) => pr.state === "MERGED");
15420
+ const open = prs.find((pr) => pr.state === "OPEN");
15150
15421
  return {
15151
- open: prs.some((pr) => pr.state === "OPEN"),
15422
+ open: open !== void 0,
15152
15423
  merged: merged !== void 0,
15153
- ...merged ? { mergedUrl: merged.url } : {}
15424
+ ...merged ? { mergedUrl: merged.url } : {},
15425
+ ...open ? { openUrl: open.url } : {}
15154
15426
  };
15155
15427
  }
15156
15428
  function hostCapabilities(folder) {
@@ -15222,6 +15494,31 @@ async function runBuildCommand(input) {
15222
15494
  try {
15223
15495
  let output;
15224
15496
  switch (input.subcommand) {
15497
+ case "evidence-copy":
15498
+ output = copyEvidence(
15499
+ input.cwd,
15500
+ input.positional?.[0],
15501
+ input.positional?.[1]
15502
+ );
15503
+ break;
15504
+ case "children":
15505
+ case "inspect":
15506
+ case "guide": {
15507
+ const parentId = requireEnv(env2, "DRISP_RUN_ID");
15508
+ const hub = input.supervisionHub ?? DrispClient.delegated(
15509
+ requireEnv(env2, "DRISP_HUB_URL"),
15510
+ requireEnv(env2, "DRISP_RUN_TOKEN")
15511
+ );
15512
+ output = await superviseChild({
15513
+ hub,
15514
+ parentId,
15515
+ operation: input.subcommand,
15516
+ childId: input.positional?.[0],
15517
+ text: input.positional?.[1],
15518
+ ...input.subcommand === "inspect" && input.positional?.[1] !== void 0 ? { after: Number(input.positional[1]) } : {}
15519
+ });
15520
+ break;
15521
+ }
15225
15522
  case "plan": {
15226
15523
  const calibration = input.dependencies?.calibration ?? await measuredForecasts(env2);
15227
15524
  output = runBuildPlan({
@@ -15310,14 +15607,50 @@ ${USAGE3}
15310
15607
  }
15311
15608
  }
15312
15609
 
15610
+ // src/app/entry/trackerCommand.ts
15611
+ import { readFile as readFile2 } from "fs/promises";
15612
+ async function runTrackerCommand(args, env2 = process.env) {
15613
+ const usage2 = "Usage: drisp tracker get <issue-id> | apply <operation.json>\nOperations: issue.revision, issue.comment, issue.attention, issue.evidence. Read the Issue first for its current version. Evidence includes revision, reference, kind and runId; staging/QA also require deploymentId. Production release confirmation is a human action.";
15614
+ try {
15615
+ if (!env2.DRISP_HUB_URL || !env2.DRISP_RUN_TOKEN)
15616
+ throw new Error(
15617
+ "This command requires a native Issue Run with DRISP_HUB_URL and DRISP_RUN_TOKEN."
15618
+ );
15619
+ const client2 = DrispClient.delegated(
15620
+ env2.DRISP_HUB_URL,
15621
+ env2.DRISP_RUN_TOKEN
15622
+ );
15623
+ const [action, argument, ...extra] = args;
15624
+ if (!argument || extra.length) throw new Error(usage2);
15625
+ if (action === "get")
15626
+ process.stdout.write(
15627
+ JSON.stringify(await client2.trackerIssue(argument)) + "\n"
15628
+ );
15629
+ else if (action === "apply") {
15630
+ const operation = trackerOperationSchema.parse(
15631
+ JSON.parse(await readFile2(argument, "utf8"))
15632
+ );
15633
+ process.stdout.write(
15634
+ JSON.stringify(await client2.trackerOperation(operation)) + "\n"
15635
+ );
15636
+ } else throw new Error(usage2);
15637
+ return 0;
15638
+ } catch (error) {
15639
+ process.stderr.write(
15640
+ (error instanceof Error ? error.message : String(error)) + "\n"
15641
+ );
15642
+ return 2;
15643
+ }
15644
+ }
15645
+
15313
15646
  // src/app/entry/doctorCommand.ts
15314
15647
  import process7 from "process";
15315
15648
 
15316
15649
  // src/harnesses/claude/system/doctorEnvironment.ts
15317
15650
  import { execFileSync as execFileSync3 } from "child_process";
15318
- import * as fs11 from "fs";
15651
+ import * as fs12 from "fs";
15319
15652
  import * as os4 from "os";
15320
- import * as path11 from "path";
15653
+ import * as path12 from "path";
15321
15654
  var MANAGED_POLICY_KEYS = [
15322
15655
  "forceLoginMethod",
15323
15656
  "forceLoginOrgUUID",
@@ -15421,8 +15754,8 @@ function collectEnvironment(options = {}) {
15421
15754
  const detectVersion = options.detectClaudeVersionFn ?? detectClaudeVersion;
15422
15755
  const runAuthStatus = options.runClaudeAuthStatusFn ?? runClaudeAuthStatus;
15423
15756
  const resolveForwarder = options.resolveHookForwarderCommandFn ?? resolveHookForwarderCommand;
15424
- const statFn = options.statFn ?? ((p) => fs11.statSync(p));
15425
- const readFileFn = options.readFileFn ?? ((p) => fs11.readFileSync(p, "utf8"));
15757
+ const statFn = options.statFn ?? ((p) => fs12.statSync(p));
15758
+ const readFileFn = options.readFileFn ?? ((p) => fs12.readFileSync(p, "utf8"));
15426
15759
  const settingsPaths = resolveClaudeSettingsSurfacePaths(
15427
15760
  homeDir,
15428
15761
  cwd,
@@ -15467,7 +15800,7 @@ function collectEnvironment(options = {}) {
15467
15800
  });
15468
15801
  let globalConfigPresent = false;
15469
15802
  try {
15470
- statFn(path11.join(homeDir, ".claude.json"));
15803
+ statFn(path12.join(homeDir, ".claude.json"));
15471
15804
  globalConfigPresent = true;
15472
15805
  } catch {
15473
15806
  globalConfigPresent = false;
@@ -15947,13 +16280,13 @@ function runRunsCommand(input) {
15947
16280
  // src/app/entry/cli.tsx
15948
16281
  import { jsx as jsx24 } from "react/jsx-runtime";
15949
16282
  function resolvePackageJsonPath(entryUrl) {
15950
- let currentDir = path12.dirname(fileURLToPath(entryUrl));
16283
+ let currentDir = path13.dirname(fileURLToPath(entryUrl));
15951
16284
  for (; ; ) {
15952
- const candidatePath = path12.join(currentDir, "package.json");
15953
- if (fs12.existsSync(candidatePath)) {
16285
+ const candidatePath = path13.join(currentDir, "package.json");
16286
+ if (fs13.existsSync(candidatePath)) {
15954
16287
  return candidatePath;
15955
16288
  }
15956
- const parentDir = path12.dirname(currentDir);
16289
+ const parentDir = path13.dirname(currentDir);
15957
16290
  if (parentDir === currentDir) {
15958
16291
  throw new Error("Could not locate package.json for CLI metadata.");
15959
16292
  }
@@ -15963,6 +16296,7 @@ function resolvePackageJsonPath(entryUrl) {
15963
16296
  var require2 = createRequire(import.meta.url);
15964
16297
  var { version } = require2(resolvePackageJsonPath(import.meta.url));
15965
16298
  var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
16299
+ "tracker",
15966
16300
  "setup",
15967
16301
  "sessions",
15968
16302
  "resume",
@@ -16123,6 +16457,12 @@ var cli = meow(
16123
16457
  runner [sub] Run the runner that connects this machine to a Team and executes its Runs
16124
16458
  (no subcommand: foreground; connect [code] --hub <url> [--replace], disconnect [team], status, restart, recover, help)
16125
16459
  build plan --input <path> Plan a Build inside an Orchestrator Run (prints one JSON object)
16460
+ tracker get <issue> Read the current native Drisp Issue
16461
+ tracker apply <json> Apply a scoped native Issue operation from a JSON file
16462
+ build children List this Build's children and their interruptions
16463
+ build inspect <run> [cursor] Read a child's state and paged history
16464
+ build guide <run> "<text>" Guide a child or answer its delegated technical question
16465
+ build evidence-copy <image> <name> Copy a screenshot into this worktree's evidence directory
16126
16466
  build tick --input <path> Run one step of a started Build (prints the next action; [--rebase-failed <ID>]...)
16127
16467
  build checks The merge gate's verdict on HEAD's GitHub runs (in a child's worktree)
16128
16468
  build step <n> Report the Run's current step: writes the step run artifact ([--qa none|web|macos|both], --profile, --merge you, --sign-off <sha>, --complete --evidence, --verify)
@@ -16315,7 +16655,7 @@ var cli = meow(
16315
16655
  }
16316
16656
  );
16317
16657
  async function main() {
16318
- const projectDir = path12.resolve(cli.flags.projectDir);
16658
+ const projectDir = path13.resolve(cli.flags.projectDir);
16319
16659
  const [command, ...commandArgs] = cli.input;
16320
16660
  const isRunCommand = command === "run" || command === "exec";
16321
16661
  if (command && !KNOWN_COMMANDS.has(command)) {
@@ -16369,7 +16709,7 @@ Available commands: ${[...KNOWN_COMMANDS].join(", ")}`
16369
16709
  await exitWith(1);
16370
16710
  return;
16371
16711
  }
16372
- const { default: WorkflowInstallWizard } = await import("./WorkflowInstallWizard-UVNJCK72.js");
16712
+ const { default: WorkflowInstallWizard } = await import("./WorkflowInstallWizard-VPBOZJY5.js");
16373
16713
  const { waitUntilExit } = render(
16374
16714
  /* @__PURE__ */ jsx24(
16375
16715
  WorkflowInstallWizard,
@@ -16447,6 +16787,10 @@ Available commands: ${[...KNOWN_COMMANDS].join(", ")}`
16447
16787
  );
16448
16788
  return;
16449
16789
  }
16790
+ if (command === "tracker") {
16791
+ await exitWith(await runTrackerCommand(commandArgs));
16792
+ return;
16793
+ }
16450
16794
  if (command === "build") {
16451
16795
  const rawArgs = process.argv.slice(2);
16452
16796
  const dashIdx = rawArgs.indexOf("--");
@@ -16549,8 +16893,8 @@ Available commands: ${[...KNOWN_COMMANDS].join(", ")}`
16549
16893
  const showSetup = isRunCommand ? false : shouldShowSetup({
16550
16894
  cliInput: cli.input,
16551
16895
  setupComplete: globalConfig.setupComplete,
16552
- globalConfigExists: fs12.existsSync(
16553
- path12.join(os5.homedir(), ".config", "athena", "config.json")
16896
+ globalConfigExists: fs13.existsSync(
16897
+ path13.join(os5.homedir(), ".config", "athena", "config.json")
16554
16898
  )
16555
16899
  });
16556
16900
  let runtimeConfig;