mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-19 03:03:27 +08:00
初始化:独立 oclaw 仓库首提交
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
This commit is contained in:
commit
ba3836f00f
579 changed files with 83112 additions and 0 deletions
53
tests/test_prompt_ci_guard.py
Normal file
53
tests/test_prompt_ci_guard.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.platform.config.paths import PROJECT_ROOT
|
||||
|
||||
|
||||
_PROMPT_CRITICAL_FILES = (
|
||||
"oclaw/chat/agent.py",
|
||||
"oclaw/agents/network_ops_agent.py",
|
||||
"oclaw/agents/factory.py",
|
||||
"oclaw/chat/agent_messages.py",
|
||||
"oclaw/openclaw_runtime/system_prompt.py",
|
||||
"oclaw/openclaw_runtime/memory_stage.py",
|
||||
"oclaw/openclaw_runtime/project_context_prompt.py",
|
||||
"oclaw/chat/agent_errors.py",
|
||||
"oclaw/platform/llm/image_message_client.py",
|
||||
"oclaw/openclaw_runtime/gateway.py",
|
||||
)
|
||||
|
||||
|
||||
def test_prompt_critical_paths_use_prompt_templates() -> None:
|
||||
for rel in _PROMPT_CRITICAL_FILES:
|
||||
text = (PROJECT_ROOT / rel).read_text(encoding="utf-8")
|
||||
assert (
|
||||
"render_prompt(" in text
|
||||
or "render_prompt_for_lang(" in text
|
||||
or "render_openclaw_prompt(" in text
|
||||
), (
|
||||
f"{rel} must render prompts from oclaw/prompts*.md"
|
||||
)
|
||||
|
||||
|
||||
def test_prompt_markdown_frontmatter_keys_present() -> None:
|
||||
roots = [
|
||||
PROJECT_ROOT / "oclaw" / "prompts",
|
||||
PROJECT_ROOT / "oclaw" / "prompts_openclaw",
|
||||
]
|
||||
for prompts_root in roots:
|
||||
for p in prompts_root.rglob("*.md"):
|
||||
if p.name == "MAPPING.md":
|
||||
continue
|
||||
raw = p.read_text(encoding="utf-8-sig")
|
||||
# Some legacy prompt bodies (not templates) are intentionally frontmatter-free.
|
||||
# CI only enforces frontmatter keys when frontmatter exists.
|
||||
if not raw.startswith("---\n"):
|
||||
continue
|
||||
assert "\n---\n" in raw, f"{p} missing frontmatter end"
|
||||
fm = raw.split("\n---\n", 1)[0]
|
||||
assert "title:" in fm, f"{p} missing title"
|
||||
assert "summary:" in fm, f"{p} missing summary"
|
||||
assert "read_when:" in fm, f"{p} missing read_when"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue