shortcutkit 0.6.1 → 0.8.1

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
@@ -34,18 +34,25 @@ files you are using.
34
34
  typed, and the `AppIntentDescriptor` the file needs is added for you.
35
35
  - **Parameters checked before you run anything.** `{ WFStoredContentGlobalValue: "yes" }` is a
36
36
  compile error; a switch takes a boolean or a reference. Enumeration choices are suggested.
37
- Any plain value slot also accepts an attachment, because that is how Shortcuts works.
37
+ A plain value slot also accepts a reference where the engine reads one, and the type says
38
+ which: a Filter action's sort key takes none, a variable picker takes any except Ask, and the
39
+ engine was asked about every key (`PARAM_VARIABLE_TYPES`). Every action has a named
40
+ parameter type (`ShowresultParams`, `RemindersCreateReminderParams`), and its output content
41
+ types are on `ACTIONS[id].outputTypes` and on the returned `Action`.
38
42
  - **Value helpers that match the engine's serialization.** `ref()` to another action's output,
39
- `variable()`, `shortcutInput()`, `clipboard()`, `currentDate()`, `ask()`, `text()` for
40
- strings with embedded references, and `picker()` for variable-picker parameters. A bare
41
- `ref()` given to a text parameter is wrapped into the token string the engine writes.
43
+ `variable()`, `shortcutInput()`, `clipboard()`, `currentDate()`, `ask()`, `deviceDetails()`,
44
+ `currentApp()`, `text()` for strings with embedded references. A bare `ref()` is what every
45
+ picker parameter takes; for a text parameter it is wrapped into the token string the engine
46
+ writes, and for an If subject into the form the app writes.
42
47
  - **Control flow.** `if()` / `otherwise()` / `endIf()`, `repeatEach()` / `endRepeatEach()`,
43
48
  `repeatCount()` / `endRepeatCount()` and `chooseFromMenu()` / `menuItem()` / `endMenu()`
44
49
  manage the grouping identifiers for you.
45
50
  - **App Intents from installed apps.** Any identifier outside the built-in set is accepted;
46
51
  built-in identifiers and their parameter keys are also validated at run time.
47
- - **Definitions and provenance.** `getDefinition(id)` returns the full record (icon, keywords,
48
- parameter classes, required resources); `provenance` says which build produced the data.
52
+ - **Definitions and provenance.** `getAction(id)` describes any identifier, built-in or App
53
+ Intent: name, parameter keys and kinds, output, descriptor. `getDefinition(id)` returns the
54
+ engine's full record for a built-in (icon, keywords, parameter classes, required resources);
55
+ `provenance` says which build produced the data.
49
56
  - **Signing.** `Shortcut.sign()` wraps `shortcuts sign` so the output imports on any device.
50
57
 
51
58
  ## How it compares
@@ -88,7 +95,7 @@ pip install shortcutkit
88
95
  ## Usage
89
96
 
90
97
  ```ts
91
- import { Shortcut, actions, ref, text } from "shortcutkit";
98
+ import { Shortcut, actions, ref, text, shortcutInput } from "shortcutkit";
92
99
 
93
100
  const s = new Shortcut("Greeting", { color: "Teal" });
94
101
  const got = s.action(actions.getstoredcontent, { WFStoredContentKey: "greeting" });
@@ -99,6 +106,20 @@ Shortcut.sign("Greeting.shortcut", "Greeting-signed.shortcut");
99
106
 
100
107
  Open the signed file and Shortcuts imports it.
101
108
 
109
+ ### Share sheet
110
+
111
+ A shortcut offered from the share sheet declares its surfaces and the input it accepts, and
112
+ reads that input with `shortcutInput()`:
113
+
114
+ ```ts
115
+ const s = new Shortcut("Page Links", { types: ["ActionExtension"], inputClasses: ["WFSafariWebPageContentItem"] });
116
+ const links = s.action(actions.runjavascriptonwebpage, { WFInput: shortcutInput(), WFJavaScript: "completion(document.links.length)" });
117
+ s.action(actions.showresult, { Text: text("Links: ", ref(links)) });
118
+ ```
119
+
120
+ `types` takes `ActionExtension` (share sheet), `QuickActions` (Finder and Services menus),
121
+ `MenuBar`, `NCWidget`, `WatchKit`, `Sleep` and `ReceivesOnScreenContent`.
122
+
102
123
  ### Control flow
103
124
 
104
125
  `if()` returns a grouping identifier that the matching `otherwise()` and `endIf()` calls take
@@ -186,9 +207,23 @@ cd python && python3 -m venv .venv && .venv/bin/pip install -e .
186
207
  .venv/bin/python -m shortcutkit demo /tmp/Demo.shortcut
187
208
  ```
188
209
 
189
- CI runs the type check, the tests, a Node import of the built package, a Python install and an
190
- unsigned build of the demo shortcut on macOS. Signing is not exercised in CI because the runner
191
- has no iCloud login.
210
+ CI runs the type check, the tests, a Node import of the built package, a Python install, the
211
+ engine verification below and an unsigned build of the demo shortcut on macOS. Signing is not
212
+ exercised in CI because the runner has no iCloud login.
213
+
214
+ ### Verifying against the engine
215
+
216
+ ```bash
217
+ bun run verify # ~3 min on a Mac that has opened Shortcuts.app once
218
+ ```
219
+
220
+ Both packages are driven over every action, every parameter key and every value form their
221
+ types admit, and the results are diffed against each other and then loaded through the
222
+ Shortcuts engine's own action objects, which report whether each value was read. Forms the
223
+ library refuses are written raw too, and the engine must refuse them as well. Whole shortcuts
224
+ built through every block helper are imported the way the app imports a file. The run fails on
225
+ any case the engine does not read; see `docs/extraction.md` for what it reports instead of
226
+ failing.
192
227
 
193
228
  ### Repository layout
194
229