shortcutkit 0.1.1 → 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/README.md +49 -10
- package/dist/generated/actions.d.ts +42534 -2725
- package/dist/index.d.ts +7 -0
- package/dist/index.js +19695 -12622
- package/dist/provenance.d.ts +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,9 +8,10 @@ Build, validate and sign Apple Shortcuts (`.shortcut`) files from TypeScript or
|
|
|
8
8
|
## About
|
|
9
9
|
|
|
10
10
|
Apple has never documented the `.shortcut` format or what its actions accept. shortcutkit
|
|
11
|
-
does not guess at either. The tools in this repository load WorkflowKit, the private
|
|
12
|
-
behind the Shortcuts app, and ask
|
|
13
|
-
action.
|
|
11
|
+
does not guess at either. The tools in this repository load WorkflowKit and ActionKit, the private
|
|
12
|
+
frameworks behind the Shortcuts app, and ask their own classes to describe and serialize
|
|
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,8 +26,12 @@ 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.
|
|
@@ -41,6 +46,22 @@ files you are using.
|
|
|
41
46
|
parameter classes, required resources); `provenance` says which build produced the data.
|
|
42
47
|
- **Signing.** `Shortcut.sign()` wraps `shortcuts sign` so the output imports on any device.
|
|
43
48
|
|
|
49
|
+
## How it compares
|
|
50
|
+
|
|
51
|
+
Every earlier library for writing Shortcuts as code kept its action list by hand, and that is
|
|
52
|
+
how the two most used ones ended: [shortcuts-js](https://github.com/joshfarrant/shortcuts-js)
|
|
53
|
+
(TypeScript, 129 actions, archived 2023) and
|
|
54
|
+
[python-shortcuts](https://github.com/alexander-akhmetov/python-shortcuts) (Python, archived
|
|
55
|
+
2024) both stopped once keeping up with Apple became a chore.
|
|
56
|
+
[Cherri](https://github.com/electrikmilk/cherri) is the active project in this space and takes
|
|
57
|
+
a different shape: a programming language with its own compiler, editor extension and package
|
|
58
|
+
manager, whose actions are defined in that language.
|
|
59
|
+
|
|
60
|
+
shortcutkit is a library, not a language. You write TypeScript or Python you already know, and
|
|
61
|
+
the action catalogue comes from the Shortcuts engine rather than from a maintainer. All 434
|
|
62
|
+
built-in actions and 1,581 Apple App Intents are covered today, and the next macOS update is
|
|
63
|
+
one `bun run extract` away.
|
|
64
|
+
|
|
44
65
|
## Installation
|
|
45
66
|
|
|
46
67
|
```bash
|
|
@@ -89,10 +110,22 @@ s.action(actions.showresult, { Text: text("Nothing stored") });
|
|
|
89
110
|
s.endIf(gid);
|
|
90
111
|
```
|
|
91
112
|
|
|
113
|
+
### Apple's apps
|
|
114
|
+
|
|
115
|
+
Apple's App Intents actions are in the catalogue under the Shortcuts app's own keys. Their
|
|
116
|
+
parameters are typed like the built-ins, and the `AppIntentDescriptor` every such action
|
|
117
|
+
carries in the file is added automatically:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
const r = s.action(actions.reminders_create_reminder, { title: text("Buy milk"), priorityLevel: "high" });
|
|
121
|
+
s.action(actions.notes_create_note, { name: "Shopping", content: text("Added ", ref(r)) });
|
|
122
|
+
```
|
|
123
|
+
|
|
92
124
|
### Actions from other apps
|
|
93
125
|
|
|
94
|
-
App Intents actions are not in the catalogue, so pass the identifier as a string
|
|
95
|
-
keys are then typed as `Record<string, Value>` and
|
|
126
|
+
Third-party App Intents actions are not in the catalogue, so pass the identifier as a string
|
|
127
|
+
and the descriptor yourself. Parameter keys are then typed as `Record<string, Value>` and
|
|
128
|
+
passed through as given:
|
|
96
129
|
|
|
97
130
|
```ts
|
|
98
131
|
s.action("com.example.app.CreateNote", { title: text("Hello"), body: ref(got) });
|
|
@@ -129,8 +162,10 @@ python -m shortcutkit demo out.shortcut
|
|
|
129
162
|
|
|
130
163
|
- [`docs/shortcut-file-format.md`](docs/shortcut-file-format.md): the `.shortcut` format end
|
|
131
164
|
to end, every field.
|
|
132
|
-
- [`docs/builtin-actions-reference.md`](docs/builtin-actions-reference.md): all
|
|
165
|
+
- [`docs/builtin-actions-reference.md`](docs/builtin-actions-reference.md): all 434 built-in
|
|
133
166
|
actions with their parameters.
|
|
167
|
+
- [`docs/apple-app-intents-reference.md`](docs/apple-app-intents-reference.md): the 1,581 App
|
|
168
|
+
Intents actions of Apple's apps, by app, with parameter kinds and enumeration cases.
|
|
134
169
|
- [`docs/parameter-encodings.md`](docs/parameter-encodings.md): how each parameter class is
|
|
135
170
|
serialized.
|
|
136
171
|
- [`docs/extraction.md`](docs/extraction.md): how the data was obtained, what did not work,
|
|
@@ -159,7 +194,7 @@ has no iCloud login.
|
|
|
159
194
|
|---|---|
|
|
160
195
|
| `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. |
|
|
161
196
|
| `python/` | The Python package. `actions.py` and `data/` are produced by the tools. |
|
|
162
|
-
| `data/` | Everything extracted from the engine: definitions, parameter encodings, serialization table, and `provenance.json`. |
|
|
197
|
+
| `data/` | Everything extracted from the engine: definitions, parameter encodings, serialization table, `apple-app-intents.json` from the Shortcuts app's registry, and `provenance.json`. |
|
|
163
198
|
| `docs/` | The format reference, action reference, encodings reference and extraction notes. |
|
|
164
199
|
| `tools/` | The extraction pipeline. |
|
|
165
200
|
|
|
@@ -169,10 +204,14 @@ Never hand-edit the generated files. Change the generator or the data and re-run
|
|
|
169
204
|
|
|
170
205
|
The extracted data is committed on purpose. It can only be produced on a Mac, through private
|
|
171
206
|
API that changes between releases, so committing it is what makes the package reproducible.
|
|
172
|
-
To refresh after a macOS update, on
|
|
207
|
+
To refresh after a macOS update, on any Mac that has opened Shortcuts.app at least once. No
|
|
208
|
+
Xcode is needed: the probes are JavaScript for Automation scripts run by `osascript`, because
|
|
209
|
+
ActionKit, which defines about a quarter of the built-in actions, only loads into Apple's own
|
|
210
|
+
platform binaries. Apple's App Intents come from the Shortcuts app's action index, which
|
|
211
|
+
Shortcuts writes on launch.
|
|
173
212
|
|
|
174
213
|
```bash
|
|
175
|
-
bun run extract # ~
|
|
214
|
+
bun run extract # ~10 s: loads WorkflowKit and ActionKit in osascript, dumps and serializes everything
|
|
176
215
|
bun install && bun test
|
|
177
216
|
bun run diff-data # what changed vs the committed data, and the semver bump it implies
|
|
178
217
|
bun run changelog # the same as a CHANGELOG.md section
|