@autohq/cli 0.1.83 → 0.1.85

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.
@@ -19605,7 +19605,6 @@ var AuthScopeSchema = external_exports.enum([
19605
19605
  "environments:write",
19606
19606
  "profiles:read",
19607
19607
  "profiles:write",
19608
- "resources:apply_dry_run",
19609
19608
  "runs:read",
19610
19609
  "runs:write",
19611
19610
  "events:write",
@@ -19696,6 +19695,24 @@ var AuthWhoamiResponseSchema = external_exports.object({
19696
19695
  })
19697
19696
  }).optional()
19698
19697
  });
19698
+ var SERVICE_ACCOUNT_READ_ONLY_SCOPES = [
19699
+ "environments:read",
19700
+ "profiles:read",
19701
+ "tools:read",
19702
+ "sessions:read",
19703
+ "runs:read"
19704
+ ];
19705
+ var SERVICE_ACCOUNT_SCOPE_PRESETS = {
19706
+ "read-only": SERVICE_ACCOUNT_READ_ONLY_SCOPES,
19707
+ applier: [
19708
+ ...SERVICE_ACCOUNT_READ_ONLY_SCOPES,
19709
+ "environments:write",
19710
+ "profiles:write",
19711
+ "tools:write",
19712
+ "sessions:write"
19713
+ ]
19714
+ };
19715
+ var ServiceAccountScopePresetSchema = external_exports.enum(["read-only", "applier"]);
19699
19716
 
19700
19717
  // ../../packages/schemas/src/primitives.ts
19701
19718
  var JsonValueSchema2 = external_exports.lazy(
@@ -20867,16 +20884,12 @@ var ProjectServiceAccountSchema = external_exports.object({
20867
20884
  scopes: external_exports.array(AuthScopeSchema),
20868
20885
  createdAt: external_exports.string().datetime()
20869
20886
  });
20870
- var ProjectServiceAccountScopeInputSchema = external_exports.union([
20871
- AuthScopeSchema,
20872
- external_exports.literal("members:none")
20873
- ]);
20874
20887
  var ProjectServiceAccountCreateRequestSchema = external_exports.object({
20875
20888
  name: ResourceNameSchema,
20876
- scopes: external_exports.array(ProjectServiceAccountScopeInputSchema).optional()
20889
+ scopes: external_exports.array(AuthScopeSchema).min(1)
20877
20890
  });
20878
20891
  var ProjectServiceAccountUpdateRequestSchema = external_exports.object({
20879
- scopes: external_exports.array(ProjectServiceAccountScopeInputSchema)
20892
+ scopes: external_exports.array(AuthScopeSchema).min(1)
20880
20893
  });
20881
20894
  var ProjectServiceAccountTokenResponseSchema = external_exports.object({
20882
20895
  serviceAccount: ProjectServiceAccountSchema,
package/dist/index.js CHANGED
@@ -15196,7 +15196,7 @@ var init_ids = __esm({
15196
15196
  });
15197
15197
 
15198
15198
  // ../../packages/schemas/src/auth.ts
15199
- var AuthRoleSchema, AuthIdentityProviderSchema, AuthScopeSchema, AUTH_SCOPES, PrincipalSchema, AuthClientSchema, AuthActorSchema, AuthContextSchema, AuthWhoamiResponseSchema;
15199
+ var AuthRoleSchema, AuthIdentityProviderSchema, AuthScopeSchema, AUTH_SCOPES, PrincipalSchema, AuthClientSchema, AuthActorSchema, AuthContextSchema, AuthWhoamiResponseSchema, SERVICE_ACCOUNT_READ_ONLY_SCOPES, SERVICE_ACCOUNT_SCOPE_PRESETS, ServiceAccountScopePresetSchema;
15200
15200
  var init_auth = __esm({
15201
15201
  "../../packages/schemas/src/auth.ts"() {
15202
15202
  "use strict";
@@ -15213,7 +15213,6 @@ var init_auth = __esm({
15213
15213
  "environments:write",
15214
15214
  "profiles:read",
15215
15215
  "profiles:write",
15216
- "resources:apply_dry_run",
15217
15216
  "runs:read",
15218
15217
  "runs:write",
15219
15218
  "events:write",
@@ -15304,6 +15303,24 @@ var init_auth = __esm({
15304
15303
  })
15305
15304
  }).optional()
15306
15305
  });
15306
+ SERVICE_ACCOUNT_READ_ONLY_SCOPES = [
15307
+ "environments:read",
15308
+ "profiles:read",
15309
+ "tools:read",
15310
+ "sessions:read",
15311
+ "runs:read"
15312
+ ];
15313
+ SERVICE_ACCOUNT_SCOPE_PRESETS = {
15314
+ "read-only": SERVICE_ACCOUNT_READ_ONLY_SCOPES,
15315
+ applier: [
15316
+ ...SERVICE_ACCOUNT_READ_ONLY_SCOPES,
15317
+ "environments:write",
15318
+ "profiles:write",
15319
+ "tools:write",
15320
+ "sessions:write"
15321
+ ]
15322
+ };
15323
+ ServiceAccountScopePresetSchema = external_exports.enum(["read-only", "applier"]);
15307
15324
  }
15308
15325
  });
15309
15326
 
@@ -16646,7 +16663,7 @@ var init_mounts = __esm({
16646
16663
  });
16647
16664
 
16648
16665
  // ../../packages/schemas/src/project-service-accounts.ts
16649
- var ProjectServiceAccountSchema, ProjectServiceAccountScopeInputSchema, ProjectServiceAccountCreateRequestSchema, ProjectServiceAccountUpdateRequestSchema, ProjectServiceAccountTokenResponseSchema, ProjectServiceAccountUpdateResponseSchema, ProjectServiceAccountRemoveResponseSchema, ProjectServiceAccountListResponseSchema;
16666
+ var ProjectServiceAccountSchema, ProjectServiceAccountCreateRequestSchema, ProjectServiceAccountUpdateRequestSchema, ProjectServiceAccountTokenResponseSchema, ProjectServiceAccountUpdateResponseSchema, ProjectServiceAccountRemoveResponseSchema, ProjectServiceAccountListResponseSchema;
16650
16667
  var init_project_service_accounts = __esm({
16651
16668
  "../../packages/schemas/src/project-service-accounts.ts"() {
16652
16669
  "use strict";
@@ -16662,16 +16679,12 @@ var init_project_service_accounts = __esm({
16662
16679
  scopes: external_exports.array(AuthScopeSchema),
16663
16680
  createdAt: external_exports.string().datetime()
16664
16681
  });
16665
- ProjectServiceAccountScopeInputSchema = external_exports.union([
16666
- AuthScopeSchema,
16667
- external_exports.literal("members:none")
16668
- ]);
16669
16682
  ProjectServiceAccountCreateRequestSchema = external_exports.object({
16670
16683
  name: ResourceNameSchema,
16671
- scopes: external_exports.array(ProjectServiceAccountScopeInputSchema).optional()
16684
+ scopes: external_exports.array(AuthScopeSchema).min(1)
16672
16685
  });
16673
16686
  ProjectServiceAccountUpdateRequestSchema = external_exports.object({
16674
- scopes: external_exports.array(ProjectServiceAccountScopeInputSchema)
16687
+ scopes: external_exports.array(AuthScopeSchema).min(1)
16675
16688
  });
16676
16689
  ProjectServiceAccountTokenResponseSchema = external_exports.object({
16677
16690
  serviceAccount: ProjectServiceAccountSchema,
@@ -21114,7 +21127,7 @@ var init_package = __esm({
21114
21127
  "package.json"() {
21115
21128
  package_default = {
21116
21129
  name: "@autohq/cli",
21117
- version: "0.1.83",
21130
+ version: "0.1.85",
21118
21131
  license: "SEE LICENSE IN README.md",
21119
21132
  publishConfig: {
21120
21133
  access: "public"
@@ -23628,7 +23641,11 @@ function useCreateServiceAccount(apiUrl) {
23628
23641
  const client = useApiClient();
23629
23642
  const queryClient = useQueryClient();
23630
23643
  return useMutation({
23631
- mutationFn: (name) => client.createProjectServiceAccount({ name }, { apiBaseUrl: apiUrl }),
23644
+ mutationFn: (name) => client.createProjectServiceAccount(
23645
+ // The TUI has no scope picker yet; mint with the applier preset.
23646
+ { name, scopes: [...SERVICE_ACCOUNT_SCOPE_PRESETS.applier] },
23647
+ { apiBaseUrl: apiUrl }
23648
+ ),
23632
23649
  onSuccess: () => queryClient.invalidateQueries({
23633
23650
  queryKey: queryKeys.serviceAccounts(apiUrl)
23634
23651
  })
@@ -23927,6 +23944,7 @@ var queryKeys, RUNS_REFETCH_INTERVAL_MS;
23927
23944
  var init_queries = __esm({
23928
23945
  "src/tui/hooks/queries.ts"() {
23929
23946
  "use strict";
23947
+ init_src();
23930
23948
  init_ApiClientContext();
23931
23949
  queryKeys = {
23932
23950
  environments: (apiUrl) => ["environments", apiUrl],
@@ -29129,7 +29147,7 @@ var onboardingSkillMarkdown = `# Onboard your user to auto
29129
29147
 
29130
29148
  You are a coding agent running inside the user's repository. Your job is to
29131
29149
  take them from zero to a working auto deployment in one conversation, with
29132
- the least possible friction. Follow the five beats in order, and run every
29150
+ the least possible friction. Follow the six beats in order, and run every
29133
29151
  waiting step in parallel with your own work.
29134
29152
 
29135
29153
  ## Ground rules
@@ -29181,7 +29199,8 @@ get me into your Slack." Then, without waiting:
29181
29199
  Build a repo dossier while the clicks happen. Explore the codebase and git
29182
29200
  history for:
29183
29201
 
29184
- - Stack and layout: languages, frameworks, build and test setup, CI config.
29202
+ - Stack and layout: languages, frameworks, build and test setup, CI and
29203
+ deploy workflows (Beat 6 wires into these).
29185
29204
  - How the team works: PR conventions, review patterns, branch and release
29186
29205
  habits, merge frequency.
29187
29206
  - Tools referenced: issue tracker keys in commits and branches, chat or
@@ -29262,6 +29281,102 @@ one workflow. Then:
29262
29281
  5. Apply with \`auto apply\` and confirm the trigger is active. Route the
29263
29282
  workflow's reports to the Slack channel from Beat 2.
29264
29283
 
29284
+ ## Beat 6: Wire CI to apply on merge
29285
+
29286
+ Every apply so far ran from this terminal under the user's own login. Its
29287
+ durable home is CI: a dry-run plan as a check on every PR, and the real
29288
+ apply when changes merge \u2014 \`.auto/\` ships the same way the code does. Do
29289
+ this once the GitHub App is connected and the first apply has succeeded.
29290
+
29291
+ 1. CI authenticates as a service account, never as the user. Create two \u2014
29292
+ the \`applier\` token lives only on the merge path, while the \`read-only\`
29293
+ token is exposed to PR-triggered runs: it can produce the dry-run plan
29294
+ but cannot perform a real apply, and it stays revocable on its own. Pipe
29295
+ each token straight into a GitHub secret so it never touches your
29296
+ transcript or disk \u2014 with \`pipefail\` and \`jq -re\` so a failed create
29297
+ cannot silently store an empty secret:
29298
+
29299
+ \`\`\`sh
29300
+ set -o pipefail
29301
+ auto service-account create github-actions-auto-apply \\
29302
+ --preset applier --json \\
29303
+ | jq -re .token | gh secret set AUTO_APPLY_SERVICE_ACCOUNT_TOKEN
29304
+ auto service-account create github-actions-auto-apply-dry-run \\
29305
+ --preset read-only --json \\
29306
+ | jq -re .token | gh secret set AUTO_APPLY_DRY_RUN_SERVICE_ACCOUNT_TOKEN
29307
+ \`\`\`
29308
+
29309
+ Confirm both pipelines exited 0 and \`gh secret list\` shows both names
29310
+ before moving on. If deploys go through a GitHub environment, scope the
29311
+ apply secret to it (\`gh secret set --env\`).
29312
+ 2. Fit into the deploy process you mapped in Beat 3. If a workflow already
29313
+ ships merges, splice two steps in after its deploy succeeds \u2014 plan
29314
+ (\`auto apply --dry-run\`), then \`auto apply\` \u2014 reusing its checkout and
29315
+ Node setup. If nothing deploys from CI yet, add the standalone workflow
29316
+ below. Either way, keep the PR dry-run check: it shows reviewers the
29317
+ exact create/update/archive plan their merge will execute.
29318
+ 3. Workflow files live outside \`.auto/\`, so show the user the file and get
29319
+ a yes; commit it on the same branch as the \`.auto/\` resources.
29320
+
29321
+ \`\`\`yaml
29322
+ name: Auto Apply
29323
+
29324
+ # Both triggers assume the default branch is main; swap in the repo's
29325
+ # actual default branch before committing.
29326
+ on:
29327
+ pull_request:
29328
+ branches: [main]
29329
+ push:
29330
+ branches: [main]
29331
+
29332
+ permissions:
29333
+ contents: read
29334
+
29335
+ concurrency:
29336
+ group: auto-apply-\${{ github.event.pull_request.number || github.ref }}
29337
+ cancel-in-progress: \${{ github.event_name == 'pull_request' }}
29338
+
29339
+ jobs:
29340
+ plan:
29341
+ runs-on: ubuntu-latest
29342
+ timeout-minutes: 10
29343
+ steps:
29344
+ - uses: actions/checkout@v4
29345
+ - uses: actions/setup-node@v4
29346
+ with:
29347
+ node-version: lts/*
29348
+ - run: npx -y --package=@autohq/cli auto apply --dry-run
29349
+ env:
29350
+ AUTO_API_TOKEN: \${{ secrets.AUTO_APPLY_DRY_RUN_SERVICE_ACCOUNT_TOKEN }}
29351
+
29352
+ apply:
29353
+ if: \${{ github.event_name == 'push' }}
29354
+ needs: plan
29355
+ runs-on: ubuntu-latest
29356
+ timeout-minutes: 10
29357
+ steps:
29358
+ - uses: actions/checkout@v4
29359
+ - uses: actions/setup-node@v4
29360
+ with:
29361
+ node-version: lts/*
29362
+ - run: npx -y --package=@autohq/cli auto apply
29363
+ env:
29364
+ AUTO_API_TOKEN: \${{ secrets.AUTO_APPLY_SERVICE_ACCOUNT_TOKEN }}
29365
+ \`\`\`
29366
+
29367
+ Adapt it to the repo: the default branch name, the team's Node setup or
29368
+ pinned tool versions, and set \`AUTO_API_BASE_URL\` only if the project runs
29369
+ against a non-default Auto host. \`pull_request\` runs from forks do not
29370
+ receive secrets; if fork PRs are routine here, run the dry-run from a
29371
+ \`pull_request_target\` workflow that checks out workflow code from the base
29372
+ branch and only \`.auto/\` from the PR head.
29373
+
29374
+ After the PR merges, watch the first run and confirm its plan reports the
29375
+ resources you already applied as unchanged. From then on, \`.auto/\` on the
29376
+ default branch is the source of truth \u2014 directory apply prunes resources
29377
+ that are no longer declared, so the team changes agents by PR, not by
29378
+ terminal.
29379
+
29265
29380
  ## Workflow playbook
29266
29381
 
29267
29382
  Candidates, strongest signals, and what confirms fit:
@@ -29287,15 +29402,20 @@ out loud when proposing.
29287
29402
  the install is approved, and have the concierge retry.
29288
29403
  - Sign-in stalls: the user may not have an invite yet; point them at the
29289
29404
  auto site and pause gracefully rather than failing.
29405
+ - \`gh secret set\` fails (no repo admin rights, gh not authenticated):
29406
+ leave the CI workflow in the PR anyway and hand the user the two
29407
+ create-and-pipe commands from Beat 6 to run themselves. Tokens are shown
29408
+ once and must never be pasted into the conversation.
29290
29409
  - A command disagrees with this document: the command is right. Re-read
29291
29410
  \`auto --help\` and adapt.
29292
29411
 
29293
29412
  ## What you leave behind
29294
29413
 
29295
29414
  - \`.auto/\` committed on a branch with a PR the user can merge: the
29296
- concierge and workflow session YAML plus \`context.md\` (the distilled
29297
- dossier). Write the PR description for teammates \u2014 it doubles as the
29298
- announcement that this repo now has an auto agent.
29415
+ concierge and workflow session YAML, the CI apply workflow from Beat 6,
29416
+ plus \`context.md\` (the distilled dossier). Write the PR description for
29417
+ teammates \u2014 it doubles as the announcement that this repo now has an
29418
+ auto agent.
29299
29419
  - With the user's opt-in, an AGENTS.md section that tells every future
29300
29420
  coding agent in this repo that auto exists, what is deployed, and how to
29301
29421
  add workflows.
@@ -30436,16 +30556,17 @@ function withApiBaseUrl(context, commandOptions) {
30436
30556
  }
30437
30557
 
30438
30558
  // src/commands/service-accounts/actions.ts
30559
+ init_src();
30439
30560
  async function createServiceAccount(input) {
30440
30561
  const response = await input.client.createProjectServiceAccount(
30441
- { name: input.name, scopes: input.commandOptions.scope },
30562
+ { name: input.name, scopes: requestedScopes(input.commandOptions) },
30442
30563
  { apiBaseUrl: input.commandOptions.apiBaseUrl }
30443
30564
  );
30444
30565
  writeServiceAccountTokenResponse(response, input);
30445
30566
  }
30446
30567
  async function updateServiceAccount(input) {
30447
30568
  const response = await input.client.updateProjectServiceAccount(
30448
- { name: input.name, scopes: input.commandOptions.scope ?? [] },
30569
+ { name: input.name, scopes: requestedScopes(input.commandOptions) },
30449
30570
  { apiBaseUrl: input.commandOptions.apiBaseUrl }
30450
30571
  );
30451
30572
  if (input.commandOptions.json) {
@@ -30472,6 +30593,33 @@ async function removeServiceAccount(input) {
30472
30593
  }
30473
30594
  input.writeOutput(`removed service-account ${response.serviceAccount.name}`);
30474
30595
  }
30596
+ function requestedScopes(options) {
30597
+ const presetNames = Object.keys(SERVICE_ACCOUNT_SCOPE_PRESETS).join(", ");
30598
+ const scopes = [];
30599
+ if (options.preset !== void 0) {
30600
+ const preset = ServiceAccountScopePresetSchema.safeParse(options.preset);
30601
+ if (!preset.success) {
30602
+ throw new Error(
30603
+ `Unknown preset "${options.preset}". Available presets: ${presetNames}.`
30604
+ );
30605
+ }
30606
+ scopes.push(...SERVICE_ACCOUNT_SCOPE_PRESETS[preset.data]);
30607
+ }
30608
+ for (const scope of options.scope ?? []) {
30609
+ if (!AuthScopeSchema.safeParse(scope).success) {
30610
+ throw new Error(
30611
+ `Unknown scope "${scope}". Valid scopes: ${AUTH_SCOPES.join(", ")}.`
30612
+ );
30613
+ }
30614
+ scopes.push(scope);
30615
+ }
30616
+ if (scopes.length === 0) {
30617
+ throw new Error(
30618
+ `Provide --preset <preset> (${presetNames}) or at least one --scope.`
30619
+ );
30620
+ }
30621
+ return [...new Set(scopes)];
30622
+ }
30475
30623
  function writeServiceAccountTokenResponse(response, input) {
30476
30624
  if (input.commandOptions.json) {
30477
30625
  input.writeOutput(JSON.stringify(response));
@@ -30494,6 +30642,9 @@ function writeServiceAccountScopesResponse(response, writeOutput) {
30494
30642
  function registerServiceAccountCommands(program, context) {
30495
30643
  const serviceAccount = program.command("service-account").description("Manage Auto project service accounts.");
30496
30644
  serviceAccount.command("create").description("Create a project service account and print its token.").argument("<name>", "service account name").option(
30645
+ "--preset <preset>",
30646
+ "grant a named scope bundle (read-only, applier)"
30647
+ ).option(
30497
30648
  "--scope <scope>",
30498
30649
  "grant a scope; repeat to grant multiple scopes",
30499
30650
  collectScopes
@@ -30507,11 +30658,13 @@ function registerServiceAccountCommands(program, context) {
30507
30658
  });
30508
30659
  }
30509
30660
  );
30510
- serviceAccount.command("update").description("Update project service account scopes.").argument("<name>", "service account name").requiredOption(
30661
+ serviceAccount.command("update").description("Update project service account scopes.").argument("<name>", "service account name").option(
30662
+ "--preset <preset>",
30663
+ "grant a named scope bundle (read-only, applier)"
30664
+ ).option(
30511
30665
  "--scope <scope>",
30512
30666
  "grant a scope; repeat to grant multiple scopes",
30513
- collectScopes,
30514
- []
30667
+ collectScopes
30515
30668
  ).option("--json", "print the updated service account as JSON").option("--api-url <url>", "Auto API base URL").option("--api-base-url <url>", "Auto API base URL").action(
30516
30669
  async (name, commandOptions) => {
30517
30670
  await updateServiceAccount({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.83",
3
+ "version": "0.1.85",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"