Skip to content

doc: update add channel doc#1653

Merged
looplj merged 1 commit into
unstablefrom
dev-tmp
May 12, 2026
Merged

doc: update add channel doc#1653
looplj merged 1 commit into
unstablefrom
dev-tmp

Conversation

@looplj

@looplj looplj commented May 12, 2026

Copy link
Copy Markdown
Owner

No description provided.

@greptile-apps

greptile-apps Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates documentation for adding a new AI provider channel, correcting stale file references and expanding the workflow steps to match the current codebase structure.

  • Agent workflow (.agent/rules/workflows/add-channel.md) is rewritten with precise file paths, line ranges, and function names that all verify against the current source code.
  • Developer guide (English and Chinese) drops the stale reference to the removed constants.ts file, adds the correct config_channels.ts / config_providers.ts split, and renames buildChannel to the current buildChannelWithTransformer.

Confidence Score: 5/5

Documentation-only update; no runtime code changed.

All referenced file names, exported symbols, and line ranges were verified against the live codebase — buildChannelWithTransformer, defaultEndpointsForChannelType, CHANNEL_CONFIGS, PROVIDER_CONFIGS, channelTypeSchema, getAPIKeyProvider, and the field.Enum type block all exist exactly where the docs say they do.

No files require special attention.

Important Files Changed

Filename Overview
.agent/rules/workflows/add-channel.md Workflow rewritten with accurate file paths and verified line ranges across all three phases (schema, frontend, finalize).
docs/en/development/development.md Stale references to constants.ts and buildChannel removed; updated to match current file names and function signatures.
docs/zh/development/development.md Chinese translation updated in sync with the English doc; all function and file name references now match the codebase.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Add new AI provider channel] --> B[1. Backend: Ent Schema]
    B --> B1["Add type to field.Enum in channel.go:37-92"]
    B1 --> B2["Run make generate"]
    B2 --> B3["Add entry to defaultEndpointsForChannelType\nchannel_endpoint.go:90-156"]
    B3 --> B4{"New API format?"}
    B4 -- Yes --> B5["Add to SupportedAPIFormats"]
    B4 -- No --> B6["Add case to buildChannelWithTransformer\nchannel_llm.go:348-951"]
    B5 --> B6
    B6 --> B7{"New credential variant?"}
    B7 -- Yes --> B8["Add validation above switch\nchannel_llm.go:320-343"]
    B7 -- No --> C
    B8 --> C[2. Frontend: Schema, Config & i18n]
    C --> C1["Append to channelTypeSchema\nschema.ts:48-102"]
    C1 --> C2["Add CHANNEL_CONFIGS entry\nconfig_channels.ts"]
    C2 --> C3["Add/extend PROVIDER_CONFIGS\nconfig_providers.ts"]
    C3 --> C4["Add translation keys\nen.json & zh.json"]
    C4 --> D[3. Finalize]
    D --> D1["Run make generate again"]
    D1 --> D2["Verify build: make build-backend"]
Loading

Reviews (2): Last reviewed commit: "doc: update add channel doc" | Re-trigger Greptile

Comment thread .agent/rules/workflows/add-channel.md
@looplj looplj force-pushed the dev-tmp branch 2 times, most recently from 97ad958 to c2fb80d Compare May 12, 2026 17:07

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the workflow and development documentation for adding new AI provider channels, detailing specific backend and frontend integration steps. Feedback indicates that the guides should also explicitly mention updating the CHANNEL_TYPE_TO_PROVIDER mapping and registering new API formats in the frontend schema to ensure proper provider grouping and recognition.


1. **Zod schema** — add the new type value to `channelTypeSchema` enum in `frontend/src/features/channels/data/schema.ts:48-102`.
- If a new API format, add to `apiFormatSchema` and `configurableChannelEndpointApiFormats` in the same file.
2. **Channel config** — add a `CHANNEL_CONFIGS` entry in `frontend/src/features/channels/data/config_channels.ts` (icon, baseURL, defaultModels, apiFormat, color).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When adding a new channel type, it is also necessary to update the CHANNEL_TYPE_TO_PROVIDER mapping in frontend/src/features/channels/data/config_channels.ts to ensure the channel is correctly associated with its provider group.

Suggested change
2. **Channel config** — add a `CHANNEL_CONFIGS` entry in `frontend/src/features/channels/data/config_channels.ts` (icon, baseURL, defaultModels, apiFormat, color).
2. **Channel config** — add a `CHANNEL_CONFIGS` entry and update `CHANNEL_TYPE_TO_PROVIDER` in `frontend/src/features/channels/data/config_channels.ts` (icon, baseURL, defaultModels, apiFormat, color).

- If adding a new transformer under `llm/transformer/`, import it and build config with `getAPIKeyProvider(ch)`

4. **Sync the frontend schema and config**
- Append the enum value to `channelTypeSchema` in [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If the new channel introduces a new API format, it must also be added to apiFormatSchema and configurableChannelEndpointApiFormats in frontend/src/features/channels/data/schema.ts to be recognized by the frontend.

Suggested change
- Append the enum value to `channelTypeSchema` in [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts)
- Append the enum value to `channelTypeSchema` in [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts)
- If a new API format is introduced, also add it to `apiFormatSchema` and `configurableChannelEndpointApiFormats` in the same file


4. **Sync the frontend schema and config**
- Append the enum value to `channelTypeSchema` in [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts)
- Add a `CHANNEL_CONFIGS` entry in [frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Updating CHANNEL_TYPE_TO_PROVIDER in config_channels.ts is a required step when adding a new channel type to ensure proper provider grouping and type safety in the frontend.

Suggested change
- Add a `CHANNEL_CONFIGS` entry in [frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts)
- Add a `CHANNEL_CONFIGS` entry and update `CHANNEL_TYPE_TO_PROVIDER` in [frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts)

- 将枚举值加入 [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) 的 Zod schema
- 在 [frontend/src/features/channels/data/constants.ts](../../../frontend/src/features/channels/data/constants.ts) 中添加渠道配置
4. **同步前端的 schema 与配置**
- 将枚举值加入 [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) 的 `channelTypeSchema`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

如果引入了新的 API 格式,必须同步更新前端的 apiFormatSchemaconfigurableChannelEndpointApiFormats,否则前端将无法识别该格式。

Suggested change
- 将枚举值加入 [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts)`channelTypeSchema`
- 将枚举值加入 [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts)`channelTypeSchema`
- 如果引入了新的 API 格式,同步添加到该文件中的 `apiFormatSchema``configurableChannelEndpointApiFormats`

- 在 [frontend/src/features/channels/data/constants.ts](../../../frontend/src/features/channels/data/constants.ts) 中添加渠道配置
4. **同步前端的 schema 与配置**
- 将枚举值加入 [frontend/src/features/channels/data/schema.ts](../../../frontend/src/features/channels/data/schema.ts) 的 `channelTypeSchema`
- 在 [frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts) 中添加 `CHANNEL_CONFIGS` 条目

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

config_channels.ts 中更新 CHANNEL_TYPE_TO_PROVIDER 是必不可少的步骤,用于确保新渠道类型能正确映射到对应的 Provider 分组。

Suggested change
-[frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts) 中添加 `CHANNEL_CONFIGS` 条目
-[frontend/src/features/channels/data/config_channels.ts](../../../frontend/src/features/channels/data/config_channels.ts) 中添加 `CHANNEL_CONFIGS` 条目并更新 `CHANNEL_TYPE_TO_PROVIDER`

@looplj looplj merged commit bfc11e0 into unstable May 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant