@moredrive/cli 0.0.0-stage → 1.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 +14 -2
- package/bin/moredrive.mjs +69 -0
- package/build-info.json +5 -0
- package/commands.md +165 -0
- package/docs/commands.md +165 -0
- package/docs/json-contract.md +58 -0
- package/docs/release-notes.md +15 -0
- package/docs/schemas/moredrive-cli-config-v1.schema.json +130 -0
- package/docs/schemas/moredrive-cli-jsonl-v2.1.schema.json +8675 -0
- package/docs/schemas/moredrive-cli-jsonl-v2.schema.json +7089 -0
- package/docs/schemas/moredrive-cli-output-v1.schema.json +388 -0
- package/docs/schemas/moredrive-cli-output-v2.1.schema.json +5836 -0
- package/docs/schemas/moredrive-cli-output-v2.schema.json +5278 -0
- package/docs/security.md +39 -0
- package/json-contract.md +58 -0
- package/package.json +24 -4
- package/release-notes.md +15 -0
- package/schemas/moredrive-cli-config-v1.schema.json +130 -0
- package/schemas/moredrive-cli-jsonl-v2.1.schema.json +8675 -0
- package/schemas/moredrive-cli-jsonl-v2.schema.json +7089 -0
- package/schemas/moredrive-cli-output-v1.schema.json +388 -0
- package/schemas/moredrive-cli-output-v2.1.schema.json +5836 -0
- package/schemas/moredrive-cli-output-v2.schema.json +5278 -0
- package/security.md +39 -0
- package/skills/moredrive-cli/SKILL.md +74 -0
- package/skills/moredrive-cli/agents/openai.yaml +4 -0
- package/third-party/commander-LICENSE +22 -0
- package/third-party/typebox-LICENSE +25 -0
package/build-info.json
ADDED
package/commands.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# CLI Commands
|
|
2
|
+
|
|
3
|
+
Global options:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
moredrive [command] --base-url <url> --profile default --config ./config.json --json
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Environment variables:
|
|
10
|
+
|
|
11
|
+
- `MOREDRIVE_BASE_URL`
|
|
12
|
+
- `MOREDRIVE_TOKEN`
|
|
13
|
+
- `MOREDRIVE_PROFILE`
|
|
14
|
+
- `MOREDRIVE_CONFIG`
|
|
15
|
+
- `MOREDRIVE_ASSUME_YES=1`
|
|
16
|
+
- `MOREDRIVE_SHARE_TOKEN`
|
|
17
|
+
|
|
18
|
+
## Auth
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
moredrive login --username alice --password-stdin --save --json
|
|
22
|
+
moredrive logout --json
|
|
23
|
+
moredrive whoami --json
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Worker APIs: `POST /api/auth/login`, `GET /api/auth/me`.
|
|
27
|
+
|
|
28
|
+
`login` never prints the token. With `--save`, the token is stored in the selected profile.
|
|
29
|
+
`--username` is required. Select exactly one password source: `--password` or `--password-stdin`.
|
|
30
|
+
|
|
31
|
+
## Config
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
moredrive config get --json
|
|
35
|
+
moredrive config set baseUrl https://moredrive-api.rdfstu.com/api --json
|
|
36
|
+
printf '%s' "$MOREDRIVE_TOKEN" | moredrive config set token --stdin --json
|
|
37
|
+
moredrive config set download.concurrency 8 --json
|
|
38
|
+
moredrive config set download.partSizeBytes 67108864 --json
|
|
39
|
+
moredrive config set download.multiRangeMinBytes 20971520 --json
|
|
40
|
+
moredrive config set download.userAgent pan.baidu.com --json
|
|
41
|
+
moredrive --profile automation config set baseUrl https://moredrive-api.rdfstu.com/api --json
|
|
42
|
+
moredrive config set defaultProfile automation --json
|
|
43
|
+
moredrive config profiles --json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Config output redacts tokens and includes the resolved `download` profile defaults. Download config keys are
|
|
47
|
+
`resume`, `concurrency`, `partSizeBytes`, `multiRangeMinBytes`, `maxRequestsPerDownload`,
|
|
48
|
+
`downloadInflightBytes`, `dlinkSoftTtlSeconds`, `maxDlinkRefreshPerDownload`, `userAgent`, and
|
|
49
|
+
`progressIntervalMs`.
|
|
50
|
+
`defaultProfile` must name an existing profile. `download.concurrency` is limited to `1-16`;
|
|
51
|
+
`partSizeBytes`, `multiRangeMinBytes`, `maxRequestsPerDownload`, and `downloadInflightBytes` must be positive
|
|
52
|
+
integers; `dlinkSoftTtlSeconds`, `maxDlinkRefreshPerDownload`, and `progressIntervalMs` may be zero.
|
|
53
|
+
|
|
54
|
+
## Drive
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
moredrive ls /docs --sort name --order asc --limit 1000 --json
|
|
58
|
+
moredrive search report --dir /docs --json
|
|
59
|
+
moredrive stat /docs/spec.md --json
|
|
60
|
+
moredrive stat fs_id:123 --json
|
|
61
|
+
moredrive mkdir /docs/new --parents --json
|
|
62
|
+
moredrive rename /docs/a.md b.md --json
|
|
63
|
+
moredrive mv /docs/a.md /archive/a.md --json
|
|
64
|
+
moredrive cp /docs/a.md /archive/copy.md --json
|
|
65
|
+
moredrive rm /archive/copy.md --yes --json
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Worker APIs: `drive/list`, `drive/search`, `drive/file/:fs_id`, `drive/mkdir`, `drive/operate`.
|
|
69
|
+
|
|
70
|
+
`rm` requires `--yes`. Directory deletion also requires `--recursive`.
|
|
71
|
+
|
|
72
|
+
Recursive download:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
moredrive download /docs --to ./downloads --recursive --jsonl
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This scans the complete Personal Drive tree and preserves `/docs/...` below the local root. It uses three file workers by default (`--file-concurrency 1-16`); `--concurrency` remains per-file Range concurrency. The scan is bounded at 5,000 files, 10,000 total entries, and 32 MiB of normalized metadata. Partial batches exit 1; `batch-limit-exceeded` exits 2. Empty directories complete without creating a local directory.
|
|
79
|
+
|
|
80
|
+
Offline schema discovery accepts `schema output --revision 2|2.1` and `schema jsonl --revision 2|2.1`; default output is the latest `2.1` artifact.
|
|
81
|
+
|
|
82
|
+
Automation must close child stdin unless a command explicitly consumes it. For stdin commands, write the input and close the stream to deliver EOF. Drain stdout and stderr concurrently while the process runs; do not wait for process exit before reading JSONL. Credential stdin is limited to 64 KiB, while `write` is bounded by `--max-bytes`. SIGINT cancels a pending stdin read and returns exit 130.
|
|
83
|
+
|
|
84
|
+
## Transfer
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
moredrive link /docs/a.zip --json
|
|
88
|
+
moredrive link /docs/a.zip --raw --json
|
|
89
|
+
moredrive download /docs/a.zip --to ./a.zip --json
|
|
90
|
+
moredrive download /docs/a.zip --to ./a.zip --concurrency 8 --part-size 64MiB --jsonl
|
|
91
|
+
moredrive download /docs/a.zip --to ./a.zip --no-resume --overwrite --json
|
|
92
|
+
moredrive download /docs/a.zip --to ./a.zip --user-agent pan.baidu.com --header "X-Trace: 1" --json
|
|
93
|
+
moredrive read /docs/spec.md --max-bytes 1048576 --json
|
|
94
|
+
moredrive upload ./a.md /docs/a.md --parents --json
|
|
95
|
+
echo "hello" | moredrive write /docs/hello.txt --json
|
|
96
|
+
echo "hello" | moredrive write /new/docs/hello.txt --parents --json
|
|
97
|
+
echo "replacement" | moredrive write /docs/hello.txt --overwrite --idempotency-key <stable-key> --json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Download always uses `dlink` direct transport in Node and sends `User-Agent: pan.baidu.com` by default. CLI does not call Worker download proxy. Large files at or above `download.multiRangeMinBytes` use bounded multi-range requests when the dlink host supports `Range`; the default range part size is `64MiB` and default concurrency is `8`. Completed ranges are stored in `target.part.json` and can be resumed. Final targets are only renamed into place after all parts complete.
|
|
101
|
+
|
|
102
|
+
Download flags:
|
|
103
|
+
|
|
104
|
+
| Flag | Default | Notes |
|
|
105
|
+
| --- | --- | --- |
|
|
106
|
+
| `--concurrency <n>` | profile or `8` | Active range request cap for one file. |
|
|
107
|
+
| `--max-concurrency <n>` | `16` | Safety cap; values above `16` are rejected. |
|
|
108
|
+
| `--part-size <size>` | profile or `64MiB` | Supports bytes, `KiB`, `MiB`, and `GiB`; `--chunk-size` is a compatibility alias. |
|
|
109
|
+
| `--resume` / `--no-resume` | profile or enabled | Matching `.part.json` manifests are reused by default. |
|
|
110
|
+
| `--user-agent <ua>` | profile or `pan.baidu.com` | Applies only to dlink downloads, not MoreDrive API requests. |
|
|
111
|
+
| `--header <name:value>` | none | Repeatable dlink request header; sensitive and downloader-controlled headers are rejected. |
|
|
112
|
+
| `--recursive` | off | Download a Personal Drive directory as a preserved-path batch. |
|
|
113
|
+
| `--file-concurrency <n>` | `3` | Concurrent files in recursive mode, from `1` to `16`. |
|
|
114
|
+
|
|
115
|
+
Upload requires `slice_upload_ticket` from `drive/upload/init` and uploads slices directly to the ticket endpoint. CLI does not fall back to Worker `drive/upload/slice`.
|
|
116
|
+
|
|
117
|
+
## Public Shares
|
|
118
|
+
|
|
119
|
+
### Save external Baidu shares (login required)
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
moredrive share save 'https://pan.baidu.com/s/1<share-key>?pwd=abcd' --to /imports --json
|
|
123
|
+
moredrive share save '<22-character-surl>' --password-stdin --to /imports --idempotency-key save-example-20261016 --json
|
|
124
|
+
moredrive share save '<baidu-url>' --to /imports --no-wait --json
|
|
125
|
+
moredrive share save-status <operation-id> --json
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
`share save` saves all top-level share entries into the current user's Personal Drive directory; the backend creates the target directory. It accepts standard Baidu `/s/1…` URLs, `/share/init?surl=…` URLs, or a 22-character surl. `pwd` is read from the URL; `--password` or `--password-stdin` overrides it (these two flags are mutually exclusive). Quote URLs in the shell. URL fragments are ignored; they do not select a share subdirectory. Knowledge-base links are unsupported.
|
|
129
|
+
|
|
130
|
+
Saves always send an idempotency key. Retain the returned `idempotencyKey` and `operationId`; after a submission timeout retry the same link, destination and passcode with the **same** key. A fresh key starts a new save intent. The default wait is 10 minutes; change it with `--operation-timeout 30s` or use `--no-wait`. A wait timeout or cancellation includes recovery identifiers. `share save-status` uses the external-save endpoint, distinct from `operation status` for file operations.
|
|
131
|
+
|
|
132
|
+
Only `completed` exits 0 by default. With `--no-wait`, `accepted` also exits 0. `running`, `partial`, `failed`, `unknown` and `requires-user-input` exit 1; `ok: true` means the status request succeeded, so also inspect `data.status`. On `unknown`, query status and avoid a new save intent. JSONL emits one final `result` or `failed` line. Validate these commands with revision `2.1` schemas. Output excludes the share URL/passcode and raw provider result.
|
|
133
|
+
|
|
134
|
+
### Read MoreDrive public shares
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
moredrive share access <share-id> --password <code> --json
|
|
138
|
+
moredrive share ls <share-id> / --share-token <token> --json
|
|
139
|
+
moredrive share stat <share-id> fs_id:123 --share-token <token> --json
|
|
140
|
+
moredrive share download <share-id> fs_id:123 --share-token <token> --to ./a.zip --json
|
|
141
|
+
moredrive share download <share-id> fs_id:123 --share-token <token> --to ./a.zip --concurrency 8 --jsonl
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Worker APIs: `share/:id/access`, `share/:id/list`, `share/:id/file`.
|
|
145
|
+
|
|
146
|
+
Share download uses `share file -> dlink -> direct download`. It supports the same resume, multi-range, UA, and header flags as private downloads, and refreshes the share file dlink when the lease expires. It does not call `share/:id/download` or `share/:id/preview`.
|
|
147
|
+
Use exactly one share token source: `--share-token`, `--share-token-file`, or `MOREDRIVE_SHARE_TOKEN`.
|
|
148
|
+
`share access --save-token-to <new-path>` creates a 0600 file and refuses to overwrite an existing file or symbolic link.
|
|
149
|
+
|
|
150
|
+
## Exit Codes
|
|
151
|
+
|
|
152
|
+
| Code | Meaning |
|
|
153
|
+
| --- | --- |
|
|
154
|
+
| 0 | Success |
|
|
155
|
+
| 1 | Generic failure |
|
|
156
|
+
| 2 | Invalid argument |
|
|
157
|
+
| 3 | Config error |
|
|
158
|
+
| 10 | Auth required or expired |
|
|
159
|
+
| 20 | Permission denied |
|
|
160
|
+
| 30 | Remote not found |
|
|
161
|
+
| 40 | Conflict |
|
|
162
|
+
| 50 | Network error |
|
|
163
|
+
| 60 | Upstream service error |
|
|
164
|
+
| 70 | Local IO error |
|
|
165
|
+
| 130 | Interrupted |
|
package/docs/commands.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# CLI Commands
|
|
2
|
+
|
|
3
|
+
Global options:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
moredrive [command] --base-url <url> --profile default --config ./config.json --json
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Environment variables:
|
|
10
|
+
|
|
11
|
+
- `MOREDRIVE_BASE_URL`
|
|
12
|
+
- `MOREDRIVE_TOKEN`
|
|
13
|
+
- `MOREDRIVE_PROFILE`
|
|
14
|
+
- `MOREDRIVE_CONFIG`
|
|
15
|
+
- `MOREDRIVE_ASSUME_YES=1`
|
|
16
|
+
- `MOREDRIVE_SHARE_TOKEN`
|
|
17
|
+
|
|
18
|
+
## Auth
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
moredrive login --username alice --password-stdin --save --json
|
|
22
|
+
moredrive logout --json
|
|
23
|
+
moredrive whoami --json
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Worker APIs: `POST /api/auth/login`, `GET /api/auth/me`.
|
|
27
|
+
|
|
28
|
+
`login` never prints the token. With `--save`, the token is stored in the selected profile.
|
|
29
|
+
`--username` is required. Select exactly one password source: `--password` or `--password-stdin`.
|
|
30
|
+
|
|
31
|
+
## Config
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
moredrive config get --json
|
|
35
|
+
moredrive config set baseUrl https://moredrive-api.rdfstu.com/api --json
|
|
36
|
+
printf '%s' "$MOREDRIVE_TOKEN" | moredrive config set token --stdin --json
|
|
37
|
+
moredrive config set download.concurrency 8 --json
|
|
38
|
+
moredrive config set download.partSizeBytes 67108864 --json
|
|
39
|
+
moredrive config set download.multiRangeMinBytes 20971520 --json
|
|
40
|
+
moredrive config set download.userAgent pan.baidu.com --json
|
|
41
|
+
moredrive --profile automation config set baseUrl https://moredrive-api.rdfstu.com/api --json
|
|
42
|
+
moredrive config set defaultProfile automation --json
|
|
43
|
+
moredrive config profiles --json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Config output redacts tokens and includes the resolved `download` profile defaults. Download config keys are
|
|
47
|
+
`resume`, `concurrency`, `partSizeBytes`, `multiRangeMinBytes`, `maxRequestsPerDownload`,
|
|
48
|
+
`downloadInflightBytes`, `dlinkSoftTtlSeconds`, `maxDlinkRefreshPerDownload`, `userAgent`, and
|
|
49
|
+
`progressIntervalMs`.
|
|
50
|
+
`defaultProfile` must name an existing profile. `download.concurrency` is limited to `1-16`;
|
|
51
|
+
`partSizeBytes`, `multiRangeMinBytes`, `maxRequestsPerDownload`, and `downloadInflightBytes` must be positive
|
|
52
|
+
integers; `dlinkSoftTtlSeconds`, `maxDlinkRefreshPerDownload`, and `progressIntervalMs` may be zero.
|
|
53
|
+
|
|
54
|
+
## Drive
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
moredrive ls /docs --sort name --order asc --limit 1000 --json
|
|
58
|
+
moredrive search report --dir /docs --json
|
|
59
|
+
moredrive stat /docs/spec.md --json
|
|
60
|
+
moredrive stat fs_id:123 --json
|
|
61
|
+
moredrive mkdir /docs/new --parents --json
|
|
62
|
+
moredrive rename /docs/a.md b.md --json
|
|
63
|
+
moredrive mv /docs/a.md /archive/a.md --json
|
|
64
|
+
moredrive cp /docs/a.md /archive/copy.md --json
|
|
65
|
+
moredrive rm /archive/copy.md --yes --json
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Worker APIs: `drive/list`, `drive/search`, `drive/file/:fs_id`, `drive/mkdir`, `drive/operate`.
|
|
69
|
+
|
|
70
|
+
`rm` requires `--yes`. Directory deletion also requires `--recursive`.
|
|
71
|
+
|
|
72
|
+
Recursive download:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
moredrive download /docs --to ./downloads --recursive --jsonl
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This scans the complete Personal Drive tree and preserves `/docs/...` below the local root. It uses three file workers by default (`--file-concurrency 1-16`); `--concurrency` remains per-file Range concurrency. The scan is bounded at 5,000 files, 10,000 total entries, and 32 MiB of normalized metadata. Partial batches exit 1; `batch-limit-exceeded` exits 2. Empty directories complete without creating a local directory.
|
|
79
|
+
|
|
80
|
+
Offline schema discovery accepts `schema output --revision 2|2.1` and `schema jsonl --revision 2|2.1`; default output is the latest `2.1` artifact.
|
|
81
|
+
|
|
82
|
+
Automation must close child stdin unless a command explicitly consumes it. For stdin commands, write the input and close the stream to deliver EOF. Drain stdout and stderr concurrently while the process runs; do not wait for process exit before reading JSONL. Credential stdin is limited to 64 KiB, while `write` is bounded by `--max-bytes`. SIGINT cancels a pending stdin read and returns exit 130.
|
|
83
|
+
|
|
84
|
+
## Transfer
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
moredrive link /docs/a.zip --json
|
|
88
|
+
moredrive link /docs/a.zip --raw --json
|
|
89
|
+
moredrive download /docs/a.zip --to ./a.zip --json
|
|
90
|
+
moredrive download /docs/a.zip --to ./a.zip --concurrency 8 --part-size 64MiB --jsonl
|
|
91
|
+
moredrive download /docs/a.zip --to ./a.zip --no-resume --overwrite --json
|
|
92
|
+
moredrive download /docs/a.zip --to ./a.zip --user-agent pan.baidu.com --header "X-Trace: 1" --json
|
|
93
|
+
moredrive read /docs/spec.md --max-bytes 1048576 --json
|
|
94
|
+
moredrive upload ./a.md /docs/a.md --parents --json
|
|
95
|
+
echo "hello" | moredrive write /docs/hello.txt --json
|
|
96
|
+
echo "hello" | moredrive write /new/docs/hello.txt --parents --json
|
|
97
|
+
echo "replacement" | moredrive write /docs/hello.txt --overwrite --idempotency-key <stable-key> --json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Download always uses `dlink` direct transport in Node and sends `User-Agent: pan.baidu.com` by default. CLI does not call Worker download proxy. Large files at or above `download.multiRangeMinBytes` use bounded multi-range requests when the dlink host supports `Range`; the default range part size is `64MiB` and default concurrency is `8`. Completed ranges are stored in `target.part.json` and can be resumed. Final targets are only renamed into place after all parts complete.
|
|
101
|
+
|
|
102
|
+
Download flags:
|
|
103
|
+
|
|
104
|
+
| Flag | Default | Notes |
|
|
105
|
+
| --- | --- | --- |
|
|
106
|
+
| `--concurrency <n>` | profile or `8` | Active range request cap for one file. |
|
|
107
|
+
| `--max-concurrency <n>` | `16` | Safety cap; values above `16` are rejected. |
|
|
108
|
+
| `--part-size <size>` | profile or `64MiB` | Supports bytes, `KiB`, `MiB`, and `GiB`; `--chunk-size` is a compatibility alias. |
|
|
109
|
+
| `--resume` / `--no-resume` | profile or enabled | Matching `.part.json` manifests are reused by default. |
|
|
110
|
+
| `--user-agent <ua>` | profile or `pan.baidu.com` | Applies only to dlink downloads, not MoreDrive API requests. |
|
|
111
|
+
| `--header <name:value>` | none | Repeatable dlink request header; sensitive and downloader-controlled headers are rejected. |
|
|
112
|
+
| `--recursive` | off | Download a Personal Drive directory as a preserved-path batch. |
|
|
113
|
+
| `--file-concurrency <n>` | `3` | Concurrent files in recursive mode, from `1` to `16`. |
|
|
114
|
+
|
|
115
|
+
Upload requires `slice_upload_ticket` from `drive/upload/init` and uploads slices directly to the ticket endpoint. CLI does not fall back to Worker `drive/upload/slice`.
|
|
116
|
+
|
|
117
|
+
## Public Shares
|
|
118
|
+
|
|
119
|
+
### Save external Baidu shares (login required)
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
moredrive share save 'https://pan.baidu.com/s/1<share-key>?pwd=abcd' --to /imports --json
|
|
123
|
+
moredrive share save '<22-character-surl>' --password-stdin --to /imports --idempotency-key save-example-20261016 --json
|
|
124
|
+
moredrive share save '<baidu-url>' --to /imports --no-wait --json
|
|
125
|
+
moredrive share save-status <operation-id> --json
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
`share save` saves all top-level share entries into the current user's Personal Drive directory; the backend creates the target directory. It accepts standard Baidu `/s/1…` URLs, `/share/init?surl=…` URLs, or a 22-character surl. `pwd` is read from the URL; `--password` or `--password-stdin` overrides it (these two flags are mutually exclusive). Quote URLs in the shell. URL fragments are ignored; they do not select a share subdirectory. Knowledge-base links are unsupported.
|
|
129
|
+
|
|
130
|
+
Saves always send an idempotency key. Retain the returned `idempotencyKey` and `operationId`; after a submission timeout retry the same link, destination and passcode with the **same** key. A fresh key starts a new save intent. The default wait is 10 minutes; change it with `--operation-timeout 30s` or use `--no-wait`. A wait timeout or cancellation includes recovery identifiers. `share save-status` uses the external-save endpoint, distinct from `operation status` for file operations.
|
|
131
|
+
|
|
132
|
+
Only `completed` exits 0 by default. With `--no-wait`, `accepted` also exits 0. `running`, `partial`, `failed`, `unknown` and `requires-user-input` exit 1; `ok: true` means the status request succeeded, so also inspect `data.status`. On `unknown`, query status and avoid a new save intent. JSONL emits one final `result` or `failed` line. Validate these commands with revision `2.1` schemas. Output excludes the share URL/passcode and raw provider result.
|
|
133
|
+
|
|
134
|
+
### Read MoreDrive public shares
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
moredrive share access <share-id> --password <code> --json
|
|
138
|
+
moredrive share ls <share-id> / --share-token <token> --json
|
|
139
|
+
moredrive share stat <share-id> fs_id:123 --share-token <token> --json
|
|
140
|
+
moredrive share download <share-id> fs_id:123 --share-token <token> --to ./a.zip --json
|
|
141
|
+
moredrive share download <share-id> fs_id:123 --share-token <token> --to ./a.zip --concurrency 8 --jsonl
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Worker APIs: `share/:id/access`, `share/:id/list`, `share/:id/file`.
|
|
145
|
+
|
|
146
|
+
Share download uses `share file -> dlink -> direct download`. It supports the same resume, multi-range, UA, and header flags as private downloads, and refreshes the share file dlink when the lease expires. It does not call `share/:id/download` or `share/:id/preview`.
|
|
147
|
+
Use exactly one share token source: `--share-token`, `--share-token-file`, or `MOREDRIVE_SHARE_TOKEN`.
|
|
148
|
+
`share access --save-token-to <new-path>` creates a 0600 file and refuses to overwrite an existing file or symbolic link.
|
|
149
|
+
|
|
150
|
+
## Exit Codes
|
|
151
|
+
|
|
152
|
+
| Code | Meaning |
|
|
153
|
+
| --- | --- |
|
|
154
|
+
| 0 | Success |
|
|
155
|
+
| 1 | Generic failure |
|
|
156
|
+
| 2 | Invalid argument |
|
|
157
|
+
| 3 | Config error |
|
|
158
|
+
| 10 | Auth required or expired |
|
|
159
|
+
| 20 | Permission denied |
|
|
160
|
+
| 30 | Remote not found |
|
|
161
|
+
| 40 | Conflict |
|
|
162
|
+
| 50 | Network error |
|
|
163
|
+
| 60 | Upstream service error |
|
|
164
|
+
| 70 | Local IO error |
|
|
165
|
+
| 130 | Interrupted |
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# JSON Contract
|
|
2
|
+
|
|
3
|
+
Every `--json` command writes exactly one JSON object to stdout.
|
|
4
|
+
|
|
5
|
+
Success:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"schemaVersion": "moredrive.cli.v2",
|
|
10
|
+
"ok": true,
|
|
11
|
+
"command": "drive.ls",
|
|
12
|
+
"data": {},
|
|
13
|
+
"warnings": [],
|
|
14
|
+
"meta": {
|
|
15
|
+
"durationMs": 12,
|
|
16
|
+
"baseUrl": "https://moredrive-api.rdfstu.com/api"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Failure:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"schemaVersion": "moredrive.cli.v2",
|
|
26
|
+
"ok": false,
|
|
27
|
+
"command": "drive.rm",
|
|
28
|
+
"error": {
|
|
29
|
+
"code": "invalid-argument",
|
|
30
|
+
"message": "rm requires --yes",
|
|
31
|
+
"retriable": false
|
|
32
|
+
},
|
|
33
|
+
"warnings": [],
|
|
34
|
+
"meta": {
|
|
35
|
+
"durationMs": 1
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Schemas:
|
|
41
|
+
|
|
42
|
+
- [moredrive-cli-output-v2.schema.json](./schemas/moredrive-cli-output-v2.schema.json)
|
|
43
|
+
- [moredrive-cli-jsonl-v2.schema.json](./schemas/moredrive-cli-jsonl-v2.schema.json)
|
|
44
|
+
- [moredrive-cli-config-v1.schema.json](./schemas/moredrive-cli-config-v1.schema.json)
|
|
45
|
+
- [moredrive-cli-output-v2.1.schema.json](./schemas/moredrive-cli-output-v2.1.schema.json)
|
|
46
|
+
- [moredrive-cli-jsonl-v2.1.schema.json](./schemas/moredrive-cli-jsonl-v2.1.schema.json)
|
|
47
|
+
|
|
48
|
+
Rules:
|
|
49
|
+
|
|
50
|
+
- JSON keys are camelCase.
|
|
51
|
+
- stdout is reserved for command data.
|
|
52
|
+
- stderr is reserved for human diagnostics.
|
|
53
|
+
- `--jsonl` emits one JSON object per line and ends with exactly one top-level `result` or `failed` event. Internal transfer events use distinct names.
|
|
54
|
+
- The JSONL schema is self-contained and can be compiled directly. Whole-stream validation additionally enforces command-family consistency, event ordering, terminal polarity, and no blank or trailing events.
|
|
55
|
+
- `--json` and `--jsonl` are mutually exclusive.
|
|
56
|
+
- `schema output/jsonl --revision 2` selects the legacy artifact; `2.1` and the default select the batch-aware artifact.
|
|
57
|
+
- URLs containing `access_token`, token values, passwords, cookies, and Authorization headers are redacted unless the user explicitly asks for `link --raw`.
|
|
58
|
+
- Recursive download success data uses `kind: "batch"` with stable item ordering. Batch items never expose provider `fsId`, raw metadata, dlinks, or headers; partial batch success still uses a success envelope and exits 1.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# MoreDrive CLI 1.3
|
|
2
|
+
|
|
3
|
+
- Recursive Personal Drive downloads are available with `download <directory> --recursive`; they preserve remote paths, use bounded file/Range concurrency, and report completed/partial/failed batch results. Scan limits are 5,000 files, 10,000 entries, and 32 MiB metadata.
|
|
4
|
+
- Batch-aware schema artifacts are published as `v2.1`; offline schema discovery accepts explicit revisions `2` and `2.1`. Revision `2` remains byte-for-byte immutable and validates only the legacy command surface; recursive batch consumers must use `2.1`.
|
|
5
|
+
|
|
6
|
+
- Bare `write` is create-only: a new path is created, an existing path returns `conflict`/exit 40, and `--overwrite` remains the explicit replacement intent.
|
|
7
|
+
- `--json` and `--jsonl` are mutually exclusive. JSONL has exactly one top-level `result` or `failed` terminal event; internal transfer events use distinct names.
|
|
8
|
+
- The public machine contract is `moredrive.cli.v2`; provider `raw`, dlink, upload identifiers, and unconstrained fields are no longer exposed.
|
|
9
|
+
- Streamed list items use the same public projection as terminal results. The standalone JSONL schema and protocol validator reject wrong terminal polarity, mixed command families, invalid ordering, blank lines, and truncated streams.
|
|
10
|
+
- Offline `schema output` and `schema jsonl` are available without config, token, or network access.
|
|
11
|
+
- Corrupt or incompatible config is `config-error`/exit 3 and must not be retried as a network failure.
|
|
12
|
+
- Credential argv remains supported for compatibility but is not recommended. Prefer environment, stdin, and file handoff options.
|
|
13
|
+
- Credential sources are mutually exclusive. Share-token file handoff creates a new 0600 file and refuses existing files or symbolic links.
|
|
14
|
+
- SIGINT is carried through destructive `rm` preflight and submission, so cancellation during stat cannot continue into deletion.
|
|
15
|
+
- The file package now contains the Skill, release docs, and schemas. The package filename, manifest, executable, and User-Agent use the CLI package version (`1.3.0`).
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://moredrive.local/schemas/moredrive-config-v1.json",
|
|
4
|
+
"title": "MoreDrive CLI config",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"schemaVersion",
|
|
8
|
+
"defaultProfile",
|
|
9
|
+
"profiles"
|
|
10
|
+
],
|
|
11
|
+
"additionalProperties": false,
|
|
12
|
+
"properties": {
|
|
13
|
+
"schemaVersion": {
|
|
14
|
+
"enum": [
|
|
15
|
+
"moredrive.config.v1",
|
|
16
|
+
"moredrive.config.v2"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"defaultProfile": {
|
|
20
|
+
"type": "string"
|
|
21
|
+
},
|
|
22
|
+
"profiles": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"additionalProperties": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"properties": {
|
|
27
|
+
"baseUrl": {
|
|
28
|
+
"type": "string"
|
|
29
|
+
},
|
|
30
|
+
"token": {
|
|
31
|
+
"type": "string"
|
|
32
|
+
},
|
|
33
|
+
"accessToken": {
|
|
34
|
+
"type": "string"
|
|
35
|
+
},
|
|
36
|
+
"refreshToken": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
39
|
+
"expiresAt": {
|
|
40
|
+
"type": "integer",
|
|
41
|
+
"minimum": 0
|
|
42
|
+
},
|
|
43
|
+
"refreshExpiresAt": {
|
|
44
|
+
"type": "integer",
|
|
45
|
+
"minimum": 0
|
|
46
|
+
},
|
|
47
|
+
"download": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"properties": {
|
|
50
|
+
"resume": {
|
|
51
|
+
"type": "boolean"
|
|
52
|
+
},
|
|
53
|
+
"concurrency": {
|
|
54
|
+
"type": "integer",
|
|
55
|
+
"minimum": 1,
|
|
56
|
+
"maximum": 16
|
|
57
|
+
},
|
|
58
|
+
"partSizeBytes": {
|
|
59
|
+
"type": "integer",
|
|
60
|
+
"minimum": 1
|
|
61
|
+
},
|
|
62
|
+
"multiRangeMinBytes": {
|
|
63
|
+
"type": "integer",
|
|
64
|
+
"minimum": 1
|
|
65
|
+
},
|
|
66
|
+
"maxRequestsPerDownload": {
|
|
67
|
+
"type": "integer",
|
|
68
|
+
"minimum": 1
|
|
69
|
+
},
|
|
70
|
+
"downloadInflightBytes": {
|
|
71
|
+
"type": "integer",
|
|
72
|
+
"minimum": 1
|
|
73
|
+
},
|
|
74
|
+
"dlinkSoftTtlSeconds": {
|
|
75
|
+
"type": "integer",
|
|
76
|
+
"minimum": 0
|
|
77
|
+
},
|
|
78
|
+
"maxDlinkRefreshPerDownload": {
|
|
79
|
+
"type": "integer",
|
|
80
|
+
"minimum": 0
|
|
81
|
+
},
|
|
82
|
+
"userAgent": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"minLength": 1
|
|
85
|
+
},
|
|
86
|
+
"progressIntervalMs": {
|
|
87
|
+
"type": "integer",
|
|
88
|
+
"minimum": 0
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"required": [],
|
|
92
|
+
"additionalProperties": false
|
|
93
|
+
},
|
|
94
|
+
"transfer": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"properties": {
|
|
97
|
+
"uploadSpeedLimit": {
|
|
98
|
+
"type": "integer",
|
|
99
|
+
"minimum": 0,
|
|
100
|
+
"maximum": 10737418240,
|
|
101
|
+
"default": 0,
|
|
102
|
+
"description": "File bytes/s shared by all uploads in this process; 0 unlimited. CLI --upload-limit overrides without saving; also accepts KiB/s and MiB/s."
|
|
103
|
+
},
|
|
104
|
+
"downloadSpeedLimit": {
|
|
105
|
+
"type": "integer",
|
|
106
|
+
"minimum": 0,
|
|
107
|
+
"maximum": 10737418240,
|
|
108
|
+
"default": 0,
|
|
109
|
+
"description": "File bytes/s shared by all downloads and connections in this process; 0 unlimited. CLI --download-limit overrides without saving; also accepts KiB/s and MiB/s."
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"required": [],
|
|
113
|
+
"additionalProperties": false
|
|
114
|
+
},
|
|
115
|
+
"createdAt": {
|
|
116
|
+
"type": "string"
|
|
117
|
+
},
|
|
118
|
+
"updatedAt": {
|
|
119
|
+
"type": "string"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"required": [],
|
|
123
|
+
"additionalProperties": false
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"sync": {
|
|
127
|
+
"type": "object"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|