@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/security.md ADDED
@@ -0,0 +1,39 @@
1
+ # CLI Security
2
+
3
+ Sensitive values:
4
+
5
+ - MoreDrive JWT
6
+ - share token
7
+ - password
8
+ - cookie
9
+ - `Authorization`
10
+ - Baidu dlink query values such as `access_token`
11
+
12
+ Prefer `MOREDRIVE_TOKEN`, `--password-stdin`, `MOREDRIVE_SHARE_TOKEN`, `--share-token-file`, and `config set token --stdin`. Credential argv may be visible in process lists and shell history. Select exactly one source for each credential. `share access --save-token-to` creates a new 0600 handoff file, refuses existing files and symbolic links, and omits the token from JSON; otherwise its token output is explicitly sensitive.
13
+
14
+ The CLI and client redact these values from errors and default JSON outputs. `moredrive link --raw --json` is the only MVP command path that intentionally returns a full dlink.
15
+
16
+ Config storage:
17
+
18
+ - The MVP stores tokens in the local JSON config file.
19
+ - POSIX writes attempt `0600` permissions.
20
+ - Windows ACL hardening is deferred.
21
+ - Token storage is isolated behind config helpers so a future keychain store can replace plaintext storage.
22
+
23
+ Destructive operations:
24
+
25
+ - `rm` requires `--yes` or `MOREDRIVE_ASSUME_YES=1`.
26
+ - Directory removal also requires `--recursive`.
27
+ - `/` is never deleted.
28
+
29
+ Recursive downloads perform a no-write scan and local target preflight before any dlink or file write. They reject symlink ancestors, including the nearest existing ancestor of a missing `--to` root, and unsafe preserved names. Batch JSON/JSONL omits dlinks, authorization headers, tokens, provider raw metadata, and `fsId`; absolute `localRoot` and `localPath` values can still appear in command logs, so use an isolated destination for sensitive automation.
30
+
31
+ Transfer safety:
32
+
33
+ - Download uses dlink direct transport with `User-Agent: pan.baidu.com`; Worker proxy download is not used by CLI MVP.
34
+ - Multi-range download writes to `target.part` and only exposes `target` after every completed range is verified by size and `Content-Range`.
35
+ - Resume manifests (`target.part.json`) store remote identity, range completion state, and a header fingerprint. They do not store raw dlinks, access tokens, share tokens, cookies, or authorization headers.
36
+ - `--header` rejects downloader-controlled headers (`Range`, `Content-Length`, `Host`, `Connection`), sensitive headers (`Authorization`, `Cookie`, `Proxy-Authorization`), and CRLF injection.
37
+ - If a dlink host ignores `Range`, CLI falls back to single-stream instead of combining unsafe byte ranges.
38
+ - Upload requires `slice_upload_ticket`; Worker proxy slice upload is not used by CLI MVP.
39
+ - If the Worker does not issue a ticket, CLI returns `unsupported`.
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: moredrive-cli
3
+ description: Safely use the MoreDrive CLI for Personal Drive reads and writes, public share access, uploads, downloads, machine-readable automation, recovery, verification, and cleanup. Use when an agent needs to inspect or transfer MoreDrive files, work with a public share, parse JSON or JSONL, or recover an interrupted CLI operation.
4
+ ---
5
+
6
+ # MoreDrive CLI
7
+
8
+ Use `moredrive --help` and command-specific `--help` as the argument contract. Resolve release documentation from this discovered `SKILL.md` path: the installed files are `../../docs/commands.md`, `../../docs/json-contract.md`, and `../../docs/security.md` relative to this file.
9
+
10
+ ## Choose Machine Output
11
+
12
+ - Use `--json --quiet` for one final object.
13
+ - Use `--jsonl --quiet` for progress streams. Parse one JSON object per line and require exactly one final top-level `result` or `failed` event.
14
+ - Never combine `--json` and `--jsonl`.
15
+ - Branch on `ok`, `error.code`, `error.retriable`, and the process exit code. Do not parse human prose.
16
+
17
+ ## Drive The Process Without Deadlocks
18
+
19
+ - The CLI is non-interactive. For commands without an explicit stdin flag, close child stdin immediately.
20
+ - For `--password-stdin`, `config set token --stdin`, or `write`, write the intended bytes and close stdin so the CLI receives EOF. Credential stdin is capped at 64 KiB; `write` uses `--max-bytes`.
21
+ - Drain stdout and stderr concurrently while the process runs. Do not wait for process exit before reading a JSONL stream, because an unread pipe can fill.
22
+ - Keep stdout exclusively for JSON/JSONL parsing. With `--jsonl --quiet`, consume lines continuously and require the final top-level terminal before treating the command as successful.
23
+
24
+ ## Authenticate Safely
25
+
26
+ - Prefer `MOREDRIVE_TOKEN` for an ephemeral app token. Treat it as a secret.
27
+ - For login, pipe the password to `moredrive login --username <name> --password-stdin --save --json`.
28
+ - Avoid `--token`, `--password`, and `--share-token`; argv may appear in process lists or shell history.
29
+ - For public shares, use `MOREDRIVE_SHARE_TOKEN` or `--share-token-file <path>`.
30
+ - Select exactly one credential source for each command; argv, stdin, file, and environment sources are mutually exclusive when they carry the same credential.
31
+ - Treat the token returned by `share access --json` as secret output. Prefer `--save-token-to <new-path>` for a 0600 handoff file; it refuses to overwrite an existing file or symbolic link.
32
+
33
+ ## Read Before Writing
34
+
35
+ 1. Run `stat` or `ls` with `--json` to confirm the exact target.
36
+ 2. Use `read --max-bytes <bytes> --json` for bounded UTF-8 text.
37
+ 3. Use `download --to <local-path> --jsonl` for binary or large data. Note that download output contains the local destination path.
38
+
39
+ ## Write With Explicit Intent
40
+
41
+ - Save an external Baidu share with `share save '<baidu-url-or-surl>' --to <remote-directory> --json`. Login is required; all top-level entries are saved and URL fragments do not select subdirectories. Use `--password-stdin` for a separate passcode; URL `pwd` is recognized automatically. Keep `operationId` and `idempotencyKey`, and recover using `share save-status <operation-id>` or the same submission key. `unknown` is not completion. `--no-wait` permits accepted submission; default waits up to 10 minutes. JSONL emits a final result only; use revision `2.1` schemas.
42
+
43
+ - Create only: pipe bytes to `moredrive write <remote-path> --json`. This succeeds only when the target is absent.
44
+ - Replace: add `--overwrite` only with explicit authorization after verifying the target.
45
+ - Set `--max-bytes` before supplying stdin.
46
+ - Add `--parents` when the remote parent directories may not exist.
47
+ - For an ambiguous write result, repeat the same path, content, flags, and `--idempotency-key`. Never generate a new key for that retry.
48
+ - Upload defaults to create-only. Add `--overwrite` only for an authorized replacement.
49
+ - Do not log stdin content, local absolute paths from upload/write, provider identifiers, raw dlinks, tokens, cookies, or authorization headers.
50
+
51
+ ## Recover
52
+
53
+ Use these default actions:
54
+
55
+ | Error | Action |
56
+ | --- | --- |
57
+ | `invalid-argument`, `config-error` | Fix local input or config; do not retry unchanged. |
58
+ | `auth-required`, `auth-expired` | Obtain valid authorization; do not retry unchanged. |
59
+ | `not-found` | Re-list the parent and verify the exact path. |
60
+ | `conflict` | Stop; request overwrite or destination-change authorization. |
61
+ | `network-timeout`, `network-unreachable` | Retry with bounded backoff when `retriable` is true. |
62
+ | `operation-submit-ambiguous` | Retry only with the reported idempotency key. |
63
+ | `cancelled` | Treat exit 130 as user interruption; resume downloads with the same destination. |
64
+ | `upstream-error` | Retry later with bounded backoff when `retriable` is true. |
65
+
66
+ Do not add an unbounded retry loop. A failed or truncated JSONL stream is never success.
67
+
68
+ ## Verify And Clean Up
69
+
70
+ After a write or upload, use `stat` and, when safe, a bounded `read` or downloaded hash to verify the result. Delete only an isolated path with `rm <path> --recursive --yes --json`; never delete `/`. Finish by verifying cleanup with `stat`, expecting `not-found` and exit 30.
71
+
72
+ For a folder download, use one root with `download <path> --to <directory> --recursive`. The CLI preserves the full remote path, uses three file workers by default (`--file-concurrency 1-16`), and keeps `--concurrency` for per-file Range requests. Scans are bounded at 5,000 files, 10,000 entries, and 32 MiB metadata. Partial results exit 1; `batch-limit-exceeded` exits 2. Batch output includes local paths, so use an isolated destination when command logs are shared. Validate recursive JSON/JSONL only with the `2.1` schema artifact.
73
+
74
+ Use `link` only for a redacted URL. `link --raw` intentionally emits a sensitive provider URL and requires explicit need and secret-safe handling.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "MoreDrive CLI"
3
+ short_description: "Safely automate MoreDrive CLI file and share workflows"
4
+ default_prompt: "Use the MoreDrive CLI to inspect, transfer, verify, and clean up files safely with machine-readable output."
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ TypeBox
2
+
3
+ Json Schema Type Builder with Static Type Resolution for TypeScript
4
+
5
+ The MIT License (MIT)
6
+
7
+ Copyright (c) 2017-2026 Haydn Paterson
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in
17
+ all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ THE SOFTWARE.