Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copilot Instructions for config_convert

## Project purpose

- Converts multiple upstream Dev-Sidecar configs into one merged config published at assets/final_config.json.
- Merge order matters: default_remote → 8odream → Sheas Cealer → manual, then remove excluded_domains entries (left-to-right precedence).

## Key modules

- src/main.py: CLI entrypoint (`--debug` enables verbose logging). Loads excluded_domains.json5, instantiates configs, merges via ExtendedDict operators, writes sorted JSON to final_config_path.
- src/Config.py: Config base class (download helpers using GitHub mirrors, JSON5 parsing). Subclasses: RemoteConfig (generic URL), GithubConfig (GitHub path with mirrors), LocalConfig (local JSON5), SheasCealerConfig (transforms Cealer list into Dev-Sidecar `server.intercepts` + `preSetIpList`, skipping IPv6 when header.skip_IPv6).
- src/ExtendedDict.py: `__add__` deep-merges dicts iteratively (rewrite=True default overwrites existing keys); `__sub__` removes keys recursively; returned type always ExtendedDict for chaining.
- src/utils.py: `is_ipv6_address` handles bracketed literals; `sort_json_object` sorts mapping keys by length desc then alphabetically to stabilize output; `show_raw_text_for_debugging` truncates to 500 chars.
- src/header.py: Central paths (manual_config.json5, excluded_domains.json5, final_config.json) and mirror lists; requires Python 3.14+ per pyproject.toml.

## Behaviors & conventions

- Merging relies on ExtendedDict semantics; if you change precedence, adjust ordering in src/main.py.
- Excluded domains are removed after all additions (`final_config = a + b + c + d - excluded_domains`).
- SheasCealer conversion: domain list cleaned (strips $/#, skips entries containing ^); each domain is processed individually; empty SNI becomes "none"; empty target becomes 127.0.0.1; only non-IPv6 targets added to `preSetIpList` when skip_IPv6.
- Output serialization: ensure_ascii=False, indent=2, and key sorting via sort_json_object before writing (match existing format for diffs/automation).
- 对话与代码注释请使用中文,日志输出维持既有英文格式。

## Local workflow

- Setup: Python 3.14+, `pip install -r requirements.txt` (exported from uv). json5 and requests are required.
- Run: `python src/main.py` (add `--debug` for verbose). Output writes to assets/final_config.json alongside manual and excluded files in assets/.

## Extending safely

- When adding new sources, prefer new Config subclasses or reuse GithubConfig/RemoteConfig; always call Config.download with mirrors to avoid single-point failures.
- If changing save logic, consider reusing Config.save to keep formatting consistent with main.py TODO.
- Maintain mirror lists in header.py; skip_IPv6 controls IPv6 handling globally.

## CI/Git flow

- dev branch for changes; main is protected/production. Actions push merged config to main using PAT. Keep output deterministic (sorting) to avoid noisy diffs.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

把Sheas Cealer的配置文件转换成Dev-Sidecar的配置文件,并支持与其他Dev-Sidecar配置合并。目前由GitHub Actions自动执行,当前每30分钟更新一次配置。

## 用法:
把https://cute-omega.github.io/other-assets/ds-config.json 填入dev-sidecar的个人远程配置,然后点击“更新远程配置”以立即生效。之后dev-sidecar会在每次启动时自动更新配置。
## 用法

## 脚本当前工作流:
把<https://cute-omega.github.io/other-assets/ds-config.json> 填入dev-sidecar的个人远程配置,然后点击“更新远程配置”以立即生效。之后dev-sidecar会在每次启动时自动更新配置。

## 脚本当前工作流

`default_remote.config + 8odream.config + sheas_cealer.config + manual.config - excluded_domains`

Expand Down Expand Up @@ -33,6 +34,7 @@ python3 src/main.py
```

## 开发

请Fork dev分支,更新也请向dev分支发PR。

推送PR前请在本地测试无bug后进行。
Expand All @@ -43,5 +45,6 @@ main分支仅用于生产用途。

本仓库使用GitHub Actions自动运行配置转换并推送到main分支。由于main分支有分支保护规则,工作流使用Personal Access Token (PAT)来绕过这些规则。

### 所需的Secrets配置:
### 所需的Secrets配置

- `PAT`: 具有repo权限的Personal Access Token,用于向main分支推送更改
Loading