baiduwangpan-cli 1.1.2 → 1.1.3

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
@@ -146,7 +146,8 @@ bdp gtree <gid> [--depth N] [--concurrency N] [--max-nodes N]
146
146
  bdp gsearch <gid> <keyword> 搜索群文件名 (全量遍历目录)
147
147
  [--page N] [--limit N] [--depth N] [--concurrency N]
148
148
  [--max-pages N] [--max-requests N] [--no-unique]
149
- [--all|--all-results] [--timeout N] [--save-partial] [--no-cache]
149
+ [--all|--all-results] [--timeout N] [--save-partial]
150
+ [--any-word] [--exact] [--no-cache]
150
151
  bdp cache [clear] 查看 / 清空会话缓存 (~/.bdp/cache/)
151
152
  ```
152
153
 
@@ -175,6 +176,8 @@ bdp cache [clear] 查看 / 清空会话缓存 (~/.bdp/cache/)
175
176
  --all, --all-results 忽略分页获取全部结果 (gsearch; 不限时, 慢但完整)
176
177
  --timeout <N> 超时秒数,到点返回已扫到的部分结果 (gsearch; 0=不限时, 默认 0)
177
178
  --save-partial 未完整时自动把已搜到的结果存为 JSON 并打印路径 (gsearch; 配 --json-file 时写该文件)
179
+ --any-word 空格分隔关键词命中任意一个即可 (gsearch; 默认=全部命中 AND)
180
+ --exact 按文件名精确匹配,忽略路径前缀 (gsearch; 大小写不敏感)
178
181
  --no-cache 禁用会话缓存 (gsearch/gtree/gshares/gls)
179
182
  ```
180
183
 
package/bin/bdp.js CHANGED
@@ -91,6 +91,10 @@ function parseArgs(argv) {
91
91
  opts.flags.timeoutMs = parseInt(argv[++i], 10) || 0;
92
92
  } else if (arg === "--save-partial") {
93
93
  opts.flags.savePartial = true;
94
+ } else if (arg === "--any-word") {
95
+ opts.flags.anyWord = true;
96
+ } else if (arg === "--exact") {
97
+ opts.flags.exact = true;
94
98
  } else if (arg === "-n" || arg === "--lines") {
95
99
  opts.flags.n = parseInt(argv[++i], 10) || 20;
96
100
  } else if (arg === "-p" || arg === "--path") {
@@ -483,6 +487,8 @@ cmds.gsearch = async (args, json) => {
483
487
  concurrency: args.flags.concurrency || 4,
484
488
  unique: args.flags.unique !== false,
485
489
  all: args.flags.all === true,
490
+ exact: args.flags.exact === true,
491
+ anyWord: args.flags.anyWord === true,
486
492
  timeoutMs: args.flags.timeoutMs || (args.flags.timeout ? args.flags.timeout * 1000 : 0),
487
493
  depth: args.flags.depth || 1,
488
494
  maxPages: args.flags.maxPages || 50,
@@ -536,7 +542,7 @@ cmds.gsearch = async (args, json) => {
536
542
  );
537
543
  };
538
544
 
539
- verboseLog(args, `gsearch gid=${gid} keyword="${keyword}" page=${opts.page} limit=${opts.limit} concurrency=${opts.concurrency} unique=${opts.unique} all=${opts.all} timeoutMs=${opts.timeoutMs} savePartial=${savePartial} depth=${opts.depth} maxPages=${opts.maxPages} maxRequests=${opts.maxRequests} cache=${opts.cache}`);
545
+ verboseLog(args, `gsearch gid=${gid} keyword="${keyword}" page=${opts.page} limit=${opts.limit} concurrency=${opts.concurrency} unique=${opts.unique} all=${opts.all} exact=${opts.exact} anyWord=${opts.anyWord} timeoutMs=${opts.timeoutMs} savePartial=${savePartial} depth=${opts.depth} maxPages=${opts.maxPages} maxRequests=${opts.maxRequests} cache=${opts.cache}`);
540
546
  const result = await group.searchFiles(gid, keyword, opts);
541
547
 
542
548
  if (result.partial) {
@@ -659,7 +665,8 @@ GROUP CHAT OPERATIONS (群聊)
659
665
  gsearch <gid> <keyword> Search group file names (全量遍历目录, 缓存命中秒回)
660
666
  [--page N] [--limit N] [--depth N] [--concurrency N]
661
667
  [--max-pages N] [--max-requests N] [--no-unique]
662
- [--all|--all-results] [--timeout N] [--save-partial] [--no-cache]
668
+ [--all|--all-results] [--timeout N] [--save-partial]
669
+ [--any-word] [--exact] [--no-cache]
663
670
  cache [clear] Show cache info or clear session cache
664
671
  error <code> Explain an error code (e.g. -3)
665
672
 
@@ -692,6 +699,8 @@ OPTIONS
692
699
  --all, --all-results Fetch all results, no paging (gsearch; slow but never truncates)
693
700
  --timeout <N> Abort after N seconds and return partial results (gsearch; 0=unlimited)
694
701
  --save-partial Auto-save partial results to JSON when scan is incomplete (gsearch)
702
+ --any-word Match ANY of the space-separated keywords (OR) (gsearch; default=ALL)
703
+ --exact Match exact file name (case-insensitive) instead of substring (gsearch)
695
704
 
696
705
  EXAMPLES
697
706
  bdp login --bduss abc123 --stoken def456
package/lib/group.js CHANGED
@@ -514,7 +514,25 @@ async function treeFiles(gid, options = {}) {
514
514
 
515
515
  async function searchFiles(gid, keyword, options = {}) {
516
516
  const gidS = toStr(gid);
517
- const kw = keyword.toLowerCase();
517
+
518
+ // 关键词解析:空格分隔多关键词。
519
+ // - 默认(all):每个词都要出现(AND,可换序)→ "玄空 飞星" 只命中同时含两者的名字(精确收窄)
520
+ // - --any-word:任一词出现即可(OR,更宽)→ "玄空 飞星" 命中含"玄空"或"飞星"的名字
521
+ // - --exact:整名精确相等(最严格);单关键词默认仍是子串包含(兼容旧行为)
522
+ const rawKw = String(keyword).toLowerCase();
523
+ const words = rawKw.split(/\s+/).filter(Boolean);
524
+ const matchMode = options.exact ? "exact" : (options.anyWord ? "any" : "all");
525
+ const matchesName = (name) => {
526
+ const n = String(name || "").toLowerCase();
527
+ if (matchMode === "exact") {
528
+ // 精确匹配按文件名(去掉路径前缀),顶层分享 name 形如 "/xxx",子目录文件 name 无前缀
529
+ const base = n.includes("/") ? n.slice(n.lastIndexOf("/") + 1) : n;
530
+ return base === rawKw;
531
+ }
532
+ if (words.length <= 1) return n.includes(rawKw);
533
+ if (matchMode === "any") return words.some((w) => n.includes(w));
534
+ return words.every((w) => n.includes(w));
535
+ };
518
536
 
519
537
  const limit = options.limit || 50;
520
538
  const page = options.page || 1;
@@ -570,7 +588,7 @@ async function searchFiles(gid, keyword, options = {}) {
570
588
  for (const share of shares) {
571
589
  if (finished) break;
572
590
  if (!share.isDir) scannedShares++;
573
- if (share.name.toLowerCase().includes(kw)) {
591
+ if (matchesName(share.name)) {
574
592
  pushIfMatch({
575
593
  name: share.name,
576
594
  path: share.name,
@@ -617,7 +635,7 @@ async function searchFiles(gid, keyword, options = {}) {
617
635
  maxPages, cache, budget, throttleState,
618
636
  });
619
637
  if (cached) cachedDirs++;
620
- const matches = files.filter((f) => f.name.toLowerCase().includes(kw));
638
+ const matches = files.filter((f) => matchesName(f.name));
621
639
  const subDirs = files.filter((f) => f.isDir);
622
640
  return { matches, subDirs };
623
641
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baiduwangpan-cli",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "百度网盘 CLI — 全盘读写 · 免下载读取文件内容 · 群聊文件浏览 (Agent 友好)",
5
5
  "main": "lib/index.js",
6
6
  "bin": {