expo-syrup-ai-kit 0.0.0-stage → 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Adam Rowe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,218 @@
1
- # Temporary Holding Version
1
+ # expo-syrup-ai-kit
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Expo plugin for Syrup AI Kit: Siri AI tools for Expo and React Native apps. Formerly `expo-siri-ai-kit`.
4
+
5
+ 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).
6
+
7
+ Using a coding agent? Install the [agent skills](#agent-skills) and ask it to "make my app work with Siri AI".
8
+
9
+ Not affiliated with or endorsed by Apple.
10
+
11
+ ## What it does when you prebuild
12
+
13
+ - **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
+ - **With the preview on, it also:**
15
+ - adds the `SIRI_AI_PREVIEW` Swift compilation condition, so `#if SIRI_AI_PREVIEW` code builds only with the 27.3 SDK;
16
+ - sets the app target's deployment target to iOS 27.3, which `@Property(title:description:)` requires. Pods keep their own targets.
17
+ - **With `evals` set, adds a UI test target for Siri Evaluations** (see [Evaluation target](#evaluation-target)), so it survives `prebuild --clean`.
18
+ - **With `skills` set, checks your Apple App Skills and adds them to the app as `Skills.skillsbundle`** (see [App Skills](#app-skills)).
19
+
20
+ Running prebuild again doesn't add anything twice.
21
+
22
+ ## Install
23
+
24
+ The full setup, including the Mac, the iPhone and a checklist for coding agents, is in [INSTALL.md](https://github.com/airowe/syrup-ai-kit/blob/main/INSTALL.md).
25
+
26
+ ```bash
27
+ npx expo install expo-syrup-ai-kit expo-app-intents
28
+ ```
29
+
30
+ ```json
31
+ {
32
+ "expo": {
33
+ "plugins": ["expo-app-intents", "expo-syrup-ai-kit"]
34
+ }
35
+ }
36
+ ```
37
+
38
+ Then prebuild with the preview on:
39
+
40
+ ```bash
41
+ SIRI_AI_PREVIEW=1 npx expo prebuild -p ios
42
+ ```
43
+
44
+ ## Options
45
+
46
+ ```json
47
+ ["expo-syrup-ai-kit", { "version": "0.3.0", "preview": true }]
48
+ ```
49
+
50
+ | Option | Default | What it does |
51
+ |---|---|---|
52
+ | `version` | The SyrupAIKit release this plugin was tested with | Uses SyrupAIKit up to the next minor version. |
53
+ | `branch` | None | Follows a SyrupAIKit branch instead. Use it only to try unreleased changes. Can't be combined with `version`. |
54
+ | `preview` | `true` when `SIRI_AI_PREVIEW=1` is set | Turns on the Siri AI Developer Preview code. |
55
+ | `tools` | None | Path to a Siri tools declaration, such as `./siri-tools.json`. Generates a Swift tool for each entry. Experimental. |
56
+ | `evals` | None | `{ "sourceDir": "siri-evals", "targetName": "MyAppEvals" }`. Adds a UI test target for Siri Evaluations. `targetName` defaults to `<AppName>Evals`. |
57
+ | `skills` | None | `{ "sourceDir": "siri-skills" }`. A folder of Apple App Skills, one folder per skill holding a `SKILL.md`. Checked against Apple's rules and compiled into the app. |
58
+
59
+ ## Evaluation target
60
+
61
+ `prebuild --clean` regenerates `ios/`, so a test target added in Xcode disappears. Keep the evaluation tests in a folder outside `ios/` and let the plugin add the target:
62
+
63
+ ```json
64
+ ["expo-syrup-ai-kit", { "preview": true, "evals": { "sourceDir": "siri-evals" } }]
65
+ ```
66
+
67
+ On every prebuild the plugin adds a `<AppName>Evals` UI test target that:
68
+
69
+ - compiles every `.swift` file under `sourceDir` (subfolders included), referenced in place rather than copied;
70
+ - tests the app target (`TEST_TARGET_NAME`), depends on it, and builds for iOS 27.3;
71
+ - links `SyrupAIEvalKit` from the same SyrupAIKit package, and copies the app's development team for signing;
72
+ - gets a shared scheme of the same name.
73
+
74
+ Run the evaluations on an iPhone on iOS 27.3 with Siri AI on:
75
+
76
+ ```bash
77
+ xcodebuild test -workspace ios/MyApp.xcworkspace -scheme MyAppEvals -destination 'platform=iOS,name=My iPhone'
78
+ ```
79
+
80
+ 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.
81
+
82
+ ## App Skills
83
+
84
+ 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:
85
+
86
+ ```
87
+ siri-skills/
88
+ cart-checkout/
89
+ SKILL.md
90
+ ```
91
+
92
+ ```markdown
93
+ ---
94
+ name: cart-checkout
95
+ description: Guides a purchase from search to checkout in ShopApp.
96
+ ---
97
+ Search for the item first, add it to the cart, then confirm the total before checking out.
98
+ ```
99
+
100
+ ```json
101
+ ["expo-syrup-ai-kit", { "preview": true, "skills": { "sourceDir": "siri-skills" } }]
102
+ ```
103
+
104
+ At prebuild the plugin copies each `SKILL.md` into `ios/<App>/Skills.skillsbundle` and adds the bundle to the app target with Xcode's skills-bundle file type, so Xcode compiles it into the app. A skill you delete stops shipping on the next prebuild.
105
+
106
+ Prebuild stops, listing every problem, if a skill breaks Apple's rules. Xcode itself ignores or only warns about some of them:
107
+
108
+ - The frontmatter has only `name` and `description`.
109
+ - `name` is 1 to 64 lowercase letters, digits and single hyphens, and matches its folder.
110
+ - `description` is one line of at most 1,024 characters.
111
+ - The body is at most 10,000 characters.
112
+ - Each skill folder holds only its `SKILL.md`.
113
+
114
+ Skills guide Siri; they don't guarantee it follows the steps in order. Nothing checks that a skill names tools your app has, so test the flow with a Siri evaluation. App Skills are part of the Siri AI Developer Preview, with the same limits on who can use them (see the [SyrupAIKit README](https://github.com/airowe/syrup-ai-kit#readme)).
115
+
116
+ ## A first tool
117
+
118
+ ```swift
119
+ // app-intents/GetQuoteIntent.swift
120
+ import AppIntents
121
+ import Foundation
122
+ import SyrupAIKit
123
+
124
+ private let tool = SiriTool(appName: "My App")
125
+
126
+ #if SIRI_AI_PREVIEW
127
+ @AppIntent(.tool)
128
+ #endif
129
+ struct GetQuoteIntent: AppIntent {
130
+ static let title: LocalizedStringResource = "Get Quote of the Day"
131
+
132
+ func perform() async throws -> some IntentResult & ReturnsValue<String> & ProvidesDialog {
133
+ let answer = await tool.answer {
134
+ let (data, _) = try await URLSession.shared.data(from: URL(string: "https://dummyjson.com/quotes/random")!)
135
+ let quote = try JSONDecoder().decode(Quote.self, from: data)
136
+ return "\(quote.quote) That's from \(quote.author)."
137
+ }
138
+ return .result(value: answer, dialog: "\(answer)")
139
+ }
140
+ }
141
+
142
+ private struct Quote: Decodable {
143
+ let quote: String
144
+ let author: String
145
+ }
146
+ ```
147
+
148
+ See the [Syrup AI Kit README](https://github.com/airowe/syrup-ai-kit#readme) for `SiriTool`, outcomes, and testing with Siri Evaluations.
149
+
150
+ ## Generating tools from a declaration (experimental)
151
+
152
+ Instead of writing Swift, list tools that call your HTTP API in a JSON file and pass its path as `tools`:
153
+
154
+ ```json
155
+ {
156
+ "tools": [
157
+ {
158
+ "name": "SearchProducts",
159
+ "title": "Search Products",
160
+ "description": "Searches the store's catalog and says how many products match and what they are called.",
161
+ "parameters": [
162
+ {
163
+ "name": "query",
164
+ "type": "string",
165
+ "title": "Search Text",
166
+ "description": "What to search the catalog for, as the person says it, like \"phone case\"."
167
+ },
168
+ { "name": "limit", "type": "int", "title": "Number of Results" }
169
+ ],
170
+ "request": { "method": "GET", "url": "https://dummyjson.com/products/search?q={query}&limit={limit}" },
171
+ "reply": "Found {total} products. The first ones are {products.title}."
172
+ }
173
+ ]
174
+ }
175
+ ```
176
+
177
+ A parameter's optional `description` is one line saying what the person gives, with an example. Siri reads it to fill the value.
178
+
179
+ 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).
180
+
181
+ ## Implementing the tools discovery proposes
182
+
183
+ The `siri-ai-discover` skill writes each tool's interface to `siri-tools.json`, and leaves how the tool gets its answer to your code. [docs/implementing-tools.md](../docs/implementing-tools.md) covers:
184
+
185
+ - the three ways to answer: a Swift tool (works today), `request` + `reply` (experimental), or `javascript` (planned);
186
+ - what every tool must do, whichever way it answers;
187
+ - how to prove each tool on a phone.
188
+
189
+ ## Showing the tool's outcome in your app
190
+
191
+ Siri Evaluations read the last outcome from the screen. Expose it from your `AppIntentsSetup` inline module:
192
+
193
+ ```swift
194
+ Function("siriToolOutcome") { () -> String in
195
+ ToolOutcomeLog.standard.last
196
+ }
197
+ ```
198
+
199
+ Then render it from JavaScript with `testID="siri-ai-tool-outcome"`.
200
+
201
+ ## Agent skills
202
+
203
+ This package includes two agent skills:
204
+
205
+ - `skills/expo-syrup-ai-kit/SKILL.md` covers setup, the outcome bridge and known prebuild problems.
206
+ - `skills/siri-ai-discover/SKILL.md` finds which Siri AI tools an app should have and writes their interfaces (name, description, parameters) to `siri-tools.json`, with an evaluation prompt for each. How each tool gets its answer is left to the app's own code.
207
+
208
+ Install them with the other Syrup AI Kit skills, including `siri-ai`, the one to start from. In Claude Code: `/plugin marketplace add airowe/syrup-ai-kit`, then `/plugin install syrup-ai-kit@syrup-ai-kit`. In other agents: `npx skills add airowe/syrup-ai-kit`.
209
+
210
+ ## Requirements
211
+
212
+ - Expo SDK 58 or later, with `expo-app-intents`.
213
+ - Xcode 27.3 beta, and an iPhone on iOS 27.3 beta with Siri AI on, for the preview.
214
+ - Tools that answer Siri are written in Swift. Expo hasn't released a way for JavaScript to answer an intent yet.
215
+
216
+ ## License
217
+
218
+ MIT
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/build');
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "expo-syrup-ai-kit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
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
+ "main": "app.plugin.js",
6
+ "types": "plugin/build/index.d.ts",
7
+ "files": [
8
+ "app.plugin.js",
9
+ "plugin/build",
10
+ "README.md",
11
+ "LICENSE",
12
+ "skills"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc -p plugin",
16
+ "clean": "node -e \"require('fs').rmSync('plugin/build',{recursive:true,force:true})\"",
17
+ "test": "jest --config plugin/jest.config.js --rootDir plugin",
18
+ "prepublishOnly": "npm run clean && npm run build && npm test"
19
+ },
20
+ "keywords": [
21
+ "expo",
22
+ "react-native",
23
+ "siri",
24
+ "app-intents",
25
+ "config-plugin",
26
+ "siri-ai",
27
+ "apple-intelligence",
28
+ "ios",
29
+ "agent-skills"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/airowe/syrup-ai-kit.git",
34
+ "directory": "expo-plugin"
35
+ },
36
+ "license": "MIT",
37
+ "peerDependencies": {
38
+ "expo": ">=58.0.0"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "expo": {
42
+ "optional": true
43
+ }
44
+ },
45
+ "devDependencies": {
46
+ "@types/jest": "^30.0.0",
47
+ "@types/node": "^26.6.6",
48
+ "expo": "^58.0.24",
49
+ "expo-module-scripts": "^56.0.3",
50
+ "xcode": "^4.0.0"
51
+ }
52
+ }
@@ -0,0 +1,25 @@
1
+ import { type ConfigPlugin } from 'expo/config-plugins';
2
+ import { type EvalsOptions } from './withSiriAIEvals';
3
+ import { type PackageRequirement } from './withSyrupAIKitPackage';
4
+ import { type SiriSkillsOptions } from './withSiriSkills';
5
+ import { type SiriToolsOptions } from './withSiriTools';
6
+ export type SyrupAIKitPluginProps = {
7
+ /** SyrupAIKit version to use, up to the next minor. Defaults to the release this plugin was tested with. */
8
+ version?: string;
9
+ /** Follow a SyrupAIKit branch instead of a release, for trying unreleased changes. */
10
+ branch?: string;
11
+ /** Turn on the Siri AI Developer Preview code. Defaults to `SIRI_AI_PREVIEW=1` in the environment. */
12
+ preview?: boolean;
13
+ /** Add a UI test target for Siri Evaluations, built from Swift files kept outside `ios/`. */
14
+ evals?: EvalsOptions;
15
+ /** Path to a Siri tools declaration, relative to the project root. Generates a Swift tool for each entry. */
16
+ tools?: string;
17
+ /** Apple App Skills: a folder, relative to the project root, with one folder per skill holding its `SKILL.md`. */
18
+ skills?: SiriSkillsOptions;
19
+ };
20
+ export declare function requirementFrom(props: SyrupAIKitPluginProps): PackageRequirement;
21
+ export declare function previewEnabled(props: SyrupAIKitPluginProps, env: NodeJS.ProcessEnv): boolean;
22
+ export declare function siriToolsOptionsFrom(props: SyrupAIKitPluginProps, expoName: string): SiriToolsOptions | undefined;
23
+ export declare function siriSkillsOptionsFrom(props: SyrupAIKitPluginProps): SiriSkillsOptions | undefined;
24
+ declare const _default: ConfigPlugin<void | SyrupAIKitPluginProps>;
25
+ export default _default;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requirementFrom = requirementFrom;
4
+ exports.previewEnabled = previewEnabled;
5
+ exports.siriToolsOptionsFrom = siriToolsOptionsFrom;
6
+ exports.siriSkillsOptionsFrom = siriSkillsOptionsFrom;
7
+ const config_plugins_1 = require("expo/config-plugins");
8
+ const withSiriAIEvals_1 = require("./withSiriAIEvals");
9
+ const withSyrupAIKitPackage_1 = require("./withSyrupAIKitPackage");
10
+ const withSiriAIPreview_1 = require("./withSiriAIPreview");
11
+ const withSiriSkills_1 = require("./withSiriSkills");
12
+ const withSiriTools_1 = require("./withSiriTools");
13
+ const pkg = require('../../package.json');
14
+ /** The SyrupAIKit release this plugin version was tested with. */
15
+ const DEFAULT_VERSION = '0.3.0';
16
+ function requirementFrom(props) {
17
+ if (props.version && props.branch) {
18
+ throw new Error('expo-syrup-ai-kit: pass either `version` or `branch`, not both');
19
+ }
20
+ return props.branch
21
+ ? { kind: 'branch', branch: props.branch }
22
+ : { kind: 'version', version: props.version ?? DEFAULT_VERSION };
23
+ }
24
+ function previewEnabled(props, env) {
25
+ return props.preview ?? env[withSiriAIPreview_1.PREVIEW_FLAG] === '1';
26
+ }
27
+ function siriToolsOptionsFrom(props, expoName) {
28
+ return props.tools ? { declarationPath: props.tools, appName: expoName } : undefined;
29
+ }
30
+ function siriSkillsOptionsFrom(props) {
31
+ if (props.skills === undefined)
32
+ return undefined;
33
+ const { sourceDir } = (props.skills ?? {});
34
+ if (typeof sourceDir !== 'string' || sourceDir.length === 0) {
35
+ throw new Error('expo-syrup-ai-kit: skills.sourceDir must name a folder of App Skills');
36
+ }
37
+ return { sourceDir };
38
+ }
39
+ /**
40
+ * One Xcode project mod, so the steps run in this order: the evals target links a product from the package
41
+ * reference, and the preview settings then cover the evals target as well as the app.
42
+ */
43
+ const withSyrupAIKit = (config, props) => {
44
+ const options = props ?? {};
45
+ const requirement = requirementFrom(options);
46
+ const preview = previewEnabled(options, process.env);
47
+ const tools = siriToolsOptionsFrom(options, config.name);
48
+ const skills = siriSkillsOptionsFrom(options);
49
+ if (tools)
50
+ config = (0, withSiriTools_1.withSiriToolFiles)(config, tools);
51
+ if (skills)
52
+ config = (0, withSiriSkills_1.withSiriSkillsBundle)(config, skills);
53
+ return (0, config_plugins_1.withXcodeProject)(config, (next) => {
54
+ (0, withSyrupAIKitPackage_1.addSyrupAIKitPackage)(next.modResults, requirement);
55
+ if (tools)
56
+ (0, withSiriTools_1.addSiriToolsGroup)(next.modResults, (0, withSiriTools_1.siriToolsFolder)(next.modRequest.projectName));
57
+ if (skills)
58
+ (0, withSiriSkills_1.addSkillsBundle)(next.modResults, (0, withSiriSkills_1.skillsBundlePath)(next.modRequest.projectName));
59
+ if (options.evals)
60
+ (0, withSiriAIEvals_1.addSiriAIEvals)(next.modResults, options.evals, next.modRequest);
61
+ if (preview)
62
+ (0, withSiriAIPreview_1.enableSiriAIPreview)(next.modResults);
63
+ return next;
64
+ });
65
+ };
66
+ exports.default = (0, config_plugins_1.createRunOncePlugin)(withSyrupAIKit, pkg.name, pkg.version);
@@ -0,0 +1,13 @@
1
+ /** Apple's limits for an App Skill's `SKILL.md`. */
2
+ export declare const MAX_NAME = 64;
3
+ export declare const MAX_DESCRIPTION = 1024;
4
+ export declare const MAX_BODY = 10000;
5
+ export declare const SKILL_FILE = "SKILL.md";
6
+ /** Problems in one skill's `SKILL.md`, checked against Apple's rules. `folder` is the skill's folder name. */
7
+ export declare function skillFileProblems(folder: string, text: string): string[];
8
+ /**
9
+ * Problems in a folder of skills: one folder per skill, each holding only a `SKILL.md`. `label` is the folder as
10
+ * the person wrote it, used in the messages. Xcode ignores extra files and only warns about unsupported fields,
11
+ * so both are reported here.
12
+ */
13
+ export declare function skillsFolderProblems(directory: string, label: string): string[];
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SKILL_FILE = exports.MAX_BODY = exports.MAX_DESCRIPTION = exports.MAX_NAME = void 0;
7
+ exports.skillFileProblems = skillFileProblems;
8
+ exports.skillsFolderProblems = skillsFolderProblems;
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
11
+ /** Apple's limits for an App Skill's `SKILL.md`. */
12
+ exports.MAX_NAME = 64;
13
+ exports.MAX_DESCRIPTION = 1024;
14
+ exports.MAX_BODY = 10_000;
15
+ exports.SKILL_FILE = 'SKILL.md';
16
+ const NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
17
+ const FIELDS = ['name', 'description'];
18
+ const FENCE = '---';
19
+ const unquote = (value) => value.replace(/^(["'])(.*)\1$/, '$2');
20
+ function splitFrontmatter(text) {
21
+ const lines = text.replace(/\r\n/g, '\n').split('\n');
22
+ if (lines[0]?.trim() !== FENCE)
23
+ return 'missing';
24
+ const close = lines.indexOf(FENCE, 1);
25
+ if (close === -1)
26
+ return 'unclosed';
27
+ const fields = new Map();
28
+ const continued = new Set();
29
+ let current;
30
+ for (const line of lines.slice(1, close)) {
31
+ const field = /^([A-Za-z_][\w-]*):\s*(.*)$/.exec(line);
32
+ if (field) {
33
+ const [, key = '', value = ''] = field;
34
+ current = key;
35
+ fields.set(key, unquote(value.trim()));
36
+ }
37
+ else if (current && line.trim() !== '') {
38
+ continued.add(current);
39
+ }
40
+ }
41
+ return { fields, continued, body: lines.slice(close + 1).join('\n') };
42
+ }
43
+ /** Problems in one skill's `SKILL.md`, checked against Apple's rules. `folder` is the skill's folder name. */
44
+ function skillFileProblems(folder, text) {
45
+ const at = `${folder}/${exports.SKILL_FILE}`;
46
+ const parsed = splitFrontmatter(text);
47
+ if (parsed === 'missing')
48
+ return [`${at}: must start with ${FENCE} frontmatter`];
49
+ if (parsed === 'unclosed')
50
+ return [`${at}: the frontmatter has no closing ${FENCE}`];
51
+ const { fields, continued, body } = parsed;
52
+ const name = fields.get('name');
53
+ const description = fields.get('description');
54
+ const problems = [];
55
+ if (!name)
56
+ problems.push(`${at}: name is required`);
57
+ if (continued.has('description') || description === '>' || description === '|') {
58
+ problems.push(`${at}: description must be one line`);
59
+ }
60
+ else if (!description) {
61
+ problems.push(`${at}: description is required`);
62
+ }
63
+ else if (description.length > exports.MAX_DESCRIPTION) {
64
+ problems.push(`${at}: description is ${description.length} characters; the limit is ${exports.MAX_DESCRIPTION}`);
65
+ }
66
+ if (name && (name.length > exports.MAX_NAME || !NAME.test(name))) {
67
+ problems.push(`${at}: name must be 1 to ${exports.MAX_NAME} lowercase letters, digits and single hyphens, not starting or ending with a hyphen`);
68
+ }
69
+ else if (name && name !== folder) {
70
+ problems.push(`${at}: name "${name}" must match its folder, "${folder}"`);
71
+ }
72
+ for (const field of fields.keys()) {
73
+ if (!FIELDS.includes(field))
74
+ problems.push(`${at}: Siri only reads name and description, not "${field}"`);
75
+ }
76
+ if (body.length > exports.MAX_BODY)
77
+ problems.push(`${at}: the body is ${body.length} characters; the limit is ${exports.MAX_BODY}`);
78
+ return problems;
79
+ }
80
+ const visible = (directory) => fs_1.default
81
+ .readdirSync(directory, { withFileTypes: true })
82
+ .filter((entry) => !entry.name.startsWith('.'))
83
+ .sort((a, b) => a.name.localeCompare(b.name));
84
+ /**
85
+ * Problems in a folder of skills: one folder per skill, each holding only a `SKILL.md`. `label` is the folder as
86
+ * the person wrote it, used in the messages. Xcode ignores extra files and only warns about unsupported fields,
87
+ * so both are reported here.
88
+ */
89
+ function skillsFolderProblems(directory, label) {
90
+ if (!fs_1.default.existsSync(directory))
91
+ return [`skills: ${label} does not exist`];
92
+ if (!fs_1.default.statSync(directory).isDirectory())
93
+ return [`skills: ${label} is not a folder`];
94
+ const entries = visible(directory);
95
+ const problems = entries
96
+ .filter((entry) => !entry.isDirectory())
97
+ .map((entry) => `${label}/${entry.name}: only skill folders go here, each with a ${exports.SKILL_FILE}`);
98
+ const skills = entries.filter((entry) => entry.isDirectory());
99
+ if (skills.length === 0)
100
+ return [...problems, `skills: ${label} has no skill folders`];
101
+ for (const skill of skills) {
102
+ const folder = path_1.default.join(directory, skill.name);
103
+ const contents = visible(folder);
104
+ if (!contents.some((entry) => entry.name === exports.SKILL_FILE && entry.isFile())) {
105
+ problems.push(`${label}/${skill.name}: has no ${exports.SKILL_FILE}`);
106
+ continue;
107
+ }
108
+ for (const extra of contents.filter((entry) => entry.name !== exports.SKILL_FILE)) {
109
+ problems.push(`${label}/${skill.name}/${extra.name}: Siri only reads ${exports.SKILL_FILE}; remove other files`);
110
+ }
111
+ const text = fs_1.default.readFileSync(path_1.default.join(folder, exports.SKILL_FILE), 'utf8');
112
+ problems.push(...skillFileProblems(skill.name, text).map((problem) => `${label}/${problem}`));
113
+ }
114
+ return problems;
115
+ }
@@ -0,0 +1,41 @@
1
+ export declare const SCALAR_TYPES: readonly ["string", "int", "double", "bool", "date"];
2
+ export type ScalarType = (typeof SCALAR_TYPES)[number];
3
+ declare const METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE"];
4
+ export type HttpMethod = (typeof METHODS)[number];
5
+ export type ToolParameter = {
6
+ name: string;
7
+ type: ScalarType;
8
+ title: string;
9
+ description?: string;
10
+ } | {
11
+ name: string;
12
+ type: 'enum';
13
+ title: string;
14
+ description?: string;
15
+ cases: Record<string, string>;
16
+ };
17
+ export type ToolRequest = {
18
+ method: HttpMethod;
19
+ url: string;
20
+ body: string[];
21
+ };
22
+ export type ToolDeclaration = {
23
+ name: string;
24
+ title: string;
25
+ description: string;
26
+ parameters: ToolParameter[];
27
+ request: ToolRequest;
28
+ reply: string;
29
+ };
30
+ export type SiriToolsDeclaration = {
31
+ appName?: string;
32
+ tools: ToolDeclaration[];
33
+ };
34
+ export declare function urlPlaceholders(url: string): string[];
35
+ /** Placeholders in a reply, or `undefined` if a `{` is never closed. */
36
+ export declare function replyPlaceholders(reply: string): string[] | undefined;
37
+ /** Every problem with a declaration, in a form a person can fix from; empty when it's valid. */
38
+ export declare function declarationProblems(input: unknown): string[];
39
+ /** The declaration with defaults filled in, or an error listing every problem in `source`. */
40
+ export declare function parseSiriTools(input: unknown, source: string): SiriToolsDeclaration;
41
+ export {};