diff --git a/build.py b/build.py index 94b952b..600183a 100644 --- a/build.py +++ b/build.py @@ -263,16 +263,32 @@ def obfuscate_scripts_dir(source_dir: str, target_dir: str) -> None: sys.exit(1) # 移动混淆后的文件到最终位置 + scripts_dst_dir = os.path.join(target_dir, "scripts") + pyarmor_runtime_dir = None + + # 先移动 scripts 目录 for item in os.listdir(temp_dir): src = os.path.join(temp_dir, item) - dst = os.path.join(target_dir, item) + if item == "scripts": + dst = os.path.join(target_dir, item) + if os.path.exists(dst): + if os.path.isdir(dst): + shutil.rmtree(dst) + else: + os.remove(dst) + shutil.move(src, dst) + elif item.startswith("pyarmor_runtime"): + pyarmor_runtime_dir = item + # 再移动 pyarmor_runtime 到 scripts 内部 + if pyarmor_runtime_dir: + src = os.path.join(temp_dir, pyarmor_runtime_dir) + dst = os.path.join(scripts_dst_dir, pyarmor_runtime_dir) if os.path.exists(dst): if os.path.isdir(dst): shutil.rmtree(dst) else: os.remove(dst) - shutil.move(src, dst) # 清理临时目录 diff --git a/openspec/config.yaml b/openspec/config.yaml index 6c3e6cf..db8d25c 100644 --- a/openspec/config.yaml +++ b/openspec/config.yaml @@ -8,7 +8,7 @@ context: | - 主机环境: 禁止污染配置,需操作须请求用户 - 开发文档: README.md,每次迭代按需更新开发文档; 禁emoji/特殊字符 - skill文档: SKILL.md,每次迭代按需更新skill文档 - - 测试: 所有需求必须设计全面测试 + - 测试: 所有需求必须设计全面测试,严禁跳过测试,无法进行的测试交用户决策 - 任务: 除非用户直接要求,禁止创建git变更任务(push/commit等); git读取允许(status/log/diff等) - 代码: 模块文件150-300行; 错误需自定义异常+清晰信息+位置上下文 - 项目阶段: 未上线,无用户,破坏性变更无需迁移说明 diff --git a/openspec/specs/skill-packaging/spec.md b/openspec/specs/skill-packaging/spec.md index db8da33..62ec57b 100644 --- a/openspec/specs/skill-packaging/spec.md +++ b/openspec/specs/skill-packaging/spec.md @@ -70,7 +70,7 @@ - **THEN** 系统不需要 --obfuscate 参数,直接执行混淆构建 ### Requirement: PyArmor 混淆执行 -系统 SHALL 调用 PyArmor 工具对 scripts 目录进行混淆。 +系统 SHALL 调用 PyArmor 工具对 scripts 目录进行混淆,然后将 pyarmor_runtime 目录移动到 scripts 内部。 #### Scenario: PyArmor 成功执行 - **WHEN** PyArmor 可用 @@ -78,7 +78,7 @@ #### Scenario: 混淆后文件输出 - **WHEN** PyArmor 混淆完成 -- **THEN** build/ 目录包含混淆后的文件和 pyarmor_runtime 子目录 +- **THEN** build/ 目录包含混淆后的 scripts 目录,且 pyarmor_runtime 子目录位于 scripts/ 内部 ### Requirement: PyArmor 未安装友好提示 系统 SHALL 在 PyArmor 未安装时提供清晰的错误提示,引导用户正确使用 `uv run --with pyarmor`。