expo-syrup-ai-kit 0.3.1 → 0.4.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.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # expo-syrup-ai-kit
2
2
 
3
+ [![npm: expo-syrup-ai-kit](https://img.shields.io/npm/v/expo-syrup-ai-kit?label=expo-syrup-ai-kit)](https://www.npmjs.com/package/expo-syrup-ai-kit)
4
+
3
5
  The Expo plugin for Syrup AI Kit: Siri AI tools for Expo and React Native apps. Formerly `expo-siri-ai-kit`.
4
6
 
5
7
  Make your Expo or React Native app work with Siri AI. This Expo config plugin for [Syrup AI Kit](https://github.com/airowe/syrup-ai-kit) lets the Swift tools in your app use SyrupAIKit, and turns on the Siri AI Developer Preview code (iOS 27.3 beta).
@@ -13,6 +15,7 @@ Not affiliated with or endorsed by Apple.
13
15
  - **Adds SyrupAIKit** as a Swift package and links it to your app target. That's where [`expo-app-intents`](https://docs.expo.dev/versions/latest/sdk/app-intents) compiles the Swift in `app-intents/`, so your tools can `import SyrupAIKit`.
14
16
  - **With the preview on, it also:**
15
17
  - adds the `SIRI_AI_PREVIEW` Swift compilation condition, so `#if SIRI_AI_PREVIEW` code builds only with the 27.3 SDK;
18
+ - lets `xcodebuild` add the `SIRI_AI_EVAL_SWITCHES` condition when you pass `SIRI_AI_EVAL_SWITCHES=YES`, for [negative controls](#negative-controls-in-an-expo-app);
16
19
  - sets the app target's deployment target to iOS 27.3, which `@Property(title:description:)` requires. Pods keep their own targets.
17
20
  - **With `evals` set, adds a UI test target for Siri Evaluations** (see [Evaluation target](#evaluation-target)), so it survives `prebuild --clean`.
18
21
  - **With `skills` set, checks your Apple App Skills and adds them to the app as `Skills.skillsbundle`** (see [App Skills](#app-skills)).
@@ -49,7 +52,7 @@ SIRI_AI_PREVIEW=1 CP_CACHE_DIR="$PWD/.cp-cache" LANG=en_US.UTF-8 npx expo prebui
49
52
  ## Options
50
53
 
51
54
  ```json
52
- ["expo-syrup-ai-kit", { "version": "0.3.1", "preview": true }]
55
+ ["expo-syrup-ai-kit", { "version": "0.4.0", "preview": true }]
53
56
  ```
54
57
 
55
58
  | Option | Default | What it does |
@@ -87,6 +90,29 @@ Use Release so the JavaScript is in the app. A Debug build loads it from the dev
87
90
 
88
91
  Prebuild fails with a clear message if `sourceDir` doesn't exist or has no `.swift` files. The file list is read at prebuild, so prebuild again after adding or removing a test file.
89
92
 
93
+ ### Negative controls in an Expo app
94
+
95
+ A negative control launches the app with an `EvalSwitch` that breaks the tool, and checks that the reply check fails (see the [SyrupAIKit README](https://github.com/airowe/syrup-ai-kit#prove-the-checks-can-fail-and-measure-without-the-apps-name)). The usual `#if DEBUG` guard around the switch doesn't work here: the evaluations run a Release build, which compiles that code out, so the tool never breaks and the control fails.
96
+
97
+ With the preview on, the plugin lets you add a `SIRI_AI_EVAL_SWITCHES` condition to one `xcodebuild` run. Guard the switch with it:
98
+
99
+ ```swift
100
+ #if DEBUG || SIRI_AI_EVAL_SWITCHES
101
+ if EvalSwitch.badHost.isOn() { return URL(string: "https://unreachable.invalid")! }
102
+ #endif
103
+ ```
104
+
105
+ and pass `SIRI_AI_EVAL_SWITCHES=YES` when you run the evaluations:
106
+
107
+ ```bash
108
+ xcodebuild test -workspace ios/MyApp.xcworkspace -scheme MyAppEvals -configuration Release \
109
+ -destination 'platform=iOS,name=My iPhone' -resultBundlePath evals.xcresult SIRI_AI_EVAL_SWITCHES=YES
110
+ ```
111
+
112
+ Only a build given `SIRI_AI_EVAL_SWITCHES=YES` compiles the check. `eas build`, an Xcode archive and any other build leave it out, so no copy of the app a person installs can be broken by a launch argument. Forgetting the setting is safe too: the switch does nothing, and the negative control fails, which tells you.
113
+
114
+ Tools from the [`tools` option](#generating-tools-from-a-declaration-experimental) honour the switch named `bad-host`: with it on, every generated tool calls `https://siri-ai-eval-bad-host.invalid`, which never resolves, and Siri says it couldn't reach the app. Define `static let badHost: EvalSwitch = "bad-host"` in your evaluation tests and use it in `ToolEvaluation.negativeControl(turningOn: .badHost, …)` with the same scenario as the tool's required evaluation.
115
+
90
116
  ## App Skills
91
117
 
92
118
  An App Skill is a short Markdown guide that tells Siri how to use several of your tools together, such as "search, add to the cart, then check out". Keep them in a folder at the project root:
@@ -191,7 +217,7 @@ A tool's optional `returns` says what Siri gets back:
191
217
  - `"dialog"` (the default): Siri says the reply word for word and ends its turn.
192
218
  - `"value"`: Siri gets the reply to use, words the answer itself, and can call another tool first. Use it for tools an [App Skill](#app-skills) names, or any tool Siri should combine with others.
193
219
 
194
- At prebuild the plugin writes one Swift tool per entry, plus a shared `SiriToolsGenerated.swift`, to `ios/<App>/SiriTools/` and compiles that folder into the app target. A bad declaration stops prebuild with every problem listed. The format, what it supports and what's still open are in [docs/spikes/tool-codegen.md](../docs/spikes/tool-codegen.md).
220
+ At prebuild the plugin writes one Swift tool per entry, plus a shared `SiriToolsGenerated.swift`, to `ios/<App>/SiriTools/` and compiles that folder into the app target. A bad declaration stops prebuild with every problem listed. Each generated tool breaks when an evaluation turns on the `bad-host` switch, for a [negative control](#negative-controls-in-an-expo-app). The format, what it supports and what's still open are in [docs/spikes/tool-codegen.md](../docs/spikes/tool-codegen.md).
195
221
 
196
222
  ## Implementing the tools discovery proposes
197
223
 
@@ -203,7 +229,7 @@ The `siri-ai-discover` skill writes each tool's interface to `siri-tools.json`,
203
229
 
204
230
  ## Showing the tool's outcome in your app
205
231
 
206
- Siri Evaluations read the last outcome from the screen. Expose it from your `AppIntentsSetup` inline module, the one `npx expo-app-intents init` created:
232
+ Siri Evaluations read the tool calls from the screen: every call since the evaluation launched the app, oldest first. Expose it from your `AppIntentsSetup` inline module, the one `npx expo-app-intents init` created:
207
233
 
208
234
  ```swift
209
235
  // app-intents/AppIntentsSetup.swift
@@ -216,7 +242,7 @@ final class AppIntentsSetup: Module {
216
242
  Name("AppIntentsSetup")
217
243
 
218
244
  Function("siriToolOutcome") { () -> String in
219
- ToolOutcomeLog.standard.last
245
+ ToolOutcomeLog.standard.summary
220
246
  }
221
247
  }
222
248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-syrup-ai-kit",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Make your Expo or React Native app work with Siri AI: the Expo config plugin for Syrup AI Kit and Apple's Siri AI Developer Preview, with agent skills.",
5
5
  "main": "app.plugin.js",
6
6
  "types": "plugin/build/index.d.ts",
@@ -12,7 +12,7 @@ const withSiriSkills_1 = require("./withSiriSkills");
12
12
  const withSiriTools_1 = require("./withSiriTools");
13
13
  const pkg = require('../../package.json');
14
14
  /** The SyrupAIKit release this plugin version was tested with. */
15
- const DEFAULT_VERSION = '0.3.1';
15
+ const DEFAULT_VERSION = '0.4.0';
16
16
  function requirementFrom(props) {
17
17
  if (props.version && props.branch) {
18
18
  throw new Error('expo-syrup-ai-kit: pass either `version` or `branch`, not both');
@@ -103,6 +103,14 @@ import SyrupAIKit
103
103
  enum SiriToolsGenerated {
104
104
  static let tool = SiriTool(appName: ${swiftString(appName)})
105
105
 
106
+ #if DEBUG || SIRI_AI_EVAL_SWITCHES
107
+ /// An evaluation's negative control turns this on at launch: every generated tool then calls a host that never
108
+ /// resolves, so Siri must say it couldn't reach the app. Builds without either condition, such as an App Store
109
+ /// archive, don't read it.
110
+ static let badHost: EvalSwitch = "bad-host"
111
+ static let unreachableURL = URL(string: "https://siri-ai-eval-bad-host.invalid")!
112
+ #endif
113
+
106
114
  /// A parameter value as Siri filled it in.
107
115
  enum Value: Sendable {
108
116
  case string(String)
@@ -156,6 +164,9 @@ enum SiriToolsGenerated {
156
164
  }
157
165
 
158
166
  func resolvedURL() throws -> URL {
167
+ #if DEBUG || SIRI_AI_EVAL_SWITCHES
168
+ if SiriToolsGenerated.badHost.isOn() { return SiriToolsGenerated.unreachableURL }
169
+ #endif
159
170
  var text = url
160
171
  for (name, value) in values {
161
172
  let encoded = value.text.addingPercentEncoding(withAllowedCharacters: .siriToolValueAllowed) ?? value.text
@@ -1,4 +1,13 @@
1
1
  import type { XcodeProject } from 'expo/config-plugins';
2
2
  export declare const PREVIEW_FLAG = "SIRI_AI_PREVIEW";
3
- /** Turns on the `SIRI_AI_PREVIEW` Swift condition and iOS 27.3 for the app target. */
3
+ /**
4
+ * Evaluations of an Expo app run a Release build, where `#if DEBUG` code is compiled out. Passing
5
+ * `SIRI_AI_EVAL_SWITCHES=YES` to `xcodebuild` adds this condition, so `#if DEBUG || SIRI_AI_EVAL_SWITCHES` code reads
6
+ * `EvalSwitch` in that build only. No other build, including an App Store archive, compiles it.
7
+ */
8
+ export declare const EVAL_SWITCHES_FLAG = "SIRI_AI_EVAL_SWITCHES";
9
+ /**
10
+ * Turns on the `SIRI_AI_PREVIEW` Swift condition and iOS 27.3 for the app target, and lets an evaluation build add
11
+ * `SIRI_AI_EVAL_SWITCHES`.
12
+ */
4
13
  export declare function enableSiriAIPreview(project: XcodeProject): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PREVIEW_FLAG = void 0;
3
+ exports.EVAL_SWITCHES_FLAG = exports.PREVIEW_FLAG = void 0;
4
4
  exports.enableSiriAIPreview = enableSiriAIPreview;
5
5
  exports.PREVIEW_FLAG = 'SIRI_AI_PREVIEW';
6
6
  /**
@@ -8,13 +8,25 @@ exports.PREVIEW_FLAG = 'SIRI_AI_PREVIEW';
8
8
  * runtime. Only the app target is raised, so prebuilt pods keep their own deployment targets.
9
9
  */
10
10
  const PREVIEW_DEPLOYMENT_TARGET = '27.3';
11
- /** Turns on the `SIRI_AI_PREVIEW` Swift condition and iOS 27.3 for the app target. */
11
+ /**
12
+ * Evaluations of an Expo app run a Release build, where `#if DEBUG` code is compiled out. Passing
13
+ * `SIRI_AI_EVAL_SWITCHES=YES` to `xcodebuild` adds this condition, so `#if DEBUG || SIRI_AI_EVAL_SWITCHES` code reads
14
+ * `EvalSwitch` in that build only. No other build, including an App Store archive, compiles it.
15
+ */
16
+ exports.EVAL_SWITCHES_FLAG = 'SIRI_AI_EVAL_SWITCHES';
17
+ /** Expands to the condition when `SIRI_AI_EVAL_SWITCHES` is `YES`, and to nothing when it is unset or anything else. */
18
+ const EVAL_SWITCHES_CONDITION = `$(${exports.EVAL_SWITCHES_FLAG}_CONDITION_$(${exports.EVAL_SWITCHES_FLAG}))`;
19
+ /**
20
+ * Turns on the `SIRI_AI_PREVIEW` Swift condition and iOS 27.3 for the app target, and lets an evaluation build add
21
+ * `SIRI_AI_EVAL_SWITCHES`.
22
+ */
12
23
  function enableSiriAIPreview(project) {
13
24
  const configurations = project.pbxXCBuildConfigurationSection();
14
25
  for (const [key, entry] of Object.entries(configurations)) {
15
26
  if (key.endsWith('_comment') || !entry?.buildSettings?.PRODUCT_NAME)
16
27
  continue;
17
- entry.buildSettings.SWIFT_ACTIVE_COMPILATION_CONDITIONS = `"$(inherited) ${exports.PREVIEW_FLAG}"`;
28
+ entry.buildSettings.SWIFT_ACTIVE_COMPILATION_CONDITIONS = `"$(inherited) ${exports.PREVIEW_FLAG} ${EVAL_SWITCHES_CONDITION}"`;
29
+ entry.buildSettings[`${exports.EVAL_SWITCHES_FLAG}_CONDITION_YES`] = exports.EVAL_SWITCHES_FLAG;
18
30
  entry.buildSettings.IPHONEOS_DEPLOYMENT_TARGET = PREVIEW_DEPLOYMENT_TARGET;
19
31
  }
20
32
  }
@@ -97,7 +97,7 @@ import SyrupAIKit
97
97
  final class AppIntentsSetup: Module {
98
98
  public func definition() -> ExpoModulesCore.ModuleDefinition {
99
99
  Name("AppIntentsSetup")
100
- Function("siriToolOutcome") { () -> String in ToolOutcomeLog.standard.last }
100
+ Function("siriToolOutcome") { () -> String in ToolOutcomeLog.standard.summary }
101
101
  }
102
102
  }
103
103
  ```
@@ -117,7 +117,7 @@ export function SiriToolOutcome() {
117
117
  }
118
118
  ```
119
119
 
120
- Render `<SiriToolOutcome />` on a screen that's always visible. The testID `siri-ai-tool-outcome` is what SyrupAIEvalKit reads. Don't hide it behind `__DEV__`: evaluations run a Release build, so the outcome would never show. If the module already exists, add the `Function` to it rather than creating a second one. Import `SyrupAIKit` the same way in every file in `app-intents/`: plain `import SyrupAIKit` here and in the tools.
120
+ Render `<SiriToolOutcome />` on a screen that's always visible. The testID `siri-ai-tool-outcome` is what SyrupAIEvalKit reads. Use `summary`, not `last`: `last` is only the newest call, so a run where Siri chains tools would hide an earlier failure. Don't hide it behind `__DEV__`: evaluations run a Release build, so the outcome would never show. If the module already exists, add the `Function` to it rather than creating a second one. Import `SyrupAIKit` the same way in every file in `app-intents/`: plain `import SyrupAIKit` here and in the tools.
121
121
 
122
122
  ## Prebuild and build traps
123
123
 
@@ -128,6 +128,7 @@ Render `<SiriToolOutcome />` on a screen that's always visible. The testID `siri
128
128
  | `ambiguous implicit access level for import of 'SyrupAIKit'` | One file in `app-intents/` has `internal import SyrupAIKit` and another plain `import SyrupAIKit`. Use one form in every file |
129
129
  | No `app-intents/AppIntentsSetup.swift` to add the outcome function to | Run `npx expo-app-intents init --examples minimal`, then prebuild again |
130
130
  | Evaluations run a Debug build | Debug loads JavaScript from the dev server, so the app needs `npx expo start` running. Use `-configuration Release` |
131
+ | Negative control's reply check passes: the `EvalSwitch` did nothing | Release compiles `#if DEBUG` out. Guard the switch with `#if DEBUG \|\| SIRI_AI_EVAL_SWITCHES` and pass `SIRI_AI_EVAL_SWITCHES=YES` to `xcodebuild test`. Generated tools already honour `bad-host` |
131
132
  | `No such module 'SyrupAIKit'` in `app-intents/` | Plugin missing from `app.json`, or prebuild not re-run after adding it |
132
133
  | Siri never calls the tool, no build error | Prebuilt without `SIRI_AI_PREVIEW=1`, so `@AppIntent(.tool)` compiled out |
133
134
  | Evaluation UI test target gone | Set the plugin's `evals: { "sourceDir": "siri-evals" }` option instead of adding the target in Xcode, then prebuild again |
@@ -227,7 +227,7 @@ These hold at the end of step 4, before you offer step 5.
227
227
  - Every `javascript` value matches its file name.
228
228
  - Every parameter appears in the spoken prompt, and nothing the prompt needs is missing.
229
229
  - Every parameter has a one-line `description` with an example value.
230
- - Two descriptions aren't easy to confuse.
230
+ - Two descriptions aren't easy to confuse, and no enum case title repeats words another tool's description is built on (a "Phones" case drew "search for phones" away from a search tool on a phone).
231
231
  - Every tool an App Skill names has `"returns": "value"`.
232
232
  - Every App Skill's steps name only tools in `siri-tools.json`, its `name` matches its folder, and its frontmatter has only `name` and `description`.
233
233
  - No existing app file changed, `app.json` included.