@cc-go-proxy/ccgp 0.0.0-stage → 0.1.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/bin/ccgp.js ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ // Starts the prebuilt ccgp binary that npm installed for this platform as an
3
+ // optional dependency (@cc-go-proxy/ccgp-<platform>-<arch>, w32 for win32), and passes
4
+ // arguments, stdio, signals and the exit code through.
5
+ 'use strict';
6
+
7
+ const { spawn } = require('node:child_process');
8
+ const { chmodSync } = require('node:fs');
9
+ const { basename } = require('node:path');
10
+
11
+ // Windows packages are named w32-<arch> (see PLATFORMS in build.mjs).
12
+ const key = `${process.platform === 'win32' ? 'w32' : process.platform}-${process.arch}`;
13
+ const pkg = `@cc-go-proxy/ccgp-${key}`;
14
+ // bin/ccgpy.js starts the ccgpy binary (ccgp with permission prompts off), bin/ccgp.js starts ccgp.
15
+ const name = basename(__filename, '.js') === 'ccgpy' ? 'ccgpy' : 'ccgp';
16
+ const exe = process.platform === 'win32' ? `${name}.exe` : name;
17
+
18
+ let bin;
19
+ try {
20
+ bin = require.resolve(`${pkg}/bin/${exe}`);
21
+ } catch {
22
+ console.error(`${name}: there is no prebuilt binary for ${key} (${pkg} is not installed).`);
23
+ console.error('If npm skipped optional dependencies (--omit=optional), install again without that flag.');
24
+ console.error('Otherwise use a release archive: https://github.com/PHPCraftdream/cc-go-proxy/releases');
25
+ console.error('or: go install github.com/PHPCraftdream/cc-go-proxy/cmd/ccgp@latest');
26
+ process.exit(1);
27
+ }
28
+
29
+ if (process.platform !== 'win32') {
30
+ try {
31
+ chmodSync(bin, 0o755); // npm does not keep the executable bit of non-bin files
32
+ } catch {
33
+ // read-only install: the bit may already be set
34
+ }
35
+ }
36
+
37
+ const child = spawn(bin, process.argv.slice(2), { stdio: 'inherit' });
38
+
39
+ // Ctrl+C reaches the child through the terminal already; do not deliver it twice.
40
+ process.on('SIGINT', () => {});
41
+ for (const sig of ['SIGTERM', 'SIGHUP']) {
42
+ process.on(sig, () => {
43
+ try {
44
+ child.kill(sig);
45
+ } catch {
46
+ // already gone
47
+ }
48
+ });
49
+ }
50
+
51
+ child.on('error', (err) => {
52
+ console.error(`${name}: cannot start ${bin}: ${err.message}`);
53
+ process.exit(1);
54
+ });
55
+ child.on('exit', (code, signal) => {
56
+ if (signal) {
57
+ process.removeAllListeners(signal);
58
+ process.kill(process.pid, signal);
59
+ return;
60
+ }
61
+ process.exit(code === null ? 1 : code);
62
+ });
package/bin/ccgpy.js ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ // Starts the prebuilt ccgp binary that npm installed for this platform as an
3
+ // optional dependency (@cc-go-proxy/ccgp-<platform>-<arch>, w32 for win32), and passes
4
+ // arguments, stdio, signals and the exit code through.
5
+ 'use strict';
6
+
7
+ const { spawn } = require('node:child_process');
8
+ const { chmodSync } = require('node:fs');
9
+ const { basename } = require('node:path');
10
+
11
+ // Windows packages are named w32-<arch> (see PLATFORMS in build.mjs).
12
+ const key = `${process.platform === 'win32' ? 'w32' : process.platform}-${process.arch}`;
13
+ const pkg = `@cc-go-proxy/ccgp-${key}`;
14
+ // bin/ccgpy.js starts the ccgpy binary (ccgp with permission prompts off), bin/ccgp.js starts ccgp.
15
+ const name = basename(__filename, '.js') === 'ccgpy' ? 'ccgpy' : 'ccgp';
16
+ const exe = process.platform === 'win32' ? `${name}.exe` : name;
17
+
18
+ let bin;
19
+ try {
20
+ bin = require.resolve(`${pkg}/bin/${exe}`);
21
+ } catch {
22
+ console.error(`${name}: there is no prebuilt binary for ${key} (${pkg} is not installed).`);
23
+ console.error('If npm skipped optional dependencies (--omit=optional), install again without that flag.');
24
+ console.error('Otherwise use a release archive: https://github.com/PHPCraftdream/cc-go-proxy/releases');
25
+ console.error('or: go install github.com/PHPCraftdream/cc-go-proxy/cmd/ccgp@latest');
26
+ process.exit(1);
27
+ }
28
+
29
+ if (process.platform !== 'win32') {
30
+ try {
31
+ chmodSync(bin, 0o755); // npm does not keep the executable bit of non-bin files
32
+ } catch {
33
+ // read-only install: the bit may already be set
34
+ }
35
+ }
36
+
37
+ const child = spawn(bin, process.argv.slice(2), { stdio: 'inherit' });
38
+
39
+ // Ctrl+C reaches the child through the terminal already; do not deliver it twice.
40
+ process.on('SIGINT', () => {});
41
+ for (const sig of ['SIGTERM', 'SIGHUP']) {
42
+ process.on(sig, () => {
43
+ try {
44
+ child.kill(sig);
45
+ } catch {
46
+ // already gone
47
+ }
48
+ });
49
+ }
50
+
51
+ child.on('error', (err) => {
52
+ console.error(`${name}: cannot start ${bin}: ${err.message}`);
53
+ process.exit(1);
54
+ });
55
+ child.on('exit', (code, signal) => {
56
+ if (signal) {
57
+ process.removeAllListeners(signal);
58
+ process.kill(process.pid, signal);
59
+ return;
60
+ }
61
+ process.exit(code === null ? 1 : code);
62
+ });
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "@cc-go-proxy/ccgp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "license": "(MIT OR Apache-2.0)",
5
+ "author": "PHPCraftdream",
6
+ "homepage": "https://github.com/PHPCraftdream/cc-go-proxy#readme",
7
+ "bugs": {
8
+ "url": "https://github.com/PHPCraftdream/cc-go-proxy/issues"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/PHPCraftdream/cc-go-proxy.git"
13
+ },
14
+ "description": "Run Claude Code on ChatGPT Codex, OpenAI-compatible APIs and z.ai GLM: a headless Go bridge with token-in-URL auth and per-profile model mapping",
15
+ "keywords": [
16
+ "claude-code",
17
+ "anthropic",
18
+ "openai",
19
+ "codex",
20
+ "proxy",
21
+ "llm",
22
+ "gateway",
23
+ "glm",
24
+ "z.ai",
25
+ "oauth",
26
+ "cli"
27
+ ],
28
+ "bin": {
29
+ "ccgp": "bin/ccgp.js",
30
+ "ccgpy": "bin/ccgpy.js"
31
+ },
32
+ "files": [
33
+ "bin",
34
+ "LICENSE-MIT",
35
+ "LICENSE-APACHE",
36
+ "NOTICE",
37
+ "THIRD_PARTY_LICENSES.md"
38
+ ],
39
+ "engines": {
40
+ "node": ">=18"
41
+ },
42
+ "optionalDependencies": {
43
+ "@cc-go-proxy/ccgp-linux-x64": "0.1.0",
44
+ "@cc-go-proxy/ccgp-linux-arm64": "0.1.0",
45
+ "@cc-go-proxy/ccgp-darwin-x64": "0.1.0",
46
+ "@cc-go-proxy/ccgp-darwin-arm64": "0.1.0",
47
+ "@cc-go-proxy/ccgp-w32-x64": "0.1.0",
48
+ "@cc-go-proxy/ccgp-w32-arm64": "0.1.0"
49
+ }
50
+ }