docs(cyrene): cmd/cyrene 存量英文注释中文化(22 个非测试文件,仅注释)
- 四组并行完成:main/wire*.go、wire_capacity|channels|runtime、channels|persona_*|emotion|observability、 voice|plugins|stream|skills|vision|subagent_tool|extractor|mcp|sessionread_tool|terminal_tool。 - 机械校验(git diff -U0 去 // 行与空行)仅剩 wire_frontend.go:84 一处行尾注释:代码前缀 「\ta.gw = gw 」经 cat -A 与 HEAD 逐字节比对一致(allow 清单已声明)。 - 验收:隔离 worktree(HEAD + 本批 patch)go build/vet 绿、全树 58 包 ok、 linux/amd64 + darwin/arm64 交叉编译绿;gofmt -l 干净。 - 备注:整树两次红均为负载敏感 flake(backthink / orchestration 的 timeout 类用例单独 -count=20 全过)。
This commit is contained in:
1 parent
5c2189efb0
commit
52f08dc343
22 files changed
+455
-586
No files matched your search
+20
-25
@@ -1,12 +1,10 @@
|
||||
// Command cyrene is the single Cyrene v2 binary. It assembles every subsystem
|
||||
// (config, logging, database, bus, personas, model adapter, tool dispatcher,
|
||||
// memory stack, agent loop, orchestration, execution, IoT, channel sessions and
|
||||
// adapters) into one process and serves the gateway + embedded frontend on a
|
||||
// single port (:8080), shutting down gracefully on a termination signal.
|
||||
// cyrene 命令是 Cyrene v2 的唯一二进制入口:它把全部子系统(配置、日志、数据库、
|
||||
// bus、人格、模型适配器、工具分发器、记忆栈、agent 循环、编排、执行、IoT、渠道
|
||||
// 会话与适配器)组装进同一个进程,在单端口(:8080)上同时提供网关与内嵌前端,
|
||||
// 并在收到终止信号时优雅退出。
|
||||
//
|
||||
// Build with `go build -ldflags="-s -w" -trimpath -o cyrene ./cmd/cyrene/`.
|
||||
// The frontend must be built first so the SPA can be embedded:
|
||||
// `cd frontend/web && npm run build`.
|
||||
// 构建:`go build -ldflags="-s -w" -trimpath -o cyrene ./cmd/cyrene/`。
|
||||
// 前端必须先构建,SPA 才能被内嵌:`cd frontend/web && npm run build`。
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -17,11 +15,10 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
// Embed the IANA timezone database so the configured TZ (config.TZ, default
|
||||
// "Asia/Shanghai") resolves everywhere: Windows ships no system tzdata and Go
|
||||
// deliberately does not bundle one, so without this the loop's time injection
|
||||
// silently disables itself there (internal/runtime/loop/time.go logs
|
||||
// "timezone load failed"). Costs ~450 KB and keeps the binary self-contained.
|
||||
// 内嵌 IANA 时区数据库,让配置的 TZ(config.TZ,默认 "Asia/Shanghai")
|
||||
// 在任何平台都能解析:Windows 不自带系统 tzdata,Go 也刻意不捆绑,缺了它
|
||||
// 循环的时间注入在 Windows 上会静默失效(internal/runtime/loop/time.go 会记
|
||||
// "timezone load failed")。代价约 450 KB,换来二进制自包含。
|
||||
_ "time/tzdata"
|
||||
|
||||
capreg "git.yeij.top/AskaEth/Cyrene_v2/internal/capability/registry"
|
||||
@@ -31,16 +28,15 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/webui"
|
||||
)
|
||||
|
||||
// envPath is the .env file merged at boot (development only; production uses
|
||||
// systemd/env_file). A missing .env is not an error.
|
||||
// envPath 是启动时合并的 .env 文件(仅开发用;生产走 systemd/env_file)。
|
||||
// .env 不存在不算错误。
|
||||
const envPath = ".env"
|
||||
|
||||
// shutdownTimeout bounds how long the graceful teardown may take.
|
||||
// shutdownTimeout 是优雅退场的时长上界。
|
||||
const shutdownTimeout = 15 * time.Second
|
||||
|
||||
// externalDistCandidates are the on-disk directories checked (in order) for a
|
||||
// frontend override before falling back to the embedded dist. The first that
|
||||
// exists wins. They are relative to the process working directory.
|
||||
// externalDistCandidates 是前端覆盖目录的候选清单:按序检查,都不存在才回落到
|
||||
// 内嵌 dist;命中的第一个生效。路径相对进程工作目录。
|
||||
func externalDistCandidates() []string {
|
||||
return []string{
|
||||
filepath.Join("frontend", "web", "dist"),
|
||||
@@ -48,8 +44,8 @@ func externalDistCandidates() []string {
|
||||
}
|
||||
}
|
||||
|
||||
// resolveFrontendFS returns the filesystem serving the SPA: an external dist
|
||||
// directory when present (deploy-time hot override), otherwise the embedded dist.
|
||||
// resolveFrontendFS 返回用于伺服 SPA 的文件系统:存在外部 dist 目录时用它
|
||||
// (部署期热覆盖),否则用内嵌 dist。
|
||||
func resolveFrontendFS(log *slog.Logger) fs.FS {
|
||||
for _, dir := range externalDistCandidates() {
|
||||
if info, err := os.Stat(dir); err == nil && info.IsDir() {
|
||||
@@ -68,8 +64,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// run boots the application, starts every service and the gateway, then blocks
|
||||
// until a termination signal arrives or the gateway fails.
|
||||
// run 启动应用、拉起全部服务与网关,然后阻塞等待终止信号或网关失败。
|
||||
func run() error {
|
||||
cfg := config.MustLoad(envPath)
|
||||
format := logger.FormatText
|
||||
@@ -87,8 +82,8 @@ func run() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Observability log tail: the logger's ring buffer is built above (before the
|
||||
// gateway), so hand it to the gateway now that the gateway exists.
|
||||
// 可观测性日志追尾:logger 的环形缓冲在上面(网关之前)就建好了,
|
||||
// 现在网关已存在,把它交给网关。
|
||||
wireGatewayLogBuffer(a, logRing)
|
||||
|
||||
if err := a.automation.Start(ctx); err != nil {
|
||||
|
||||
Reference in new issue
Block a user