mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-11-27 17:00:37 +00:00
fix(skill-creator): reject Windows device names during initialization (#8638)
This commit is contained in:
parent
ad3e86b784
commit
c5758d1bba
@ -217,7 +217,7 @@ Discovery follows operator-managed directory symlinks, but skips links back to a
|
|||||||
|
|
||||||
Skill Markdown and bundled text resources use UTF-8. Skill-creator CLI and review utilities read and write text explicitly as UTF-8 so localized skills behave consistently across operating systems.
|
Skill Markdown and bundled text resources use UTF-8. Skill-creator CLI and review utilities read and write text explicitly as UTF-8 so localized skills behave consistently across operating systems.
|
||||||
|
|
||||||
For standalone skill creation, `scripts/init_skill.py <skill-name> --path <directory>` creates a new direct child of the chosen directory. Names can be up to 40 characters long and consist of lowercase ASCII letters and digits, optionally grouped with single hyphens (for example, `data-analyzer`). The creator and packager write progress to stdout and report errors on stderr.
|
For standalone skill creation, `scripts/init_skill.py <skill-name> --path <directory>` creates a new direct child of the chosen directory. Names can be up to 40 characters long and consist of lowercase ASCII letters and digits, optionally grouped with single hyphens (for example, `data-analyzer`). The initializer rejects Windows reserved device names, such as `nul` and `com1`, on every platform before creating files. The creator and packager write progress to stdout and report errors on stderr.
|
||||||
|
|
||||||
For standalone skill exports, the bundled skill creator's `scripts/package_skill.py` can be run by file path from any directory, or as `python -m scripts.package_skill` from the skill-creator directory. Both entry points validate the skill before writing a `.skill` archive. The packager requires a regular `SKILL.md` file and skips symbolic links to files and directories in the skill. Copy any linked resources the skill needs into its directory before packaging.
|
For standalone skill exports, the bundled skill creator's `scripts/package_skill.py` can be run by file path from any directory, or as `python -m scripts.package_skill` from the skill-creator directory. Both entry points validate the skill before writing a `.skill` archive. The packager requires a regular `SKILL.md` file and skips symbolic links to files and directories in the skill. Copy any linked resources the skill needs into its directory before packaging.
|
||||||
|
|
||||||
|
|||||||
@ -217,6 +217,12 @@ def init_skill(skill_name, path):
|
|||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Keep the standalone initializer aligned with SkillStorage creation.
|
||||||
|
# The name grammar above excludes the other Windows device spellings.
|
||||||
|
if re.fullmatch(r"con|prn|aux|nul|com[1-9]|lpt[1-9]", skill_name):
|
||||||
|
print(f"❌ Error: Skill name {skill_name!r} is a reserved Windows device name.", file=sys.stderr)
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
root = Path(path).resolve()
|
root = Path(path).resolve()
|
||||||
skill_dir = root / skill_name
|
skill_dir = root / skill_name
|
||||||
|
|||||||
@ -80,8 +80,8 @@ def test_packager_reports_input_errors_on_stderr(tmp_path, source, diagnostic):
|
|||||||
assert diagnostic not in result.stdout
|
assert diagnostic not in result.stdout
|
||||||
|
|
||||||
|
|
||||||
def test_init_creates_skill_under_requested_root(tmp_path):
|
@pytest.mark.parametrize("name", ["example-" + "2" * 32, "com0", "nul-report"])
|
||||||
name = "example-" + "2" * 32
|
def test_init_creates_skill_under_requested_root(tmp_path, name):
|
||||||
root = tmp_path / "skills"
|
root = tmp_path / "skills"
|
||||||
result = run_cli("init_skill", name, "--path", root, cwd=tmp_path)
|
result = run_cli("init_skill", name, "--path", root, cwd=tmp_path)
|
||||||
assert result.returncode == 0, result.stdout + result.stderr
|
assert result.returncode == 0, result.stdout + result.stderr
|
||||||
@ -143,6 +143,15 @@ def test_init_rejects_invalid_name_before_creating_directories(tmp_path, name):
|
|||||||
assert not list(tmp_path.iterdir())
|
assert not list(tmp_path.iterdir())
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("name", ["con", "prn", "aux", "nul", "com1", "com9", "lpt1", "lpt9"])
|
||||||
|
def test_init_rejects_windows_device_names_before_creating_directories(tmp_path, name):
|
||||||
|
root = tmp_path / "skills"
|
||||||
|
result = run_cli("init_skill", name, "--path", root, cwd=tmp_path)
|
||||||
|
assert result.returncode == 1, result.stdout + result.stderr
|
||||||
|
assert f"Skill name {name!r} is a reserved Windows device name" in result.stderr
|
||||||
|
assert not root.exists()
|
||||||
|
|
||||||
|
|
||||||
def test_init_rejects_existing_directory_link(tmp_path):
|
def test_init_rejects_existing_directory_link(tmp_path):
|
||||||
root = tmp_path / "skills"
|
root = tmp_path / "skills"
|
||||||
root.mkdir()
|
root.mkdir()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user