vibego 0.2.55__py3-none-any.whl → 0.2.57__py3-none-any.whl

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.

Potentially problematic release.


This version of vibego might be problematic. Click here for more details.

bot.py CHANGED
@@ -1344,6 +1344,36 @@ ATTACHMENT_USAGE_HINT = (
1344
1344
  _FS_SAFE_PATTERN = re.compile(r"[^A-Za-z0-9._-]")
1345
1345
 
1346
1346
 
1347
+ def _attachment_directory_prefix_for_display(relative_path: str) -> Optional[str]:
1348
+ """根据附件相对路径推导目录前缀,便于提示模型定位。"""
1349
+
1350
+ path_str = (relative_path or "").strip()
1351
+ if not path_str:
1352
+ return None
1353
+
1354
+ try:
1355
+ parent = Path(path_str).parent
1356
+ except Exception:
1357
+ return None
1358
+
1359
+ parent_str = parent.as_posix()
1360
+ if parent_str in {"", "."}:
1361
+ if path_str.startswith("./"):
1362
+ parent_str = "./"
1363
+ elif path_str.startswith("/"):
1364
+ parent_str = "/"
1365
+ else:
1366
+ return None
1367
+ else:
1368
+ if path_str.startswith("./") and not parent_str.startswith(("./", "/")):
1369
+ parent_str = f"./{parent_str}"
1370
+
1371
+ if not parent_str.endswith("/"):
1372
+ parent_str = f"{parent_str}/"
1373
+
1374
+ return parent_str
1375
+
1376
+
1347
1377
  def _sanitize_fs_component(value: str, fallback: str) -> str:
1348
1378
  """清理路径片段中的特殊字符,避免越权访问。"""
1349
1379
 
@@ -1417,16 +1447,27 @@ def _guess_extension(mime_type: Optional[str], fallback: str = ".bin") -> str:
1417
1447
 
1418
1448
 
1419
1449
  def _attachment_dir_for_message(message: Message, media_group_id: Optional[str] = None) -> Path:
1420
- """为当前消息(或媒体组)生成稳定的附件目录。"""
1450
+ """为当前消息生成附件目录,按项目标识 + 日期归档,便于模型定位。"""
1421
1451
 
1422
- chat_part = _sanitize_fs_component(str(message.chat.id), "chat")
1423
- base = ATTACHMENT_STORAGE_ROOT / chat_part
1424
- if media_group_id:
1425
- group_part = _sanitize_fs_component(media_group_id, str(message.message_id))
1426
- target = base / f"group_{group_part}"
1427
- else:
1428
- timestamp = int((message.date or datetime.now(UTC)).timestamp())
1429
- target = base / f"msg_{timestamp}_{message.message_id}"
1452
+ # media_group_id 参数保留用于兼容旧调用,目前统一归档至日期目录。
1453
+ _ = media_group_id
1454
+
1455
+ # 优先使用项目 slug,回退到 bot 名称或通用前缀。
1456
+ project_identifier = PROJECT_SLUG or ""
1457
+ sanitized_project = _sanitize_fs_component(project_identifier, "project")
1458
+ if sanitized_project == "project":
1459
+ bot_username = getattr(message.bot, "username", None)
1460
+ sanitized_project = _sanitize_fs_component(bot_username or "bot", "bot")
1461
+
1462
+ # 使用消息时间(UTC)格式化日期,确保相同日期的附件集中存放。
1463
+ event_time = message.date or datetime.now(UTC)
1464
+ try:
1465
+ event_time = event_time.astimezone(UTC)
1466
+ except Exception:
1467
+ event_time = datetime.now(UTC)
1468
+ date_component = event_time.strftime("%Y-%m-%d")
1469
+
1470
+ target = ATTACHMENT_STORAGE_ROOT / sanitized_project / date_component
1430
1471
  target.mkdir(parents=True, exist_ok=True)
1431
1472
  return target
1432
1473
 
@@ -1617,7 +1658,15 @@ def _build_prompt_with_attachments(
1617
1658
  if base_text:
1618
1659
  sections.append(base_text)
1619
1660
  if attachments:
1620
- lines = ["附件列表(文件位于项目工作目录,可直接读取):"]
1661
+ directory_hint: Optional[str] = None
1662
+ for item in attachments:
1663
+ directory_hint = _attachment_directory_prefix_for_display(item.relative_path)
1664
+ if directory_hint:
1665
+ break
1666
+ if directory_hint:
1667
+ lines = [f"附件列表(文件位于项目工作目录({directory_hint}),可直接读取):"]
1668
+ else:
1669
+ lines = ["附件列表(文件位于项目工作目录,可直接读取):"]
1621
1670
  for idx, item in enumerate(attachments, 1):
1622
1671
  lines.append(
1623
1672
  f"{idx}. {item.display_name}({item.mime_type})→ {item.relative_path}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vibego
3
- Version: 0.2.55
3
+ Version: 0.2.57
4
4
  Summary: vibego CLI:用于初始化与管理 Telegram Master Bot 的工具
5
5
  Author: Hypha
6
6
  License-Expression: LicenseRef-Proprietary
@@ -1,4 +1,4 @@
1
- bot.py,sha256=hjebHpgW7tR9fNxkdbgNLFNYaz4MNgtsq_Sci2VljPM,289835
1
+ bot.py,sha256=-on8QBKAHcMtSWShP3cvqTJof2gWXLMUtPieaj7EpmM,291534
2
2
  logging_setup.py,sha256=gvxHi8mUwK3IhXJrsGNTDo-DR6ngkyav1X-tvlBF_IE,4613
3
3
  master.py,sha256=Jwxf6I94jOADzb9Xio1wb-tWy5wgQ9PlmdpKW4mhQMg,117114
4
4
  project_repository.py,sha256=UcthtSGOJK0cTE5bQCneo3xkomRG-kyc1N1QVqxeHIs,17577
@@ -426,14 +426,14 @@ tasks/constants.py,sha256=tS1kZxBIUm3JJUMHm25XI-KHNUZl5NhbbuzjzL_rF-c,299
426
426
  tasks/fsm.py,sha256=rKXXLEieQQU4r2z_CZUvn1_70FXiZXBBugF40gpe_tQ,1476
427
427
  tasks/models.py,sha256=N_qqRBo9xMSV0vbn4k6bLBXT8C_dp_oTFUxvdx16ZQM,2459
428
428
  tasks/service.py,sha256=w_S_aWiVqRXzXEpimLDsuCCCX2lB5uDkff9aKThBw9c,41916
429
- vibego_cli/__init__.py,sha256=asbT5tFazlPcS692PW0b6GBg_fWkYpf-mZn02hiG-p4,311
429
+ vibego_cli/__init__.py,sha256=4SS400ravryVKHd1SCM6mZ6KOnzAD0aN3Bzkhcg9rb0,311
430
430
  vibego_cli/__main__.py,sha256=qqTrYmRRLe4361fMzbI3-CqpZ7AhTofIHmfp4ykrrBY,158
431
431
  vibego_cli/config.py,sha256=VxkPJMq01tA3h3cOkH-z_tiP7pMgfSGGicRvUnCWkhI,3054
432
432
  vibego_cli/deps.py,sha256=1nRXI7Dd-S1hYE8DligzK5fIluQWETRUj4_OKL0DikQ,1419
433
433
  vibego_cli/main.py,sha256=X__NXwZnIDIFbdKSTbNyZgZHKcPlN0DQz9sqTI1aQ9E,12158
434
434
  vibego_cli/data/worker_requirements.txt,sha256=QSt30DSSSHtfucTFPpc7twk9kLS5rVLNTcvDiagxrZg,62
435
- vibego-0.2.55.dist-info/METADATA,sha256=McMxELuZfQ_ByCmOD3gRCEIqec4IHYK1pPNjMpn8xxM,10519
436
- vibego-0.2.55.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
437
- vibego-0.2.55.dist-info/entry_points.txt,sha256=Lsy_zm-dlyxt8-9DL9blBReIwU2k22c8-kifr46ND1M,48
438
- vibego-0.2.55.dist-info/top_level.txt,sha256=R56CT3nW5H5v3ce0l3QDN4-C4qxTrNWzRTwrxnkDX4U,69
439
- vibego-0.2.55.dist-info/RECORD,,
435
+ vibego-0.2.57.dist-info/METADATA,sha256=uYSuc5xbtB4s-QP6Fmq7PU2IuECkWBoJomUrSa-NuZg,10519
436
+ vibego-0.2.57.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
437
+ vibego-0.2.57.dist-info/entry_points.txt,sha256=Lsy_zm-dlyxt8-9DL9blBReIwU2k22c8-kifr46ND1M,48
438
+ vibego-0.2.57.dist-info/top_level.txt,sha256=R56CT3nW5H5v3ce0l3QDN4-C4qxTrNWzRTwrxnkDX4U,69
439
+ vibego-0.2.57.dist-info/RECORD,,
vibego_cli/__init__.py CHANGED
@@ -7,6 +7,6 @@ from __future__ import annotations
7
7
 
8
8
  __all__ = ["main", "__version__"]
9
9
 
10
- __version__ = "0.2.55"
10
+ __version__ = "0.2.57"
11
11
 
12
12
  from .main import main # noqa: E402