@sanity/ailf 0.1.11 → 0.1.13

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.
@@ -92,7 +92,7 @@ export interface ResolvedConfig {
92
92
  /** Before option for comparison */
93
93
  beforeOption?: string;
94
94
  /** Task source adapter selection */
95
- taskSourceType?: "content-lake" | "yaml";
95
+ taskSourceType?: "content-lake" | "repo" | "yaml";
96
96
  /** Path to repo-based tasks directory (e.g., .ailf/tasks/) */
97
97
  repoTasksPath?: string;
98
98
  /** Report store project ID from .ailf/config.yaml reportStore block */
@@ -53,7 +53,7 @@ export interface ResolvedOptions {
53
53
  remote: boolean;
54
54
  repoTasksPath?: string;
55
55
  taskOption?: string;
56
- taskSourceType?: "content-lake" | "yaml";
56
+ taskSourceType?: "content-lake" | "repo" | "yaml";
57
57
  urlArgs: string[];
58
58
  apiUrl: string;
59
59
  apiKey?: string;
@@ -246,7 +246,9 @@ function resolveTaskSourceType(raw) {
246
246
  return undefined; // default — Content Lake
247
247
  if (raw === "yaml")
248
248
  return "yaml";
249
- console.error(`❌ Invalid --task-source "${raw}". Must be "yaml" or "content-lake".`);
249
+ if (raw === "repo")
250
+ return "repo";
251
+ console.error(`❌ Invalid --task-source "${raw}". Must be "yaml", "repo", or "content-lake".`);
250
252
  process.exit(1);
251
253
  }
252
254
  // ---------------------------------------------------------------------------
@@ -269,18 +271,27 @@ export async function executePipeline(cliOpts) {
269
271
  process.exit(1);
270
272
  }
271
273
  const { FileConfigAdapter } = await import("../adapters/config-sources/file-config-adapter.js");
274
+ const { createAppContext } = await import("../composition-root.js");
275
+ const callerCwd = process.env.AILF_CALLER_CWD ?? process.cwd();
272
276
  const adapter = new FileConfigAdapter(cliOpts.config, ROOT);
273
277
  const config = await adapter.resolve();
274
- const ctx = buildAppContext(
275
- // Build a minimal ResolvedOptions to satisfy the bridge.
276
- // FileConfigAdapter already resolved to ResolvedConfig, so we
277
- // pass it through by constructing AppContext directly.
278
- computeResolvedOptions(cliOpts), ROOT);
279
- // Override config with the file-based config
280
- const fileCtx = { ...ctx, config };
278
+ // Merge CLI-only flags that aren't in the config file.
279
+ // The file config (from the API payload) has taskSourceType and other
280
+ // pipeline options, but CLI-only args like --repo-tasks-path and
281
+ // --output are only available from the command line.
282
+ if (cliOpts.repoTasksPath) {
283
+ config.repoTasksPath = resolve(callerCwd, cliOpts.repoTasksPath);
284
+ }
285
+ if (cliOpts.output) {
286
+ config.outputPath = resolve(callerCwd, cliOpts.output);
287
+ }
288
+ // Create AppContext directly from the merged config so adapters
289
+ // (especially taskSource) are wired from the file config's
290
+ // taskSourceType — not from CLI defaults.
291
+ const ctx = createAppContext(config);
281
292
  const pipelineStart = Date.now();
282
- const steps = buildStepSequence(fileCtx, pipelineStart);
283
- const result = await orchestratePipeline(fileCtx, steps);
293
+ const steps = buildStepSequence(ctx, pipelineStart);
294
+ const result = await orchestratePipeline(ctx, steps);
284
295
  writePipelineResult(result);
285
296
  process.exit(result.success ? 0 : 1);
286
297
  }
@@ -39,7 +39,7 @@ export function createPipelineCommand() {
39
39
  .option("--config <path>", "Load pipeline config from a JSON/YAML file (overrides most CLI flags)")
40
40
  .option("-o, --output <path>", "Write PR comment markdown to file")
41
41
  .option("--promptfoo-url <url>", "Promptfoo share URL for report")
42
- .option("--task-source <type>", "Task definition source: content-lake (default — Sanity Content Lake), yaml (tasks/*.yaml files, legacy)", "content-lake")
42
+ .option("--task-source <type>", "Task definition source: content-lake (default — Sanity Content Lake), repo (repo tasks only, no Content Lake merge), yaml (tasks/*.yaml files, legacy)", "content-lake")
43
43
  .option("--repo-tasks-path <path>", "Path to repo-based task definitions (.ailf/tasks/ directory)")
44
44
  .option("--remote", "Submit evaluation to the AILF API instead of running locally", false)
45
45
  .option("--api-url <url>", "AILF API base URL (default: https://ailf-api.sanity.build)")
@@ -78,6 +78,17 @@ function createCache(config) {
78
78
  return new ContentLakeCacheAdapter(local, createReportStore(config));
79
79
  }
80
80
  function createTaskSource(config) {
81
+ // "repo" mode — use ONLY repo tasks, no Content Lake or YAML merge.
82
+ // This is the correct mode for API-triggered inline-task evaluations
83
+ // where the caller sent their own task definitions. Without this,
84
+ // CompositeTaskSource would merge the caller's tasks with ALL Content
85
+ // Lake tasks, running the entire suite instead of just the caller's.
86
+ if (config.taskSourceType === "repo") {
87
+ if (!config.repoTasksPath) {
88
+ throw new Error('taskSourceType "repo" requires --repo-tasks-path to be set');
89
+ }
90
+ return new RepoTaskSource(config.repoTasksPath);
91
+ }
81
92
  // Primary source — selected by config.taskSourceType
82
93
  // Content Lake tasks may require the report token for access.
83
94
  const primary = config.taskSourceType === "yaml"
@@ -87,7 +98,8 @@ function createTaskSource(config) {
87
98
  process.env.SANITY_API_TOKEN ??
88
99
  undefined,
89
100
  }));
90
- // If repo tasks path is set, combine primary + repo sources
101
+ // If repo tasks path is set, combine primary + repo sources.
102
+ // This is the "augment" mode — repo tasks extend the primary source.
91
103
  if (config.repoTasksPath) {
92
104
  return new CompositeTaskSource([
93
105
  primary,
@@ -77,6 +77,10 @@ function mapDebug(debug) {
77
77
  function mapTaskSourceType(taskMode) {
78
78
  if (taskMode === "content-lake" || taskMode === "yaml")
79
79
  return taskMode;
80
- // "inline" is handled separately by the caller; maps to undefined
80
+ // "inline" means the caller sent inline tasks that will be materialized
81
+ // to a temp directory and loaded via --repo-tasks-path. Use "repo" to
82
+ // ensure ONLY those tasks are used (no Content Lake merge).
83
+ if (taskMode === "inline")
84
+ return "repo";
81
85
  return undefined;
82
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ailf",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "restricted"