@autohq/cli 0.1.165 → 0.1.166

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.
@@ -22806,6 +22806,21 @@ var SetupOnboardingPullRequestSchema = external_exports.object({
22806
22806
  var SetupOnboardingPullRequestCreateResponseSchema = external_exports.object({
22807
22807
  pullRequest: SetupOnboardingPullRequestSchema
22808
22808
  });
22809
+ var SetupOnboardingPullRequestStatusRequestSchema = external_exports.object({
22810
+ githubConnection: external_exports.string().trim().min(1).optional(),
22811
+ repo: GithubSyncRepositoryFullNameSchema,
22812
+ pullRequestNumber: external_exports.coerce.number().int().positive()
22813
+ });
22814
+ var SetupOnboardingPullRequestStatusResponseSchema = external_exports.object({
22815
+ pullRequest: external_exports.object({
22816
+ merged: external_exports.boolean(),
22817
+ state: external_exports.string().trim().min(1)
22818
+ }),
22819
+ apply: external_exports.object({
22820
+ applied: external_exports.boolean()
22821
+ }),
22822
+ ready: external_exports.boolean()
22823
+ });
22809
22824
 
22810
22825
  // ../../packages/schemas/src/runtimes.ts
22811
22826
  var RuntimeRecordSchema = external_exports.object({
@@ -26467,7 +26482,7 @@ Object.assign(lookup, {
26467
26482
  // package.json
26468
26483
  var package_default = {
26469
26484
  name: "@autohq/cli",
26470
- version: "0.1.165",
26485
+ version: "0.1.166",
26471
26486
  license: "SEE LICENSE IN README.md",
26472
26487
  publishConfig: {
26473
26488
  access: "public"
package/dist/index.js CHANGED
@@ -19589,7 +19589,7 @@ var init_session_commands = __esm({
19589
19589
  });
19590
19590
 
19591
19591
  // ../../packages/schemas/src/setup.ts
19592
- var SetupOnboardingPullRequestCreateRequestSchema, SetupOnboardingPullRequestSchema, SetupOnboardingPullRequestCreateResponseSchema;
19592
+ var SetupOnboardingPullRequestCreateRequestSchema, SetupOnboardingPullRequestSchema, SetupOnboardingPullRequestCreateResponseSchema, SetupOnboardingPullRequestStatusRequestSchema, SetupOnboardingPullRequestStatusResponseSchema;
19593
19593
  var init_setup = __esm({
19594
19594
  "../../packages/schemas/src/setup.ts"() {
19595
19595
  "use strict";
@@ -19611,6 +19611,21 @@ var init_setup = __esm({
19611
19611
  SetupOnboardingPullRequestCreateResponseSchema = external_exports.object({
19612
19612
  pullRequest: SetupOnboardingPullRequestSchema
19613
19613
  });
19614
+ SetupOnboardingPullRequestStatusRequestSchema = external_exports.object({
19615
+ githubConnection: external_exports.string().trim().min(1).optional(),
19616
+ repo: GithubSyncRepositoryFullNameSchema,
19617
+ pullRequestNumber: external_exports.coerce.number().int().positive()
19618
+ });
19619
+ SetupOnboardingPullRequestStatusResponseSchema = external_exports.object({
19620
+ pullRequest: external_exports.object({
19621
+ merged: external_exports.boolean(),
19622
+ state: external_exports.string().trim().min(1)
19623
+ }),
19624
+ apply: external_exports.object({
19625
+ applied: external_exports.boolean()
19626
+ }),
19627
+ ready: external_exports.boolean()
19628
+ });
19614
19629
  }
19615
19630
  });
19616
19631
 
@@ -21005,6 +21020,23 @@ function createApiClient(input) {
21005
21020
  }
21006
21021
  );
21007
21022
  },
21023
+ async getSetupOnboardingPullRequestStatus(request, options = {}) {
21024
+ const project = await activeProject();
21025
+ const searchParams = [
21026
+ ["repo", request.repo],
21027
+ ["pullRequestNumber", String(request.pullRequestNumber)]
21028
+ ];
21029
+ if (request.githubConnection) {
21030
+ searchParams.push(["githubConnection", request.githubConnection]);
21031
+ }
21032
+ return requestJson(
21033
+ projectApiPath(project, "/setup/onboarding-pr"),
21034
+ {
21035
+ apiBaseUrl: options.apiBaseUrl,
21036
+ searchParams
21037
+ }
21038
+ );
21039
+ },
21008
21040
  ...createResourceApi({
21009
21041
  activeProject,
21010
21042
  apiUrl,
@@ -21549,7 +21581,7 @@ var init_package = __esm({
21549
21581
  "package.json"() {
21550
21582
  package_default = {
21551
21583
  name: "@autohq/cli",
21552
- version: "0.1.165",
21584
+ version: "0.1.166",
21553
21585
  license: "SEE LICENSE IN README.md",
21554
21586
  publishConfig: {
21555
21587
  access: "public"
@@ -35462,8 +35494,12 @@ function registerSessionCommands(program, context) {
35462
35494
  }
35463
35495
 
35464
35496
  // src/commands/setup/actions.ts
35497
+ init_browser();
35465
35498
  init_file();
35466
35499
  init_login();
35500
+ var SETUP_STATUS_POLL_INTERVAL_MS = 5e3;
35501
+ var SETUP_STATUS_HINT_EVERY_POLLS = 12;
35502
+ var SETUP_STATUS_MAX_CONSECUTIVE_ERRORS = 12;
35467
35503
  async function setupAction(context, options) {
35468
35504
  const apiBaseUrl = apiUrlFromOptions(context, options);
35469
35505
  const client = createContextApiClient(context);
@@ -35494,15 +35530,26 @@ async function setupAction(context, options) {
35494
35530
  context.writeOutput("");
35495
35531
  context.writeOutput(`Opened PR #${response.pullRequest.number}.`);
35496
35532
  if (response.pullRequest.url) {
35533
+ if (options.browser !== false) {
35534
+ (options.openBrowser ?? openBrowser)(response.pullRequest.url);
35535
+ }
35497
35536
  context.writeOutput(response.pullRequest.url);
35498
35537
  }
35499
35538
  context.writeOutput("");
35500
- context.writeOutput("Next steps:");
35501
- context.writeOutput("1. Review and merge the PR.");
35502
35539
  context.writeOutput(
35503
- "2. Wait for GitHub Sync to apply the merged `.auto` directory."
35540
+ "Review and merge the PR. Auto will wait here and detect when the onboarding agent has been applied."
35504
35541
  );
35505
- context.writeOutput("3. Tag `@auto.onboarding` in Slack to begin.");
35542
+ await waitForOnboardingReady(context, client, {
35543
+ apiBaseUrl,
35544
+ githubConnection: github.name,
35545
+ repo,
35546
+ pullRequestNumber: response.pullRequest.number,
35547
+ pollIntervalMs: options.statusPollIntervalMs,
35548
+ sleep: options.sleep
35549
+ });
35550
+ context.writeOutput("");
35551
+ context.writeOutput("Onboarding is ready.");
35552
+ context.writeOutput("Tag `@auto.onboarding` in Slack to begin.");
35506
35553
  }
35507
35554
  async function showPitchAndWait(context) {
35508
35555
  context.writeOutput(setupPitchText());
@@ -35797,6 +35844,68 @@ async function askRequired(context, question) {
35797
35844
  readline.close();
35798
35845
  }
35799
35846
  }
35847
+ async function waitForOnboardingReady(context, client, input) {
35848
+ const sleep4 = input.sleep ?? defaultSleep;
35849
+ const pollIntervalMs = input.pollIntervalMs ?? SETUP_STATUS_POLL_INTERVAL_MS;
35850
+ let reportedMerged = false;
35851
+ let reportedApplied = false;
35852
+ let pollCount = 0;
35853
+ let consecutiveStatusErrors = 0;
35854
+ for (; ; ) {
35855
+ pollCount += 1;
35856
+ const status = await client.getSetupOnboardingPullRequestStatus(
35857
+ {
35858
+ githubConnection: input.githubConnection,
35859
+ repo: input.repo,
35860
+ pullRequestNumber: input.pullRequestNumber
35861
+ },
35862
+ { apiBaseUrl: input.apiBaseUrl }
35863
+ ).catch((error51) => {
35864
+ consecutiveStatusErrors += 1;
35865
+ if (consecutiveStatusErrors === 1) {
35866
+ context.writeOutput(
35867
+ "Status check failed; retrying while the onboarding PR remains open."
35868
+ );
35869
+ }
35870
+ if (consecutiveStatusErrors >= SETUP_STATUS_MAX_CONSECUTIVE_ERRORS) {
35871
+ throw error51;
35872
+ }
35873
+ return void 0;
35874
+ });
35875
+ if (!status) {
35876
+ await sleep4(pollIntervalMs);
35877
+ continue;
35878
+ }
35879
+ consecutiveStatusErrors = 0;
35880
+ if (!status.pullRequest.merged && status.pullRequest.state === "closed") {
35881
+ throw new Error(
35882
+ "The onboarding PR was closed without being merged. Re-run `auto setup` to open it again."
35883
+ );
35884
+ }
35885
+ if (!status.pullRequest.merged && status.pullRequest.state !== "open") {
35886
+ throw new Error(
35887
+ `The onboarding PR is in unexpected state "${status.pullRequest.state}". Check the PR, then rerun \`auto setup\` if needed.`
35888
+ );
35889
+ }
35890
+ if (status.pullRequest.merged && !reportedMerged) {
35891
+ context.writeOutput("Detected PR merge.");
35892
+ reportedMerged = true;
35893
+ }
35894
+ if (status.apply.applied && !reportedApplied) {
35895
+ context.writeOutput("Detected GitHub Sync apply.");
35896
+ reportedApplied = true;
35897
+ }
35898
+ if (status.ready) {
35899
+ return;
35900
+ }
35901
+ if (pollCount % SETUP_STATUS_HINT_EVERY_POLLS === 0) {
35902
+ context.writeOutput(
35903
+ status.pullRequest.merged ? "Still waiting for GitHub Sync to apply the onboarding agent..." : "Still waiting for the onboarding PR to be merged..."
35904
+ );
35905
+ }
35906
+ await sleep4(pollIntervalMs);
35907
+ }
35908
+ }
35800
35909
  function organizationLabel(organization) {
35801
35910
  return `${organization.organizationName} (${organization.organizationSlug})`;
35802
35911
  }
@@ -35806,6 +35915,9 @@ function isRecord3(value) {
35806
35915
  function isDefined(value) {
35807
35916
  return value !== void 0;
35808
35917
  }
35918
+ function defaultSleep(delayMs) {
35919
+ return new Promise((resolve3) => setTimeout(resolve3, delayMs));
35920
+ }
35809
35921
 
35810
35922
  // src/commands/setup/commands.ts
35811
35923
  function registerSetupCommands(program, context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.165",
3
+ "version": "0.1.166",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"