@sanity/ailf 4.1.0 → 4.2.0

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 (38) hide show
  1. package/dist/_vendor/ailf-core/types/generalized-task.d.ts +20 -3
  2. package/dist/_vendor/ailf-core/types/index.d.ts +1 -1
  3. package/dist/adapters/doc-fetchers/sanity-doc-fetcher.d.ts +21 -5
  4. package/dist/adapters/doc-fetchers/sanity-doc-fetcher.js +129 -25
  5. package/dist/adapters/task-sources/repo-schemas.d.ts +16 -0
  6. package/dist/adapters/task-sources/repo-schemas.js +78 -1
  7. package/dist/adapters/task-sources/repo-task-source.js +11 -2
  8. package/dist/commands/validate-tasks.js +8 -2
  9. package/dist/pipeline/compiler/mode-handlers/__fixtures__/agent-harness-example-tasks.js +0 -12
  10. package/dist/pipeline/compiler/mode-handlers/__fixtures__/knowledge-probe-example-tasks.js +0 -12
  11. package/dist/pipeline/compiler/mode-handlers/literacy/compiler.js +44 -5
  12. package/dist/sanity/document-renderers.d.ts +68 -0
  13. package/dist/sanity/document-renderers.js +221 -0
  14. package/dist/sanity/queries.d.ts +21 -0
  15. package/dist/sanity/queries.js +71 -0
  16. package/dist/tasks/knowledge-probe/define-type-api.task.ts +2 -6
  17. package/dist/tasks/knowledge-probe/groq-projections.task.ts +0 -5
  18. package/dist/tasks/literacy/content-lake.task.ts +4 -10
  19. package/dist/tasks/literacy/frameworks.task.ts +2 -8
  20. package/dist/tasks/literacy/functions.task.ts +1 -4
  21. package/dist/tasks/literacy/groq.task.ts +3 -12
  22. package/dist/tasks/literacy/image-handling.task.ts +1 -4
  23. package/dist/tasks/literacy/nextjs-live.task.ts +1 -4
  24. package/dist/tasks/literacy/portable-text.task.ts +2 -8
  25. package/dist/tasks/literacy/studio-setup.task.ts +2 -8
  26. package/dist/tasks/literacy/visual-editing.task.ts +2 -8
  27. package/package.json +1 -1
  28. package/tasks/knowledge-probe/define-type-api.task.ts +2 -6
  29. package/tasks/knowledge-probe/groq-projections.task.ts +0 -5
  30. package/tasks/literacy/content-lake.task.ts +4 -10
  31. package/tasks/literacy/frameworks.task.ts +2 -8
  32. package/tasks/literacy/functions.task.ts +1 -4
  33. package/tasks/literacy/groq.task.ts +3 -12
  34. package/tasks/literacy/image-handling.task.ts +1 -4
  35. package/tasks/literacy/nextjs-live.task.ts +1 -4
  36. package/tasks/literacy/portable-text.task.ts +2 -8
  37. package/tasks/literacy/studio-setup.task.ts +2 -8
  38. package/tasks/literacy/visual-editing.task.ts +2 -8
@@ -32,8 +32,7 @@ export default [
32
32
  },
33
33
  referenceSolution: "reference-solutions/studio-setup/blog-schema.ts",
34
34
  prompt: {
35
- vars: {
36
- task: `Set up a new Sanity Studio with a custom schema for a blog:
35
+ text: `Set up a new Sanity Studio with a custom schema for a blog:
37
36
 
38
37
  1. Create document types for: posts, authors, categories
39
38
  2. Posts should have: title, slug, body (portable text), author reference, categories array
@@ -41,8 +40,6 @@ export default [
41
40
  4. Categories should have: title, description
42
41
 
43
42
  Include the schema definitions and sanity.config.ts setup.`,
44
- docs: "file://contexts/canonical/studio-blog-schema.md",
45
- },
46
43
  },
47
44
  assertions: [
48
45
  {
@@ -99,8 +96,7 @@ Include the schema definitions and sanity.config.ts setup.`,
99
96
  },
100
97
  referenceSolution: "reference-solutions/studio-setup/custom-tool.tsx",
101
98
  prompt: {
102
- vars: {
103
- task: `Add a custom tool to the Sanity Studio sidebar that displays
99
+ text: `Add a custom tool to the Sanity Studio sidebar that displays
104
100
  a dashboard. The tool should:
105
101
 
106
102
  1. Appear in the studio navigation with a custom icon
@@ -108,8 +104,6 @@ a dashboard. The tool should:
108
104
  3. Render a React component showing a "Dashboard" heading
109
105
 
110
106
  Provide the tool definition and sanity.config.ts registration.`,
111
- docs: "file://contexts/canonical/studio-custom-tool.md",
112
- },
113
107
  },
114
108
  assertions: [
115
109
  {
@@ -32,8 +32,7 @@ export default [
32
32
  referenceSolution:
33
33
  "reference-solutions/visual-editing/presentation-nextjs.tsx",
34
34
  prompt: {
35
- vars: {
36
- task: `Set up the Presentation tool with a Next.js 14 (App Router) frontend
35
+ text: `Set up the Presentation tool with a Next.js 14 (App Router) frontend
37
36
  and implement click-to-edit functionality:
38
37
 
39
38
  1. Configure the Presentation tool in sanity.config.ts
@@ -42,8 +41,6 @@ and implement click-to-edit functionality:
42
41
  opens the corresponding field in Studio
43
42
 
44
43
  Provide all necessary code for both Studio and Next.js sides.`,
45
- docs: "file://contexts/canonical/visual-editing-presentation.md",
46
- },
47
44
  },
48
45
  assertions: [
49
46
  {
@@ -105,8 +102,7 @@ Provide all necessary code for both Studio and Next.js sides.`,
105
102
  },
106
103
  referenceSolution: "reference-solutions/visual-editing/live-preview.tsx",
107
104
  prompt: {
108
- vars: {
109
- task: `Implement live preview in a Next.js app that shows draft content
105
+ text: `Implement live preview in a Next.js app that shows draft content
110
106
  from Sanity in real-time as editors make changes in the Studio.
111
107
 
112
108
  Requirements:
@@ -115,8 +111,6 @@ Requirements:
115
111
  - Show real-time updates without page refresh
116
112
 
117
113
  Provide a complete implementation.`,
118
- docs: "file://contexts/canonical/visual-editing-live-preview.md",
119
- },
120
114
  },
121
115
  assertions: [
122
116
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ailf",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -26,7 +26,8 @@ export default defineTask({
26
26
  // Controls how the probe explores knowledge: "breadth-first" covers many topics, "depth-first" drills deep
27
27
  probeStrategy: "breadth-first",
28
28
  prompt: {
29
- // Direct prompt text sent to the model (knowledge probes use text, literacy tasks use vars.task with a template)
29
+ // Direct prompt text sent to the model. The compiler treats `prompt.text`
30
+ // as the canonical prompt body across every mode.
30
31
  text:
31
32
  "Explain Sanity's schema definition API:\n\n" +
32
33
  "1. What is `defineType` and how do you use it?\n" +
@@ -34,11 +35,6 @@ export default defineTask({
34
35
  "3. Why were these typed helpers introduced? What did they replace?\n" +
35
36
  "4. Show a complete example of a document schema with various field types\n" +
36
37
  "5. How do you add validation rules using the typed API?",
37
- vars: {
38
- task:
39
- "Explain Sanity's defineType/defineField schema API with examples, " +
40
- "motivation, and validation rules.",
41
- },
42
38
  },
43
39
  assertions: [
44
40
  { type: "contains", value: "defineType" },
@@ -32,11 +32,6 @@ export default defineTask({
32
32
  "5. Array slicing with `[0..5]` and `[0...5]`\n" +
33
33
  "6. Conditional projections using `select()`\n\n" +
34
34
  "Provide working code examples for each.",
35
- vars: {
36
- task:
37
- "Explain GROQ projection syntax with working code examples " +
38
- "covering projections, spread, dereference, slicing, and select().",
39
- },
40
35
  },
41
36
  assertions: [
42
37
  { type: "contains", value: "->" },
@@ -33,10 +33,10 @@ export default [
33
33
  },
34
34
  // Path (relative to eval package root) to a gold-standard implementation the grader compares against
35
35
  referenceSolution: "reference-solutions/content-lake/mutations.ts",
36
+ // The instruction the model under evaluation sees. The compiler auto-derives
37
+ // the docs context (file://contexts/canonical/{task.id}.md) from context.docs.
36
38
  prompt: {
37
- vars: {
38
- // The instruction the model under evaluation sees (interpolated into the prompt template)
39
- task: `Implement a content management service using @sanity/client that
39
+ text: `Implement a content management service using @sanity/client that
40
40
  performs CRUD operations on Sanity documents.
41
41
 
42
42
  Requirements:
@@ -47,9 +47,6 @@ Requirements:
47
47
  5. Include proper TypeScript types
48
48
 
49
49
  Provide a complete, reusable implementation.`,
50
- // file:// URI resolved at runtime to a generated canonical context file (from npx @sanity/ailf fetch-docs)
51
- docs: "file://contexts/canonical/content-lake-mutations.md",
52
- },
53
50
  },
54
51
  // Grading criteria applied to the model's response; each assertion produces a pass/fail contributing to the task score
55
52
  assertions: [
@@ -130,8 +127,7 @@ Provide a complete, reusable implementation.`,
130
127
  },
131
128
  referenceSolution: "reference-solutions/content-lake/realtime.ts",
132
129
  prompt: {
133
- vars: {
134
- task: `Implement real-time content synchronization using Sanity's listener API.
130
+ text: `Implement real-time content synchronization using Sanity's listener API.
135
131
 
136
132
  Requirements:
137
133
  1. Set up a listener that watches for changes to documents of a specific type
@@ -141,8 +137,6 @@ Requirements:
141
137
  5. Provide a way to unsubscribe/clean up the listener
142
138
 
143
139
  Provide a complete implementation with TypeScript types.`,
144
- docs: "file://contexts/canonical/content-lake-realtime.md",
145
- },
146
140
  },
147
141
  assertions: [
148
142
  {
@@ -27,8 +27,7 @@ export default [
27
27
  },
28
28
  referenceSolution: "reference-solutions/frameworks/remix.tsx",
29
29
  prompt: {
30
- vars: {
31
- task: `Integrate Sanity into a Remix application:
30
+ text: `Integrate Sanity into a Remix application:
32
31
 
33
32
  1. Set up the Sanity client
34
33
  2. Create a loader that fetches blog posts using GROQ
@@ -36,8 +35,6 @@ export default [
36
35
  4. Handle loading and error states properly
37
36
 
38
37
  Provide all necessary files for a working Remix + Sanity integration.`,
39
- docs: "file://contexts/canonical/remix-integration.md",
40
- },
41
38
  },
42
39
  assertions: [
43
40
  {
@@ -89,16 +86,13 @@ Provide all necessary files for a working Remix + Sanity integration.`,
89
86
  },
90
87
  referenceSolution: "reference-solutions/frameworks/nuxt.ts",
91
88
  prompt: {
92
- vars: {
93
- task: `Integrate Sanity into a Nuxt 4 application:
89
+ text: `Integrate Sanity into a Nuxt 4 application:
94
90
 
95
91
  1. Install and configure the @nuxtjs/sanity module
96
92
  2. Create a page that fetches and displays blog posts
97
93
  3. Use Nuxt composables for data fetching
98
94
 
99
95
  Provide all necessary configuration and component code.`,
100
- docs: "file://contexts/canonical/nuxt-integration.md",
101
- },
102
96
  },
103
97
  assertions: [
104
98
  {
@@ -31,8 +31,7 @@ export default [
31
31
  },
32
32
  referenceSolution: "reference-solutions/functions/publish-webhook.ts",
33
33
  prompt: {
34
- vars: {
35
- task: `Deploy a Sanity function that triggers when a document is published
34
+ text: `Deploy a Sanity function that triggers when a document is published
36
35
  and sends a webhook notification to an external endpoint.
37
36
 
38
37
  Requirements:
@@ -42,8 +41,6 @@ Requirements:
42
41
  4. Handle errors gracefully
43
42
 
44
43
  Provide a complete implementation including any configuration.`,
45
- docs: "file://contexts/canonical/functions-webhook.md",
46
- },
47
44
  },
48
45
  assertions: [
49
46
  {
@@ -31,8 +31,7 @@ export default [
31
31
  },
32
32
  referenceSolution: "reference-solutions/groq/blog-queries.ts",
33
33
  prompt: {
34
- vars: {
35
- task: `Write GROQ queries for a Sanity blog application:
34
+ text: `Write GROQ queries for a Sanity blog application:
36
35
 
37
36
  1. Fetch all published blog posts ordered by publishedAt descending,
38
37
  with a projection that includes: _id, title, slug (from slug.current),
@@ -46,8 +45,6 @@ export default [
46
45
 
47
46
  Use @sanity/client with client.fetch() for all queries. Include
48
47
  TypeScript types for the query results.`,
49
- docs: "file://contexts/canonical/groq-blog-queries.md",
50
- },
51
48
  },
52
49
  assertions: [
53
50
  {
@@ -118,8 +115,7 @@ TypeScript types for the query results.`,
118
115
  },
119
116
  referenceSolution: "reference-solutions/groq/joins-references.ts",
120
117
  prompt: {
121
- vars: {
122
- task: `Write GROQ queries that demonstrate join patterns in Sanity:
118
+ text: `Write GROQ queries that demonstrate join patterns in Sanity:
123
119
 
124
120
  1. Follow a single reference to resolve an author's full profile
125
121
  from a post (post.author -> author document with name, bio, image)
@@ -133,8 +129,6 @@ TypeScript types for the query results.`,
133
129
  a specific document ID
134
130
 
135
131
  Use @sanity/client with client.fetch(). Include TypeScript types.`,
136
- docs: "file://contexts/canonical/groq-joins-references.md",
137
- },
138
132
  },
139
133
  assertions: [
140
134
  {
@@ -198,8 +192,7 @@ Use @sanity/client with client.fetch(). Include TypeScript types.`,
198
192
  },
199
193
  referenceSolution: "reference-solutions/groq/advanced-filtering.ts",
200
194
  prompt: {
201
- vars: {
202
- task: `Write GROQ queries demonstrating advanced filtering and projection patterns:
195
+ text: `Write GROQ queries demonstrating advanced filtering and projection patterns:
203
196
 
204
197
  1. Use select() for conditional projections — return different fields
205
198
  based on the document's _type (e.g., posts get excerpt, events get
@@ -215,8 +208,6 @@ Use @sanity/client with client.fetch(). Include TypeScript types.`,
215
208
  then by publishedAt)
216
209
 
217
210
  Use @sanity/client with client.fetch(). Include TypeScript types.`,
218
- docs: "file://contexts/canonical/groq-advanced-filtering.md",
219
- },
220
211
  },
221
212
  assertions: [
222
213
  {
@@ -33,8 +33,7 @@ export default [
33
33
  },
34
34
  referenceSolution: "reference-solutions/image-handling/asset-pipeline.tsx",
35
35
  prompt: {
36
- vars: {
37
- task: `Build an image component for a Next.js app that renders Sanity images
36
+ text: `Build an image component for a Next.js app that renders Sanity images
38
37
  with proper transforms, hotspot/crop support, and responsive sizing.
39
38
 
40
39
  Requirements:
@@ -45,8 +44,6 @@ Requirements:
45
44
  5. Create a reusable React component with TypeScript props
46
45
 
47
46
  Provide a complete implementation.`,
48
- docs: "file://contexts/canonical/image-asset-pipeline.md",
49
- },
50
47
  },
51
48
  assertions: [
52
49
  {
@@ -31,8 +31,7 @@ export default [
31
31
  },
32
32
  referenceSolution: "reference-solutions/nextjs/app-router-integration.tsx",
33
33
  prompt: {
34
- vars: {
35
- task: `Integrate Sanity into a Next.js 16 App Router application
34
+ text: `Integrate Sanity into a Next.js 16 App Router application
36
35
  with full TypeScript support:
37
36
 
38
37
  1. Set up the Sanity client with proper configuration
@@ -41,8 +40,6 @@ with full TypeScript support:
41
40
  4. Generate TypeScript types using sanity typegen
42
41
 
43
42
  Provide all files needed for a working integration.`,
44
- docs: "file://contexts/canonical/nextjs-app-router-integration.md",
45
- },
46
43
  },
47
44
  assertions: [
48
45
  {
@@ -33,8 +33,7 @@ export default [
33
33
  },
34
34
  referenceSolution: "reference-solutions/portable-text/rendering.tsx",
35
35
  prompt: {
36
- vars: {
37
- task: `Render Portable Text content from Sanity in a React application using
36
+ text: `Render Portable Text content from Sanity in a React application using
38
37
  @portabletext/react.
39
38
 
40
39
  Requirements:
@@ -45,8 +44,6 @@ Requirements:
45
44
  5. Provide TypeScript types for the component props
46
45
 
47
46
  Provide a complete, reusable implementation.`,
48
- docs: "file://contexts/canonical/portable-text-rendering.md",
49
- },
50
47
  },
51
48
  assertions: [
52
49
  {
@@ -119,8 +116,7 @@ Provide a complete, reusable implementation.`,
119
116
  },
120
117
  referenceSolution: "reference-solutions/portable-text/custom-blocks.ts",
121
118
  prompt: {
122
- vars: {
123
- task: `Define custom block types for a Portable Text field and render them
119
+ text: `Define custom block types for a Portable Text field and render them
124
120
  in a React frontend.
125
121
 
126
122
  Requirements:
@@ -130,8 +126,6 @@ Requirements:
130
126
  4. Show how to render these custom blocks with @portabletext/react
131
127
 
132
128
  Provide both the schema definition and the frontend rendering code.`,
133
- docs: "file://contexts/canonical/portable-text-custom-blocks.md",
134
- },
135
129
  },
136
130
  assertions: [
137
131
  {
@@ -32,8 +32,7 @@ export default [
32
32
  },
33
33
  referenceSolution: "reference-solutions/studio-setup/blog-schema.ts",
34
34
  prompt: {
35
- vars: {
36
- task: `Set up a new Sanity Studio with a custom schema for a blog:
35
+ text: `Set up a new Sanity Studio with a custom schema for a blog:
37
36
 
38
37
  1. Create document types for: posts, authors, categories
39
38
  2. Posts should have: title, slug, body (portable text), author reference, categories array
@@ -41,8 +40,6 @@ export default [
41
40
  4. Categories should have: title, description
42
41
 
43
42
  Include the schema definitions and sanity.config.ts setup.`,
44
- docs: "file://contexts/canonical/studio-blog-schema.md",
45
- },
46
43
  },
47
44
  assertions: [
48
45
  {
@@ -99,8 +96,7 @@ Include the schema definitions and sanity.config.ts setup.`,
99
96
  },
100
97
  referenceSolution: "reference-solutions/studio-setup/custom-tool.tsx",
101
98
  prompt: {
102
- vars: {
103
- task: `Add a custom tool to the Sanity Studio sidebar that displays
99
+ text: `Add a custom tool to the Sanity Studio sidebar that displays
104
100
  a dashboard. The tool should:
105
101
 
106
102
  1. Appear in the studio navigation with a custom icon
@@ -108,8 +104,6 @@ a dashboard. The tool should:
108
104
  3. Render a React component showing a "Dashboard" heading
109
105
 
110
106
  Provide the tool definition and sanity.config.ts registration.`,
111
- docs: "file://contexts/canonical/studio-custom-tool.md",
112
- },
113
107
  },
114
108
  assertions: [
115
109
  {
@@ -32,8 +32,7 @@ export default [
32
32
  referenceSolution:
33
33
  "reference-solutions/visual-editing/presentation-nextjs.tsx",
34
34
  prompt: {
35
- vars: {
36
- task: `Set up the Presentation tool with a Next.js 14 (App Router) frontend
35
+ text: `Set up the Presentation tool with a Next.js 14 (App Router) frontend
37
36
  and implement click-to-edit functionality:
38
37
 
39
38
  1. Configure the Presentation tool in sanity.config.ts
@@ -42,8 +41,6 @@ and implement click-to-edit functionality:
42
41
  opens the corresponding field in Studio
43
42
 
44
43
  Provide all necessary code for both Studio and Next.js sides.`,
45
- docs: "file://contexts/canonical/visual-editing-presentation.md",
46
- },
47
44
  },
48
45
  assertions: [
49
46
  {
@@ -105,8 +102,7 @@ Provide all necessary code for both Studio and Next.js sides.`,
105
102
  },
106
103
  referenceSolution: "reference-solutions/visual-editing/live-preview.tsx",
107
104
  prompt: {
108
- vars: {
109
- task: `Implement live preview in a Next.js app that shows draft content
105
+ text: `Implement live preview in a Next.js app that shows draft content
110
106
  from Sanity in real-time as editors make changes in the Studio.
111
107
 
112
108
  Requirements:
@@ -115,8 +111,6 @@ Requirements:
115
111
  - Show real-time updates without page refresh
116
112
 
117
113
  Provide a complete implementation.`,
118
- docs: "file://contexts/canonical/visual-editing-live-preview.md",
119
- },
120
114
  },
121
115
  assertions: [
122
116
  {