claude-codex-code-review 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,22 +13,50 @@
13
13
 
14
14
  ## 安装
15
15
 
16
- ### 使用 curl
16
+ ### 全局安装(默认)
17
17
 
18
- 在目标项目根目录执行:
18
+ 安装后所有项目都可以直接使用 `/codex-review`,无需逐个项目安装。
19
+
20
+ 使用 npx:
21
+
22
+ ```bash
23
+ npx claude-codex-code-review install
24
+ ```
25
+
26
+ 使用 curl:
19
27
 
20
28
  ```bash
21
29
  curl -fsSL https://raw.githubusercontent.com/lkkwxy/claude-codex-claude-codex-review-claude/main/scripts/install.sh | bash
22
30
  ```
23
31
 
32
+ 全局安装会:
33
+
34
+ - 将脚本安装到 `~/.claude/scripts/codex-review.sh`
35
+ - 将斜杠命令安装到 `~/.claude/commands/codex-review.md`
36
+ - 将 `.ai-review/` 加入全局 gitignore,确保中间文件不会被任何项目提交
37
+
38
+ 如果某个项目需要自定义配置,在该项目根目录创建 `.codex-review.yml` 即可。
39
+
40
+ ### 项目级安装
41
+
42
+ 如果只想在单个项目中使用,可以在项目根目录执行:
43
+
44
+ #### 使用 curl
45
+
46
+ 在目标项目根目录执行:
47
+
48
+ ```bash
49
+ curl -fsSL https://raw.githubusercontent.com/lkkwxy/claude-codex-claude-codex-review-claude/main/scripts/install.sh | bash -s -- --local
50
+ ```
51
+
24
52
  注意:`curl | bash` 必须使用 `raw.githubusercontent.com` 地址,不能使用 GitHub 页面里的 `blob/main` 地址。
25
53
 
26
- ### 使用 npx
54
+ #### 使用 npx
27
55
 
28
- 发布到 npm 后,可以在目标项目根目录执行:
56
+ 在目标项目根目录执行:
29
57
 
30
58
  ```bash
31
- npx claude-codex-code-review install
59
+ npx claude-codex-code-review install -- --local
32
60
  ```
33
61
 
34
62
  也可以指定安装目录:
@@ -45,7 +73,7 @@ npx claude-codex-code-review install -- --force
45
73
 
46
74
  ## 使用
47
75
 
48
- 安装后,在目标项目里打开 Claude Code,运行:
76
+ 安装后,在任意项目里打开 Claude Code,运行:
49
77
 
50
78
  ```text
51
79
  /codex-review
package/bin/codex-review CHANGED
@@ -2,9 +2,17 @@
2
2
  set -u
3
3
  set -o pipefail
4
4
 
5
- PACKAGE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
5
+ SOURCE="${BASH_SOURCE[0]}"
6
+ while [ -L "$SOURCE" ]; do
7
+ SCRIPT_DIR="$(cd "$(dirname "$SOURCE")" && pwd -P)"
8
+ SOURCE="$(readlink "$SOURCE")"
9
+ [[ "$SOURCE" != /* ]] && SOURCE="$SCRIPT_DIR/$SOURCE"
10
+ done
11
+ PACKAGE_ROOT="$(cd "$(dirname "$SOURCE")/.." && pwd -P)"
6
12
  TARGET_DIR="$(pwd)"
7
13
  FORCE=0
14
+ GLOBAL=1
15
+ LOCAL=0
8
16
 
9
17
  usage() {
10
18
  cat <<'USAGE'
@@ -12,15 +20,17 @@ Usage:
12
20
  claude-codex-code-review install [options]
13
21
  claude-codex-code-review --help
14
22
 
15
- Installs the Claude Code /codex-review command into the current project.
23
+ Installs the Claude Code /codex-review command globally (default) or into a specific project.
16
24
 
17
25
  Options:
18
- --target-dir <dir> Install into a specific project directory. Default: current directory.
19
- --force Overwrite existing codex-review files.
20
- -h, --help Show this help.
26
+ --local Install into the current project instead of globally.
27
+ --target-dir <dir> Install into a specific project directory (implies --local).
28
+ --force Overwrite existing codex-review files.
29
+ -h, --help Show this help.
21
30
 
22
31
  Examples:
23
32
  npx claude-codex-code-review install
33
+ npx claude-codex-code-review install -- --local
24
34
  npx claude-codex-code-review install -- --target-dir /path/to/project
25
35
  npx claude-codex-code-review install -- --force
26
36
  USAGE
@@ -65,6 +75,53 @@ append_gitignore_once() {
65
75
  fi
66
76
  }
67
77
 
78
+ install_global() {
79
+ local global_commands_dir="$HOME/.claude/commands"
80
+ local global_scripts_dir="$HOME/.claude/scripts"
81
+ local script_path="$global_scripts_dir/codex-review.sh"
82
+ local source_template="$PACKAGE_ROOT/.claude/commands/codex-review.md"
83
+ local source_script="$PACKAGE_ROOT/scripts/codex-review.sh"
84
+
85
+ if [ ! -f "$source_template" ]; then
86
+ fail "package template is missing: $source_template"
87
+ fi
88
+ if [ ! -f "$source_script" ]; then
89
+ fail "package template is missing: $source_script"
90
+ fi
91
+
92
+ mkdir -p "$global_commands_dir"
93
+ mkdir -p "$global_scripts_dir"
94
+
95
+ if [ -f "$global_scripts_dir/codex-review.sh" ] && [ "$FORCE" -ne 1 ]; then
96
+ log "Keeping existing $global_scripts_dir/codex-review.sh"
97
+ else
98
+ cp "$source_script" "$global_scripts_dir/codex-review.sh"
99
+ chmod +x "$global_scripts_dir/codex-review.sh"
100
+ log "Installed $global_scripts_dir/codex-review.sh"
101
+ fi
102
+
103
+ if [ -f "$global_commands_dir/codex-review.md" ] && [ "$FORCE" -ne 1 ]; then
104
+ log "Keeping existing $global_commands_dir/codex-review.md"
105
+ else
106
+ sed "s|Bash(scripts/codex-review.sh:|Bash(${script_path}:|g;
107
+ s|scripts/codex-review.sh \"\$ARGUMENTS\"|${script_path} \"\$ARGUMENTS\"|g" \
108
+ "$source_template" > "$global_commands_dir/codex-review.md"
109
+ log "Installed $global_commands_dir/codex-review.md"
110
+ fi
111
+
112
+ local excludes_file
113
+ excludes_file="$(git config --global core.excludesFile 2>/dev/null || true)"
114
+ if [ -z "$excludes_file" ]; then
115
+ excludes_file="$HOME/.gitignore_global"
116
+ git config --global core.excludesFile "$excludes_file"
117
+ log "Set git global core.excludesFile to $excludes_file"
118
+ fi
119
+ append_gitignore_once "$excludes_file"
120
+
121
+ log "Global install complete. /codex-review is now available in all projects."
122
+ log "Optional: create .codex-review.yml in any project to customize settings."
123
+ }
124
+
68
125
  COMMAND="${1:-install}"
69
126
  case "$COMMAND" in
70
127
  install)
@@ -81,13 +138,19 @@ esac
81
138
 
82
139
  while [ "$#" -gt 0 ]; do
83
140
  case "$1" in
141
+ --local)
142
+ GLOBAL=0
143
+ shift
144
+ ;;
84
145
  --target-dir)
85
146
  [ "$#" -ge 2 ] || fail "--target-dir requires a value."
86
147
  TARGET_DIR="$2"
148
+ GLOBAL=0
87
149
  shift 2
88
150
  ;;
89
151
  --target-dir=*)
90
152
  TARGET_DIR="${1#*=}"
153
+ GLOBAL=0
91
154
  shift
92
155
  ;;
93
156
  --force)
@@ -104,6 +167,11 @@ while [ "$#" -gt 0 ]; do
104
167
  esac
105
168
  done
106
169
 
170
+ if [ "$GLOBAL" -eq 1 ]; then
171
+ install_global
172
+ exit 0
173
+ fi
174
+
107
175
  mkdir -p "$TARGET_DIR"
108
176
  cd "$TARGET_DIR" || fail "cannot enter target directory: $TARGET_DIR"
109
177
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-codex-code-review",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Install a Claude Code /codex-review command that runs Codex CLI review and lets Claude apply selected fixes.",
5
5
  "license": "MIT",
6
6
  "bin": {