Skip to content

Commit 46212e1

Browse files
committed
docs: copy README.md, CHANGED.md, and .agents/skills from feat/rust-v0.104.0
1 parent ffd726a commit 46212e1

7 files changed

Lines changed: 918 additions & 39 deletions

File tree

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
---
2+
name: codex-upstream-reapply
3+
description: "Tag-based upstream sync for a fork/secondary-development repo: fetch tags, let the user choose a tag, create a fresh branch from that tag, then read the old customization branch’s git changes + intent Markdown to re-implement the requirements on the new branch (no merge/rebase of the old branch)."
4+
---
5+
6+
# Codex Upstream Reapply
7+
8+
## Overview
9+
10+
用于“二开/魔改”场景的 tag 同步:先 `git fetch upstream --tags` 拉取 tags,让用户选择一个 tag 版本,从该 tag 创建新分支作为开发起点;然后读取旧二开分支的 git changes 与意图 Markdown,在新分支上“重实现”需求(不 merge/rebase 旧分支历史)。
11+
12+
## Inputs (每次明确这些东西)
13+
14+
- `REMOTE`:拉取 tags 的 remote(默认 `upstream`
15+
- `TAG`:你选择的 tag 版本(作为新分支起点)
16+
- `OLD_BRANCH`:原本二开的分支(包含改动 + 意图 Markdown;默认取“当前分支”)
17+
- `NEW_BRANCH`:从 tag 新建的分支名(脚本默认 `feat/<tag-name>`
18+
- 可选:`OLD_BASE_TAG`(仅当基线推断不可靠时显式指定)
19+
20+
## Workflow (推荐:完全不 merge / 不 rebase 旧分支)
21+
22+
### 0) Acceptance criteria (必读)
23+
24+
- 禁止运行 `cargo test`(不需要写/跑测试)。
25+
- 不得生成测试代码或快照文件:确保本次变更里没有新增/修改测试代码或 `*.snap`/`*.snap.new`
26+
-`codex-rs` 目录下执行 `cargo build -p codex-cli`,确认能正常启动运行。
27+
- 更新根目录 `README.md``Codex build` 徽章版本:使用选定 `TAG` 的版本号,并附加该 tag 指向的短 commit(例如 `v0.94.0-dce99bc`)。推荐使用 `https://img.shields.io/static/v1?label=codex%20build&message=<tag>-<short_commit>&color=2ea043`
28+
29+
### 0) One-time setup(如果还没有)
30+
31+
确认是否已有 `origin`(fork)和 `upstream`(openai/codex),如没有再添加;已有就跳过 `remote add`
32+
33+
```bash
34+
git remote -v
35+
git remote add origin <ORIGIN_GIT_URL>
36+
git remote add upstream https://github.com/openai/codex.git
37+
```
38+
39+
### 1) Freeze OLD_BRANCH (把现有改动“固化”为可回看的参考)
40+
41+
- 把工作区改动都提交到 `OLD_BRANCH`(包括你写的意图 Markdown)。
42+
- 建议把 `OLD_BRANCH` 推到你的 fork 远端(例如 `origin`),避免本地丢失。
43+
- 可选:打一个 snapshot tag/branch,方便以后回溯。
44+
45+
### 2) Fetch tags & choose TAG
46+
47+
```bash
48+
git fetch upstream --tags --prune
49+
git for-each-ref --sort=-creatordate --format='%(creatordate:iso8601) %(refname:short)' refs/tags
50+
```
51+
52+
让用户从列表中选择一个 `TAG`(例如 `v0.2`)。
53+
54+
### 3) Generate a re-implementation bundle & create NEW_BRANCH
55+
56+
用脚本生成“重实现材料包”(默认输出到 `/tmp/codex-upstream-reapply/...`),并从 `TAG` 创建 `NEW_BRANCH`
57+
58+
```bash
59+
# 建议在 OLD_BRANCH 上执行;省略 --old-branch 时默认使用当前分支作为 OLD_BRANCH
60+
bash .agents/skills/codex-upstream-reapply/scripts/start_from_tag.sh \
61+
--remote upstream --tag TAG
62+
```
63+
64+
它会记录:
65+
66+
- `OLD_BRANCH` 相对 `TAG``merge-base`(作为改动基线)
67+
- 变更文件清单、diff patch、commit 列表
68+
-(默认)复制所有“变更过的 Markdown 意图文档”的旧版内容到 bundle 里
69+
-(可选)用 `--copy-all` 复制所有变更文件的旧版内容(用于离线阅读)
70+
并且会把 `OLD_BRANCH``README.md``CHANGED.md``.agents/skills/` 原样复制到 `NEW_BRANCH`(不改内容;如有差异会自动提交一次)。
71+
72+
如果基线推断可疑(脚本会提示),请显式指定旧分支基线 tag:
73+
74+
```bash
75+
bash .agents/skills/codex-upstream-reapply/scripts/start_from_tag.sh \
76+
--remote upstream --tag TAG \
77+
--old-base-tag v0.1
78+
```
79+
80+
### 4) Read OLD_BRANCH as reference (理解需求与意图,而不是直接套 patch)
81+
82+
从 bundle 里先读清楚“要实现什么”,再开始在 `NEW_BRANCH` 上写代码。
83+
84+
常用命令(在 `NEW_BRANCH` 上也能直接读取旧分支文件):
85+
86+
```bash
87+
git show OLD_BRANCH:path/to/file
88+
git diff OLD_BRANCH -- path/to/file
89+
```
90+
91+
如果你需要“旧分支相对当时基线的真实改动”,用 bundle 里的 `BASE_COMMIT`(在 `META.md` 里):
92+
93+
```bash
94+
git diff BASE_COMMIT..OLD_BRANCH -- path/to/file
95+
```
96+
97+
### 5) Re-implement on NEW_BRANCH
98+
99+
- 按“需求点/模块”拆分小 commit 逐步实现。
100+
- 让意图文档与实现保持一致(必要时更新 Markdown)。
101+
- 不跑测试;不要生成或更新任何测试文件/快照文件。
102+
103+
### 5.1) Status header 规范(改动 TUI 状态栏时)
104+
105+
- Nerd Font 图标(固定):
106+
- model: `\u{ee9c}`
107+
- directory: `\u{f07c}`
108+
- git: `\u{f418}`
109+
- rate limit: `\u{f464}`
110+
- 配色(固定):
111+
- model(icon + label):`cyan`
112+
- directory(icon + path):`yellow`
113+
- git icon + branch:`blue`
114+
- git ahead:`green`
115+
- git behind:`red`
116+
- git changed:`yellow`
117+
- git untracked:`red`
118+
- rate limit(icon + summary):`cyan`
119+
- segment separator `" │ "``dim`
120+
121+
### 6) Build (codex-rs)
122+
123+
`codex-rs` 目录下执行:
124+
125+
```bash
126+
cargo build -p codex-cli
127+
```
128+
129+
### 7) Sanity checks
130+
131+
比较“你最终在新分支做了哪些改动”(相对 `TAG`):
132+
133+
```bash
134+
git diff --stat TAG..NEW_BRANCH
135+
git diff TAG..NEW_BRANCH
136+
```
137+
138+
对照旧分支材料包,确认需求点都覆盖到即可(不要求 diff 完全一致)。
139+
140+
更多对照方式(worktree、merge-base 对照等)见 `references/advanced.md`
141+
142+
## How changes are computed from OLD_BRANCH
143+
144+
默认用以下方式推断旧分支的“改动基线”:
145+
146+
```bash
147+
BASE_COMMIT="$(git merge-base TAG OLD_BRANCH)"
148+
git diff "${BASE_COMMIT}..OLD_BRANCH"
149+
```
150+
151+
如果推断结果可疑(例如 `OLD_BRANCH` 的历史标记与 `TAG` 不一致),脚本会停止并要求你明确指定:
152+
153+
```bash
154+
--old-base-tag v0.1
155+
```
156+
157+
这样可以准确得到 “从 v0.1 到 OLD_BRANCH 的全部二开变更”。
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Advanced Recipes
2+
3+
## Two worktrees for side-by-side porting (recommended)
4+
5+
Use when:
6+
- You want to read old code/docs while implementing on the new tag-based branch.
7+
- You want to avoid constantly switching branches.
8+
9+
Example:
10+
11+
```bash
12+
# In repo root (adjust paths as needed)
13+
git fetch upstream --tags --prune
14+
15+
# Old branch worktree (reference)
16+
git worktree add /tmp/wt-old OLD_BRANCH
17+
18+
# New branch worktree (fresh branch from selected tag)
19+
git worktree add -b NEW_BRANCH /tmp/wt-new TAG
20+
```
21+
22+
Cleanup:
23+
24+
```bash
25+
git worktree remove /tmp/wt-old
26+
git worktree remove /tmp/wt-new
27+
```
28+
29+
## Find the real delta of OLD_BRANCH (merge-base vs tag)
30+
31+
Use when:
32+
- Your old branch was based on an older tag/commit and you want the exact “custom delta”.
33+
34+
Example:
35+
36+
```bash
37+
BASE_COMMIT="$(git merge-base TAG OLD_BRANCH)"
38+
git diff "${BASE_COMMIT}..OLD_BRANCH" > /tmp/old-delta.patch
39+
git diff --name-status "${BASE_COMMIT}..OLD_BRANCH"
40+
```
41+
42+
## Read old files without switching branches
43+
44+
Use when:
45+
- You are on NEW_BRANCH but want to view old docs/code quickly.
46+
47+
```bash
48+
git show OLD_BRANCH:path/to/file
49+
```
50+
51+
For diffs:
52+
53+
```bash
54+
git diff OLD_BRANCH -- path/to/file
55+
```
56+
57+
## Compare “custom delta” old vs new
58+
59+
Use when:
60+
- NEW_BRANCH is based on a selected tag and you want to verify your re-implementation covers the old intent.
61+
62+
```bash
63+
OLD_BASE="$(git merge-base TAG OLD_BRANCH)"
64+
65+
# Old delta (against its original base)
66+
git diff "${OLD_BASE}..OLD_BRANCH" > /tmp/old.patch
67+
68+
# New delta (against selected tag)
69+
git diff TAG..NEW_BRANCH > /tmp/new.patch
70+
71+
# Optional quick check (names only)
72+
git diff --name-status "${OLD_BASE}..OLD_BRANCH"
73+
git diff --name-status TAG..NEW_BRANCH
74+
```

0 commit comments

Comments
 (0)