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
57 changes: 22 additions & 35 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ jobs:
shell: pwsh
env:
RELEASE_TAG: ${{ github.ref_name }}
run: node scripts/verify-release-version.js --tag $env:RELEASE_TAG
run: |
node scripts/verify-release-version.js --tag $env:RELEASE_TAG
node scripts/read-release-metadata.js --tag $env:RELEASE_TAG

- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
Expand All @@ -58,24 +60,11 @@ jobs:

- name: Package release assets
shell: pwsh
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
$ErrorActionPreference = "Stop"
$version = "${{ github.ref_name }}".TrimStart("v")
$assetRoot = "artifacts/release"
New-Item -ItemType Directory -Force -Path $assetRoot | Out-Null

$exe = "artifacts/win-x64/CodexProviderSync.exe"
$zip = Join-Path $assetRoot "codex-provider-sync-v$version-win-x64.zip"
Compress-Archive -Path "artifacts/win-x64/*" -DestinationPath $zip -Force
Copy-Item $exe (Join-Path $assetRoot "CodexProviderSync.exe") -Force

$assets = Get-ChildItem -File $assetRoot | Sort-Object Name
$checksums = foreach ($asset in $assets) {
$hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $asset.FullName).Hash.ToLowerInvariant()
"$hash $($asset.Name)"
Set-Content -LiteralPath "$($asset.FullName).sha256" -Value "$hash $($asset.Name)" -Encoding ASCII
}
Set-Content -LiteralPath (Join-Path $assetRoot "checksums.txt") -Value $checksums -Encoding ASCII
$version = $env:RELEASE_TAG.Substring(1)
./scripts/package-release-assets.ps1 -Version $version -PublishOutput artifacts/win-x64 -Output artifacts/release

- name: Upload packaged assets
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
Expand All @@ -91,6 +80,19 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.1
with:
node-version: "24"

- name: Resolve versioned Chinese release announcement
id: release_metadata
shell: bash
run: node scripts/read-release-metadata.js --tag "$GITHUB_REF_NAME" --github-output "$GITHUB_OUTPUT"

- name: Download packaged assets
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
Expand All @@ -100,23 +102,8 @@ jobs:
- name: Upload release assets
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
with:
name: ${{ steps.release_metadata.outputs.release_title }}
body_path: ${{ steps.release_metadata.outputs.release_body_path }}
files: |
artifacts/release/*
fail_on_unmatched_files: true
body: |
## Windows SmartScreen 提示
当前 Windows GUI 未做代码签名,首次运行时可能提示“发布者未知”或“Windows 已保护你的电脑”。这是未签名 EXE 的常见提示。

请确认下载来源是本项目 GitHub Releases,并可用随附的 SHA256 文件校验后运行。

## 安全边界
- 不会修改 auth.json
- 不会改写对话正文或消息历史
- 不会修改 updated_at 来改变排序
- 不会重新加密 encrypted_content

## 回滚
可使用 `codex-provider restore <backup-dir>` 恢复本工具创建的备份。

## 已知事项
含 encrypted_content 的历史会话跨 provider/account 后,通常只能恢复列表可见性;继续对话或 compact 仍可能失败。
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 更新日志

本文件记录面向用户和集成方的重要变化。完整的发布叙事、升级说明和下载入口见对应版本的中文发布说明;实现证据和测试门禁见技术发布说明。

## [0.4.0] - 2026-08-04

### 新增

- 新增实验性 Windows 自动化接口,支持 `describe`、`status`、`plan`、`sync`、`switch`、`restore` 和 `prune`。
- 新增独立 SQLite Home 支持,以及按 Codex Home 保存的 Windows GUI SQLite Home 配置。
- 新增独立 Automation ZIP;单文件 GUI 和包含全部工具的 Windows ZIP 保持可用。

### 变更

- Windows GUI 与自动化接口改为共享 Application 用例,Core 继续统一负责配置、rollout、SQLite、备份、恢复、锁和 WSL 安全策略。
- 新备份使用 metadata v2 记录 SQLite Home 和数据库文件,同时继续支持旧版托管备份。
- GitHub Release 正文改为读取随版本 tag 入库的中文发布说明。

### 修复

- 修复多文件写入部分成功后无法可靠补偿的问题;失败和取消现在会按事务记录回滚。
- SQLite 提交结果无法确认时改为保守恢复,不再把不确定状态报告为成功。
- 强化锁所有权恢复、SQLite 快照恢复和 WSL UNC 路径安全诊断。

### 安全

- 写操作在目标修改前创建绑定备份,并保留崩溃恢复信息。
- 自动化接口的写操作默认只生成计划;实际执行需要 `--apply`、匹配的计划文件和 SHA-256 摘要。
- 自动化路径拒绝 `auth.json`、符号链接、reparse point 和非绝对路径。

### 升级说明

- v0.3.1 / v0.3.2 Windows GUI 可以通过内置更新升级,但内置更新只替换单文件 GUI。
- 升级不要求手动迁移配置;需要自动化接口的用户应单独下载 Automation ZIP 或 Windows 完整包。

[中文发布说明](docs/release-notes/v0.4.0-zh.md) · [技术发布说明](docs/RELEASE_NOTES_V0.4.0.md) · [完整变更对比](https://github.com/Dailin521/codex-provider-sync/compare/v0.3.2...v0.4.0)

更早版本见 [GitHub Releases](https://github.com/Dailin521/codex-provider-sync/releases)。
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ PR 中请特别说明:
- 自动化测试、真实手测和未执行项目。
- GUI 变化的前后截图。

## 准备发布

发布 tag 前需要:

1. 将 [中文发布说明模板](docs/release-notes/TEMPLATE-zh.md) 复制为 `docs/release-notes/v<版本>-zh.md`。
2. 填写文件顶部的 `release-title`、面向用户的升级结果、下载、升级说明、安全边界、验证结果和实际贡献者。
3. 更新 `CHANGELOG.md`,并确认 `package.json`、`package-lock.json` 和所有发布项目版本一致。
4. 运行 `node scripts/read-release-metadata.js --tag v<版本>` 和 `node scripts/verify-release-version.js --tag v<版本>`。
5. 运行完整测试和发布构建,再创建指向 `main` 中已验证提交的 tag。

发布工作流会读取与 tag 同名的中文发布说明,并生成单文件 GUI、独立 Automation ZIP、Windows 完整包和对应 SHA-256。缺少发布说明、标题与 tag 不匹配,或遗漏固定的下载、安全和限制声明时会直接停止。

## English quick guide

- Small fixes, tests, and documentation updates can be submitted directly as a PR. Please open an Issue before starting a large feature, behavior change, or refactor.
Expand Down
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ Codex 切换 `model_provider` 后,旧会话可能从 Desktop 或 `/resume` 中

本工具不负责登录、认证或切换账号;请先用原有方式完成 Provider 切换,再执行同步。

## 它与 Provider 切换工具的关系

包括 cc-switch 在内的 Provider 管理工具,主要负责账号、API Key、`auth.json` 或 `config.toml` 的切换,有些工具也提供自己的历史会话处理能力。codex-provider-sync 刻意不接管认证,它专注于切换之后的会话可见性元数据、rollout、SQLite、备份和恢复。

如果你正在使用的切换工具已经能让全部历史会话保持可见,就不需要重复同步。以下情况仍适合使用本工具:

- 使用多个切换工具,或先切换后才发现旧会话已经按 Provider 分开。
- 需要同时核对并修复 rollout、SQLite 和项目可见性,而不只修改配置文件。
- SQLite Home 与 Codex Home 分开存放,特别是 Windows Codex Home + WSL SQLite Home。
- 需要可恢复的批量同步、明确的备份记录和事务回滚保护。

## 它会处理什么

- 同步 `~/.codex/sessions` 和 `~/.codex/archived_sessions` 中的 rollout metadata。
Expand All @@ -40,7 +51,13 @@ Codex 切换 `model_provider` 后,旧会话可能从 Desktop 或 `/resume` 中

### Windows GUI

普通 Windows 用户建议直接从 [Releases](https://github.com/Dailin521/codex-provider-sync/releases/latest) 下载并解压:
普通 Windows 用户只需从 [Releases](https://github.com/Dailin521/codex-provider-sync/releases/latest) 下载单文件 GUI:

| 使用场景 | Release 资产 | 更新方式 |
| --- | --- | --- |
| 只需要 Windows GUI | `CodexProviderSync.exe` | 支持软件内自动更新 |
| 脚本、CI 或 AI Agent | `codex-provider-sync-v<版本>-automation-win-x64.zip` | 手动下载更新 |
| GUI 与自动化接口都需要 | `codex-provider-sync-v<版本>-win-x64.zip` | 手动下载更新 |

1. 打开 `CodexProviderSync.exe`
2. 点击“刷新”
Expand Down Expand Up @@ -90,9 +107,9 @@ codex-provider sync --codex-home /mnt/c/Users/you/.codex --sqlite-home /home/you

`status` 会显示 effective SQLite Home 和来源。显式路径缺少 `state_5.sqlite` 时,状态查询只报告诊断,`sync`、`switch` 和数据库恢复不会偷偷回退到其它位置。默认布局中的数据库被删除时,`restore` 可以根据备份 metadata 在原默认位置重建数据库。

### Business Automation API(v0.4 实验性)
### 自动化接口(v0.4 实验性)

v0.4 Windows Release 构建同时包含 `CodexProviderSync.Automation.exe``automation-protocol-v0.4.schema.json`。这个一次性进程接口与 Windows GUI 共用同一套 Application 用例;每次调用只在 stdout 输出一份协议 `0.4` JSON,诊断信息写入 stderr。
Release 提供独立的 Windows 自动化接口包,内含 `CodexProviderSync.Automation.exe``automation-protocol-v0.4.schema.json` 和中文快速说明;Windows 完整包也包含这些文件。这个一次性进程接口与 Windows GUI 共用同一套 Application 用例;每次调用只在 stdout 输出一份协议 `0.4` JSON,诊断信息写入 stderr。普通桌面用户不需要下载自动化接口包

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update the operator contract before shipping Automation

Once this release is tagged, the README and packaged assets advertise CodexProviderSync.Automation.exe, but the repository's mandatory operator guide still states that no Automation executable is shipped. AGENTS-aware tools will therefore treat the newly published interface as unavailable; either update the operator contract as part of this change or do not publish the executable.

AGENTS.md reference: AGENTS.md:L22-L24

Useful? React with 👍 / 👎.


| 命令 | 用途 |
| --- | --- |
Expand All @@ -118,6 +135,8 @@ $planDigest = $planResponse.data.digest

计划有有效期、绑定规范化输入和目标状态,并由持久化 ledger 保证只能使用一次;默认 ledger 位于 `<Codex Home>\tmp\provider-sync-automation-ledger`。所有路径参数必须是绝对路径,不能穿过符号链接或 reparse point,Automation 也拒绝直接指向或访问 `auth.json`。协议仍处于 pre-1.0 实验阶段,`0.4` 之外不承诺兼容。

中文分步示例见 [自动化接口快速开始](docs/AUTOMATION_QUICKSTART_ZH.md)。

## 安全与限制

每次 `sync` / `switch` 前都会备份到:
Expand All @@ -139,7 +158,10 @@ $planDigest = $planResponse.data.digest

- [Windows GUI 说明](docs/README_GUI_ZH.md)
- macOS GUI 说明:[中文](docs/README_MAC_GUI_ZH.md) · [English](docs/README_MAC_GUI_EN.md)
- [v0.4.0 Release Notes(Draft)](docs/RELEASE_NOTES_V0.4.0.md)
- [v0.4.0 中文发布说明](docs/release-notes/v0.4.0-zh.md)
- [v0.4.0 技术发布说明](docs/RELEASE_NOTES_V0.4.0.md)
- [更新日志](CHANGELOG.md)
- [自动化接口快速开始](docs/AUTOMATION_QUICKSTART_ZH.md)
- [v0.4 Automation 执行计划](docs/V0.4_AUTOMATION_PLAN.md)
- [English documentation](docs/README_EN.md)
- [AI / Agent 操作指南](AGENTS.md)
Expand Down
6 changes: 3 additions & 3 deletions docs/AUTOMATION_DESIGN_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
>
> The v0.4 source and Windows Release build contain an Automation executable,
> protocol schema, GUI manifest, and isolated GUI bridge. Implementation commit
> `7545b5d` passed the visible Headful Windows release gate; v0.4 has not been
> tagged or published as a formal Release. Protocol `0.4` is a pre-1.0
> compatibility boundary.
> `7545b5d` passed the visible Headful Windows release gate, and v0.4.0 was
> published on 2026-08-04. Protocol `0.4` remains a pre-1.0 compatibility
> boundary.

## Motivation

Expand Down
70 changes: 70 additions & 0 deletions docs/AUTOMATION_QUICKSTART_ZH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 自动化接口快速开始

`CodexProviderSync.Automation.exe` 是供脚本、持续集成(CI)和 AI Agent 调用的实验性 Windows 接口。普通桌面用户不需要它,直接使用 `CodexProviderSync.exe` 即可。

自动化接口包包含:

- `CodexProviderSync.Automation.exe`
- `automation-protocol-v0.4.schema.json`
- 本说明文件

接口每次运行只向标准输出写入一份协议 `0.4` JSON;诊断信息写入标准错误。所有路径都必须是绝对路径。

## 只读命令

```powershell
# 查看协议能力和安全要求
.\CodexProviderSync.Automation.exe describe

# 查看当前 Provider、rollout 和 SQLite 状态
.\CodexProviderSync.Automation.exe status `
--codex-home C:\Users\you\.codex
```

## 先生成计划

写命令默认不会修改数据。以下示例生成一份同步计划:

```powershell
$planResponse = .\CodexProviderSync.Automation.exe plan `
--operation sync `
--codex-home C:\Users\you\.codex `
--provider openai | ConvertFrom-Json

$planPath = 'C:\Temp\codex-provider-sync-plan.json'
$planJson = $planResponse.data | ConvertTo-Json -Depth 100 -Compress
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::WriteAllText($planPath, $planJson, $utf8NoBom)
$planDigest = $planResponse.data.digest
```

请先检查返回的计划、警告和目标列表。计划会绑定当前输入与目标状态,具有有效期,并且只能使用一次。

## 明确执行计划

确认计划无误后,使用同一组操作参数,并同时提供 `--apply`、计划文件和计划摘要:

```powershell
.\CodexProviderSync.Automation.exe sync `
--codex-home C:\Users\you\.codex `
--provider openai `
--apply `
--plan $planPath `
--plan-digest $planDigest
```

如果目标状态在计划生成后发生变化,执行会被拒绝,需要重新生成计划。同步和切换仍遵循 Core 的备份、事务、回滚、锁和 WSL UNC 安全规则。

## 支持的命令

| 命令 | 用途 |
| --- | --- |
| `describe` | 查看协议能力和安全要求 |
| `status` | 只读检查当前状态 |
| `plan` | 为写操作生成计划 |
| `sync` | 同步历史会话元数据 |
| `switch` | 切换 Provider/model 后同步 |
| `restore` | 恢复托管备份 |
| `prune` | 清理旧的托管备份 |

完整参数、安全限制和返回结构见项目 [README](../README.md) 与 `automation-protocol-v0.4.schema.json`。协议 `0.4` 仍处于 1.0 之前的实验阶段,未来可能发生不兼容变更。
23 changes: 19 additions & 4 deletions docs/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ If all of your relays can reliably reuse one `model_provider` ID and history rem

The tool does not sign in, manage accounts, or switch authentication. Switch Provider using your normal workflow first, then synchronize history.

## Relationship to Provider Switchers

Provider managers, including cc-switch, primarily switch accounts, API keys, `auth.json`, or `config.toml`; some also provide their own history handling. codex-provider-sync deliberately leaves authentication alone and focuses on post-switch visibility metadata, rollout files, SQLite state, managed backups, and restoration.

If your current switcher already keeps all history visible, you do not need to run another synchronization. This project remains useful when several switching workflows have split existing history, rollout and SQLite need to be reconciled together, SQLite Home is separate from Codex Home, or backup-backed transactional repair is required.

## What It Updates

- Rollout metadata under `~/.codex/sessions` and `~/.codex/archived_sessions`.
Expand All @@ -40,7 +46,13 @@ The tool does not sign in, manage accounts, or switch authentication. Switch Pro

### Windows GUI

For normal Windows use, download and extract `CodexProviderSync.exe` from [Releases](https://github.com/Dailin521/codex-provider-sync/releases/latest):
For normal Windows use, download the standalone GUI from [Releases](https://github.com/Dailin521/codex-provider-sync/releases/latest):

| Use case | Release asset | Update method |
| --- | --- | --- |
| Windows GUI only | `CodexProviderSync.exe` | Built-in updates supported |
| Scripts, CI, or AI agents | `codex-provider-sync-v<version>-automation-win-x64.zip` | Manual update |
| GUI and Automation together | `codex-provider-sync-v<version>-win-x64.zip` | Manual update |

1. Open `CodexProviderSync.exe`.
2. Click `刷新` (Refresh).
Expand Down Expand Up @@ -92,9 +104,9 @@ codex-provider sync --codex-home /mnt/c/Users/you/.codex --sqlite-home /home/you

Node.js 24+ uses the built-in `node:sqlite` module. Older supported Node.js releases use the optional `better-sqlite3` dependency.

### Business Automation API (experimental v0.4)
### Automation API (experimental v0.4)

The v0.4 Windows Release build also contains `CodexProviderSync.Automation.exe` and `automation-protocol-v0.4.schema.json`. This one-shot process interface uses the same Application use cases as the Windows GUI. Each invocation emits exactly one protocol `0.4` JSON document on stdout and sends diagnostics to stderr.
Releases provide a separate Windows Automation package containing `CodexProviderSync.Automation.exe`, `automation-protocol-v0.4.schema.json`, and a Chinese quick start. The complete Windows package contains the same files. This one-shot process interface uses the same Application use cases as the Windows GUI. Each invocation emits exactly one protocol `0.4` JSON document on stdout and sends diagnostics to stderr. Normal desktop users do not need the Automation package.

| Command | Purpose |
| --- | --- |
Expand Down Expand Up @@ -140,7 +152,10 @@ Before each `sync` or `switch`, the tool creates a backup under:

- [Windows GUI guide](README_GUI_ZH.md)
- [macOS GUI guide](README_MAC_GUI_EN.md)
- [v0.4.0 Release Notes (Draft)](RELEASE_NOTES_V0.4.0.md)
- [v0.4.0 Chinese release announcement](release-notes/v0.4.0-zh.md)
- [v0.4.0 technical release notes](RELEASE_NOTES_V0.4.0.md)
- [Changelog](../CHANGELOG.md)
- [Chinese Automation quick start](AUTOMATION_QUICKSTART_ZH.md)
- [v0.4 Automation execution plan](V0.4_AUTOMATION_PLAN.md)
- [中文说明](../README.md)
- [AI / Agent guide](../AGENTS.md)
Expand Down
Loading