@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/docs/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`.
|
package/json-contract.md
ADDED
|
@@ -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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moredrive/cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "MoreDrive command-line client",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/",
|
|
13
|
+
"docs/",
|
|
14
|
+
"schemas/",
|
|
15
|
+
"skills/",
|
|
16
|
+
"third-party/",
|
|
17
|
+
"*.md",
|
|
18
|
+
"build-info.json"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=22"
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"moredrive": "bin/moredrive.mjs"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/release-notes.md
ADDED
|
@@ -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
|
+
}
|