Skip to content
Open
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
265 changes: 265 additions & 0 deletions .agents/skills/codex-upstream-reapply/SKILL.md

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions .agents/skills/codex-upstream-reapply/references/advanced.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Advanced Recipes

## Two worktrees for side-by-side porting (recommended)

Use when:
- You want to read old code/docs while implementing on the new tag-based branch.
- You want to avoid constantly switching branches.

Example:

```bash
# In repo root (adjust paths as needed)
git fetch upstream 'refs/tags/rust-*:refs/tags/rust-*' --prune

# Old branch worktree (reference)
git worktree add /tmp/wt-old OLD_BRANCH

# New branch worktree (fresh branch from selected tag)
git worktree add -b NEW_BRANCH /tmp/wt-new TAG
```

Cleanup:

```bash
git worktree remove /tmp/wt-old
git worktree remove /tmp/wt-new
```

## Find the real delta of OLD_BRANCH (merge-base vs tag)

Use when:
- Your old branch was based on an older tag/commit and you want the exact “custom delta”.

Example:

```bash
BASE_COMMIT="$(git merge-base TAG OLD_BRANCH)"
git diff "${BASE_COMMIT}..OLD_BRANCH" > /tmp/old-delta.patch
git diff --name-status "${BASE_COMMIT}..OLD_BRANCH"
```

## Read old files without switching branches

Use when:
- You are on NEW_BRANCH but want to view old docs/code quickly.

```bash
git show OLD_BRANCH:path/to/file
```

For diffs:

```bash
git diff OLD_BRANCH -- path/to/file
```

## Compare “custom delta” old vs new

Use when:
- NEW_BRANCH is based on a selected tag and you want to verify your re-implementation covers the old intent.

```bash
OLD_BASE="$(git merge-base TAG OLD_BRANCH)"

# Old delta (against its original base)
git diff "${OLD_BASE}..OLD_BRANCH" > /tmp/old.patch

# New delta (against selected tag)
git diff TAG..NEW_BRANCH > /tmp/new.patch

# Optional quick check (names only)
git diff --name-status "${OLD_BASE}..OLD_BRANCH"
git diff --name-status TAG..NEW_BRANCH
```
34 changes: 34 additions & 0 deletions .agents/skills/codex-upstream-reapply/references/npm-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# NPM Release Reapply Rules

## Package identity

- npm package: `@loongphy/codext`
- Platform packages: `@loongphy/codext-{linux-x64,linux-arm64,darwin-x64,darwin-arm64,win32-x64}`
- User command: `codext` (not `codex`)
- Native binary inside vendor: `codex` / `codex.exe` (unchanged)
- All user-facing text (tooltips, resume hints, README) must say `codext`

## Mandatory copy from OLD_BRANCH

Use the OLD_BRANCH release workflow as the `F_OLD` packaging baseline, then apply the release CI sync procedure before pushing. Copy these codext packaging files from OLD_BRANCH:

1. `.github/workflows/rust-release.yml`
2. `.github/scripts/install-musl-build-tools.sh`
3. `.github/scripts/rusty_v8_bazel.py`
4. `codex-cli/package.json`
5. `codex-cli/bin/codex.js`
6. `codex-cli/bin/rg`
7. `codex-cli/scripts/build_npm_package.py`
8. `codex-cli/scripts/install_native_deps.py`

## Mandatory deletes

Delete all `.github/workflows/*` that OLD_BRANCH deleted (i.e. workflows carried over from the upstream tag but not needed by this fork). Do not blindly delete workflows that upstream TAG newly added — evaluate those after the mandatory steps.

## Verify release workflow compatibility

Read [release-ci-sync.md](release-ci-sync.md) together with the npm release work, immediately before the final commit and push. It defines the three-way `U_OLD` / `F_OLD` / `U_NEW` comparison, the build/GitHub Release/npm Release scope, model-driven application of upstream changes, and the required final report.

## After mandatory steps

Only then evaluate upstream TAG's new/changed CI files. If they don't affect the release pipeline, ignore them. If they must be merged, do minimal integration without changing package names or command names.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Release CI Sync

Run this procedure together with the npm/release work, after implementation is complete and immediately before the final commit and push. This is a release workflow review, not a GitHub Actions monitoring loop.

## Scope

Only carry upstream release workflow changes that affect:

1. Build and shipped artifacts.
2. GitHub Release assets.
3. npm package staging or publication.

Use the artifact flow to decide scope:

```text
build -> upload/download -> archive/vendor -> GitHub Release or npm publish
```

Include setup, signing, checksum, and verification changes when they affect that flow. Exclude unrelated upstream products and jobs, such as website deployment or an independent wheel, unless the current codext release consumes their output.

## Three-way inputs

Use the explicit old base tag. Do not infer it from branch names:

```text
U_OLD = OLD_BASE_TAG:.github/workflows/rust-release.yml
F_OLD = OLD_BRANCH:.github/workflows/rust-release.yml
U_NEW = NEW_TAG:.github/workflows/rust-release.yml
```

Read `git diff U_OLD..U_NEW` to discover upstream's final release changes. Treat `F_OLD` as the working release baseline because it contains the known-good codext packaging flow. Do not replace it with `U_NEW` wholesale.

## Model decision

The model decides which upstream changes to apply. Inventory and `git diff` are evidence, not an automatic patch authority.

For every upstream release change, classify it as:

- `APPLIED`: patch or re-implement it in the existing codext build, GitHub Release, or npm Release flow.
- `OVERRIDE`: retain the codext behavior because it is an intentional long-term fork policy.
- `NOT_APPLIED`: leave it out when it is outside the three release scopes.

When the workflow structures differ, re-implement the upstream behavior in the existing codext structure. Do not force a textual patch or replace the whole workflow.

Do not hardcode a particular upstream binary in this procedure. Discover binaries from the upstream release matrix and trace each one through the artifact flow. Companion binaries required by an existing codext executable are in scope; independent upstream products are not automatically added.

Changes that cannot be proved relevant to the three scopes are not applied. Report them in the final response with the upstream change, its purpose, and why it was not applied.

## Fork overrides

Read `release-overrides.json` before making the decision. It contains only long-lived codext policy, such as package identity, command name, and intentionally different release triggers.

The model may update the manifest automatically when a difference is clearly a durable fork policy. Include that update in the same commit as the release workflow changes. Explain every manifest change in the final response. Do not add one-off tag-specific observations to the manifest.

## Required checks

Before committing and pushing npm/release work:

1. Run `bash .agents/skills/codex-upstream-reapply/scripts/check_release_artifact_parity.sh` as a generic structural preflight.
2. Compare the upstream binary matrix with the current build commands and follow every in-scope output through upload, archive/vendor, and publish steps.
3. Use the upstream workspace-level Cargo invocation for the selected binary set; do not split companion binaries into separate package builds.
4. Run the skill's local build acceptance. Do not run tests, snapshots, formatters, or linters under the reapply guardrails.
5. Include `APPLIED`, `OVERRIDE`, and `NOT_APPLIED` decisions in the final report.

GitHub Actions is a separate follow-up workflow. Do not wait for or repeatedly repair Actions unless the user explicitly asks to read or fix CI.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"workflow": ".github/workflows/rust-release.yml",
"scope": [
"build-artifacts",
"github-release",
"npm-release"
],
"identity": {
"npm_package": "@loongphy/codext",
"platform_package_prefix": "@loongphy/codext-",
"cli_command": "codext"
},
"trigger": {
"mode": "main_push",
"reason": "codext publishes continuous fork builds instead of upstream tag releases"
},
"allowed_deviations": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -euo pipefail

repo_root="$(git rev-parse --show-toplevel)"
workflow="${repo_root}/.github/workflows/rust-release.yml"

if [[ ! -f "${workflow}" || ! -f "${repo_root}/codex-cli/package.json" ]]; then
exit 0
fi

required_patterns=(
"cargo build"
"actions/upload-artifact"
"npm publish"
)
for pattern in "${required_patterns[@]}"; do
if ! rg -F --quiet -- "${pattern}" "${workflow}"; then
echo "[ERROR] Release workflow is missing required release surface: ${pattern}" >&2
exit 1
fi
done

for path in \
"${repo_root}/codex-cli/scripts/build_npm_package.py" \
"${repo_root}/codex-cli/scripts/install_native_deps.py" \
"${repo_root}/scripts/install/install.sh" \
"${repo_root}/scripts/install/install.ps1" \
"${repo_root}/scripts/codex_package/cargo.py"; do
if [[ ! -f "${path}" ]]; then
echo "[ERROR] Release packaging path is missing: ${path}" >&2
exit 1
fi
done

echo "[OK] Release CI structural preflight passed; complete semantic review from release-ci-sync.md"
Loading