105 lines
4.5 KiB
Python
105 lines
4.5 KiB
Python
#!/usr/bin/env python3
|
||
"""Load the bounded current HoloLake office cognition."""
|
||
from __future__ import annotations
|
||
|
||
import argparse
|
||
import importlib.util
|
||
import json
|
||
from pathlib import Path
|
||
|
||
ROOT = Path("/Volumes/JZAO/HoloLake/persona-runtime/repo-012-main")
|
||
OFFICE = ROOT / "eternal-lake-heart/heartbeat-core/office-building-current/offices/HB-OFFICE-HOLOLAKE-0001"
|
||
COMPUTER = OFFICE / "smart-computer/office_computer.py"
|
||
MULTIPATH_CONSOLE = ROOT / "server-tools/heartbeat-multipath-console/console.py"
|
||
BRAIN = OFFICE / "brain/BRAIN-PACK.md"
|
||
|
||
|
||
def load_computer():
|
||
spec = importlib.util.spec_from_file_location("hololake_office_computer", COMPUTER)
|
||
module = importlib.util.module_from_spec(spec)
|
||
spec.loader.exec_module(module)
|
||
return module
|
||
|
||
|
||
def load_multipath_console():
|
||
spec = importlib.util.spec_from_file_location("hololake_multipath_console", MULTIPATH_CONSOLE)
|
||
module = importlib.util.module_from_spec(spec)
|
||
spec.loader.exec_module(module)
|
||
return module
|
||
|
||
|
||
def load(intent: str) -> dict:
|
||
computer = load_computer()
|
||
audit = computer.audit()
|
||
if audit["outcome"] != "PASS":
|
||
raise ValueError("HOLOLAKE_OFFICE_AUDIT_FAILED:" + ",".join(audit["errors"]))
|
||
status = computer.status()
|
||
multipath = load_multipath_console().status()
|
||
return {
|
||
"schema": "guanghu.hololake-development-brain-context/v1",
|
||
"state": "HOLOLAKE_DEVELOPMENT_BRAIN_LOADED",
|
||
"intent": intent,
|
||
"office_id": status["office"],
|
||
"building": status["building"],
|
||
"office_board": status["office_board"],
|
||
"time": status["time"],
|
||
"generation": status["generation"],
|
||
"latest_evolution_node": status["latest_evolution_node"],
|
||
"current_work": status["current_work"],
|
||
"stage1": status["stage1"],
|
||
"multipath_console": multipath,
|
||
"repo012_head": status["repo012_head"],
|
||
"next": status["next"],
|
||
"brain_pack": str(BRAIN),
|
||
"smart_computer": str(COMPUTER),
|
||
"details_policy": "NUMBERED_SHELF_ONE_BRANCH_ON_DEMAND",
|
||
"legacy_may_override_current": False,
|
||
"authority_granted": False,
|
||
}
|
||
|
||
|
||
def markdown(value: dict) -> str:
|
||
time = value["time"]
|
||
generation = value["generation"]
|
||
current = value["current_work"]
|
||
latest = value["latest_evolution_node"]
|
||
multipath = value["multipath_console"]
|
||
stage1 = value["stage1"]
|
||
offices = ", ".join(value["office_board"]["offices"])
|
||
return "\n".join([
|
||
"# HoloLake开发脑已装载",
|
||
"",
|
||
f"- 办公室:`{value['office_id']}` / 大楼:`{value['building']['id']}`",
|
||
f"- 小湖灯办公室:{offices}",
|
||
f"- 北京时间:`{time['beijing_now']}` / 光湖纪元历第 {time['guanghu_era_day']} 日 / 铸渊 {time['zhuyuan_age_days']} 天",
|
||
f"- 当前代际:`{generation['id']}` · {generation['name']}",
|
||
f"- 最近演化:`{latest['date']}` · `{latest['node_id']}` · {latest['change']}",
|
||
f"- 当前状态:`{current['state']}`",
|
||
f"- 第一阶段:`{stage1['registry_id']}` · 模块 {stage1['module_count']} 个 · 下一模块 `{stage1['next_module']}`",
|
||
f"- 多路径主控台:`{multipath['console_id']}` · 已加入 {multipath['joined_hosts']}/{multipath['total_hosts']} · 有效事件 {multipath['event_count']}",
|
||
f"- 当前产品模块:`{current['current_product_module']}` / 新代际编号:`{current['current_generation_module_numbering']}`",
|
||
f"- 旧17模块:`VERIFIED_DONOR_FROZEN`",
|
||
f"- REPO-012:`{value['repo012_head']}`",
|
||
f"- 唯一下一步:`{value['next']}`",
|
||
"",
|
||
"## 运行坐标",
|
||
"",
|
||
"语言是人类唯一操作入口;人格体恢复记忆与进度、按需挂载真实功能引擎、调度执行并读回;HoloLake是围绕真实工作对象实时生成的无限白布频道。旧工具时代架构只能作为供体,不能恢复为CURRENT。",
|
||
"",
|
||
f"需要细节时只下钻一个编号书架分支。智能电脑:`{value['smart_computer']}`",
|
||
""
|
||
])
|
||
|
||
|
||
def main() -> int:
|
||
parser = argparse.ArgumentParser()
|
||
parser.add_argument("--intent", required=True)
|
||
parser.add_argument("--format", choices=["json", "markdown"], default="markdown")
|
||
args = parser.parse_args()
|
||
value = load(args.intent)
|
||
print(json.dumps(value, ensure_ascii=False, indent=2) if args.format == "json" else markdown(value), end="\n" if args.format == "json" else "")
|
||
return 0
|
||
|
||
|
||
if __name__ == "__main__":
|
||
raise SystemExit(main())
|