mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-16 19:00:47 +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
56
openclaw_runtime/system_prompt.py
Normal file
56
openclaw_runtime/system_prompt.py
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from oclaw.openclaw_runtime.memory_stage import render_memory_context_block
|
||||
from oclaw.openclaw_runtime.project_context_prompt import build_project_context_block
|
||||
from oclaw.openclaw_runtime.skills_prompt import build_skills_catalog_block
|
||||
from oclaw.openclaw_runtime.types import OpenClawMemoryContext
|
||||
from oclaw.prompts.loader import render_openclaw_prompt
|
||||
from oclaw.tools.base import ToolRegistry
|
||||
|
||||
|
||||
def build_openclaw_executor_system_prompt(
|
||||
*,
|
||||
store: Any,
|
||||
tools: ToolRegistry | None,
|
||||
base_url: str,
|
||||
base_system: str,
|
||||
memory_context: OpenClawMemoryContext | None,
|
||||
lang: str,
|
||||
workspace_dir: str | None = None,
|
||||
skill_binding_role: str | None = None,
|
||||
) -> str:
|
||||
"""Build the final system string for the oclaw executor (memory block + skills catalog).
|
||||
|
||||
`lang` is reserved for future localized system fragments; current templates are bilingual/static.
|
||||
"""
|
||||
_ = lang # reserved for i18n extensions
|
||||
final_system = str(base_system or "").strip()
|
||||
project_block = build_project_context_block(store=store, workspace_dir=workspace_dir)
|
||||
if project_block:
|
||||
final_system = f"{final_system}\n\n{project_block}".strip()
|
||||
mem_block = render_memory_context_block(memory_context or OpenClawMemoryContext())
|
||||
if mem_block:
|
||||
final_system = render_openclaw_prompt(
|
||||
"runtime/system_with_memory.md",
|
||||
variables={"system_prompt": final_system, "memory_context": mem_block},
|
||||
strict=True,
|
||||
)
|
||||
if tools is not None:
|
||||
cat = build_skills_catalog_block(
|
||||
store=store,
|
||||
registry=tools,
|
||||
base_url=str(base_url or ""),
|
||||
skill_binding_role=skill_binding_role,
|
||||
)
|
||||
if cat.strip():
|
||||
final_system = render_openclaw_prompt(
|
||||
"runtime/system_with_skills.md",
|
||||
variables={"system_body": final_system, "skills_catalog": cat},
|
||||
strict=True,
|
||||
)
|
||||
return final_system
|
||||
|
||||
|
||||
__all__ = ["build_openclaw_executor_system_prompt"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue