Add DATA_PATHS golden standard and resolve_data_path helpers.
All checks were successful
技能自动化发布 / release (push) Successful in 5s
All checks were successful
技能自动化发布 / release (push) Successful in 5s
Document skill-owned file layout under user data dir, extend runtime_paths with standard subdir helpers, add POLICY-DATA-PATH-001, and update CONFIG/RUNTIME cross-references. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -44,6 +44,7 @@ POLICY_IDS = (
|
||||
"POLICY-CONTROL-001",
|
||||
"POLICY-CONTROL-002",
|
||||
"POLICY-CONTROL-003",
|
||||
"POLICY-DATA-PATH-001",
|
||||
)
|
||||
|
||||
STRUCTURE_PATHS = (
|
||||
@@ -681,6 +682,58 @@ class TestPolicyControl003(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
class TestPolicyDataPath001(unittest.TestCase):
|
||||
def test_env_example_has_no_cwd_relative_paths(self) -> None:
|
||||
path = os.path.join(get_skill_root(), ".env.example")
|
||||
offenders: list[str] = []
|
||||
with open(path, encoding="utf-8") as f:
|
||||
for lineno, line in enumerate(f, 1):
|
||||
stripped = line.strip()
|
||||
if not stripped or stripped.startswith("#"):
|
||||
continue
|
||||
active = stripped.split("#", 1)[0].strip()
|
||||
if re.search(r"=\s*\./", active):
|
||||
offenders.append(f".env.example:{lineno}: {active}")
|
||||
self.assertEqual(
|
||||
offenders,
|
||||
[],
|
||||
msg=_policy_msg(
|
||||
"POLICY-DATA-PATH-001",
|
||||
"development/DATA_PATHS.md",
|
||||
"\n".join(offenders) or "CWD-relative ./ paths in .env.example",
|
||||
),
|
||||
)
|
||||
|
||||
def test_runtime_paths_exposes_resolve_data_path(self) -> None:
|
||||
import util.runtime_paths as rp
|
||||
|
||||
self.assertTrue(callable(getattr(rp, "resolve_data_path", None)))
|
||||
self.assertTrue(callable(getattr(rp, "list_resolved_data_paths", None)))
|
||||
|
||||
def test_business_scripts_do_not_abspath_config_get(self) -> None:
|
||||
skill_root = get_skill_root()
|
||||
pattern = re.compile(r"os\.path\.abspath\s*\(\s*config\.get\b")
|
||||
offenders: list[str] = []
|
||||
for rel in _walk_files(skill_root, "scripts", suffix=".py"):
|
||||
if rel.replace("\\", "/") == "scripts/util/runtime_paths.py":
|
||||
continue
|
||||
text = _read_text(os.path.join(skill_root, rel))
|
||||
for lineno, line in enumerate(text.splitlines(), 1):
|
||||
if line.strip().startswith("#"):
|
||||
continue
|
||||
if pattern.search(line):
|
||||
offenders.append(f"{rel}:{lineno}: {line.strip()}")
|
||||
self.assertEqual(
|
||||
offenders,
|
||||
[],
|
||||
msg=_policy_msg(
|
||||
"POLICY-DATA-PATH-001",
|
||||
"development/DATA_PATHS.md",
|
||||
"\n".join(offenders),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class TestPolicyDocs001(unittest.TestCase):
|
||||
def test_policy_matrix_exists_and_lists_policy_ids(self) -> None:
|
||||
skill_root = get_skill_root()
|
||||
|
||||
Reference in New Issue
Block a user