-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregenerate.sh
More file actions
executable file
·70 lines (61 loc) · 2.66 KB
/
regenerate.sh
File metadata and controls
executable file
·70 lines (61 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
#
# Clean-room regeneration of the App Server protocol types.
#
# Why "clean-room": we delete ALL of src/ before regenerating, so that types
# the new Codex version renamed or removed disappear from the working tree and
# show up as deletions/renames in `git add` — a plain re-run would leave stale
# files behind and only ever show additions/modifications.
#
# Steps:
# 1. Resolve + print the codex binary and its version.
# 2. rm -rf src (so removals/renames surface in the diff)
# 3. codex app-server generate-ts --out ./src --experimental
# 4. git add -A src
# 5. Print an A/D/M summary, the file count, and the detected version.
#
# Binary selection (first match wins):
# - $PWRDRVR_CODEX_BIN if set
# - Codex Desktop's bundled binary (default)
# To pin an EXACT released version (recommended for a real release), download
# the matching release binary and point PWRDRVR_CODEX_BIN at it — see AGENTS.md.
#
set -euo pipefail
CODEX_BIN="${PWRDRVR_CODEX_BIN:-/Applications/Codex.app/Contents/Resources/codex}"
# Repo root = parent of this script's directory.
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
if [[ ! -x "$CODEX_BIN" ]]; then
echo "error: codex binary not found or not executable: $CODEX_BIN" >&2
echo " set PWRDRVR_CODEX_BIN to a codex binary (see AGENTS.md)." >&2
exit 1
fi
VERSION_RAW="$("$CODEX_BIN" --version)" # e.g. "codex-cli 0.135.0"
VERSION="${VERSION_RAW##* }" # -> "0.135.0"
echo "codex binary : $CODEX_BIN"
echo "codex version: $VERSION_RAW"
echo
# 1. Delete all generated code so removals/renames surface in the diff.
echo "==> rm -rf src"
rm -rf src
mkdir -p src
# 2. Regenerate (experimental surface included).
echo "==> codex app-server generate-ts --out ./src --experimental"
"$CODEX_BIN" app-server generate-ts --out ./src --experimental
# 3. Stage so added/removed/changed files all appear in `git status`.
echo "==> git add -A src"
git add -A src
# 4. Summary.
echo
echo "Staged changes (A=added, D=deleted, M=modified, R=renamed):"
git diff --cached --name-status -- src | sed 's/^/ /'
echo
echo " added : $(git diff --cached --name-status -- src | grep -c '^A' || true)"
echo " deleted : $(git diff --cached --name-status -- src | grep -c '^D' || true)"
echo " modified: $(git diff --cached --name-status -- src | grep -c '^M' || true)"
echo " .ts files now: $(find src -name '*.ts' | wc -l | tr -d ' ')"
echo
echo "Detected codex version: $VERSION"
echo "Next: set package.json \"version\" and \"codexCliVersion\" to \"$VERSION\","
echo " refresh the README \"Current generated source\" line + file count,"
echo " then run \`pnpm typecheck\`. See AGENTS.md."