myagent-ai 1.23.40 → 1.23.41

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/cli.py +25 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myagent-ai",
3
- "version": "1.23.40",
3
+ "version": "1.23.41",
4
4
  "description": "本地桌面端执行型AI助手 - Open Interpreter 风格 | Local Desktop Execution-Oriented AI Assistant",
5
5
  "main": "main.py",
6
6
  "bin": {
package/scripts/cli.py CHANGED
@@ -340,13 +340,37 @@ async def cmd_rm(args):
340
340
  async def cmd_grep(args):
341
341
  """搜索文件内容"""
342
342
  import argparse
343
+ # [v1.23.40] 预过滤不支持的参数,防止 Agent 把系统 grep 参数传进来
344
+ _unsupported = {"-n", "--line-number", "-l", "--files-with-matches",
345
+ "-r", "-R", "--recursive", "-i", "--ignore-case",
346
+ "-c", "--count", "-w", "--word-regexp", "-v", "--invert-match",
347
+ "-e", "--regexp", "--include", "--exclude", "-E", "-F", "-P"}
348
+ _filtered = []
349
+ _skip_next = False
350
+ for i, a in enumerate(args):
351
+ if _skip_next:
352
+ _skip_next = False
353
+ continue
354
+ # 处理 -nPattern 或 --name=Value 格式
355
+ if a in _unsupported:
356
+ _skip_next = True
357
+ continue
358
+ if any(a.startswith(k) for k in _unsupported):
359
+ # 带值参数如 --max=50 这种已经在 argparse 处理了
360
+ if "=" not in a:
361
+ _skip_next = True
362
+ continue
363
+ _filtered.append(a)
364
+ if not _filtered:
365
+ _filtered = args # fallback
366
+
343
367
  p = argparse.ArgumentParser(prog="myagent-ai grep", description="在目录中搜索文件内容")
344
368
  p.add_argument("query", help="搜索关键词")
345
369
  p.add_argument("path", help="搜索目录路径")
346
370
  p.add_argument("-p", "--pattern", default="*", help="文件匹配模式 (如 *.py)")
347
371
  p.add_argument("--max", type=int, default=50, help="最大结果数 (默认50)")
348
372
  p.add_argument("--depth", type=int, default=10, help="最大递归深度 (默认10)")
349
- a = p.parse_args(args)
373
+ a = p.parse_args(_filtered)
350
374
 
351
375
  from skills.file_skill import FileSearchSkill
352
376
  skill = FileSearchSkill()