agentleFS
BenedictKingBenedictKing/ccx/backend-go/CLAUDE.md

ccx / backend-go

CLAUDE.md4k starsChanged 2 months agoMITView on GitHub

Go 后端核心服务:HTTP API、多上游适配、协议转换、多渠道调度、会话管理、指标与日志记录、配置热重载。 说明:实际命令以 backend-go/Makefile 为准。 所有日志输出使用 [Component-Action] 标签格式,禁止使用 emoji。 渠道日志模型定义于 internal/metrics/channel_log.go。 关键字段包括: - status - statusCode - requestSource - interfaceType - baseUrl - keyMask 对于 Images 渠道,还会额外记录: - operation:generations / edits / variations

Trending

Quiet since September.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 1 mentionJun 2026: 1 mentionJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 1 mentionOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the BenedictKing/ccx repository that our weekly crawl found: only 3 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

The file

Files
CLAUDE.md

backend-go 模块文档

← 根目录

模块职责

Go 后端核心服务:HTTP API、多上游适配、协议转换、多渠道调度、会话管理、指标与日志记录、配置热重载。

启动命令

make dev
make run
make build
make test
make test-cover
make fmt
make lint
make deps

说明:实际命令以 backend-go/Makefile 为准。

API 总览

代理入口

  • GET /health
  • POST /v1/messages
  • POST /v1/messages/count_tokens
  • POST /v1/chat/completions
  • POST /v1/responses
  • POST /v1/responses/compact
  • GET /v1/models
  • GET /v1/models/:model
  • POST /v1beta/models/{model}:generateContent
  • POST /v1/images/generations
  • POST /v1/images/edits
  • POST /v1/images/variations
  • POST /v1/embeddings

管理入口

  • /api/messages/channels/*
  • /api/chat/channels/*
  • /api/responses/channels/*
  • /api/gemini/channels/*
  • /api/images/channels/*
  • /api/vectors/channels/*

能力测试

能力测试接口仅适用于 messages、chat、responses、gemini。 Images 与 Vectors 当前没有 capability-test / snapshot 路由。

关键实现点

渠道类型

当前正式支持六类渠道:

  • messages
  • chat
  • responses
  • gemini
  • images
  • vectors

Provider 接口

所有上游服务实现 internal/providers/Provider 接口:

type Provider interface {
    ConvertToProviderRequest(c *gin.Context, upstream *config.UpstreamConfig, apiKey string) (*http.Request, []byte, error)
    ConvertToClaudeResponse(providerResp *types.ProviderResponse) (*types.ClaudeResponse, error)
    HandleStreamResponse(body io.ReadCloser) (<-chan string, <-chan error, error)
}

核心模块

模块职责
internal/handlers/代理与管理接口处理器
internal/providers/上游适配
internal/converters/Responses 协议转换
internal/scheduler/多渠道调度
internal/session/会话与 Trace 亲和性
internal/config/配置管理与热重载
internal/metrics/指标、日志、持久化

日志规范

所有日志输出使用 [Component-Action] 标签格式,禁止使用 emoji。

log.Printf("[Component-Action] 消息内容: %v", value)

Channels logs

渠道日志模型定义于 internal/metrics/channel_log.go。

关键字段包括:

  • status
  • statusCode
  • requestSource
  • interfaceType
  • baseUrl
  • keyMask

对于 Images 渠道,还会额外记录:

  • operation:generations / edits / variations

扩展指南

添加新上游能力

  1. 在 internal/providers/ 中新增或扩展 provider
  2. 在需要时补充 internal/converters/ 的协议转换
  3. 接入对应 handler、调度与前端配置
  4. 将指标、日志与模型过滤纳入统一链路

调整调度逻辑

  • 修改 internal/scheduler/
  • 如涉及熔断、恢复或日志,联动检查 internal/metrics/
  • 调度优先级链路(Override → Promotion → Trace 亲和 → 优先级排序 → 降级)说明见 README.md#调度优先级链路

文档导航

  • ../README.md - 项目入口
  • README.md - 后端专项文档
  • ../docs/guide/architecture.md - 架构说明
  • ../docs/guide/development.md - 开发指南
  • ../docs/guide/release.md - 发布流程

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.