@autohq/cli 0.1.363 → 0.1.364

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.
@@ -23492,7 +23492,7 @@ Object.assign(lookup, {
23492
23492
  // package.json
23493
23493
  var package_default = {
23494
23494
  name: "@autohq/cli",
23495
- version: "0.1.363",
23495
+ version: "0.1.364",
23496
23496
  license: "SEE LICENSE IN README.md",
23497
23497
  publishConfig: {
23498
23498
  access: "public"
@@ -25876,9 +25876,21 @@ var GithubSyncBindingCreateRequestSchema = external_exports.object({
25876
25876
  branch: GithubSyncProductionBranchSchema.optional(),
25877
25877
  ciWatchdog: GithubSyncCiWatchdogSchema.optional()
25878
25878
  });
25879
+ var GithubSyncInitialSyncSchema = external_exports.object({
25880
+ started: external_exports.boolean(),
25881
+ headSha: external_exports.string().trim().min(1).optional(),
25882
+ workflowId: external_exports.string().trim().min(1).optional(),
25883
+ reason: external_exports.enum([
25884
+ "no_auto_directory",
25885
+ "already_applied",
25886
+ "probe_failed",
25887
+ "start_failed"
25888
+ ]).optional()
25889
+ });
25879
25890
  var GithubSyncBindingCreateResponseSchema = external_exports.object({
25880
25891
  binding: GithubSyncBindingSchema,
25881
- created: external_exports.boolean()
25892
+ created: external_exports.boolean(),
25893
+ initialSync: GithubSyncInitialSyncSchema.optional()
25882
25894
  });
25883
25895
  var GithubSyncBindingListResponseSchema = external_exports.object({
25884
25896
  bindings: external_exports.array(GithubSyncBindingSchema)
@@ -28793,19 +28805,32 @@ var SetupOnboardingPullRequestSchema = external_exports.object({
28793
28805
  baseBranch: GithubSyncProductionBranchSchema,
28794
28806
  headSha: external_exports.string().trim().min(1)
28795
28807
  });
28796
- var SetupOnboardingPullRequestCreateResponseSchema = external_exports.object({
28797
- pullRequest: SetupOnboardingPullRequestSchema
28808
+ var SetupOnboardingSyncSchema = external_exports.object({
28809
+ branch: GithubSyncProductionBranchSchema,
28810
+ headSha: external_exports.string().trim().min(1).optional(),
28811
+ workflowStarted: external_exports.boolean()
28798
28812
  });
28813
+ var SetupOnboardingPullRequestCreateResponseSchema = external_exports.discriminatedUnion("mode", [
28814
+ external_exports.object({
28815
+ mode: external_exports.literal("pull_request"),
28816
+ pullRequest: SetupOnboardingPullRequestSchema
28817
+ }),
28818
+ external_exports.object({
28819
+ mode: external_exports.literal("sync"),
28820
+ sync: SetupOnboardingSyncSchema
28821
+ })
28822
+ ]);
28799
28823
  var SetupOnboardingPullRequestStatusRequestSchema = external_exports.object({
28800
28824
  githubConnection: external_exports.string().trim().min(1).optional(),
28801
28825
  repo: GithubSyncRepositoryFullNameSchema,
28802
- pullRequestNumber: external_exports.coerce.number().int().positive()
28826
+ // Absent in sync mode: there is no bootstrap PR, so readiness is apply-only.
28827
+ pullRequestNumber: external_exports.coerce.number().int().positive().optional()
28803
28828
  });
28804
28829
  var SetupOnboardingPullRequestStatusResponseSchema = external_exports.object({
28805
28830
  pullRequest: external_exports.object({
28806
28831
  merged: external_exports.boolean(),
28807
28832
  state: external_exports.string().trim().min(1)
28808
- }),
28833
+ }).optional(),
28809
28834
  apply: external_exports.object({
28810
28835
  applied: external_exports.boolean()
28811
28836
  }),
package/dist/index.js CHANGED
@@ -17234,7 +17234,7 @@ var init_connections = __esm({
17234
17234
  });
17235
17235
 
17236
17236
  // ../../packages/schemas/src/github-sync.ts
17237
- var GITHUB_SYNC_AUTO_PATH, GITHUB_SYNC_CI_WATCHDOG_DEFAULT_DELAY_MS, GithubSyncRepositoryFullNameSchema, GithubSyncProductionBranchSchema, GithubSyncCiWatchdogWorkflowSchema, GithubSyncCiWatchdogSchema, GithubSyncBindingSchema, GithubSyncBindingCreateRequestSchema, GithubSyncBindingCreateResponseSchema, GithubSyncBindingListResponseSchema, GithubSyncTriggerArtifactSchema, GithubSyncWorkflowInputSchema, GithubSyncWorkflowResultSchema;
17237
+ var GITHUB_SYNC_AUTO_PATH, GITHUB_SYNC_CI_WATCHDOG_DEFAULT_DELAY_MS, GithubSyncRepositoryFullNameSchema, GithubSyncProductionBranchSchema, GithubSyncCiWatchdogWorkflowSchema, GithubSyncCiWatchdogSchema, GithubSyncBindingSchema, GithubSyncBindingCreateRequestSchema, GithubSyncInitialSyncSchema, GithubSyncBindingCreateResponseSchema, GithubSyncBindingListResponseSchema, GithubSyncTriggerArtifactSchema, GithubSyncWorkflowInputSchema, GithubSyncWorkflowResultSchema;
17238
17238
  var init_github_sync = __esm({
17239
17239
  "../../packages/schemas/src/github-sync.ts"() {
17240
17240
  "use strict";
@@ -17280,9 +17280,21 @@ var init_github_sync = __esm({
17280
17280
  branch: GithubSyncProductionBranchSchema.optional(),
17281
17281
  ciWatchdog: GithubSyncCiWatchdogSchema.optional()
17282
17282
  });
17283
+ GithubSyncInitialSyncSchema = external_exports.object({
17284
+ started: external_exports.boolean(),
17285
+ headSha: external_exports.string().trim().min(1).optional(),
17286
+ workflowId: external_exports.string().trim().min(1).optional(),
17287
+ reason: external_exports.enum([
17288
+ "no_auto_directory",
17289
+ "already_applied",
17290
+ "probe_failed",
17291
+ "start_failed"
17292
+ ]).optional()
17293
+ });
17283
17294
  GithubSyncBindingCreateResponseSchema = external_exports.object({
17284
17295
  binding: GithubSyncBindingSchema,
17285
- created: external_exports.boolean()
17296
+ created: external_exports.boolean(),
17297
+ initialSync: GithubSyncInitialSyncSchema.optional()
17286
17298
  });
17287
17299
  GithubSyncBindingListResponseSchema = external_exports.object({
17288
17300
  bindings: external_exports.array(GithubSyncBindingSchema)
@@ -20507,7 +20519,7 @@ var init_session_turns = __esm({
20507
20519
  });
20508
20520
 
20509
20521
  // ../../packages/schemas/src/setup.ts
20510
- var SetupOnboardingPullRequestCreateRequestSchema, SetupOnboardingPullRequestSchema, SetupOnboardingPullRequestCreateResponseSchema, SetupOnboardingPullRequestStatusRequestSchema, SetupOnboardingPullRequestStatusResponseSchema;
20522
+ var SetupOnboardingPullRequestCreateRequestSchema, SetupOnboardingPullRequestSchema, SetupOnboardingSyncSchema, SetupOnboardingPullRequestCreateResponseSchema, SetupOnboardingPullRequestStatusRequestSchema, SetupOnboardingPullRequestStatusResponseSchema;
20511
20523
  var init_setup = __esm({
20512
20524
  "../../packages/schemas/src/setup.ts"() {
20513
20525
  "use strict";
@@ -20526,19 +20538,32 @@ var init_setup = __esm({
20526
20538
  baseBranch: GithubSyncProductionBranchSchema,
20527
20539
  headSha: external_exports.string().trim().min(1)
20528
20540
  });
20529
- SetupOnboardingPullRequestCreateResponseSchema = external_exports.object({
20530
- pullRequest: SetupOnboardingPullRequestSchema
20541
+ SetupOnboardingSyncSchema = external_exports.object({
20542
+ branch: GithubSyncProductionBranchSchema,
20543
+ headSha: external_exports.string().trim().min(1).optional(),
20544
+ workflowStarted: external_exports.boolean()
20531
20545
  });
20546
+ SetupOnboardingPullRequestCreateResponseSchema = external_exports.discriminatedUnion("mode", [
20547
+ external_exports.object({
20548
+ mode: external_exports.literal("pull_request"),
20549
+ pullRequest: SetupOnboardingPullRequestSchema
20550
+ }),
20551
+ external_exports.object({
20552
+ mode: external_exports.literal("sync"),
20553
+ sync: SetupOnboardingSyncSchema
20554
+ })
20555
+ ]);
20532
20556
  SetupOnboardingPullRequestStatusRequestSchema = external_exports.object({
20533
20557
  githubConnection: external_exports.string().trim().min(1).optional(),
20534
20558
  repo: GithubSyncRepositoryFullNameSchema,
20535
- pullRequestNumber: external_exports.coerce.number().int().positive()
20559
+ // Absent in sync mode: there is no bootstrap PR, so readiness is apply-only.
20560
+ pullRequestNumber: external_exports.coerce.number().int().positive().optional()
20536
20561
  });
20537
20562
  SetupOnboardingPullRequestStatusResponseSchema = external_exports.object({
20538
20563
  pullRequest: external_exports.object({
20539
20564
  merged: external_exports.boolean(),
20540
20565
  state: external_exports.string().trim().min(1)
20541
- }),
20566
+ }).optional(),
20542
20567
  apply: external_exports.object({
20543
20568
  applied: external_exports.boolean()
20544
20569
  }),
@@ -30415,10 +30440,13 @@ function createApiClient(input) {
30415
30440
  },
30416
30441
  async getSetupOnboardingPullRequestStatus(request, options = {}) {
30417
30442
  const project = await activeProject();
30418
- const searchParams = [
30419
- ["repo", request.repo],
30420
- ["pullRequestNumber", String(request.pullRequestNumber)]
30421
- ];
30443
+ const searchParams = [["repo", request.repo]];
30444
+ if (request.pullRequestNumber !== void 0) {
30445
+ searchParams.push([
30446
+ "pullRequestNumber",
30447
+ String(request.pullRequestNumber)
30448
+ ]);
30449
+ }
30422
30450
  if (request.githubConnection) {
30423
30451
  searchParams.push(["githubConnection", request.githubConnection]);
30424
30452
  }
@@ -31549,7 +31577,7 @@ var init_package = __esm({
31549
31577
  "package.json"() {
31550
31578
  package_default = {
31551
31579
  name: "@autohq/cli",
31552
- version: "0.1.363",
31580
+ version: "0.1.364",
31553
31581
  license: "SEE LICENSE IN README.md",
31554
31582
  publishConfig: {
31555
31583
  access: "public"
@@ -33347,9 +33375,14 @@ var init_template_variables = __esm({
33347
33375
  });
33348
33376
 
33349
33377
  // ../../packages/schemas/src/project-apply-files/agent-authoring.ts
33350
- function readApplyDocument(path2, document, fileIndex) {
33378
+ function readApplyDocument(path2, document, fileIndex, contextVariables) {
33351
33379
  assertAgentAuthoringDocument(document, path2);
33352
- const result = compileAgentDocumentValue(document, path2, fileIndex);
33380
+ const result = compileAgentDocumentValue(
33381
+ document,
33382
+ path2,
33383
+ fileIndex,
33384
+ contextVariables
33385
+ );
33353
33386
  return result.resources.map((resource) => ({
33354
33387
  resource,
33355
33388
  generatedFromAgent: resource !== result.resource
@@ -33407,12 +33440,13 @@ function dedupeGeneratedResources(records) {
33407
33440
  }
33408
33441
  return deduped.map((record2) => record2.resource);
33409
33442
  }
33410
- function compileAgentDocumentValue(document, path2, fileIndex) {
33443
+ function compileAgentDocumentValue(document, path2, fileIndex, contextVariables) {
33411
33444
  return compileAgentDraftResources(
33412
33445
  compileAgentDocument2(document, path2, {
33413
33446
  fileIndex,
33414
33447
  stack: [],
33415
- variables: /* @__PURE__ */ new Map()
33448
+ variables: /* @__PURE__ */ new Map(),
33449
+ ...contextVariables && Object.keys(contextVariables).length > 0 ? { contextVariables: new Map(Object.entries(contextVariables)) } : {}
33416
33450
  }),
33417
33451
  path2
33418
33452
  );
@@ -33427,7 +33461,10 @@ function compileAgentDocument2(document, path2, context) {
33427
33461
  if (!isRecord2(document)) {
33428
33462
  throw new Error(`Invalid agent authoring file ${path2}: expected object`);
33429
33463
  }
33430
- const variables = context.stack.length === 0 ? readVariableScope(document, normalizedPath) : context.variables;
33464
+ const variables = context.stack.length === 0 ? new Map([
33465
+ ...context.contextVariables ?? /* @__PURE__ */ new Map(),
33466
+ ...readVariableScope(document, normalizedPath)
33467
+ ]) : context.variables;
33431
33468
  let merged = emptyAgentDraft();
33432
33469
  for (const importPath of importPaths2(document)) {
33433
33470
  const imported = resolveImportPath2(
@@ -33757,7 +33794,10 @@ function readProjectApplyDirectorySource(input) {
33757
33794
  ).sort((left, right) => left.path.localeCompare(right.path));
33758
33795
  const resourceRecords = [];
33759
33796
  for (const file2 of agentFiles) {
33760
- const request = readProjectApplyDocumentSourceFile(file2, { fileIndex });
33797
+ const request = readProjectApplyDocumentSourceFile(file2, {
33798
+ fileIndex,
33799
+ ...input.contextVariables ? { contextVariables: input.contextVariables } : {}
33800
+ });
33761
33801
  resourceRecords.push(
33762
33802
  ...request.resources.map((resource) => ({
33763
33803
  resource,
@@ -33808,7 +33848,7 @@ function readProjectApplyDocumentSourceFile(file2, options = {}) {
33808
33848
  }
33809
33849
  }
33810
33850
  const resourceRecords = documents.flatMap(
33811
- (document) => readApplyDocument(file2.path, document, fileIndex)
33851
+ (document) => readApplyDocument(file2.path, document, fileIndex, options.contextVariables)
33812
33852
  );
33813
33853
  return ProjectApplyRequestSchema.parse({
33814
33854
  delete: [],
@@ -51575,7 +51615,7 @@ async function setupAction(rawContext, options) {
51575
51615
  "To kick things off, Auto will open a PR adding an onboarding agent that walks you through the rest of the process. Once you merge the PR, add `@auto` to a Slack channel, tag `@auto.onboarding` in a message, and that agent will take it from there."
51576
51616
  );
51577
51617
  context.writeOutput("");
51578
- context.writeOutput("Opening the onboarding PR...");
51618
+ context.writeOutput("Preparing the onboarding agent...");
51579
51619
  const response = await client.createSetupOnboardingPullRequest(
51580
51620
  {
51581
51621
  githubConnection: github.name,
@@ -51584,32 +51624,42 @@ async function setupAction(rawContext, options) {
51584
51624
  },
51585
51625
  { apiBaseUrl }
51586
51626
  );
51587
- context.writeOutput("");
51588
- context.writeOutput(`Opened PR #${response.pullRequest.number}.`);
51589
- if (response.pullRequest.url) {
51590
- await explainBrowserStep(context, {
51591
- browser: options.browser,
51592
- heading: "Review the onboarding PR",
51593
- body: [
51594
- "Auto will open the pull request it just created.",
51595
- "Reviewing and merging this PR adds the onboarding agent to `.auto/`. GitHub Sync applies it after merge; then add `@auto` to a Slack channel and tag `@auto.onboarding` to start."
51596
- ],
51597
- prompt: "Press Enter to open the PR."
51598
- });
51599
- if (options.browser !== false) {
51600
- (options.openBrowser ?? openBrowser)(response.pullRequest.url);
51627
+ if (response.mode === "sync") {
51628
+ context.writeOutput("");
51629
+ context.writeOutput(
51630
+ `This repo already has Auto set up: found an onboarding agent under \`.auto/agents/\` on ${response.sync.branch}. Syncing its resources instead of opening a PR.`
51631
+ );
51632
+ context.writeOutput(
51633
+ "Auto will wait here and detect when the onboarding agent has been applied."
51634
+ );
51635
+ } else {
51636
+ context.writeOutput("");
51637
+ context.writeOutput(`Opened PR #${response.pullRequest.number}.`);
51638
+ if (response.pullRequest.url) {
51639
+ await explainBrowserStep(context, {
51640
+ browser: options.browser,
51641
+ heading: "Review the onboarding PR",
51642
+ body: [
51643
+ "Auto will open the pull request it just created.",
51644
+ "Reviewing and merging this PR adds the onboarding agent to `.auto/`. GitHub Sync applies it after merge; then add `@auto` to a Slack channel and tag `@auto.onboarding` to start."
51645
+ ],
51646
+ prompt: "Press Enter to open the PR."
51647
+ });
51648
+ if (options.browser !== false) {
51649
+ (options.openBrowser ?? openBrowser)(response.pullRequest.url);
51650
+ }
51651
+ context.writeOutput(response.pullRequest.url);
51601
51652
  }
51602
- context.writeOutput(response.pullRequest.url);
51653
+ context.writeOutput("");
51654
+ context.writeOutput(
51655
+ "Review and merge the PR. Auto will wait here and detect when the onboarding agent has been applied."
51656
+ );
51603
51657
  }
51604
- context.writeOutput("");
51605
- context.writeOutput(
51606
- "Review and merge the PR. Auto will wait here and detect when the onboarding agent has been applied."
51607
- );
51608
51658
  await waitForOnboardingReady(context, client, {
51609
51659
  apiBaseUrl,
51610
51660
  githubConnection: github.name,
51611
51661
  repo,
51612
- pullRequestNumber: response.pullRequest.number,
51662
+ ...response.mode === "pull_request" ? { pullRequestNumber: response.pullRequest.number } : {},
51613
51663
  pollIntervalMs: options.statusPollIntervalMs,
51614
51664
  sleep: options.sleep
51615
51665
  });
@@ -52053,13 +52103,13 @@ async function waitForOnboardingReady(context, client, input) {
52053
52103
  {
52054
52104
  githubConnection: input.githubConnection,
52055
52105
  repo: input.repo,
52056
- pullRequestNumber: input.pullRequestNumber
52106
+ ...input.pullRequestNumber !== void 0 ? { pullRequestNumber: input.pullRequestNumber } : {}
52057
52107
  },
52058
52108
  { apiBaseUrl: input.apiBaseUrl }
52059
52109
  ).catch((error51) => {
52060
52110
  consecutiveStatusErrors += 1;
52061
52111
  if (consecutiveStatusErrors === 1) {
52062
- context.writeOutput("Waiting for PR to be merged...");
52112
+ context.writeOutput("Waiting for onboarding to be ready...");
52063
52113
  }
52064
52114
  if (consecutiveStatusErrors >= SETUP_STATUS_MAX_CONSECUTIVE_ERRORS) {
52065
52115
  throw error51;
@@ -52071,17 +52121,18 @@ async function waitForOnboardingReady(context, client, input) {
52071
52121
  continue;
52072
52122
  }
52073
52123
  consecutiveStatusErrors = 0;
52074
- if (!status.pullRequest.merged && status.pullRequest.state === "closed") {
52124
+ const pullRequest = status.pullRequest;
52125
+ if (pullRequest && !pullRequest.merged && pullRequest.state === "closed") {
52075
52126
  throw new Error(
52076
52127
  "The onboarding PR was closed without being merged. Re-run `auto setup` to open it again."
52077
52128
  );
52078
52129
  }
52079
- if (!status.pullRequest.merged && status.pullRequest.state !== "open") {
52130
+ if (pullRequest && !pullRequest.merged && pullRequest.state !== "open") {
52080
52131
  throw new Error(
52081
- `The onboarding PR is in unexpected state "${status.pullRequest.state}". Check the PR, then rerun \`auto setup\` if needed.`
52132
+ `The onboarding PR is in unexpected state "${pullRequest.state}". Check the PR, then rerun \`auto setup\` if needed.`
52082
52133
  );
52083
52134
  }
52084
- if (status.pullRequest.merged && !reportedMerged) {
52135
+ if (pullRequest?.merged && !reportedMerged) {
52085
52136
  context.writeOutput("Detected PR merge.");
52086
52137
  reportedMerged = true;
52087
52138
  }
@@ -52094,7 +52145,7 @@ async function waitForOnboardingReady(context, client, input) {
52094
52145
  }
52095
52146
  if (pollCount % SETUP_STATUS_HINT_EVERY_POLLS === 0) {
52096
52147
  context.writeOutput(
52097
- status.pullRequest.merged ? "Still waiting for GitHub Sync to apply the onboarding agent..." : "Still waiting for the onboarding PR to be merged..."
52148
+ !pullRequest || pullRequest.merged ? "Still waiting for GitHub Sync to apply the onboarding agent..." : "Still waiting for the onboarding PR to be merged..."
52098
52149
  );
52099
52150
  }
52100
52151
  await sleep5(pollIntervalMs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.363",
3
+ "version": "0.1.364",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"