shortcutkit 0.2.0 → 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 +35 -12
- package/dist/generated/actions.d.ts +42064 -3191
- package/dist/index.d.ts +17 -0
- package/dist/index.js +5936 -131
- package/dist/provenance.d.ts +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,8 @@ Build, validate and sign Apple Shortcuts (`.shortcut`) files from TypeScript or
|
|
|
10
10
|
Apple has never documented the `.shortcut` format or what its actions accept. shortcutkit
|
|
11
11
|
does not guess at either. The tools in this repository load WorkflowKit and ActionKit, the private
|
|
12
12
|
frameworks behind the Shortcuts app, and ask their own classes to describe and serialize
|
|
13
|
-
every built-in action.
|
|
13
|
+
every built-in action. Apple's own apps' actions come from the Shortcuts app's action index,
|
|
14
|
+
the only readable copy of the App Intents registry. Every action identifier, parameter key, value encoding, icon colour, and even the
|
|
14
15
|
UTF-16 offset rule for embedded references came out of the engine, not from a person reading
|
|
15
16
|
files. The package cannot disagree with the app.
|
|
16
17
|
|
|
@@ -25,15 +26,20 @@ files you are using.
|
|
|
25
26
|
|
|
26
27
|
## Features
|
|
27
28
|
|
|
28
|
-
- **Every built-in action, typed.** `actions.*` lists all
|
|
29
|
+
- **Every built-in action, typed.** `actions.*` lists all 434 identifiers, with each action's
|
|
29
30
|
name, description, summary, output and parameter keys as hover documentation.
|
|
31
|
+
- **Apple's apps too.** 1,581 App Intents actions from 80 Apple apps and system components,
|
|
32
|
+
Create Reminder, Create Note, Send Message, the System Settings toggles, under the keys the
|
|
33
|
+
Shortcuts app itself assigns them: `actions.reminders_create_reminder`. Enumeration cases are
|
|
34
|
+
typed, and the `AppIntentDescriptor` the file needs is added for you.
|
|
30
35
|
- **Parameters checked before you run anything.** `{ WFStoredContentGlobalValue: "yes" }` is a
|
|
31
36
|
compile error; a switch takes a boolean or a reference. Enumeration choices are suggested.
|
|
32
37
|
Any plain value slot also accepts an attachment, because that is how Shortcuts works.
|
|
33
38
|
- **Value helpers that match the engine's serialization.** `ref()` to another action's output,
|
|
34
39
|
`variable()`, `shortcutInput()`, `clipboard()`, `currentDate()`, `ask()`, `text()` for
|
|
35
40
|
strings with embedded references, and `picker()` for variable-picker parameters.
|
|
36
|
-
- **Control flow.** `if()` / `otherwise()` / `endIf()
|
|
41
|
+
- **Control flow.** `if()` / `otherwise()` / `endIf()`, `repeatEach()` / `endRepeatEach()`,
|
|
42
|
+
`repeatCount()` / `endRepeatCount()` and `chooseFromMenu()` / `menuItem()` / `endMenu()`
|
|
37
43
|
manage the grouping identifiers for you.
|
|
38
44
|
- **App Intents from installed apps.** Any identifier outside the built-in set is accepted;
|
|
39
45
|
built-in identifiers and their parameter keys are also validated at run time.
|
|
@@ -53,8 +59,9 @@ a different shape: a programming language with its own compiler, editor extensio
|
|
|
53
59
|
manager, whose actions are defined in that language.
|
|
54
60
|
|
|
55
61
|
shortcutkit is a library, not a language. You write TypeScript or Python you already know, and
|
|
56
|
-
the action catalogue comes from the Shortcuts engine rather than from a maintainer. All
|
|
57
|
-
built-in actions are covered today, and the next macOS update is
|
|
62
|
+
the action catalogue comes from the Shortcuts engine rather than from a maintainer. All 434
|
|
63
|
+
built-in actions and 1,581 Apple App Intents are covered today, and the next macOS update is
|
|
64
|
+
one `bun run extract` away.
|
|
58
65
|
|
|
59
66
|
## Installation
|
|
60
67
|
|
|
@@ -104,10 +111,22 @@ s.action(actions.showresult, { Text: text("Nothing stored") });
|
|
|
104
111
|
s.endIf(gid);
|
|
105
112
|
```
|
|
106
113
|
|
|
114
|
+
### Apple's apps
|
|
115
|
+
|
|
116
|
+
Apple's App Intents actions are in the catalogue under the Shortcuts app's own keys. Their
|
|
117
|
+
parameters are typed like the built-ins, and the `AppIntentDescriptor` every such action
|
|
118
|
+
carries in the file is added automatically:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
const r = s.action(actions.reminders_create_reminder, { title: text("Buy milk"), priorityLevel: "high" });
|
|
122
|
+
s.action(actions.notes_create_note, { name: "Shopping", content: text("Added ", ref(r)) });
|
|
123
|
+
```
|
|
124
|
+
|
|
107
125
|
### Actions from other apps
|
|
108
126
|
|
|
109
|
-
App Intents actions are not in the catalogue, so pass the identifier as a string
|
|
110
|
-
keys are then typed as `Record<string, Value>` and
|
|
127
|
+
Third-party App Intents actions are not in the catalogue, so pass the identifier as a string
|
|
128
|
+
and the descriptor yourself. Parameter keys are then typed as `Record<string, Value>` and
|
|
129
|
+
passed through as given:
|
|
111
130
|
|
|
112
131
|
```ts
|
|
113
132
|
s.action("com.example.app.CreateNote", { title: text("Hello"), body: ref(got) });
|
|
@@ -144,8 +163,10 @@ python -m shortcutkit demo out.shortcut
|
|
|
144
163
|
|
|
145
164
|
- [`docs/shortcut-file-format.md`](docs/shortcut-file-format.md): the `.shortcut` format end
|
|
146
165
|
to end, every field.
|
|
147
|
-
- [`docs/builtin-actions-reference.md`](docs/builtin-actions-reference.md): all
|
|
166
|
+
- [`docs/builtin-actions-reference.md`](docs/builtin-actions-reference.md): all 434 built-in
|
|
148
167
|
actions with their parameters.
|
|
168
|
+
- [`docs/apple-app-intents-reference.md`](docs/apple-app-intents-reference.md): the 1,581 App
|
|
169
|
+
Intents actions of Apple's apps, by app, with parameter kinds and enumeration cases.
|
|
149
170
|
- [`docs/parameter-encodings.md`](docs/parameter-encodings.md): how each parameter class is
|
|
150
171
|
serialized.
|
|
151
172
|
- [`docs/extraction.md`](docs/extraction.md): how the data was obtained, what did not work,
|
|
@@ -174,7 +195,7 @@ has no iCloud login.
|
|
|
174
195
|
|---|---|
|
|
175
196
|
| `src/` | The TypeScript package source. `src/generated/actions.ts` is produced by the tools. `bun run build` bundles it into `dist/`, which is what npm ships. |
|
|
176
197
|
| `python/` | The Python package. `actions.py` and `data/` are produced by the tools. |
|
|
177
|
-
| `data/` | Everything extracted from the engine: definitions, parameter encodings, serialization table, and `provenance.json`. |
|
|
198
|
+
| `data/` | Everything extracted from the engine: definitions, parameter encodings, serialization table, `apple-app-intents.json` from the Shortcuts app's registry, and `provenance.json`. |
|
|
178
199
|
| `docs/` | The format reference, action reference, encodings reference and extraction notes. |
|
|
179
200
|
| `tools/` | The extraction pipeline. |
|
|
180
201
|
|
|
@@ -184,9 +205,11 @@ Never hand-edit the generated files. Change the generator or the data and re-run
|
|
|
184
205
|
|
|
185
206
|
The extracted data is committed on purpose. It can only be produced on a Mac, through private
|
|
186
207
|
API that changes between releases, so committing it is what makes the package reproducible.
|
|
187
|
-
To refresh after a macOS update, on any Mac
|
|
188
|
-
for Automation scripts run by `osascript`, because
|
|
189
|
-
the built-in actions, only loads into Apple's own
|
|
208
|
+
To refresh after a macOS update, on any Mac that has opened Shortcuts.app at least once. No
|
|
209
|
+
Xcode is needed: the probes are JavaScript for Automation scripts run by `osascript`, because
|
|
210
|
+
ActionKit, which defines about a quarter of the built-in actions, only loads into Apple's own
|
|
211
|
+
platform binaries. Apple's App Intents come from the Shortcuts app's action index, which
|
|
212
|
+
Shortcuts writes on launch.
|
|
190
213
|
|
|
191
214
|
```bash
|
|
192
215
|
bun run extract # ~10 s: loads WorkflowKit and ActionKit in osascript, dumps and serializes everything
|