@sanity/ailf 0.1.32 → 0.1.33

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.
@@ -101,6 +101,13 @@ export async function buildRemoteRequest(options) {
101
101
  raw.discoveryReport = true;
102
102
  if (config.noRemoteCache)
103
103
  raw.noRemoteCache = true;
104
+ // Caller git metadata — auto-detect from CI environment variables.
105
+ // When running via `ailf pipeline --remote` in a GitHub Actions workflow,
106
+ // the GITHUB_* env vars identify the *calling* repo (not the AILF core
107
+ // repo). This ensures report provenance attributes to the right repo.
108
+ const callerGit = detectCallerGit();
109
+ if (callerGit)
110
+ raw.callerGit = callerGit;
104
111
  // 4. Validate the assembled request
105
112
  const parsed = PipelineRequestSchema.parse(raw);
106
113
  return { request: parsed, taskCount: tasks.length };
@@ -180,3 +187,32 @@ function buildFilterOptions(config) {
180
187
  return undefined;
181
188
  return { areas, taskIds, tags };
182
189
  }
190
+ /**
191
+ * Auto-detect caller git metadata from GitHub Actions environment variables.
192
+ *
193
+ * When the CLI runs in a calling repo's CI (via `npx @sanity/ailf pipeline
194
+ * --remote`), the GITHUB_* env vars reflect that repo — not the AILF core
195
+ * repo. We capture them here so the API can carry them through to report
196
+ * provenance.
197
+ *
198
+ * Returns undefined when not running in GitHub Actions.
199
+ */
200
+ function detectCallerGit() {
201
+ const repo = process.env.GITHUB_REPOSITORY;
202
+ if (!repo)
203
+ return undefined;
204
+ const sha = process.env.GITHUB_SHA;
205
+ const ref = process.env.GITHUB_REF ?? "";
206
+ // For PRs, GITHUB_HEAD_REF is the source branch name (e.g., "fix/docs").
207
+ // For pushes, GITHUB_REF_NAME is the branch (e.g., "main").
208
+ const branch = process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME;
209
+ // Extract PR number from GITHUB_REF (refs/pull/123/merge)
210
+ const prMatch = ref.match(/^refs\/pull\/(\d+)\//);
211
+ const prNumber = prMatch ? parseInt(prMatch[1], 10) : undefined;
212
+ return {
213
+ repo,
214
+ ...(sha ? { sha } : {}),
215
+ ...(branch ? { branch } : {}),
216
+ ...(prNumber ? { prNumber } : {}),
217
+ };
218
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ailf",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "restricted"