docs(comments): 注释中文化 · internal/runtime/model + internal/services/backthink(54 文件,纯替换)
- 只翻注释/文档字符串:`go/scanner` 剥注释后按 token 序列+literal 逐 token 比对,**54/54 文件 SAME**;
改动文件总行数与 HEAD 漂移 = 0(严格 1:1,无合并/拆行)
- 裁决编号与 design 节号逐字保留(03.4.1/03.4.2/03.4.3/14.4.1/14.4.5/07.4.2-4、design/04 §3.1/§3.2 等);
`chat_template_kwargs` / `enable_thinking` / `reasoning_effort` / `thinking:{type}` 字段名与形状说明未动
- 存疑译法(已登记):`persona` 在叙事语境用「角色」、标识符语境保留 `persona`(仓库既有模块本身混用);
`rung`→「级」;`provider` 存在「提供商/提供者」两种落笔(可按需一键统一)
- 复核:build/vet 绿 + 两包测试绿;gofmt 干净;残留英文注释 0 条
- 既有存量(未修,只报告):`model/anthropic_test.go` 612 行 >500;`applyAnthropicEvent` 115 行 >80
This commit is contained in:
1 parent
f5cf117482
commit
3dc1232bc2
54 files changed
+1923
-1923
No files matched your search
@@ -13,8 +13,8 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/db"
|
||||
)
|
||||
|
||||
// mockThinker records every Think invocation and returns a fixed conclusion. It
|
||||
// respects ctx cancellation so Stop can drain a hung pass.
|
||||
// mockThinker 记录每次 Think 调用并返回固定结论。它
|
||||
// 尊重 ctx 取消,好让 Stop 能排空挂住的轮次。
|
||||
type mockThinker struct {
|
||||
mu sync.Mutex
|
||||
text string
|
||||
@@ -45,12 +45,12 @@ func (m *mockThinker) Think(ctx context.Context, sessionID, trigger string) (str
|
||||
func (m *mockThinker) count() int { m.mu.Lock(); defer m.mu.Unlock(); return m.calls }
|
||||
func (m *mockThinker) lastTrigger() string { m.mu.Lock(); defer m.mu.Unlock(); return m.last }
|
||||
|
||||
// mockState returns a fixed UserState.
|
||||
// mockState 返回固定的 UserState。
|
||||
type mockState struct{ state UserState }
|
||||
|
||||
func (m *mockState) Current(context.Context) (UserState, error) { return m.state, nil }
|
||||
|
||||
// mockPusher records Push calls and returns a fixed result.
|
||||
// mockPusher 记录 Push 调用并返回固定结果。
|
||||
type mockPusher struct {
|
||||
mu sync.Mutex
|
||||
result PushResult
|
||||
@@ -70,7 +70,7 @@ func (p *mockPusher) Push(ctx context.Context, req PushRequest) PushResult {
|
||||
|
||||
func (p *mockPusher) count() int { p.mu.Lock(); defer p.mu.Unlock(); return p.calls }
|
||||
|
||||
// mockActive implements ActiveClient.
|
||||
// mockActive 实现 ActiveClient。
|
||||
type mockActive struct {
|
||||
mu sync.Mutex
|
||||
n int
|
||||
@@ -87,7 +87,7 @@ func (m *mockActive) SendProactive(ctx context.Context, msg adapter.UnifiedMessa
|
||||
return m.n, m.err
|
||||
}
|
||||
|
||||
// mockIMAdapter implements IMAdapter.
|
||||
// mockIMAdapter 实现 IMAdapter。
|
||||
type mockIMAdapter struct {
|
||||
mu sync.Mutex
|
||||
err error
|
||||
@@ -105,14 +105,14 @@ func (m *mockIMAdapter) SendProactive(ctx context.Context, msg adapter.UnifiedMe
|
||||
|
||||
func (m *mockIMAdapter) count() int { m.mu.Lock(); defer m.mu.Unlock(); return m.calls }
|
||||
|
||||
// mockGate implements PushGate.
|
||||
// mockGate 实现 PushGate。
|
||||
type mockGate struct{ allow bool }
|
||||
|
||||
func (g *mockGate) Allow(context.Context, PushKind) bool { return g.allow }
|
||||
func (g *mockGate) RecordPush(PushKind) {}
|
||||
|
||||
// newTestDB opens an isolated in-memory SQLite handle for one test and closes it
|
||||
// on cleanup.
|
||||
// newTestDB 为单个测试打开一个隔离的内存 SQLite 句柄,并在
|
||||
// 清理时关闭它。
|
||||
func newTestDB(t *testing.T) *sql.DB {
|
||||
t.Helper()
|
||||
h, err := db.Open(context.Background(), ":memory:", nil)
|
||||
@@ -123,12 +123,12 @@ func newTestDB(t *testing.T) *sql.DB {
|
||||
return h
|
||||
}
|
||||
|
||||
// discardLog returns a logger that writes nowhere.
|
||||
// discardLog 返回一个什么都不写的日志器。
|
||||
func discardLog() *slog.Logger {
|
||||
return slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
}
|
||||
|
||||
// eventually polls cond until it is true or the deadline passes.
|
||||
// eventually 轮询 cond 直到它为真或超过期限。
|
||||
func eventually(t *testing.T, timeout time.Duration, cond func() bool) {
|
||||
t.Helper()
|
||||
deadline := time.Now().Add(timeout)
|
||||
|
||||
Reference in new issue
Block a user