-
Notifications
You must be signed in to change notification settings - Fork 41
refactor(pipeline): 优化 Pipeline 保存路径及浏览器打开逻辑 #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: 基于子串匹配的目录推断可能会误分类路径,改为检查路径段会更可靠。
由于当前启发式会查找类似
"downloads" in lower_path这样的子串,它同样会匹配诸如/home/user/mydownloads_backup或/data/documents_archive这样的路径,而且是第一个匹配就生效。为避免这种情况,建议遍历Path(file_path).parts,并将完整路径段与每个类别的一小段白名单进行匹配。这样推断出的起始目录会更准确,对于拥有类似命名文件夹的用户也不那么出乎意料。建议的实现:
maa_mcp/pipeline.py文件顶部已经导入了from pathlib import Path(看起来已经存在,因为使用了Path.home(),但最好确认一下)。file_path可能不是Path实例,请确保在此之前将其转换(例如file_path = Path(file_path))。Original comment in English
suggestion: Directory inference based on substring matching can misclassify paths and might be better done by inspecting path segments.
Because the heuristic looks for substrings like
"downloads" in lower_path, it will also match paths such as/home/user/mydownloads_backupor/data/documents_archive, and the first match wins. To avoid this, consider iterating overPath(file_path).partsand matching full path segments against a small whitelist per category. This should make the inferred start directory more accurate and less surprising for users with similarly named folders.Suggested implementation:
from pathlib import Pathis imported at the top ofmaa_mcp/pipeline.py(it appears to be present already sincePath.home()is used, but confirm).file_pathmight not be aPathinstance, ensure it is converted beforehand (e.g.,file_path = Path(file_path)).