activitysmith-cli 1.20.0 → 1.20.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 +61 -17
- package/package.json +1 -1
- package/src/approvals.js +26 -14
- package/src/cli.js +3 -6
package/README.md
CHANGED
|
@@ -710,9 +710,7 @@ activitysmith badge 0
|
|
|
710
710
|
|
|
711
711
|
## Approvals
|
|
712
712
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
Let your agents ask for your approval before they act, such as sending an email to customers or deploying to production. The request reaches your iPhone as a Live Activity or an actionable Push Notification, both with two buttons. The agent waits until you tap one and continues only when you approve.
|
|
713
|
+
Let your agents ask for your approval before they act, such as sending an email to customers or deploying to production. The request reaches your iPhone as a Time Sensitive Push Notification. Tap it to open the request on a review screen in the ActivitySmith app. Approve or reject it, or write a reply. The agent waits for your answer and continues only when you approve.
|
|
716
714
|
|
|
717
715
|
```bash
|
|
718
716
|
activitysmith approval request "Send the pricing update email to 214 customers?" \
|
|
@@ -732,10 +730,12 @@ Exit codes for `approval request` and `approval wait`:
|
|
|
732
730
|
- `1`: Rejected, timed out after 30 minutes, or cancelled. Do not continue.
|
|
733
731
|
- `2`: The request failed, for example because no device is paired.
|
|
734
732
|
- `3`: Still pending after `--timeout`, or sent with `--no-wait`.
|
|
733
|
+
- `4`: Replied. The reply text follows `Reply:`. Follow the reply instead of the original action.
|
|
734
|
+
- `5`: Chosen. The chosen option follows `Chosen:` and `Option ID:`. Do that option.
|
|
735
735
|
|
|
736
736
|
### Show the exact command
|
|
737
737
|
|
|
738
|
-
Add `--command` with the exact command that waits for approval. The
|
|
738
|
+
Add `--command` with the exact command that waits for approval. The review screen shows the command and the current directory:
|
|
739
739
|
|
|
740
740
|
```bash
|
|
741
741
|
activitysmith approval request "Run the database migration?" \
|
|
@@ -743,7 +743,61 @@ activitysmith approval request "Run the database migration?" \
|
|
|
743
743
|
--command "npm run db:migrate -- --env production"
|
|
744
744
|
```
|
|
745
745
|
|
|
746
|
-
Add `--details` for
|
|
746
|
+
Add `--details` for context, up to 4,000 characters. Add `--scope` to show where the action applies, such as `environment:production`.
|
|
747
|
+
|
|
748
|
+
### Add changes, links, and screenshots
|
|
749
|
+
|
|
750
|
+
Give the review screen what you need to decide:
|
|
751
|
+
|
|
752
|
+
```bash
|
|
753
|
+
activitysmith approval request "Deploy the new checkout to production?" \
|
|
754
|
+
--approve-label "Deploy" \
|
|
755
|
+
--git-changes main...HEAD \
|
|
756
|
+
--link "Pull request=https://github.com/acme/shop/pull/42" \
|
|
757
|
+
--screenshot "shots/checkout.png=New checkout"
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
- `--git-changes` adds a summary of `git diff`: how many files changed, the lines added and removed, and the 2 most changed files. Without a range, it uses the uncommitted changes.
|
|
761
|
+
- `--change <path:added:removed>` adds one file by hand, such as `src/app.ts:12:3`. Repeat it to add more files. Each file adds to the same summary.
|
|
762
|
+
- `--link <title=url>` adds an https link that opens in the app. Add up to 5.
|
|
763
|
+
- `--screenshot <file=title>` uploads a PNG, JPEG, or WebP file of up to 2 MB. The title is optional. Add up to 5.
|
|
764
|
+
|
|
765
|
+
Screenshots are deleted 7 days after the decision.
|
|
766
|
+
|
|
767
|
+
### Offer options
|
|
768
|
+
|
|
769
|
+
Ask the user to pick one of 2 to 4 options instead of approve or reject. Give each option an ID and a label. Add `--recommended` to mark the option you would pick:
|
|
770
|
+
|
|
771
|
+
```bash
|
|
772
|
+
activitysmith approval request "Which settings layout should I ship?" \
|
|
773
|
+
--option "tabs=Tabs across the top" \
|
|
774
|
+
--option "sidebar=Sidebar navigation" \
|
|
775
|
+
--recommended sidebar \
|
|
776
|
+
--option-screenshot tabs=shots/tabs.png \
|
|
777
|
+
--option-screenshot sidebar=shots/sidebar.png
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
The review screen letters the options A to D. When you choose one, the command prints the option and exits with code `5`:
|
|
781
|
+
|
|
782
|
+
```text
|
|
783
|
+
Chosen: Sidebar navigation
|
|
784
|
+
Option ID: sidebar
|
|
785
|
+
Do the chosen option.
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
Without an ID, as in `--option "Sidebar navigation"`, the options get the IDs `a`, `b`, `c`, and `d`.
|
|
789
|
+
|
|
790
|
+
### Read a reply
|
|
791
|
+
|
|
792
|
+
On the review screen, you can write a reply instead of a decision, such as "Send it tomorrow at 9 instead." The command then prints the reply and exits with code `4`:
|
|
793
|
+
|
|
794
|
+
```text
|
|
795
|
+
Replied. Read the reply and follow it. Do not run the original action unless the reply says to.
|
|
796
|
+
Reply:
|
|
797
|
+
Send it tomorrow at 9 instead.
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
Add `--json` to get the full approval with `status`, `reply`, `selected_option_id`, and `selected_option`.
|
|
747
801
|
|
|
748
802
|
### Wait in steps
|
|
749
803
|
|
|
@@ -761,19 +815,9 @@ activitysmith approval get apr_Xk3pQ8mV2nR7tL9w
|
|
|
761
815
|
activitysmith approval cancel apr_Xk3pQ8mV2nR7tL9w
|
|
762
816
|
```
|
|
763
817
|
|
|
764
|
-
Cancel a request when the action is no longer needed. Its
|
|
765
|
-
|
|
766
|
-
### Change how the request looks
|
|
818
|
+
Cancel a request when the action is no longer needed. Its Push Notification is removed from your devices.
|
|
767
819
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
```bash
|
|
771
|
-
activitysmith approval request "Refund order #4821 for $129?" \
|
|
772
|
-
--approve-label "Refund" \
|
|
773
|
-
--badge "Billing" \
|
|
774
|
-
--color orange \
|
|
775
|
-
--icon creditcard
|
|
776
|
-
```
|
|
820
|
+
`--delivery`, `--color`, `--icon`, and `--badge` are no longer used. The CLI still accepts them so older scripts keep working, and ignores them.
|
|
777
821
|
|
|
778
822
|
## Metadata
|
|
779
823
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "activitysmith-cli",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.1",
|
|
4
4
|
"description": "Command-line interface for ActivitySmith. Send Push Notifications, start, update, and end Live Activities, and set App Icon Badge Counts from your terminal.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"activitysmith",
|
package/src/approvals.js
CHANGED
|
@@ -7,8 +7,10 @@ export const APPROVAL_LIMITS = {
|
|
|
7
7
|
minOptions: 2,
|
|
8
8
|
maxOptions: 4,
|
|
9
9
|
optionLabel: 80,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
maxTopFiles: 2,
|
|
11
|
+
topFileName: 500,
|
|
12
|
+
maxFilesChanged: 1_000_000,
|
|
13
|
+
maxChangedLines: 1_000_000_000,
|
|
12
14
|
maxLinks: 5,
|
|
13
15
|
linkTitle: 120,
|
|
14
16
|
linkUrl: 2000,
|
|
@@ -133,19 +135,29 @@ export const readGitChanges = async (range, { cwd = process.cwd() } = {}) => {
|
|
|
133
135
|
}
|
|
134
136
|
};
|
|
135
137
|
|
|
136
|
-
//
|
|
138
|
+
// The name the review screen shows: the last path component. Full paths never leave the machine.
|
|
139
|
+
export const changedFileName = (path) => {
|
|
140
|
+
const trimmed = path.trim().replace(/[\\/]+$/, "");
|
|
141
|
+
const name = trimmed.slice(Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\")) + 1) || trimmed;
|
|
142
|
+
return name.slice(0, APPROVAL_LIMITS.topFileName);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Reduces changed files to what the review screen shows: the file count, the line totals, and the
|
|
146
|
+
// names of the 2 most changed files (added plus removed). Returns undefined when nothing changed.
|
|
137
147
|
export const buildApprovalChanges = (files) => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
const changed = files.filter((file) => file.path && file.path.trim());
|
|
149
|
+
if (changed.length === 0) return undefined;
|
|
150
|
+
// Array sort is stable, so files with the same line count keep their order.
|
|
151
|
+
const topFiles = [...changed]
|
|
152
|
+
.sort((a, b) => b.added + b.removed - (a.added + a.removed))
|
|
153
|
+
.slice(0, APPROVAL_LIMITS.maxTopFiles)
|
|
154
|
+
.map((file) => changedFileName(file.path));
|
|
155
|
+
return {
|
|
156
|
+
files_changed: Math.min(APPROVAL_LIMITS.maxFilesChanged, changed.length),
|
|
157
|
+
lines_added: Math.min(APPROVAL_LIMITS.maxChangedLines, changed.reduce((total, file) => total + file.added, 0)),
|
|
158
|
+
lines_removed: Math.min(APPROVAL_LIMITS.maxChangedLines, changed.reduce((total, file) => total + file.removed, 0)),
|
|
159
|
+
top_files: topFiles,
|
|
160
|
+
};
|
|
149
161
|
};
|
|
150
162
|
|
|
151
163
|
// Reads the type from the file signature, as the API does, so a renamed file fails before upload.
|
package/src/cli.js
CHANGED
|
@@ -2087,9 +2087,9 @@ approvalCommand
|
|
|
2087
2087
|
)
|
|
2088
2088
|
.option(
|
|
2089
2089
|
"--git-changes [range]",
|
|
2090
|
-
"Show the
|
|
2090
|
+
"Show the file count, line totals, and the 2 most changed file names from git diff: uncommitted changes, or a range such as main...HEAD"
|
|
2091
2091
|
)
|
|
2092
|
-
.option("--change <path:added:removed>", "A changed file and its line counts, such as src/app.ts:12:3. Repeatable", repeatable(parseChangeArgument))
|
|
2092
|
+
.option("--change <path:added:removed>", "A changed file and its line counts, such as src/app.ts:12:3. Repeatable. Adds to the same summary", repeatable(parseChangeArgument))
|
|
2093
2093
|
.option("--link <[title=]url>", "An https link to open from the review screen, such as a pull request. Repeatable, 5 at most", repeatable(parseLinkArgument))
|
|
2094
2094
|
.option("--channels <slugs>", "Comma-separated channel slugs. Omit to ask on every paired device")
|
|
2095
2095
|
.option("--timeout <seconds>", "Stop waiting after this many seconds and exit 3 if still pending", parsePositiveSeconds)
|
|
@@ -2124,10 +2124,7 @@ approvalCommand
|
|
|
2124
2124
|
...(options.gitChanges !== undefined ? await readGitChanges(options.gitChanges) : []),
|
|
2125
2125
|
...(options.change ?? []),
|
|
2126
2126
|
];
|
|
2127
|
-
const
|
|
2128
|
-
if (omitted > 0 && !globalOptions.json) {
|
|
2129
|
-
console.error(`Showing the ${APPROVAL_LIMITS.maxChangedFiles} most changed files. ${omitted} more are left out.`);
|
|
2130
|
-
}
|
|
2127
|
+
const changes = buildApprovalChanges(changedFiles);
|
|
2131
2128
|
const channels = String(options.channels ?? "")
|
|
2132
2129
|
.split(",")
|
|
2133
2130
|
.map((slug) => slug.trim())
|