@intentius/chant 0.124.84 → 0.124.86

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.
Files changed (254) hide show
  1. package/dist/bundle-check.d.ts +102 -0
  2. package/dist/bundle-check.d.ts.map +1 -0
  3. package/dist/bundle-check.js +310 -0
  4. package/dist/chant-install.d.ts +100 -0
  5. package/dist/chant-install.d.ts.map +1 -0
  6. package/dist/chant-install.js +158 -0
  7. package/dist/ci-commit.d.ts +19 -6
  8. package/dist/ci-commit.d.ts.map +1 -1
  9. package/dist/ci-commit.js +23 -4
  10. package/dist/ci-evidence-jobs.d.ts +54 -0
  11. package/dist/ci-evidence-jobs.d.ts.map +1 -0
  12. package/dist/ci-evidence-jobs.js +55 -0
  13. package/dist/ci-image.d.ts +274 -0
  14. package/dist/ci-image.d.ts.map +1 -0
  15. package/dist/ci-image.js +635 -0
  16. package/dist/ci-login.d.ts +150 -0
  17. package/dist/ci-login.d.ts.map +1 -0
  18. package/dist/ci-login.js +240 -0
  19. package/dist/ci-product.d.ts +16 -0
  20. package/dist/ci-product.d.ts.map +1 -1
  21. package/dist/ci-product.js +17 -0
  22. package/dist/cli/commands/import-index.js +2 -2
  23. package/dist/cli/handlers/build.d.ts +8 -0
  24. package/dist/cli/handlers/build.d.ts.map +1 -1
  25. package/dist/cli/handlers/build.js +22 -4
  26. package/dist/cli/handlers/ci-check.d.ts.map +1 -1
  27. package/dist/cli/handlers/ci-check.js +57 -2
  28. package/dist/cli/handlers/ci-evidence.d.ts +3 -0
  29. package/dist/cli/handlers/ci-evidence.d.ts.map +1 -0
  30. package/dist/cli/handlers/ci-evidence.js +171 -0
  31. package/dist/cli/handlers/components.js +3 -3
  32. package/dist/cli/handlers/dead-guards.d.ts +3 -0
  33. package/dist/cli/handlers/dead-guards.d.ts.map +1 -0
  34. package/dist/cli/handlers/dead-guards.js +35 -0
  35. package/dist/cli/handlers/graph.js +4 -4
  36. package/dist/cli/handlers/lifecycle.d.ts +2 -1
  37. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  38. package/dist/cli/handlers/lifecycle.js +5 -4
  39. package/dist/cli/handlers/local-chant.d.ts +16 -0
  40. package/dist/cli/handlers/local-chant.d.ts.map +1 -0
  41. package/dist/cli/handlers/local-chant.js +109 -0
  42. package/dist/cli/handlers/operator.js +2 -2
  43. package/dist/cli/handlers/search.js +5 -5
  44. package/dist/cli/main.d.ts.map +1 -1
  45. package/dist/cli/main.js +38 -0
  46. package/dist/cli/parse-args.d.ts.map +1 -1
  47. package/dist/cli/parse-args.js +28 -0
  48. package/dist/cli/registry.d.ts +16 -0
  49. package/dist/cli/registry.d.ts.map +1 -1
  50. package/dist/components/check-hooks.d.ts +49 -0
  51. package/dist/components/check-hooks.d.ts.map +1 -1
  52. package/dist/components/check-hooks.js +64 -4
  53. package/dist/components/check-steps.d.ts +17 -0
  54. package/dist/components/check-steps.d.ts.map +1 -1
  55. package/dist/components/check-steps.js +37 -5
  56. package/dist/components/product-pipeline.d.ts +23 -0
  57. package/dist/components/product-pipeline.d.ts.map +1 -1
  58. package/dist/components/product-pipeline.js +6 -2
  59. package/dist/components/product-plan.d.ts +137 -0
  60. package/dist/components/product-plan.d.ts.map +1 -0
  61. package/dist/components/product-plan.js +143 -0
  62. package/dist/components/release-compile.d.ts.map +1 -1
  63. package/dist/components/release-compile.js +2 -2
  64. package/dist/config.d.ts +39 -1
  65. package/dist/config.d.ts.map +1 -1
  66. package/dist/config.js +35 -3
  67. package/dist/dead-guards.d.ts +82 -0
  68. package/dist/dead-guards.d.ts.map +1 -0
  69. package/dist/dead-guards.js +436 -0
  70. package/dist/discovery/files.d.ts +3 -1
  71. package/dist/discovery/files.d.ts.map +1 -1
  72. package/dist/discovery/files.js +5 -3
  73. package/dist/drift-issue.d.ts +152 -0
  74. package/dist/drift-issue.d.ts.map +1 -0
  75. package/dist/drift-issue.js +167 -0
  76. package/dist/floor-table.d.ts +30 -0
  77. package/dist/floor-table.d.ts.map +1 -0
  78. package/dist/floor-table.data.d.ts +3 -0
  79. package/dist/floor-table.data.d.ts.map +1 -0
  80. package/dist/floor-table.data.js +178 -0
  81. package/dist/floor-table.js +56 -0
  82. package/dist/forge-flags.d.ts +90 -0
  83. package/dist/forge-flags.d.ts.map +1 -0
  84. package/dist/forge-flags.js +184 -0
  85. package/dist/lexicon.d.ts +69 -0
  86. package/dist/lexicon.d.ts.map +1 -1
  87. package/dist/lifecycle/gated-op.d.ts +7 -1
  88. package/dist/lifecycle/gated-op.d.ts.map +1 -1
  89. package/dist/lifecycle/gated-op.js +7 -4
  90. package/dist/local-chant.d.ts +98 -0
  91. package/dist/local-chant.d.ts.map +1 -0
  92. package/dist/local-chant.js +307 -0
  93. package/dist/op/activities/predict-behaviour.js +2 -2
  94. package/dist/op/op-waves-evidence-spec.d.ts +13 -0
  95. package/dist/op/op-waves-evidence-spec.d.ts.map +1 -0
  96. package/dist/op/op-waves-evidence-spec.js +21 -0
  97. package/dist/op/op-waves-evidence.d.ts +38 -0
  98. package/dist/op/op-waves-evidence.d.ts.map +1 -0
  99. package/dist/op/op-waves-evidence.js +57 -0
  100. package/dist/op/op-waves-run.d.ts +4 -0
  101. package/dist/op/op-waves-run.d.ts.map +1 -1
  102. package/dist/op/op-waves-run.js +24 -1
  103. package/dist/op/op-waves.d.ts +17 -1
  104. package/dist/op/op-waves.d.ts.map +1 -1
  105. package/dist/op/op-waves.js +23 -0
  106. package/dist/op/schedule-overdue.d.ts +41 -9
  107. package/dist/op/schedule-overdue.d.ts.map +1 -1
  108. package/dist/op/schedule-overdue.js +154 -25
  109. package/dist/plan-summary.d.ts +25 -0
  110. package/dist/plan-summary.d.ts.map +1 -1
  111. package/dist/plan-summary.js +31 -0
  112. package/dist/pr-plan-note.d.ts +35 -0
  113. package/dist/pr-plan-note.d.ts.map +1 -1
  114. package/dist/pr-plan-note.js +10 -0
  115. package/dist/pr-post.d.ts +23 -0
  116. package/dist/pr-post.d.ts.map +1 -1
  117. package/dist/pr-post.js +125 -3
  118. package/dist/release-floors.d.ts +31 -1
  119. package/dist/release-floors.d.ts.map +1 -1
  120. package/dist/release-floors.js +31 -1
  121. package/dist/state-migration.d.ts +24 -0
  122. package/dist/state-migration.d.ts.map +1 -1
  123. package/dist/state-migration.js +100 -5
  124. package/dist/wave-runtime.mjs +305 -298
  125. package/dist/workspace/lexicon-outputs.d.ts.map +1 -1
  126. package/dist/workspace/lexicon-outputs.js +21 -7
  127. package/dist/workspace/reason-codes.d.ts +3 -0
  128. package/dist/workspace/reason-codes.d.ts.map +1 -1
  129. package/dist/workspace/reason-codes.js +4 -0
  130. package/dist/workspace/ref-gate.schema.json +85 -0
  131. package/dist/workspace/search-contract.d.ts +1 -1
  132. package/dist/workspace/search-contract.d.ts.map +1 -1
  133. package/dist/workspace/trust/check-evidence-report.d.ts +51 -0
  134. package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -0
  135. package/dist/workspace/trust/check-evidence-report.js +102 -0
  136. package/dist/workspace/trust/check-evidence.d.ts +126 -0
  137. package/dist/workspace/trust/check-evidence.d.ts.map +1 -0
  138. package/dist/workspace/trust/check-evidence.js +237 -0
  139. package/dist/workspace/trust/local-evidence.d.ts +120 -0
  140. package/dist/workspace/trust/local-evidence.d.ts.map +1 -0
  141. package/dist/workspace/trust/local-evidence.js +259 -0
  142. package/dist/workspace/trust/policy.d.ts +84 -0
  143. package/dist/workspace/trust/policy.d.ts.map +1 -1
  144. package/dist/workspace/trust/policy.js +94 -1
  145. package/dist/workspace/trust/ref-gate-cli.d.ts +33 -0
  146. package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -0
  147. package/dist/workspace/trust/ref-gate-cli.js +234 -0
  148. package/dist/workspace/trust/ref-gate-fixture.d.ts +38 -0
  149. package/dist/workspace/trust/ref-gate-fixture.d.ts.map +1 -0
  150. package/dist/workspace/trust/ref-gate-fixture.js +97 -0
  151. package/dist/workspace/trust/ref-gate.d.ts +187 -0
  152. package/dist/workspace/trust/ref-gate.d.ts.map +1 -0
  153. package/dist/workspace/trust/ref-gate.js +430 -0
  154. package/dist/workspace/trust/trust-files.d.ts.map +1 -1
  155. package/dist/workspace/trust/trust-files.js +18 -1
  156. package/package.json +1 -1
  157. package/src/bundle-check.test.ts +140 -0
  158. package/src/bundle-check.ts +352 -0
  159. package/src/chant-install.test.ts +112 -0
  160. package/src/chant-install.ts +179 -0
  161. package/src/ci-commit.test.ts +45 -0
  162. package/src/ci-commit.ts +38 -4
  163. package/src/ci-evidence-jobs.ts +67 -0
  164. package/src/ci-image.test.ts +506 -0
  165. package/src/ci-image.ts +822 -0
  166. package/src/ci-login.test.ts +235 -0
  167. package/src/ci-login.ts +307 -0
  168. package/src/ci-product.ts +18 -0
  169. package/src/cli/commands/__fixtures__/source-dir-include/chant.config.json +1 -0
  170. package/src/cli/commands/__fixtures__/source-dir-include/infra.ts +1 -0
  171. package/src/cli/commands/__fixtures__/source-dir-include/scripts/run-on-load.ts +3 -0
  172. package/src/cli/commands/__fixtures__/source-dir-root/chant.config.json +1 -0
  173. package/src/cli/commands/__fixtures__/source-dir-root/infra.test.ts +1 -0
  174. package/src/cli/commands/__fixtures__/source-dir-root/infra.ts +1 -0
  175. package/src/cli/commands/__fixtures__/source-dir-root/scripts/run-on-load.ts +3 -0
  176. package/src/cli/commands/__fixtures__/source-dir-scoped/app.ts +3 -0
  177. package/src/cli/commands/__fixtures__/source-dir-scoped/chant.config.json +1 -0
  178. package/src/cli/commands/__fixtures__/source-dir-scoped/infra/net.ts +1 -0
  179. package/src/cli/commands/__fixtures__/source-dir-scoped/scripts/run-on-load.ts +3 -0
  180. package/src/cli/commands/import-index.ts +2 -2
  181. package/src/cli/handlers/build-source-dir.test.ts +64 -0
  182. package/src/cli/handlers/build.ts +21 -4
  183. package/src/cli/handlers/ci-check.ts +56 -3
  184. package/src/cli/handlers/ci-evidence.ts +162 -0
  185. package/src/cli/handlers/components.ts +3 -3
  186. package/src/cli/handlers/dead-guards.ts +37 -0
  187. package/src/cli/handlers/graph.ts +4 -4
  188. package/src/cli/handlers/lifecycle.ts +5 -4
  189. package/src/cli/handlers/local-chant.ts +106 -0
  190. package/src/cli/handlers/operator.ts +2 -2
  191. package/src/cli/handlers/search.ts +5 -5
  192. package/src/cli/main.test.ts +7 -0
  193. package/src/cli/main.ts +38 -0
  194. package/src/cli/parse-args.ts +21 -0
  195. package/src/cli/registry.ts +16 -0
  196. package/src/components/check-evidence-stage.test.ts +80 -0
  197. package/src/components/check-hooks.ts +84 -4
  198. package/src/components/check-local-evidence-stage.test.ts +141 -0
  199. package/src/components/check-steps.ts +56 -6
  200. package/src/components/product-pipeline.ts +28 -3
  201. package/src/components/product-plan.test.ts +87 -0
  202. package/src/components/product-plan.ts +226 -0
  203. package/src/components/release-compile.ts +2 -2
  204. package/src/config.ts +44 -3
  205. package/src/dead-guards.test.ts +206 -0
  206. package/src/dead-guards.ts +446 -0
  207. package/src/discovery/files.ts +5 -3
  208. package/src/drift-issue-bundle.test.ts +31 -0
  209. package/src/drift-issue.test.ts +206 -0
  210. package/src/drift-issue.ts +274 -0
  211. package/src/fit-note.test.ts +44 -0
  212. package/src/floor-table.data.ts +180 -0
  213. package/src/floor-table.ts +77 -0
  214. package/src/forge-flags.test.ts +110 -0
  215. package/src/forge-flags.ts +208 -0
  216. package/src/gate-decision-bundle.test.ts +1 -0
  217. package/src/lexicon.ts +68 -0
  218. package/src/lifecycle/gated-op.ts +10 -5
  219. package/src/local-chant.e2e.test.ts +94 -0
  220. package/src/local-chant.test.ts +162 -0
  221. package/src/local-chant.ts +341 -0
  222. package/src/op/activities/predict-behaviour.ts +2 -2
  223. package/src/op/op-waves-evidence-spec.ts +24 -0
  224. package/src/op/op-waves-evidence.test.ts +130 -0
  225. package/src/op/op-waves-evidence.ts +57 -0
  226. package/src/op/op-waves-run.ts +25 -1
  227. package/src/op/op-waves.ts +31 -1
  228. package/src/op/schedule-overdue.test.ts +85 -0
  229. package/src/op/schedule-overdue.ts +162 -26
  230. package/src/plan-summary.ts +40 -0
  231. package/src/pr-plan-note.ts +34 -0
  232. package/src/pr-post-plan-note.test.ts +146 -0
  233. package/src/pr-post.ts +127 -3
  234. package/src/release-floors.ts +44 -1
  235. package/src/stage-hooks-bundle.test.ts +1 -0
  236. package/src/state-migration.test.ts +52 -1
  237. package/src/state-migration.ts +107 -5
  238. package/src/workspace/lexicon-outputs.ts +23 -6
  239. package/src/workspace/reason-codes.test.ts +3 -0
  240. package/src/workspace/reason-codes.ts +4 -0
  241. package/src/workspace/ref-gate.schema.json +85 -0
  242. package/src/workspace/trust/check-evidence-report.ts +106 -0
  243. package/src/workspace/trust/check-evidence.test.ts +133 -0
  244. package/src/workspace/trust/check-evidence.ts +257 -0
  245. package/src/workspace/trust/local-evidence.test.ts +127 -0
  246. package/src/workspace/trust/local-evidence.ts +266 -0
  247. package/src/workspace/trust/policy.ts +134 -1
  248. package/src/workspace/trust/ref-gate-cli.ts +244 -0
  249. package/src/workspace/trust/ref-gate-fixture.ts +125 -0
  250. package/src/workspace/trust/ref-gate.e2e.test.ts +76 -0
  251. package/src/workspace/trust/ref-gate.test.ts +247 -0
  252. package/src/workspace/trust/ref-gate.ts +538 -0
  253. package/src/workspace/trust/trust-files.test.ts +16 -0
  254. package/src/workspace/trust/trust-files.ts +41 -1
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Cloud login steps from the OIDC token file (#4788): a CI job's step that
3
+ * writes the forge's OIDC token to a file and points each cloud's own tools
4
+ * at it, for AWS, GCP and Azure, on GitHub, GitLab and Forgejo.
5
+ *
6
+ * ./ci-identity.ts trades the token for short-lived credentials before the
7
+ * checkout. This is the other way a CI product logs in: the job keeps the
8
+ * token in a file and the cloud's SDK, command line or Terraform provider
9
+ * trades it itself, again whenever its credentials run out. That is what
10
+ * the AWS SDKs' web identity provider, Google's `external_account`
11
+ * credentials and the azurerm provider's OIDC read, and what terragucci's
12
+ * `oidcScript`, `gcpScript` and `azureScript` and SQL Yodeler's Forgejo
13
+ * login wrote for themselves.
14
+ *
15
+ * The step runs {@link LOGIN_JS} with `node -e` from `/`, so it reads none
16
+ * of the checkout's files and needs nothing installed. Per cloud it takes
17
+ * the token from, in order: the cloud's `tokenFile`, a file the runner
18
+ * provides (left where it is, so a runner that refreshes it keeps the job
19
+ * logged in); the GitLab `id_tokens` variable {@link idTokenVar}; the forge's
20
+ * token request URL with the cloud's audience (GitHub, and Forgejo 15 with
21
+ * Forgejo Runner 12.5 and `enable-openid-connect: true`). A token it got
22
+ * goes to a file of its own under `RUNNER_TEMP` (else `TMPDIR`, else
23
+ * `/tmp`), mode 0600. Then it sets:
24
+ *
25
+ * AWS AWS_ROLE_ARN, AWS_WEB_IDENTITY_TOKEN_FILE, AWS_ROLE_SESSION_NAME,
26
+ * AWS_REGION, AWS_DEFAULT_REGION (and AWS_ENDPOINT_URL_STS with
27
+ * `endpoint`)
28
+ * GCP GOOGLE_APPLICATION_CREDENTIALS and
29
+ * CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE, an `external_account`
30
+ * file per service account that trades the token at Google's STS
31
+ * and impersonates the account
32
+ * Azure AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_FEDERATED_TOKEN_FILE
33
+ * (the Azure SDKs), ARM_USE_OIDC, ARM_CLIENT_ID, ARM_TENANT_ID,
34
+ * ARM_OIDC_TOKEN_FILE_PATH (azurerm), the subscription in
35
+ * AZURE_SUBSCRIPTION_ID and ARM_SUBSCRIPTION_ID, and with `cli`
36
+ * `az login --federated-token` for the `az` command line
37
+ *
38
+ * gcloud reads CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE, so it needs no
39
+ * `gcloud auth login`. On GitHub and Forgejo the variables go to
40
+ * `$GITHUB_ENV`; on GitLab the script evaluates the `export` lines the
41
+ * login prints, which name files and hold no token, then unsets the token
42
+ * variables and the spec. No file of variables is left to delete.
43
+ *
44
+ * Per target and per stage: the spec is a {@link CloudTradeSpec} without
45
+ * Pulumi, the plan or apply side of what `resolveCloudIdentity` gives, so a
46
+ * product passes the stage's own. A cloud's `targets` name the identities
47
+ * other targets take (#4332). The step then writes the
48
+ * {@link CLOUD_TARGETS_ENV} file the trade writes, each identity's
49
+ * variables in it, and a product hands each target's tool its own with
50
+ * `targetCloudEnv`, as after the trade.
51
+ *
52
+ * The functions return {@link OpWaveRunStep}s and the job's `idTokens`, the
53
+ * shape `OpWavesPipelineOptions.waveJobs[].before` and `recordPlans` take
54
+ * (#4791), so a product passes the login to chant's generators instead of
55
+ * writing it into their files.
56
+ */
57
+ import { type CloudTradeSpec } from "./ci-identity.js";
58
+ import type { OpWaveRunStep } from "./lexicon.js";
59
+ /** The variable the login step reads its {@link CloudLoginSpec} from, as JSON. */
60
+ export declare const LOGIN_SPEC_ENV = "CHANT_CLOUD_LOGIN";
61
+ /** The forges a login step is rendered for. */
62
+ export type LoginForge = "github" | "gitlab" | "forgejo";
63
+ /** What a cloud's login may add to its trade spec: a token file the runner provides. */
64
+ interface TokenFileOption {
65
+ /**
66
+ * A file holding the job's OIDC token for this cloud, which the runner
67
+ * provides, such as a Forgejo runner's own. A leading `$NAME` or
68
+ * `${NAME}` is the job's variable. The job then requests no token for
69
+ * this cloud.
70
+ */
71
+ tokenFile?: string;
72
+ }
73
+ /** One job's login, per cloud: a {@link CloudTradeSpec}'s AWS, GCP and Azure parts, with defaults, and the login's own options. */
74
+ export interface CloudLoginSpec {
75
+ aws?: Omit<NonNullable<CloudTradeSpec["aws"]>, "region" | "audience"> & TokenFileOption & {
76
+ /** Default `us-east-1`. */
77
+ region?: string;
78
+ /** The token's audience. Default `sts.amazonaws.com`. */
79
+ audience?: string;
80
+ /** AWS_ROLE_SESSION_NAME, 2 to 64 of letters, digits and `+=,.@_-`. Default `chant`. */
81
+ sessionName?: string;
82
+ };
83
+ gcp?: Omit<NonNullable<CloudTradeSpec["gcp"]>, "audience"> & TokenFileOption & {
84
+ /** The token's audience. Default `https://iam.googleapis.com/<provider>`. */
85
+ audience?: string;
86
+ };
87
+ azure?: Omit<NonNullable<CloudTradeSpec["azure"]>, "audience" | "database"> & TokenFileOption & {
88
+ /** The token's audience. Default `api://AzureADTokenExchange`. */
89
+ audience?: string;
90
+ /** Also `az login --service-principal --federated-token` as the job's own client, for the `az` command line. Default false. */
91
+ cli?: boolean;
92
+ };
93
+ }
94
+ /** A job's login: its steps, and the OIDC tokens the job requests. */
95
+ export interface CloudLoginSteps {
96
+ /**
97
+ * The steps, in order. GitHub and Forgejo: each one `run:` step, its lines
98
+ * joined by newlines. GitLab: their lines in the job's script.
99
+ */
100
+ steps: OpWaveRunStep[];
101
+ /**
102
+ * The tokens the job requests, `{ <variable>: <audience> }`, as
103
+ * `recordPlans.idTokens` and a wave's `idTokens` take them: GitLab
104
+ * `id_tokens:`, and on GitHub and Forgejo the job's `id-token: write`
105
+ * (Forgejo `enable-openid-connect: true`). Empty when every cloud names a
106
+ * `tokenFile`.
107
+ */
108
+ idTokens: Record<string, string>;
109
+ }
110
+ /** `spec` with every default filled, as the login script reads it, refused when a value cannot be held by the job. */
111
+ export declare function cloudLoginSpec(spec: CloudLoginSpec): CloudLoginSpec;
112
+ /**
113
+ * The login, a script for `node -e` with no dependency. argv 1 is the file
114
+ * it writes, argv 2 its format (`github-env` appends `NAME=value` lines to
115
+ * the file; `sh` prints `export` lines, and argv 1 is `-`), argv 3 the forge, for what a job
116
+ * with no token is told. {@link LOGIN_SPEC_ENV} is the spec, defaults filled
117
+ * ({@link cloudLoginSpec}). It never prints a token.
118
+ */
119
+ export declare const LOGIN_JS: string;
120
+ /** The shell line that runs the login from `/`, writing `out` in `format`. */
121
+ export declare function loginLine(out: string, format: "github-env" | "sh", forge: LoginForge): string;
122
+ /**
123
+ * A GitHub Actions job's cloud login (#4788): one step that requests the
124
+ * OIDC token per cloud, writes each to a file and appends the clouds'
125
+ * variables to `$GITHUB_ENV`, so every later step has them. The job needs
126
+ * `id-token: write`, which `idTokens` asks chant's generators for.
127
+ */
128
+ export declare function githubCloudLogin(spec: CloudLoginSpec): CloudLoginSteps;
129
+ /**
130
+ * A Forgejo Actions job's cloud login (#4788), as on GitHub. Forgejo 15 with
131
+ * Forgejo Runner 12.5 serves the token to a job with
132
+ * `enable-openid-connect: true`, which the forgejo lexicon sets for a job
133
+ * that asks for `id-token: write`. On an older Forgejo, give each cloud a
134
+ * `tokenFile` the runner provides; the job then requests none.
135
+ */
136
+ export declare function forgejoCloudLogin(spec: CloudLoginSpec): CloudLoginSteps;
137
+ /** The GitLab variable the login's `export` lines are kept in until the script evaluates them. */
138
+ export declare const GITLAB_LOGIN_VARS = "CHANT_CLOUD_LOGIN_VARS";
139
+ /**
140
+ * A GitLab CI job's cloud login (#4788): script lines that write each
141
+ * cloud's `id_tokens` token to a file, evaluate the clouds' variables, and
142
+ * unset the token variables and the spec, so later lines hold the token
143
+ * only in its file. The job's `id_tokens:` are `idTokens`, each
144
+ * `{ aud: <audience> }`.
145
+ */
146
+ export declare function gitlabCloudLogin(given: CloudLoginSpec): CloudLoginSteps;
147
+ /** A job's cloud login on `forge` (#4788): {@link githubCloudLogin}, {@link gitlabCloudLogin} or {@link forgejoCloudLogin}. */
148
+ export declare function cloudLogin(forge: LoginForge, spec: CloudLoginSpec): CloudLoginSteps;
149
+ export {};
150
+ //# sourceMappingURL=ci-login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ci-login.d.ts","sourceRoot":"","sources":["../src/ci-login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,kFAAkF;AAClF,eAAO,MAAM,cAAc,sBAAsB,CAAC;AAElD,+CAA+C;AAC/C,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzD,wFAAwF;AACxF,UAAU,eAAe;IACvB;;;;;OAK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MAAM,CAE7F;AAYD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,CAEtE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,CAEvE;AAED,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAE1D;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CAmBvE;AAED,+HAA+H;AAC/H,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,GAAG,eAAe,CAEnF"}
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Cloud login steps from the OIDC token file (#4788): a CI job's step that
3
+ * writes the forge's OIDC token to a file and points each cloud's own tools
4
+ * at it, for AWS, GCP and Azure, on GitHub, GitLab and Forgejo.
5
+ *
6
+ * ./ci-identity.ts trades the token for short-lived credentials before the
7
+ * checkout. This is the other way a CI product logs in: the job keeps the
8
+ * token in a file and the cloud's SDK, command line or Terraform provider
9
+ * trades it itself, again whenever its credentials run out. That is what
10
+ * the AWS SDKs' web identity provider, Google's `external_account`
11
+ * credentials and the azurerm provider's OIDC read, and what terragucci's
12
+ * `oidcScript`, `gcpScript` and `azureScript` and SQL Yodeler's Forgejo
13
+ * login wrote for themselves.
14
+ *
15
+ * The step runs {@link LOGIN_JS} with `node -e` from `/`, so it reads none
16
+ * of the checkout's files and needs nothing installed. Per cloud it takes
17
+ * the token from, in order: the cloud's `tokenFile`, a file the runner
18
+ * provides (left where it is, so a runner that refreshes it keeps the job
19
+ * logged in); the GitLab `id_tokens` variable {@link idTokenVar}; the forge's
20
+ * token request URL with the cloud's audience (GitHub, and Forgejo 15 with
21
+ * Forgejo Runner 12.5 and `enable-openid-connect: true`). A token it got
22
+ * goes to a file of its own under `RUNNER_TEMP` (else `TMPDIR`, else
23
+ * `/tmp`), mode 0600. Then it sets:
24
+ *
25
+ * AWS AWS_ROLE_ARN, AWS_WEB_IDENTITY_TOKEN_FILE, AWS_ROLE_SESSION_NAME,
26
+ * AWS_REGION, AWS_DEFAULT_REGION (and AWS_ENDPOINT_URL_STS with
27
+ * `endpoint`)
28
+ * GCP GOOGLE_APPLICATION_CREDENTIALS and
29
+ * CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE, an `external_account`
30
+ * file per service account that trades the token at Google's STS
31
+ * and impersonates the account
32
+ * Azure AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_FEDERATED_TOKEN_FILE
33
+ * (the Azure SDKs), ARM_USE_OIDC, ARM_CLIENT_ID, ARM_TENANT_ID,
34
+ * ARM_OIDC_TOKEN_FILE_PATH (azurerm), the subscription in
35
+ * AZURE_SUBSCRIPTION_ID and ARM_SUBSCRIPTION_ID, and with `cli`
36
+ * `az login --federated-token` for the `az` command line
37
+ *
38
+ * gcloud reads CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE, so it needs no
39
+ * `gcloud auth login`. On GitHub and Forgejo the variables go to
40
+ * `$GITHUB_ENV`; on GitLab the script evaluates the `export` lines the
41
+ * login prints, which name files and hold no token, then unsets the token
42
+ * variables and the spec. No file of variables is left to delete.
43
+ *
44
+ * Per target and per stage: the spec is a {@link CloudTradeSpec} without
45
+ * Pulumi, the plan or apply side of what `resolveCloudIdentity` gives, so a
46
+ * product passes the stage's own. A cloud's `targets` name the identities
47
+ * other targets take (#4332). The step then writes the
48
+ * {@link CLOUD_TARGETS_ENV} file the trade writes, each identity's
49
+ * variables in it, and a product hands each target's tool its own with
50
+ * `targetCloudEnv`, as after the trade.
51
+ *
52
+ * The functions return {@link OpWaveRunStep}s and the job's `idTokens`, the
53
+ * shape `OpWavesPipelineOptions.waveJobs[].before` and `recordPlans` take
54
+ * (#4791), so a product passes the login to chant's generators instead of
55
+ * writing it into their files.
56
+ */
57
+ import { CLOUD_TARGETS_ENV, IDENTITY_KEY, idTokenVar, } from "./ci-identity.js";
58
+ /** The variable the login step reads its {@link CloudLoginSpec} from, as JSON. */
59
+ export const LOGIN_SPEC_ENV = "CHANT_CLOUD_LOGIN";
60
+ const LOGIN_CLOUDS = ["aws", "gcp", "azure"];
61
+ /** The provider's resource name without the `//iam.googleapis.com/` prefix, as ci-identity reads it. */
62
+ const providerPath = (p) => p.replace(/^(https:)?\/\/iam\.googleapis\.com\//, "");
63
+ /** A value the login writes to a job's environment: printable ASCII with no space or quote. */
64
+ const SAFE = /^[\x21-\x7e]+$/;
65
+ const SESSION_NAME = /^[\w+=,.@-]{2,64}$/;
66
+ const TOKEN_FILE = /^(\$\{?[A-Za-z_][A-Za-z0-9_]*\}?)?[\w./-]+$/;
67
+ /** `spec` with every default filled, as the login script reads it, refused when a value cannot be held by the job. */
68
+ export function cloudLoginSpec(spec) {
69
+ const extra = Object.keys(spec).filter((k) => !LOGIN_CLOUDS.includes(k));
70
+ if (extra.length > 0)
71
+ throw new Error(`a cloud login covers ${LOGIN_CLOUDS.join(", ")}; ${extra.join(", ")} ${extra.includes("pulumi") ? "(Pulumi Cloud) is traded, with ci-identity's trade step" : "is no cloud it knows"}`);
72
+ if (spec.azure?.database)
73
+ throw new Error("a cloud login gives Azure no database token: trade the token with ci-identity's trade step for azure.database");
74
+ const out = {};
75
+ if (spec.aws)
76
+ out.aws = { ...spec.aws, region: spec.aws.region ?? "us-east-1", audience: spec.aws.audience ?? "sts.amazonaws.com" };
77
+ if (spec.gcp) {
78
+ const provider = providerPath(spec.gcp.provider);
79
+ out.gcp = { ...spec.gcp, provider, audience: spec.gcp.audience ?? `https://iam.googleapis.com/${provider}` };
80
+ }
81
+ if (spec.azure)
82
+ out.azure = { ...spec.azure, audience: spec.azure.audience ?? "api://AzureADTokenExchange" };
83
+ for (const cloud of LOGIN_CLOUDS) {
84
+ const c = out[cloud];
85
+ if (!c)
86
+ continue;
87
+ const key = IDENTITY_KEY[cloud];
88
+ const ids = [c[key], ...(c.targets ?? []).map((t) => t[key])].filter((v) => v !== undefined);
89
+ if (ids.length === 0)
90
+ throw new Error(`the ${cloud} login names no identity: give it ${key}, or targets`);
91
+ for (const [k, v] of Object.entries(c)) {
92
+ if (typeof v === "string" && !SAFE.test(v))
93
+ throw new Error(`the ${cloud} login's ${k} is ${JSON.stringify(v)}; a job holds printable ASCII with no space`);
94
+ }
95
+ for (const id of ids)
96
+ if (typeof id !== "string" || !SAFE.test(id))
97
+ throw new Error(`the ${cloud} login's identity ${JSON.stringify(id)} is not one a job can hold`);
98
+ if (c.tokenFile !== undefined && !TOKEN_FILE.test(String(c.tokenFile)))
99
+ throw new Error(`the ${cloud} login's tokenFile ${JSON.stringify(c.tokenFile)} is not a file path`);
100
+ }
101
+ if (out.aws?.sessionName !== undefined && !SESSION_NAME.test(out.aws.sessionName))
102
+ throw new Error(`the aws login's sessionName ${JSON.stringify(out.aws.sessionName)} is not 2 to 64 of letters, digits and +=,.@_-`);
103
+ if (out.azure?.cli && !out.azure.clientId)
104
+ throw new Error("the azure login's cli logs the az command line in as the job's own client, so it needs clientId");
105
+ return out;
106
+ }
107
+ /**
108
+ * The login, a script for `node -e` with no dependency. argv 1 is the file
109
+ * it writes, argv 2 its format (`github-env` appends `NAME=value` lines to
110
+ * the file; `sh` prints `export` lines, and argv 1 is `-`), argv 3 the forge, for what a job
111
+ * with no token is told. {@link LOGIN_SPEC_ENV} is the spec, defaults filled
112
+ * ({@link cloudLoginSpec}). It never prints a token.
113
+ */
114
+ export const LOGIN_JS = [
115
+ 'const fs=require("fs"),crypto=require("crypto");',
116
+ "const [out,format,forge]=process.argv.slice(1);",
117
+ "const Q=String.fromCharCode(39);",
118
+ 'const fail=(m)=>{console.error("chant: the cloud login failed: "+m);process.exit(1)};',
119
+ `let spec;try{spec=JSON.parse(process.env.${LOGIN_SPEC_ENV}||"")}catch{fail("${LOGIN_SPEC_ENV} is not JSON")}`,
120
+ 'const clean=(v)=>typeof v==="string"&&/^[\\x21-\\x7e]+$/.test(v);',
121
+ 'const trim=(u)=>String(u).replace(/\\/+$/,"");',
122
+ 'const tmp=trim(process.env.RUNNER_TEMP||process.env.TMPDIR||"/tmp");',
123
+ 'const rand=()=>crypto.randomBytes(8).toString("hex");',
124
+ 'const NO={github:"it needs permissions: id-token: write, and a pull request from a fork gets none",forgejo:"Forgejo serves one from version 15, with Forgejo Runner 12.5 or later, to a job with enable-openid-connect: true; on an older Forgejo give the cloud a tokenFile the runner provides"};',
125
+ // A cloud's token: the runner's file, else GitLab's id_tokens variable, else the forge's request URL, into a file of its own.
126
+ "const tokenFile=async(cloud,s)=>{",
127
+ 'if(s.tokenFile){const f=s.tokenFile.replace(/^\\$\\{?([A-Za-z_][A-Za-z0-9_]*)\\}?/,(m,v)=>process.env[v]||"");let t;try{t=fs.readFileSync(f,"utf8").trim()}catch{throw new Error(cloud+"\\u0027s tokenFile "+f+" cannot be read")}if(!t)throw new Error(cloud+"\\u0027s tokenFile "+f+" is empty");return f}',
128
+ 'const name="CHANT_ID_TOKEN_"+cloud.toUpperCase();let v=process.env[name];',
129
+ 'if(!v){if(forge==="gitlab")throw new Error("the job has no "+name+": it needs id_tokens: "+name+": aud: "+s.audience);',
130
+ "const u=process.env.ACTIONS_ID_TOKEN_REQUEST_URL,k=process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;",
131
+ 'if(!u||!k)throw new Error("the job can request no OIDC token for "+cloud+": "+(NO[forge]||NO.github));',
132
+ 'const r=await fetch(u+(u.includes("?")?"&":"?")+"audience="+encodeURIComponent(s.audience),{headers:{authorization:"bearer "+k,accept:"application/json"}});',
133
+ 'if(!r.ok)throw new Error("the OIDC token request answered "+r.status);',
134
+ 'try{v=JSON.parse(await r.text()).value}catch{throw new Error("the OIDC token request answered with no JSON")}}',
135
+ 'if(!clean(v))throw new Error("the job\\u0027s OIDC token for "+cloud+" is not a token");',
136
+ 'const f=tmp+"/chant-oidc-"+cloud+"-"+rand();fs.writeFileSync(f,v,{mode:0o600,flag:"wx"});return f};',
137
+ `const KEY=${JSON.stringify(IDENTITY_KEY)};`,
138
+ 'const ids=(c)=>{const s=spec[c],l=[];if(s[KEY[c]])l.push(s[KEY[c]]);for(const t of s.targets||[])if(!l.includes(t[KEY[c]]))l.push(t[KEY[c]]);return l};',
139
+ "const vars={},said=[],by={};",
140
+ "const run=async()=>{",
141
+ 'if(spec.aws){const a=spec.aws;const f=await tokenFile("aws",a);by.aws={};',
142
+ 'for(const role of ids("aws")){by.aws[role]={AWS_ROLE_ARN:role,AWS_WEB_IDENTITY_TOKEN_FILE:f,AWS_ROLE_SESSION_NAME:a.sessionName||"chant",AWS_REGION:a.region,AWS_DEFAULT_REGION:a.region,...(a.endpoint?{AWS_ENDPOINT_URL_STS:trim(a.endpoint)}:{})};said.push(role)}',
143
+ "if(a.role)Object.assign(vars,by.aws[a.role])}",
144
+ 'if(spec.gcp){const c=spec.gcp;const f=await tokenFile("gcp",c);by.gcp={};',
145
+ 'const sts=trim(c.stsEndpoint||"https://sts.googleapis.com"),iam=trim(c.iamEndpoint||"https://iamcredentials.googleapis.com");',
146
+ 'for(const sa of ids("gcp")){const cf=tmp+"/chant-gcp-"+rand()+".json";',
147
+ 'fs.writeFileSync(cf,JSON.stringify({type:"external_account",audience:"//iam.googleapis.com/"+c.provider,subject_token_type:"urn:ietf:params:oauth:token-type:jwt",token_url:sts+"/v1/token",service_account_impersonation_url:iam+"/v1/projects/-/serviceAccounts/"+sa+":generateAccessToken",credential_source:{file:f}})+"\\n",{mode:0o600,flag:"wx"});',
148
+ "by.gcp[sa]={GOOGLE_APPLICATION_CREDENTIALS:cf,CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE:cf};said.push(sa)}",
149
+ "if(c.serviceAccount)Object.assign(vars,by.gcp[c.serviceAccount])}",
150
+ 'if(spec.azure){const z=spec.azure;const f=await tokenFile("azure",z);by.azure={};',
151
+ "for(const cid of ids(\"azure\")){by.azure[cid]={AZURE_CLIENT_ID:cid,AZURE_TENANT_ID:z.tenantId,AZURE_FEDERATED_TOKEN_FILE:f,ARM_USE_OIDC:\"true\",ARM_CLIENT_ID:cid,ARM_TENANT_ID:z.tenantId,ARM_OIDC_TOKEN_FILE_PATH:f,...(z.subscriptionId?{AZURE_SUBSCRIPTION_ID:z.subscriptionId,ARM_SUBSCRIPTION_ID:z.subscriptionId}:{}),...(z.authority?{AZURE_AUTHORITY_HOST:trim(z.authority)}:{})};said.push(cid)}",
152
+ "if(z.clientId)Object.assign(vars,by.azure[z.clientId]);",
153
+ // The az command line keeps a login of its own; the token goes on its argv, as `az login` takes it.
154
+ 'if(z.cli){const r=require("child_process").spawnSync("az",["login","--service-principal","--username",z.clientId,"--tenant",z.tenantId,"--federated-token",fs.readFileSync(f,"utf8").trim(),"--allow-no-subscriptions","--output","none"],{stdio:["ignore","ignore","inherit"]});',
155
+ 'if(r.error)throw new Error("az login could not run: "+r.error.message);if(r.status!==0)throw new Error("az login exited "+r.status);',
156
+ 'if(z.subscriptionId){const s=require("child_process").spawnSync("az",["account","set","--subscription",z.subscriptionId],{stdio:["ignore","ignore","inherit"]});if(s.status!==0)throw new Error("az account set exited "+s.status)}}}',
157
+ // #4332: with targets, every identity's variables go in the trade's targets file, which targetCloudEnv reads.
158
+ 'const clouds=Object.keys(by);if(clouds.some((c)=>(spec[c].targets||[]).length>0)){',
159
+ 'const doc={version:1,clouds:{}};for(const c of clouds){const s=spec[c];doc.clouds[c]={...(s[KEY[c]]?{default:s[KEY[c]]}:{}),targets:(s.targets||[]).map((t)=>({targets:t.targets,identity:t[KEY[c]]})),vars:by[c]}}',
160
+ `const tf=tmp+"/chant-cloud-targets-"+rand()+".json";fs.writeFileSync(tf,JSON.stringify(doc),{mode:0o600,flag:"wx"});vars.${CLOUD_TARGETS_ENV}=tf}`,
161
+ 'for(const [k,v] of Object.entries(vars))if(!clean(v))throw new Error(k+" is not a value the job can hold");',
162
+ 'if(format==="github-env")fs.appendFileSync(out,Object.entries(vars).map(([k,v])=>k+"="+v+"\\n").join(""));',
163
+ 'else process.stdout.write(Object.entries(vars).map(([k,v])=>"export "+k+"="+Q+v.split(Q).join(Q+"\\\\"+Q+Q)+Q+"\\n").join(""));',
164
+ 'for(const s of said)console.error("chant: logged in from the OIDC token file as "+s)};',
165
+ "run().catch((e)=>fail(e&&e.message?e.message:String(e)));",
166
+ ].join("");
167
+ const sh = (s) => `'${s.split("'").join(`'\\''`)}'`;
168
+ /** The tokens a login's job requests: one per cloud with no `tokenFile`, with the cloud's audience. */
169
+ function loginIdTokens(spec) {
170
+ return Object.fromEntries(LOGIN_CLOUDS.filter((c) => spec[c] && spec[c].tokenFile === undefined).map((c) => [idTokenVar(c), spec[c].audience]));
171
+ }
172
+ /** The step's name: which clouds it logs in to. */
173
+ const stepName = (spec) => `Cloud login (chant ci-login: ${LOGIN_CLOUDS.filter((c) => spec[c]).join(", ")})`;
174
+ /** The shell line that runs the login from `/`, writing `out` in `format`. */
175
+ export function loginLine(out, format, forge) {
176
+ return `(cd / && node -e '${LOGIN_JS}' "${out}" ${format} ${forge})`;
177
+ }
178
+ /** A GitHub Actions or Forgejo Actions login: one step that appends the variables to `$GITHUB_ENV`. */
179
+ function actionsLogin(forge, given) {
180
+ const spec = cloudLoginSpec(given);
181
+ if (Object.keys(spec).length === 0)
182
+ return { steps: [], idTokens: {} };
183
+ return {
184
+ steps: [{ name: stepName(spec), run: [`export ${LOGIN_SPEC_ENV}=${sh(JSON.stringify(spec))}`, loginLine("$GITHUB_ENV", "github-env", forge)] }],
185
+ idTokens: loginIdTokens(spec),
186
+ };
187
+ }
188
+ /**
189
+ * A GitHub Actions job's cloud login (#4788): one step that requests the
190
+ * OIDC token per cloud, writes each to a file and appends the clouds'
191
+ * variables to `$GITHUB_ENV`, so every later step has them. The job needs
192
+ * `id-token: write`, which `idTokens` asks chant's generators for.
193
+ */
194
+ export function githubCloudLogin(spec) {
195
+ return actionsLogin("github", spec);
196
+ }
197
+ /**
198
+ * A Forgejo Actions job's cloud login (#4788), as on GitHub. Forgejo 15 with
199
+ * Forgejo Runner 12.5 serves the token to a job with
200
+ * `enable-openid-connect: true`, which the forgejo lexicon sets for a job
201
+ * that asks for `id-token: write`. On an older Forgejo, give each cloud a
202
+ * `tokenFile` the runner provides; the job then requests none.
203
+ */
204
+ export function forgejoCloudLogin(spec) {
205
+ return actionsLogin("forgejo", spec);
206
+ }
207
+ /** The GitLab variable the login's `export` lines are kept in until the script evaluates them. */
208
+ export const GITLAB_LOGIN_VARS = "CHANT_CLOUD_LOGIN_VARS";
209
+ /**
210
+ * A GitLab CI job's cloud login (#4788): script lines that write each
211
+ * cloud's `id_tokens` token to a file, evaluate the clouds' variables, and
212
+ * unset the token variables and the spec, so later lines hold the token
213
+ * only in its file. The job's `id_tokens:` are `idTokens`, each
214
+ * `{ aud: <audience> }`.
215
+ */
216
+ export function gitlabCloudLogin(given) {
217
+ const spec = cloudLoginSpec(given);
218
+ if (Object.keys(spec).length === 0)
219
+ return { steps: [], idTokens: {} };
220
+ const idTokens = loginIdTokens(spec);
221
+ return {
222
+ steps: [
223
+ {
224
+ name: stepName(spec),
225
+ run: [
226
+ `export ${LOGIN_SPEC_ENV}=${sh(JSON.stringify(spec))}`,
227
+ // An assignment's status is its command substitution's, so a failed login stops the script.
228
+ `${GITLAB_LOGIN_VARS}="$${loginLine("-", "sh", "gitlab")}"`,
229
+ `eval "$${GITLAB_LOGIN_VARS}"`,
230
+ `unset ${[GITLAB_LOGIN_VARS, LOGIN_SPEC_ENV, ...Object.keys(idTokens)].join(" ")}`,
231
+ ],
232
+ },
233
+ ],
234
+ idTokens,
235
+ };
236
+ }
237
+ /** A job's cloud login on `forge` (#4788): {@link githubCloudLogin}, {@link gitlabCloudLogin} or {@link forgejoCloudLogin}. */
238
+ export function cloudLogin(forge, spec) {
239
+ return forge === "gitlab" ? gitlabCloudLogin(spec) : actionsLogin(forge, spec);
240
+ }
@@ -32,6 +32,22 @@ export declare const PR_PREVIEW_FLOOR = "0.124.55";
32
32
  export { decideRelayClick, handleRelayRequest, NOTIFY_RELAY_POINTS_FLOOR, relayPrincipalFor, RELAY_ENV, slackRelayClick, slackSignature, startRelayServer, teamsRelayClick, teamsSignature, verifySlackRequest, verifyTeamsRequest, type RelayAnswer, type RelayClick, type RelayDeps, type RelayPending, type RelayRequest, type RelayResponse, type RelaySettings, } from "./notify-relay.js";
33
33
  export { componentWaveOutputsFile, componentWaveSteps, componentWavesSpec, productAgentSpec, productCommand, productDriftAgent, productPipelineJobs, productWavesSpec, productWavesSpecFile, PRODUCT_WAVES_SPEC_DIR, type ComponentWaveStepOptions, type ComponentWaveSteps, type ComponentWavesSpecOptions, type ProductAgentOptions, type ProductPipelineJobs, type ProductPipelineOptions, } from "./components/product-pipeline.js";
34
34
  export { prActionJob, PR_ACTION_JOB, prApplyComment, prCommentLockJobs, prCommentPreviewJob, prLoopSetup, engineSetupLines, withProductBin, type PrActionJob, type PrActionJobOptions, type PrCommentLockJob, type PrCommentPreviewJob } from "./components/pr-pipeline.js";
35
+ /**
36
+ * The product plan (#4799): `productPipelineJobs(forge, env, { words,
37
+ * productPlan })` runs the product's plan verb in place of `pr-plan`, one
38
+ * plan job and one plan-note job per target, each with only its target's
39
+ * variables and secrets and an optional write probe, and `pr-post` posts the
40
+ * plan note hand-off the verb wrote (`planNoteHandoff`, `PR_PLAN_NOTE_FILE`
41
+ * in `@intentius/chant/pr-plan-note`). The forge lexicons render the
42
+ * workflow in process with no component graph: `generateProductPlanPipeline`
43
+ * (github), `generateForgejoProductPlanPipeline` (forgejo) and
44
+ * `generateGitlabProductPlanPipeline` (gitlab), each under
45
+ * `components/product-plan-pipeline`. A product feature-detects on this
46
+ * floor.
47
+ */
48
+ export declare const PRODUCT_PLAN_FLOOR = "0.124.86";
49
+ export { productPlanJobs, PR_PLAN_NOTE_WORDS_ENV, type ProductPlanJob, type ProductPlanOptions, type ProductPlanTarget } from "./components/product-plan.js";
50
+ export { planNoteHandoff, PR_PLAN_NOTE_FILE, type PrPlanNoteHandoff } from "./pr-plan-note.js";
35
51
  /**
36
52
  * Day-2 actions in the product pipeline (#4654): the `action` comment
37
53
  * command counted as answered by the product's own workflow
@@ -1 +1 @@
1
- {"version":3,"file":"ci-product.d.ts","sourceRoot":"","sources":["../src/ci-product.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAE3C,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAErK,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,aAA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AAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhI;;;;;;GAMG;AACH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,KAAK,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AACtK,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAE1F;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,aAAsB,CAAC;AAC1D,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEjF;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC5H,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EACL,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,YAAY,GAClB,MAAM,QAAQ,CAAC"}
@@ -9,6 +9,7 @@
9
9
  * and `assertProductWords` present means the rest is too.
10
10
  */
11
11
  import { OTLP_EXPORTER_FLOOR } from "./otlp.js";
12
+ import { NEXT_RELEASE } from "./release-floors.js";
12
13
  /**
13
14
  * The first chant with the product pipeline (#4550): the words, the
14
15
  * `pull-request` op-wave approval source, `runCommandInProcess(argv, {
@@ -30,6 +31,22 @@ export const PR_PREVIEW_FLOOR = "0.124.55";
30
31
  export { decideRelayClick, handleRelayRequest, NOTIFY_RELAY_POINTS_FLOOR, relayPrincipalFor, RELAY_ENV, slackRelayClick, slackSignature, startRelayServer, teamsRelayClick, teamsSignature, verifySlackRequest, verifyTeamsRequest, } from "./notify-relay.js";
31
32
  export { componentWaveOutputsFile, componentWaveSteps, componentWavesSpec, productAgentSpec, productCommand, productDriftAgent, productPipelineJobs, productWavesSpec, productWavesSpecFile, PRODUCT_WAVES_SPEC_DIR, } from "./components/product-pipeline.js";
32
33
  export { prActionJob, PR_ACTION_JOB, prApplyComment, prCommentLockJobs, prCommentPreviewJob, prLoopSetup, engineSetupLines, withProductBin } from "./components/pr-pipeline.js";
34
+ /**
35
+ * The product plan (#4799): `productPipelineJobs(forge, env, { words,
36
+ * productPlan })` runs the product's plan verb in place of `pr-plan`, one
37
+ * plan job and one plan-note job per target, each with only its target's
38
+ * variables and secrets and an optional write probe, and `pr-post` posts the
39
+ * plan note hand-off the verb wrote (`planNoteHandoff`, `PR_PLAN_NOTE_FILE`
40
+ * in `@intentius/chant/pr-plan-note`). The forge lexicons render the
41
+ * workflow in process with no component graph: `generateProductPlanPipeline`
42
+ * (github), `generateForgejoProductPlanPipeline` (forgejo) and
43
+ * `generateGitlabProductPlanPipeline` (gitlab), each under
44
+ * `components/product-plan-pipeline`. A product feature-detects on this
45
+ * floor.
46
+ */
47
+ export const PRODUCT_PLAN_FLOOR = NEXT_RELEASE;
48
+ export { productPlanJobs, PR_PLAN_NOTE_WORDS_ENV } from "./components/product-plan.js";
49
+ export { planNoteHandoff, PR_PLAN_NOTE_FILE } from "./pr-plan-note.js";
33
50
  /**
34
51
  * Day-2 actions in the product pipeline (#4654): the `action` comment
35
52
  * command counted as answered by the product's own workflow
@@ -86,7 +86,7 @@ export function indexImportReportJson(report) {
86
86
  async function projectEntities(projectDir, src, plugins) {
87
87
  const entities = new Map();
88
88
  try {
89
- const { loadChantConfigUpward } = await import("../../config.js");
89
+ const { loadChantConfigUpward, resolveSourceDir } = await import("../../config.js");
90
90
  const { config, configPath } = await loadChantConfigUpward(projectDir);
91
91
  if (!configPath)
92
92
  return { entities };
@@ -95,7 +95,7 @@ async function projectEntities(projectDir, src, plugins) {
95
95
  return { entities };
96
96
  const { build } = await import("../../build.js");
97
97
  const { isObservableDeclarable } = await import("../../declarable.js");
98
- const root = src ? resolve(src) : resolve(dirname(configPath), config.sourceDir ?? ".");
98
+ const root = resolveSourceDir(dirname(configPath), config, src ? resolve(src) : undefined);
99
99
  const result = await build(root, projectPlugins.map((p) => p.serializer), undefined, { config: config });
100
100
  if (result.errors.length > 0) {
101
101
  return { entities, warning: `the project at ${root} does not build, so no indexed resource was checked against its declarations` };
@@ -6,5 +6,13 @@ import type { CommandContext } from "../registry.js";
6
6
  * it, so a build never writes a job that fails on its own line.
7
7
  */
8
8
  export declare function prLoopFlagsProblem(args: Pick<CommandContext["args"], "prLoop" | "applyBeforeMerge" | "merge" | "mergeTokenEnv" | "mergeMethod" | "respond" | "decideBackend" | "decideModel" | "targetDependents"> & Partial<Pick<CommandContext["args"], "controlRepo" | "controlSettings">>): string | undefined;
9
+ /**
10
+ * The directory `chant build` builds (#4794). A path argument wins. With
11
+ * none, at the root of a project, it is the one source-dir rule's
12
+ * (`resolveSourceDir`): the config's `sourceDir`, else the root. Below the
13
+ * root it is the directory the command runs in, as it always was. Kept
14
+ * relative, so the paths the build prints read as before.
15
+ */
16
+ export declare function buildPathOf(args: Pick<CommandContext["args"], "path" | "pathGiven">): Promise<string>;
9
17
  export declare function runBuild(ctx: CommandContext): Promise<number>;
10
18
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAyGlD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,kBAAkB,GAAG,OAAO,GAAG,eAAe,GAAG,aAAa,GAAG,SAAS,GAAG,eAAe,GAAG,aAAa,GAAG,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,iBAAiB,CAAC,CAAC,GAAG,MAAM,GAAG,SAAS,CAgClT;AAsTD,wBAAsB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsJnE"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAyGlD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,kBAAkB,GAAG,OAAO,GAAG,eAAe,GAAG,aAAa,GAAG,SAAS,GAAG,eAAe,GAAG,aAAa,GAAG,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,iBAAiB,CAAC,CAAC,GAAG,MAAM,GAAG,SAAS,CAgClT;AAsTD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAM3G;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAwJnE"}
@@ -1,10 +1,10 @@
1
1
  import { writeFileSync, mkdirSync } from "node:fs";
2
- import { dirname, resolve } from "node:path";
2
+ import { dirname, join, relative, resolve } from "node:path";
3
3
  import { buildCommand, buildCommandWatch, printErrors, printWarnings, resolveBuildFormat } from "../commands/build.js";
4
4
  import { formatError, formatInfo, formatSuccess, formatBold } from "../format.js";
5
5
  import { reportUninstalledDependencies } from "../dependencies.js";
6
6
  import { generateComponentsPipeline } from "../../components/cli-support.js";
7
- import { loadChantConfigUpward } from "../../config.js";
7
+ import { loadChantConfigUpward, resolveSourceDir } from "../../config.js";
8
8
  import { resolveCliBuildParams, parseParamFlags } from "../build-params-cli.js";
9
9
  import { findWorkspaceRoot } from "../../project-root.js";
10
10
  import { resolvePromotionSource } from "../../components/promote-order.js";
@@ -451,15 +451,33 @@ async function runGenerateComponents(ctx) {
451
451
  }
452
452
  return 0;
453
453
  }
454
+ /**
455
+ * The directory `chant build` builds (#4794). A path argument wins. With
456
+ * none, at the root of a project, it is the one source-dir rule's
457
+ * (`resolveSourceDir`): the config's `sourceDir`, else the root. Below the
458
+ * root it is the directory the command runs in, as it always was. Kept
459
+ * relative, so the paths the build prints read as before.
460
+ */
461
+ export async function buildPathOf(args) {
462
+ if (args.pathGiven)
463
+ return args.path;
464
+ const here = resolve(args.path);
465
+ const loaded = await loadChantConfigUpward(here).catch(() => undefined);
466
+ if (!loaded?.configPath || resolve(dirname(loaded.configPath)) !== here || loaded.config.sourceDir === undefined)
467
+ return args.path;
468
+ return join(args.path, relative(here, resolveSourceDir(here, loaded.config)));
469
+ }
454
470
  export async function runBuild(ctx) {
455
- const { args, plugins } = ctx;
471
+ const { plugins } = ctx;
456
472
  let { serializers } = ctx;
457
473
  // Generate mode (#563): synthesize CI YAML from components instead of
458
474
  // running a normal lexicon build. Checked first since it does not need
459
475
  // `serializers`/lexicon resources at all.
460
- if (args.components && args.generate) {
476
+ if (ctx.args.components && ctx.args.generate) {
461
477
  return runGenerateComponents(ctx);
462
478
  }
479
+ // #4794: the lexicon build reads the config's sourceDir when no path is given.
480
+ const args = { ...ctx.args, path: await buildPathOf(ctx.args) };
463
481
  // Filter to a single lexicon when --lexicon is specified
464
482
  if (args.lexicon) {
465
483
  serializers = serializers.filter((s) => s.name === args.lexicon);
@@ -1 +1 @@
1
- {"version":3,"file":"ci-check.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/ci-check.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAsBlD,wBAAsB,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBrE"}
1
+ {"version":3,"file":"ci-check.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/ci-check.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA2DlD,wBAAsB,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BrE"}