@hunyed15/codecgc 0.1.0 → 0.1.1

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/INSTALLATION.md CHANGED
@@ -34,16 +34,21 @@ npm --version # 应显示 9.x.x 或更高
34
34
 
35
35
  ## 安装 CodeCGC
36
36
 
37
- ### 方式 1:从源码全局安装(推荐)
37
+ ### 方式 1:从 npm 全局安装(推荐)
38
38
 
39
39
  ```bash
40
- # 1. 解压 release 包到本地目录
41
- cd /path/to/codecgc/release
40
+ # 使用 npm 官方源安装
41
+ npm install -g @hunyed15/codecgc --registry=https://registry.npmjs.org/
42
+ ```
43
+
44
+ 安装完成后,CodeCGC 会尝试自动执行一次用户级 Claude 集成,相当于:
42
45
 
43
- # 2. 全局安装
44
- npm install -g .
46
+ ```bash
47
+ cgc-install --mode user
45
48
  ```
46
49
 
50
+ 如果安装阶段因为 Python 未就绪而跳过了这一步,可以在装好 Python 后手动补执行该命令。
51
+
47
52
  安装后,以下命令将全局可用:
48
53
  - `cgc`
49
54
  - `cgc-install`
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # CodeCGC Release v0.1.0
1
+ # CodeCGC Release v0.1.1
2
2
 
3
3
  ## 📦 发布内容
4
4
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## 📋 版本信息
8
8
 
9
- - **版本号**: 0.1.0
9
+ - **版本号**: 0.1.1
10
10
  - **发布日期**: 2026-05-04
11
11
  - **Python 要求**: >= 3.10
12
12
  - **Node.js 要求**: >= 20.0.0
@@ -36,20 +36,19 @@
36
36
  ### 1. 安装
37
37
 
38
38
  ```bash
39
- # 进入 release 目录
40
- cd /path/to/codecgc/release
41
-
42
- # 安装 CodeCGC
43
- npm install -g .
39
+ # npm 安装 CodeCGC
40
+ npm install -g @hunyed15/codecgc --registry=https://registry.npmjs.org/
44
41
 
45
42
  # 安装 Python 依赖
46
43
  pip install pyyaml
47
44
 
48
- # 安装 MCP 服务器
49
- cd codexmcp && pip install -e . && cd ..
50
- cd geminimcp && pip install -e . && cd ..
45
+ # 如自动集成未生效,可手动补执行
46
+ cgc-install --mode user
51
47
  ```
52
48
 
49
+ 全局安装完成后,CodeCGC 会尝试自动写入 Claude 用户级集成到 `~/.claude`。
50
+ 如果安装时 Python 尚未就绪,自动集成会跳过,此时可在安装 Python 后手动执行 `cgc-install --mode user`。
51
+
53
52
  ### 2. 初始化项目
54
53
 
55
54
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hunyed15/codecgc",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Claude-hosted multi-model workflow product shell for CodeCGC.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -23,6 +23,7 @@
23
23
  "cgc-route": "bin/cgc-route.js"
24
24
  },
25
25
  "scripts": {
26
+ "postinstall": "node scripts/postinstall_codecgc.js",
26
27
  "cgc:help": "node bin/cgc.js --help",
27
28
  "cgc:status": "node bin/cgc-status.js --format summary",
28
29
  "cgc:doctor": "node bin/cgc-doctor.js --format summary",
@@ -39,6 +40,7 @@
39
40
  "files": [
40
41
  "bin/",
41
42
  "scripts/*.py",
43
+ "scripts/postinstall_codecgc.js",
42
44
  "scripts/README-codecgc-cli.md",
43
45
  ".claude/hooks/route-edit.ps1",
44
46
  "codecgc/cgc/",
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require("node:child_process");
4
+ const path = require("node:path");
5
+
6
+ function shouldRunUserInstall() {
7
+ const globalFlag = String(process.env.npm_config_global || "").toLowerCase();
8
+ const localPrefix = String(process.env.npm_config_local_prefix || "");
9
+ const prefix = String(process.env.npm_config_prefix || "");
10
+
11
+ if (globalFlag === "true") {
12
+ return true;
13
+ }
14
+ if (prefix && localPrefix && prefix !== localPrefix) {
15
+ return true;
16
+ }
17
+ return false;
18
+ }
19
+
20
+ function findPython() {
21
+ const override = String(process.env.CODECGC_PYTHON_COMMAND || "").trim();
22
+ const candidates = override
23
+ ? [override]
24
+ : (process.platform === "win32" ? ["python", "py"] : ["python3", "python"]);
25
+
26
+ for (const command of candidates) {
27
+ const probe = spawnSync(command, ["--version"], {
28
+ encoding: "utf8",
29
+ shell: false,
30
+ });
31
+ if (probe.status === 0) {
32
+ return command;
33
+ }
34
+ }
35
+ return "";
36
+ }
37
+
38
+ function main() {
39
+ if (!shouldRunUserInstall()) {
40
+ return 0;
41
+ }
42
+
43
+ const python = findPython();
44
+ if (!python) {
45
+ console.warn("[codecgc] Skipped automatic Claude integration: Python was not found.");
46
+ console.warn("[codecgc] Run `cgc-install --mode user` after installing Python.");
47
+ return 0;
48
+ }
49
+
50
+ const repoRoot = path.resolve(__dirname, "..");
51
+ const installScript = path.join(repoRoot, "scripts", "install_codecgc.py");
52
+ const result = spawnSync(
53
+ python,
54
+ [installScript, "--mode", "user", "--format", "summary"],
55
+ {
56
+ cwd: repoRoot,
57
+ stdio: "inherit",
58
+ shell: false,
59
+ env: {
60
+ ...process.env,
61
+ PYTHONIOENCODING: process.env.PYTHONIOENCODING || "utf-8",
62
+ PYTHONUTF8: process.env.PYTHONUTF8 || "1",
63
+ },
64
+ },
65
+ );
66
+
67
+ if (result.status !== 0) {
68
+ console.warn("[codecgc] Automatic Claude integration did not complete during npm install.");
69
+ console.warn("[codecgc] You can retry manually with `cgc-install --mode user`.");
70
+ }
71
+
72
+ return 0;
73
+ }
74
+
75
+ process.exit(main());