@gonkagate/claude-code 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.
Files changed (49) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +201 -0
  3. package/README.md +98 -0
  4. package/bin/gonkagate-claude-code.js +15 -0
  5. package/dist/cli.d.ts +15 -0
  6. package/dist/cli.js +111 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/constants/gateway.d.ts +2 -0
  9. package/dist/constants/gateway.js +3 -0
  10. package/dist/constants/gateway.js.map +1 -0
  11. package/dist/constants/models.d.ts +27 -0
  12. package/dist/constants/models.js +28 -0
  13. package/dist/constants/models.js.map +1 -0
  14. package/dist/install/backup.d.ts +1 -0
  15. package/dist/install/backup.js +10 -0
  16. package/dist/install/backup.js.map +1 -0
  17. package/dist/install/load-settings.d.ts +6 -0
  18. package/dist/install/load-settings.js +32 -0
  19. package/dist/install/load-settings.js.map +1 -0
  20. package/dist/install/local-git-ignore.d.ts +1 -0
  21. package/dist/install/local-git-ignore.js +76 -0
  22. package/dist/install/local-git-ignore.js.map +1 -0
  23. package/dist/install/merge-env.d.ts +4 -0
  24. package/dist/install/merge-env.js +35 -0
  25. package/dist/install/merge-env.js.map +1 -0
  26. package/dist/install/object-utils.d.ts +1 -0
  27. package/dist/install/object-utils.js +4 -0
  28. package/dist/install/object-utils.js.map +1 -0
  29. package/dist/install/prompts.d.ts +25 -0
  30. package/dist/install/prompts.js +78 -0
  31. package/dist/install/prompts.js.map +1 -0
  32. package/dist/install/settings-paths.d.ts +2 -0
  33. package/dist/install/settings-paths.js +15 -0
  34. package/dist/install/settings-paths.js.map +1 -0
  35. package/dist/install/validate-api-key.d.ts +1 -0
  36. package/dist/install/validate-api-key.js +15 -0
  37. package/dist/install/validate-api-key.js.map +1 -0
  38. package/dist/install/write-settings.d.ts +2 -0
  39. package/dist/install/write-settings.js +25 -0
  40. package/dist/install/write-settings.js.map +1 -0
  41. package/dist/types/settings.d.ts +10 -0
  42. package/dist/types/settings.js +2 -0
  43. package/dist/types/settings.js.map +1 -0
  44. package/docs/how-it-works.md +46 -0
  45. package/docs/security.md +30 -0
  46. package/docs/troubleshooting.md +74 -0
  47. package/package.json +56 -0
  48. package/scripts/install.ps1 +12 -0
  49. package/scripts/install.sh +9 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ - Added a curated model registry and model picker to the public installer flow.
6
+ - Added `--model <model-key>` and `--model=<model-key>` support for curated non-secret model selection.
7
+ - Kept the public Claude Code contract tight by limiting model selection to the curated GonkaGate registry only.
8
+ - Updated docs and tests for model selection while preserving local git ignore protection and owner-only settings file permissions.
9
+
10
+ ## 0.1.0
11
+
12
+ - Initial public onboarding repo for connecting local Claude Code to GonkaGate.
13
+ - Added interactive Node CLI installer with hidden API key prompt.
14
+ - Added user and local Claude Code settings install scopes.
15
+ - Added JSON merge, backup, and validation behavior for Claude Code settings.
16
+ - Added public README plus troubleshooting, security, and how-it-works docs.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # gonkagate-claude-code
2
+
3
+ Set up Claude Code to use GonkaGate in one step.
4
+
5
+ This tool configures local `Claude Code` to use GonkaGate's Anthropic-compatible gateway at `https://api.gonkagate.com`.
6
+
7
+ It does not install `Claude Code` itself. It sets up an existing local Claude Code install.
8
+
9
+ ## Quick Start
10
+
11
+ ```bash
12
+ npx @gonkagate/claude-code
13
+ ```
14
+
15
+ You will be asked for:
16
+
17
+ - your GonkaGate API key (`gp-...`)
18
+ - a model from the supported GonkaGate list
19
+ - setup scope: `user` or `local`
20
+
21
+ You need:
22
+
23
+ - local `Claude Code`
24
+ - Node.js 18+
25
+ - a GonkaGate API key
26
+
27
+ ## What It Does
28
+
29
+ The tool writes Claude Code settings so you can keep running `claude` normally afterward.
30
+
31
+ By default it writes to:
32
+
33
+ - `~/.claude/settings.json`
34
+
35
+ If you choose local scope, it writes to:
36
+
37
+ - `.claude/settings.local.json`
38
+
39
+ It also:
40
+
41
+ - preserves unrelated Claude Code settings
42
+ - creates a backup before overwriting an existing settings file
43
+ - writes settings files with owner-only permissions
44
+ - adds `.claude/settings.local.json` to `.git/info/exclude` for local setup inside a git repo
45
+
46
+ ## Fixed GonkaGate Setup
47
+
48
+ These parts are intentionally fixed:
49
+
50
+ - Base URL: `https://api.gonkagate.com`
51
+ - Auth variable: `ANTHROPIC_AUTH_TOKEN`
52
+ - Model choice: only from the curated supported list
53
+
54
+ This tool does not ask for a custom base URL and does not accept arbitrary custom model IDs.
55
+
56
+ ## Supported Model
57
+
58
+ Current public Claude Code model:
59
+
60
+ - `qwen3-235b` -> `qwen/qwen3-235b-a22b-instruct-2507-fp8`
61
+
62
+ The selected model is written into all Claude Code model env vars used by this setup flow.
63
+
64
+ ## Verify
65
+
66
+ After setup:
67
+
68
+ 1. If Claude Code was previously logged directly into Anthropic, run `claude auth logout`
69
+ 2. Start Claude Code normally with `claude`
70
+ 3. Run `/status`
71
+ 4. Confirm the active gateway is `https://api.gonkagate.com`
72
+
73
+ ## What This Tool Does Not Do
74
+
75
+ - It does not configure `claude.ai`
76
+ - It does not edit `.zshrc`, `.bashrc`, PowerShell profiles, or other shell startup files
77
+ - It does not write `.env` files
78
+ - It does not support arbitrary custom model IDs
79
+ - It does not support custom base URL overrides
80
+
81
+ ## Need Help?
82
+
83
+ - Troubleshooting: [docs/troubleshooting.md](docs/troubleshooting.md)
84
+ - Security notes: [docs/security.md](docs/security.md)
85
+ - Internal behavior: [docs/how-it-works.md](docs/how-it-works.md)
86
+
87
+ ## Development
88
+
89
+ ```bash
90
+ npm install
91
+ npm run dev
92
+ ```
93
+
94
+ Useful commands:
95
+
96
+ - `npm run build`
97
+ - `npm test`
98
+ - `npm run ci`
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { CommanderError } from "commander";
4
+ import { run } from "../dist/cli.js";
5
+
6
+ run().catch((error) => {
7
+ if (error instanceof CommanderError) {
8
+ process.exitCode = error.exitCode;
9
+ return;
10
+ }
11
+
12
+ const message = error instanceof Error ? error.message : String(error);
13
+ console.error(`\nError: ${message}`);
14
+ process.exitCode = 1;
15
+ });
package/dist/cli.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { InstallScope } from "./types/settings.js";
2
+ import type { SupportedModelKey } from "./constants/models.js";
3
+ interface CliOptions {
4
+ help: boolean;
5
+ version: boolean;
6
+ scope?: InstallScope;
7
+ modelKey?: SupportedModelKey;
8
+ }
9
+ interface ProgramOutput {
10
+ writeOut?: (str: string) => void;
11
+ writeErr?: (str: string) => void;
12
+ }
13
+ export declare function parseCliOptions(argv: string[], output?: ProgramOutput): CliOptions;
14
+ export declare function run(argv?: string[]): Promise<void>;
15
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,111 @@
1
+ import process from "node:process";
2
+ import { pathToFileURL } from "node:url";
3
+ import { Command, CommanderError, Option } from "commander";
4
+ import { DEFAULT_MODEL_KEY, SUPPORTED_MODELS, SUPPORTED_MODEL_KEYS, requireSupportedModel } from "./constants/models.js";
5
+ import { createBackup } from "./install/backup.js";
6
+ import { loadSettings } from "./install/load-settings.js";
7
+ import { ensureLocalSettingsIgnored } from "./install/local-git-ignore.js";
8
+ import { mergeSettingsWithGonkaEnv } from "./install/merge-env.js";
9
+ import { promptForApiKey, promptForModel, promptForScope } from "./install/prompts.js";
10
+ import { getSettingsTarget } from "./install/settings-paths.js";
11
+ import { validateApiKey } from "./install/validate-api-key.js";
12
+ import { writeSettings } from "./install/write-settings.js";
13
+ function rejectApiKeyArgs(argv) {
14
+ if (argv.some((arg) => arg === "--api-key" || arg.startsWith("--api-key="))) {
15
+ throw new Error("Passing API keys via CLI arguments is intentionally unsupported. Run the installer interactively instead.");
16
+ }
17
+ }
18
+ function createProgram(output) {
19
+ const supportedModelLines = SUPPORTED_MODELS.map((model) => {
20
+ const defaultSuffix = model.key === DEFAULT_MODEL_KEY ? " (default)" : "";
21
+ return ` ${model.key} ${model.displayName}${defaultSuffix}`;
22
+ }).join("\n");
23
+ const program = new Command()
24
+ .name("gonkagate-claude-code")
25
+ .description("GonkaGate Claude Code installer")
26
+ .addOption(new Option("--model <model-key>", "Skip the model prompt with a curated supported model.").choices(SUPPORTED_MODEL_KEYS))
27
+ .addOption(new Option("--scope <scope>", "Skip the scope prompt. Choose user or local.").choices(["user", "local"]))
28
+ .helpOption("-h, --help", "Show this help.")
29
+ .version("0.1.0", "-v, --version", "Show the package version.")
30
+ .addHelpText("after", `
31
+ Examples:
32
+ npx @gonkagate/claude-code
33
+ npx @gonkagate/claude-code --model ${DEFAULT_MODEL_KEY}
34
+ npx @gonkagate/claude-code --scope local
35
+
36
+ Supported model keys:
37
+ ${supportedModelLines}
38
+ `)
39
+ .exitOverride();
40
+ if (output) {
41
+ program.configureOutput(output);
42
+ }
43
+ return program;
44
+ }
45
+ export function parseCliOptions(argv, output) {
46
+ rejectApiKeyArgs(argv);
47
+ const program = createProgram(output);
48
+ program.parse(["node", "gonkagate-claude-code", ...argv]);
49
+ const options = program.opts();
50
+ return {
51
+ help: false,
52
+ version: false,
53
+ scope: options.scope,
54
+ modelKey: options.model
55
+ };
56
+ }
57
+ function printIntro() {
58
+ console.log("Connect Claude Code to GonkaGate in one step.\n");
59
+ console.log("This installer writes Claude Code settings for GonkaGate's public gateway.");
60
+ console.log("Base URL is fixed to https://api.gonkagate.com and is not configurable.");
61
+ console.log(`Model choice is limited to the curated GonkaGate-supported list: ${SUPPORTED_MODEL_KEYS.join(", ")}.\n`);
62
+ }
63
+ function printSuccess(targetPath, scope, selectedModel, backupPath) {
64
+ console.log("\nInstall complete.\n");
65
+ console.log(`Updated: ${targetPath}`);
66
+ console.log(`Model: ${selectedModel.displayName} (${selectedModel.modelId})`);
67
+ if (backupPath) {
68
+ console.log(`Backup: ${backupPath}`);
69
+ }
70
+ console.log("\nNext steps:");
71
+ console.log("1. If Claude Code still shows direct Anthropic auth, run: claude auth logout");
72
+ console.log("2. Start Claude Code normally: claude");
73
+ console.log("3. In Claude Code, run: /status");
74
+ console.log("4. Confirm the active gateway is https://api.gonkagate.com");
75
+ if (scope === "local") {
76
+ console.log("\nLocal scope reminder:");
77
+ console.log("Keep .claude/settings.local.json uncommitted.");
78
+ }
79
+ }
80
+ export async function run(argv = process.argv.slice(2)) {
81
+ const options = parseCliOptions(argv);
82
+ printIntro();
83
+ const apiKey = validateApiKey(await promptForApiKey());
84
+ const selectedModel = options.modelKey
85
+ ? requireSupportedModel(options.modelKey)
86
+ : await promptForModel(SUPPORTED_MODELS, DEFAULT_MODEL_KEY);
87
+ const scope = options.scope ?? (await promptForScope("user"));
88
+ const target = getSettingsTarget(scope, process.cwd());
89
+ if (scope === "local") {
90
+ await ensureLocalSettingsIgnored(target.path);
91
+ }
92
+ const loaded = await loadSettings(target.path);
93
+ const mergedSettings = mergeSettingsWithGonkaEnv(loaded.settings, apiKey, selectedModel);
94
+ const backupPath = loaded.exists ? await createBackup(target.path) : undefined;
95
+ await writeSettings(target.path, mergedSettings);
96
+ printSuccess(target.path, scope, selectedModel, backupPath);
97
+ }
98
+ function handleCliError(error) {
99
+ if (error instanceof CommanderError) {
100
+ process.exitCode = error.exitCode;
101
+ return;
102
+ }
103
+ const message = error instanceof Error ? error.message : String(error);
104
+ console.error(`\nError: ${message}`);
105
+ process.exitCode = 1;
106
+ }
107
+ const isEntrypoint = process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href;
108
+ if (isEntrypoint) {
109
+ run().catch(handleCliError);
110
+ }
111
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,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AC;IACrC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE9G,IAAI,YAAY,EAAE,CAAC;IACjB,GAAG,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const GONKAGATE_BASE_URL = "https://api.gonkagate.com";
2
+ export declare const CLAUDE_SETTINGS_SCHEMA_URL = "https://json.schemastore.org/claude-code-settings.json";
@@ -0,0 +1,3 @@
1
+ export const GONKAGATE_BASE_URL = "https://api.gonkagate.com";
2
+ export const CLAUDE_SETTINGS_SCHEMA_URL = "https://json.schemastore.org/claude-code-settings.json";
3
+ //# sourceMappingURL=gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/constants/gateway.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAC9D,MAAM,CAAC,MAAM,0BAA0B,GAAG,wDAAwD,CAAC"}
@@ -0,0 +1,27 @@
1
+ export interface SupportedModelDefinition {
2
+ key: string;
3
+ displayName: string;
4
+ modelId: string;
5
+ description?: string;
6
+ isDefault?: boolean;
7
+ }
8
+ export declare const SUPPORTED_MODELS: readonly [{
9
+ readonly key: "qwen3-235b";
10
+ readonly displayName: "Qwen 3 235B Instruct";
11
+ readonly modelId: "qwen/qwen3-235b-a22b-instruct-2507-fp8";
12
+ readonly description: "Current GonkaGate public Claude Code model.";
13
+ readonly isDefault: true;
14
+ }];
15
+ export type SupportedModel = (typeof SUPPORTED_MODELS)[number];
16
+ export type SupportedModelKey = SupportedModel["key"];
17
+ export declare const DEFAULT_MODEL: {
18
+ readonly key: "qwen3-235b";
19
+ readonly displayName: "Qwen 3 235B Instruct";
20
+ readonly modelId: "qwen/qwen3-235b-a22b-instruct-2507-fp8";
21
+ readonly description: "Current GonkaGate public Claude Code model.";
22
+ readonly isDefault: true;
23
+ };
24
+ export declare const DEFAULT_MODEL_KEY: SupportedModelKey;
25
+ export declare const SUPPORTED_MODEL_KEYS: "qwen3-235b"[];
26
+ export declare function getSupportedModelByKey(key: string): SupportedModel | undefined;
27
+ export declare function requireSupportedModel(key: string): SupportedModel;
@@ -0,0 +1,28 @@
1
+ const curatedModelRegistry = [
2
+ {
3
+ key: "qwen3-235b",
4
+ displayName: "Qwen 3 235B Instruct",
5
+ modelId: "qwen/qwen3-235b-a22b-instruct-2507-fp8",
6
+ description: "Current GonkaGate public Claude Code model.",
7
+ isDefault: true
8
+ }
9
+ ];
10
+ const defaultModels = curatedModelRegistry.filter((model) => model.isDefault);
11
+ if (defaultModels.length !== 1) {
12
+ throw new Error(`Expected exactly one default supported model, found ${defaultModels.length}.`);
13
+ }
14
+ export const SUPPORTED_MODELS = curatedModelRegistry;
15
+ export const DEFAULT_MODEL = defaultModels[0];
16
+ export const DEFAULT_MODEL_KEY = DEFAULT_MODEL.key;
17
+ export const SUPPORTED_MODEL_KEYS = SUPPORTED_MODELS.map((model) => model.key);
18
+ export function getSupportedModelByKey(key) {
19
+ return SUPPORTED_MODELS.find((model) => model.key === key);
20
+ }
21
+ export function requireSupportedModel(key) {
22
+ const model = getSupportedModelByKey(key);
23
+ if (!model) {
24
+ throw new Error(`Unsupported model key "${key}". Supported model keys: ${SUPPORTED_MODEL_KEYS.join(", ")}`);
25
+ }
26
+ return model;
27
+ }
28
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/constants/models.ts"],"names":[],"mappings":"AAQA,MAAM,oBAAoB,GAAG;IAC3B;QACE,GAAG,EAAE,YAAY;QACjB,WAAW,EAAE,sBAAsB;QACnC,OAAO,EAAE,wCAAwC;QACjD,WAAW,EAAE,6CAA6C;QAC1D,SAAS,EAAE,IAAI;KAChB;CACqD,CAAC;AAEzD,MAAM,aAAa,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAE9E,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC/B,MAAM,IAAI,KAAK,CAAC,uDAAuD,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;AAClG,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAGrD,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAsB,aAAa,CAAC,GAAG,CAAC;AACtE,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAE/E,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,MAAM,KAAK,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAE1C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,4BAA4B,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9G,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function createBackup(filePath: string): Promise<string>;
@@ -0,0 +1,10 @@
1
+ import { copyFile } from "node:fs/promises";
2
+ function toBackupSuffix(timestamp = new Date()) {
3
+ return timestamp.toISOString().replace(/[:.]/g, "-");
4
+ }
5
+ export async function createBackup(filePath) {
6
+ const backupPath = `${filePath}.backup-${toBackupSuffix()}`;
7
+ await copyFile(filePath, backupPath);
8
+ return backupPath;
9
+ }
10
+ //# sourceMappingURL=backup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup.js","sourceRoot":"","sources":["../../src/install/backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,SAAS,cAAc,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE;IAC5C,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB;IACjD,MAAM,UAAU,GAAG,GAAG,QAAQ,WAAW,cAAc,EAAE,EAAE,CAAC;IAC5D,MAAM,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { ClaudeCodeSettings } from "../types/settings.js";
2
+ export interface LoadSettingsResult {
3
+ exists: boolean;
4
+ settings: ClaudeCodeSettings;
5
+ }
6
+ export declare function loadSettings(filePath: string): Promise<LoadSettingsResult>;
@@ -0,0 +1,32 @@
1
+ import { access, constants, readFile } from "node:fs/promises";
2
+ import { isPlainObject } from "./object-utils.js";
3
+ export async function loadSettings(filePath) {
4
+ try {
5
+ await access(filePath, constants.F_OK);
6
+ }
7
+ catch {
8
+ return {
9
+ exists: false,
10
+ settings: {}
11
+ };
12
+ }
13
+ const raw = await readFile(filePath, "utf8");
14
+ let parsed;
15
+ try {
16
+ parsed = JSON.parse(raw);
17
+ }
18
+ catch {
19
+ throw new Error(`Failed to parse JSON in ${filePath}. Fix or restore that file before rerunning the installer.`);
20
+ }
21
+ if (!isPlainObject(parsed)) {
22
+ throw new Error(`Expected ${filePath} to contain a JSON object.`);
23
+ }
24
+ if ("env" in parsed && parsed.env !== undefined && !isPlainObject(parsed.env)) {
25
+ throw new Error(`Expected "env" in ${filePath} to be a JSON object when present.`);
26
+ }
27
+ return {
28
+ exists: true,
29
+ settings: parsed
30
+ };
31
+ }
32
+ //# sourceMappingURL=load-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-settings.js","sourceRoot":"","sources":["../../src/install/load-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAOlD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB;IACjD,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC7C,IAAI,MAAe,CAAC;IAEpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,4DAA4D,CAAC,CAAC;IACnH,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,YAAY,QAAQ,4BAA4B,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,KAAK,IAAI,MAAM,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9E,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,oCAAoC,CAAC,CAAC;IACrF,CAAC;IAED,OAAO;QACL,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,MAAM;KACjB,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function ensureLocalSettingsIgnored(targetPath: string): Promise<void>;
@@ -0,0 +1,76 @@
1
+ import { access, mkdir, readFile, stat, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ export async function ensureLocalSettingsIgnored(targetPath) {
4
+ const gitContext = await findGitContext(path.dirname(targetPath));
5
+ if (!gitContext) {
6
+ return;
7
+ }
8
+ const relativeTargetPath = path.relative(gitContext.repoRoot, targetPath);
9
+ if (relativeTargetPath.startsWith("..")) {
10
+ throw new Error("Expected local Claude Code settings to stay inside the current git repository.");
11
+ }
12
+ const normalizedRelativePath = relativeTargetPath.split(path.sep).join("/");
13
+ const ignoreEntry = `/${normalizedRelativePath}`;
14
+ const excludePath = path.join(gitContext.gitDir, "info", "exclude");
15
+ const existingContent = await readOptionalFile(excludePath);
16
+ const existingEntries = new Set(existingContent
17
+ .split(/\r?\n/)
18
+ .map((line) => line.trim())
19
+ .filter((line) => line.length > 0 && !line.startsWith("#")));
20
+ if (existingEntries.has(ignoreEntry)) {
21
+ return;
22
+ }
23
+ await mkdir(path.dirname(excludePath), { recursive: true });
24
+ const nextContent = existingContent.length === 0
25
+ ? `${ignoreEntry}\n`
26
+ : `${existingContent}${existingContent.endsWith("\n") ? "" : "\n"}${ignoreEntry}\n`;
27
+ await writeFile(excludePath, nextContent, "utf8");
28
+ }
29
+ async function findGitContext(startDirectory) {
30
+ let currentDirectory = path.resolve(startDirectory);
31
+ for (;;) {
32
+ const gitMarkerPath = path.join(currentDirectory, ".git");
33
+ const gitDir = await resolveGitDir(gitMarkerPath, currentDirectory);
34
+ if (gitDir) {
35
+ return {
36
+ gitDir,
37
+ repoRoot: currentDirectory
38
+ };
39
+ }
40
+ const parentDirectory = path.dirname(currentDirectory);
41
+ if (parentDirectory === currentDirectory) {
42
+ return null;
43
+ }
44
+ currentDirectory = parentDirectory;
45
+ }
46
+ }
47
+ async function resolveGitDir(gitMarkerPath, repoRoot) {
48
+ try {
49
+ const gitMarkerStats = await stat(gitMarkerPath);
50
+ if (gitMarkerStats.isDirectory()) {
51
+ return gitMarkerPath;
52
+ }
53
+ if (gitMarkerStats.isFile()) {
54
+ const markerContent = await readFile(gitMarkerPath, "utf8");
55
+ const match = /^gitdir:\s*(.+)\s*$/m.exec(markerContent);
56
+ if (!match) {
57
+ throw new Error(`Could not resolve gitdir from ${gitMarkerPath}.`);
58
+ }
59
+ return path.resolve(repoRoot, match[1]);
60
+ }
61
+ return null;
62
+ }
63
+ catch {
64
+ return null;
65
+ }
66
+ }
67
+ async function readOptionalFile(filePath) {
68
+ try {
69
+ await access(filePath);
70
+ return await readFile(filePath, "utf8");
71
+ }
72
+ catch {
73
+ return "";
74
+ }
75
+ }
76
+ //# sourceMappingURL=local-git-ignore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-git-ignore.js","sourceRoot":"","sources":["../../src/install/local-git-ignore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,IAAI,MAAM,WAAW,CAAC;AAO7B,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,UAAkB;IACjE,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IAElE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IAED,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAE1E,IAAI,kBAAkB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,M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AAC;IACd,CAAC;AACH,CAAC;AAED,KAAK,UAAU,gBAAgB,CAAC,QAAgB;IAC9C,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { SupportedModel } from "../constants/models.js";
2
+ import type { ClaudeCodeSettings } from "../types/settings.js";
3
+ export declare const GONKAGATE_ENV_KEYS: readonly ["ANTHROPIC_BASE_URL", "ANTHROPIC_AUTH_TOKEN", "ANTHROPIC_MODEL", "ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_SONNET_MODEL", "ANTHROPIC_DEFAULT_HAIKU_MODEL", "CLAUDE_CODE_SUBAGENT_MODEL"];
4
+ export declare function mergeSettingsWithGonkaEnv(settings: ClaudeCodeSettings, apiKey: string, selectedModel: SupportedModel): ClaudeCodeSettings;
@@ -0,0 +1,35 @@
1
+ import { CLAUDE_SETTINGS_SCHEMA_URL, GONKAGATE_BASE_URL } from "../constants/gateway.js";
2
+ import { isPlainObject } from "./object-utils.js";
3
+ export const GONKAGATE_ENV_KEYS = [
4
+ "ANTHROPIC_BASE_URL",
5
+ "ANTHROPIC_AUTH_TOKEN",
6
+ "ANTHROPIC_MODEL",
7
+ "ANTHROPIC_DEFAULT_OPUS_MODEL",
8
+ "ANTHROPIC_DEFAULT_SONNET_MODEL",
9
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL",
10
+ "CLAUDE_CODE_SUBAGENT_MODEL"
11
+ ];
12
+ function buildGonkaEnv(apiKey, selectedModel) {
13
+ return {
14
+ ANTHROPIC_BASE_URL: GONKAGATE_BASE_URL,
15
+ ANTHROPIC_AUTH_TOKEN: apiKey,
16
+ ANTHROPIC_MODEL: selectedModel.modelId,
17
+ ANTHROPIC_DEFAULT_OPUS_MODEL: selectedModel.modelId,
18
+ ANTHROPIC_DEFAULT_SONNET_MODEL: selectedModel.modelId,
19
+ ANTHROPIC_DEFAULT_HAIKU_MODEL: selectedModel.modelId,
20
+ CLAUDE_CODE_SUBAGENT_MODEL: selectedModel.modelId
21
+ };
22
+ }
23
+ export function mergeSettingsWithGonkaEnv(settings, apiKey, selectedModel) {
24
+ const existingEnv = isPlainObject(settings.env) ? { ...settings.env } : {};
25
+ delete existingEnv.ANTHROPIC_API_KEY;
26
+ return {
27
+ ...settings,
28
+ $schema: settings.$schema ?? CLAUDE_SETTINGS_SCHEMA_URL,
29
+ env: {
30
+ ...existingEnv,
31
+ ...buildGonkaEnv(apiKey, selectedModel)
32
+ }
33
+ };
34
+ }
35
+ //# sourceMappingURL=merge-env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-env.js","sourceRoot":"","sources":["../../src/install/merge-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGzF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,oBAAoB;IACpB,sBAAsB;IACtB,iBAAiB;IACjB,8BAA8B;IAC9B,gCAAgC;IAChC,+BAA+B;IAC/B,4BAA4B;CACpB,CAAC;AAEX,SAAS,aAAa,CAAC,MAAc,EAAE,aAA6B;IAClE,OAAO;QACL,kBAAkB,EAAE,kBAAkB;QACtC,oBAAoB,EAAE,MAAM;QAC5B,eAAe,EAAE,aAAa,CAAC,OAAO;QACtC,4BAA4B,EAAE,aAAa,CAAC,OAAO;QACnD,8BAA8B,EAAE,aAAa,CAAC,OAAO;QACrD,6BAA6B,EAAE,aAAa,CAAC,OAAO;QACpD,0BAA0B,EAAE,aAAa,CAAC,OAAO;KAClD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,QAA4B,EAC5B,MAAc,EACd,aAA6B;IAE7B,MAAM,WAAW,GAAG,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3E,OAAO,WAAW,CAAC,iBAAiB,CAAC;IAErC,OAAO;QACL,GAAG,QAAQ;QACX,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,0BAA0B;QACvD,GAAG,EAAE;YACH,GAAG,WAAW;YACd,GAAG,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC;SACxC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
@@ -0,0 +1,4 @@
1
+ export function isPlainObject(value) {
2
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3
+ }
4
+ //# sourceMappingURL=object-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-utils.js","sourceRoot":"","sources":["../../src/install/object-utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { SupportedModel, SupportedModelKey } from "../constants/models.js";
2
+ import type { InstallScope } from "../types/settings.js";
3
+ export declare function promptForApiKey(): Promise<string>;
4
+ interface SelectChoice<Value> {
5
+ value: Value;
6
+ name: string;
7
+ description?: string;
8
+ short?: string;
9
+ }
10
+ interface SelectPromptConfig<Value> {
11
+ message: string;
12
+ choices: readonly SelectChoice<Value>[];
13
+ default: Value;
14
+ pageSize?: number;
15
+ loop?: boolean;
16
+ theme?: {
17
+ indexMode?: "hidden" | "number";
18
+ };
19
+ }
20
+ type SelectPrompt<Value> = (config: SelectPromptConfig<Value>) => Promise<Value>;
21
+ export declare function buildScopePromptConfig(defaultScope: InstallScope): SelectPromptConfig<InstallScope>;
22
+ export declare function promptForScope(defaultScope: InstallScope, selectPrompt?: SelectPrompt<InstallScope>): Promise<InstallScope>;
23
+ export declare function buildModelPromptConfig(models: readonly SupportedModel[], defaultModelKey: SupportedModelKey): SelectPromptConfig<SupportedModelKey>;
24
+ export declare function promptForModel(models: readonly SupportedModel[], defaultModelKey: SupportedModelKey, selectPrompt?: SelectPrompt<SupportedModelKey>): Promise<SupportedModel>;
25
+ export {};
@@ -0,0 +1,78 @@
1
+ import process from "node:process";
2
+ import { password, select } from "@inquirer/prompts";
3
+ export async function promptForApiKey() {
4
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
5
+ throw new Error("Interactive setup requires a TTY so the API key can be entered securely.");
6
+ }
7
+ return password({
8
+ message: "GonkaGate API key",
9
+ mask: "*",
10
+ validate: (value) => (value.trim().length > 0 ? true : "API key is required.")
11
+ }).catch(rethrowPromptExit);
12
+ }
13
+ export function buildScopePromptConfig(defaultScope) {
14
+ return {
15
+ message: "Install scope",
16
+ default: defaultScope,
17
+ choices: [
18
+ {
19
+ value: "user",
20
+ name: "User",
21
+ short: "user",
22
+ description: "Write ~/.claude/settings.json for your user account."
23
+ },
24
+ {
25
+ value: "local",
26
+ name: "Local",
27
+ short: "local",
28
+ description: "Write .claude/settings.local.json in the current repository."
29
+ }
30
+ ],
31
+ loop: false,
32
+ theme: {
33
+ indexMode: "number"
34
+ }
35
+ };
36
+ }
37
+ export async function promptForScope(defaultScope, selectPrompt = select) {
38
+ return selectPrompt(buildScopePromptConfig(defaultScope)).catch(rethrowPromptExit);
39
+ }
40
+ export function buildModelPromptConfig(models, defaultModelKey) {
41
+ if (models.length === 0) {
42
+ throw new Error("No supported GonkaGate models are configured.");
43
+ }
44
+ const defaultModel = requireDefaultModel(models, defaultModelKey);
45
+ return {
46
+ message: "Choose a GonkaGate model",
47
+ default: defaultModel.key,
48
+ choices: models.map((model) => ({
49
+ value: model.key,
50
+ name: model.displayName,
51
+ short: model.key,
52
+ description: model.description ? `${model.description} Model ID: ${model.modelId}` : `Model ID: ${model.modelId}`
53
+ })),
54
+ pageSize: Math.min(models.length, 8),
55
+ loop: false,
56
+ theme: {
57
+ indexMode: "number"
58
+ }
59
+ };
60
+ }
61
+ export async function promptForModel(models, defaultModelKey, selectPrompt = select) {
62
+ const selectedModelKey = await selectPrompt(buildModelPromptConfig(models, defaultModelKey)).catch(rethrowPromptExit);
63
+ return requireDefaultModel(models, selectedModelKey);
64
+ }
65
+ function requireDefaultModel(models, defaultModelKey) {
66
+ const defaultModel = models.find((model) => model.key === defaultModelKey);
67
+ if (!defaultModel) {
68
+ throw new Error(`Default model "${defaultModelKey}" is not present in the supported model registry.`);
69
+ }
70
+ return defaultModel;
71
+ }
72
+ function rethrowPromptExit(error) {
73
+ if (error instanceof Error && (error.name === "ExitPromptError" || error.name === "AbortPromptError")) {
74
+ throw new Error("Installation cancelled.");
75
+ }
76
+ throw error;
77
+ }
78
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/install/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIrD,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;IAC9F,CAAC;IAED,OAAO,QAAQ,CAAC;QACd,OAAO,EAAE,mBAAmB;QAC5B,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CA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sTarget } from "../types/settings.js";
2
+ export declare function getSettingsTarget(scope: InstallScope, cwd: string, userHome?: string): SettingsTarget;
@@ -0,0 +1,15 @@
1
+ import { homedir } from "node:os";
2
+ import path from "node:path";
3
+ export function getSettingsTarget(scope, cwd, userHome = homedir()) {
4
+ if (scope === "user") {
5
+ return {
6
+ scope,
7
+ path: path.join(userHome, ".claude", "settings.json")
8
+ };
9
+ }
10
+ return {
11
+ scope,
12
+ path: path.join(cwd, ".claude", "settings.local.json")
13
+ };
14
+ }
15
+ //# sourceMappingURL=settings-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-paths.js","sourceRoot":"","sources":["../../src/install/settings-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,MAAM,UAAU,iBAAiB,CAAC,KAAmB,EAAE,GAAW,EAAE,QAAQ,GAAG,OAAO,EAAE;IACtF,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QACrB,OAAO;YACL,KAAK;YACL,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,eAAe,CAAC;SACtD,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK;QACL,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,qBAAqB,CAAC;KACvD,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function validateApiKey(rawValue: string): string;
@@ -0,0 +1,15 @@
1
+ const GONKAGATE_API_KEY_PATTERN = /^gp-[A-Za-z0-9][A-Za-z0-9._-]*$/;
2
+ export function validateApiKey(rawValue) {
3
+ const apiKey = rawValue.trim();
4
+ if (apiKey.length === 0) {
5
+ throw new Error("API key is required.");
6
+ }
7
+ if (!apiKey.startsWith("gp-")) {
8
+ throw new Error('Expected a GonkaGate API key that starts with "gp-".');
9
+ }
10
+ if (!GONKAGATE_API_KEY_PATTERN.test(apiKey)) {
11
+ throw new Error("The API key format looks invalid. Expected a regular GonkaGate API key like gp-...");
12
+ }
13
+ return apiKey;
14
+ }
15
+ //# sourceMappingURL=validate-api-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-api-key.js","sourceRoot":"","sources":["../../src/install/validate-api-key.ts"],"names":[],"mappings":"AAAA,MAAM,yBAAyB,GAAG,iCAAiC,CAAC;AAEpE,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;IAE/B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;IACxG,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ClaudeCodeSettings } from "../types/settings.js";
2
+ export declare function writeSettings(filePath: string, settings: ClaudeCodeSettings): Promise<void>;
@@ -0,0 +1,25 @@
1
+ import { chmod, mkdir, stat } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import writeFileAtomic from "write-file-atomic";
4
+ export async function writeSettings(filePath, settings) {
5
+ const directory = path.dirname(filePath);
6
+ const content = `${JSON.stringify(settings, null, 2)}\n`;
7
+ const targetMode = await resolveTargetMode(filePath);
8
+ await mkdir(directory, { recursive: true });
9
+ await writeFileAtomic(filePath, content, {
10
+ encoding: "utf8",
11
+ fsync: true,
12
+ mode: targetMode
13
+ });
14
+ await chmod(filePath, targetMode);
15
+ }
16
+ async function resolveTargetMode(filePath) {
17
+ try {
18
+ const existingStats = await stat(filePath);
19
+ return (existingStats.mode & 0o600) || 0o600;
20
+ }
21
+ catch {
22
+ return 0o600;
23
+ }
24
+ }
25
+ //# sourceMappingURL=write-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-settings.js","sourceRoot":"","sources":["../../src/install/write-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAgB,EAAE,QAA4B;IAChF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;IACzD,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAErD,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,MAAM,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE;QACvC,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,UAAU;KACjB,CAAC,CAAC;IACH,MAAM,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AACpC,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,QAAgB;IAC/C,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3C,OAAO,CAAC,aAAa,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,KAAK,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type InstallScope = "user" | "local";
2
+ export interface ClaudeCodeSettings {
3
+ $schema?: string;
4
+ env?: Record<string, unknown>;
5
+ [key: string]: unknown;
6
+ }
7
+ export interface SettingsTarget {
8
+ scope: InstallScope;
9
+ path: string;
10
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/types/settings.ts"],"names":[],"mappings":""}
@@ -0,0 +1,46 @@
1
+ # How It Works
2
+
3
+ `gonkagate-claude-code` is a small Node-based installer for local `Claude Code`.
4
+
5
+ ## Fixed product contract
6
+
7
+ These values are intentionally fixed by the installer:
8
+
9
+ - Base URL: `https://api.gonkagate.com`
10
+ - Auth variable: `ANTHROPIC_AUTH_TOKEN`
11
+ - Model selection comes only from a curated in-repo allowlist
12
+
13
+ Today the curated public Claude Code model registry contains one supported entry:
14
+
15
+ - `qwen3-235b` -> `qwen/qwen3-235b-a22b-instruct-2507-fp8` (default, current only option)
16
+
17
+ Users provide only:
18
+
19
+ - a GonkaGate API key starting with `gp-`
20
+ - a supported model choice from the curated list, or `--model <model-key>`
21
+ - an install scope: `user` or `local`
22
+
23
+ ## Target files
24
+
25
+ The installer writes one Claude Code settings file:
26
+
27
+ - user scope -> `~/.claude/settings.json`
28
+ - local scope -> `.claude/settings.local.json`
29
+
30
+ It does not touch any shell profile or other configuration file.
31
+
32
+ For `local` scope inside a git repository, it also adds `.claude/settings.local.json` to `.git/info/exclude` before writing the file.
33
+
34
+ ## Write behavior
35
+
36
+ When the target file already exists, the installer:
37
+
38
+ 1. Parses the existing JSON
39
+ 2. Refuses to continue if the JSON is invalid
40
+ 3. Creates a timestamped backup
41
+ 4. Preserves unrelated settings
42
+ 5. Updates only the relevant `env` keys, including all Claude model env vars with the selected curated model id
43
+ 6. Adds Claude Code's JSON schema if `$schema` is missing
44
+ 7. Writes the final settings file with owner-only permissions
45
+
46
+ If `ANTHROPIC_API_KEY` is present, it is removed so bearer-token auth through `ANTHROPIC_AUTH_TOKEN` becomes the default path.
@@ -0,0 +1,30 @@
1
+ # Security Notes
2
+
3
+ ## Secret entry
4
+
5
+ The recommended install flow is interactive:
6
+
7
+ ```bash
8
+ npx @gonkagate/claude-code
9
+ ```
10
+
11
+ The installer asks for the API key through a hidden prompt. It intentionally rejects `--api-key ...` arguments so secrets do not end up in shell history or process lists.
12
+
13
+ ## Where the key is stored
14
+
15
+ Claude Code reads environment variables from its settings files. That means the GonkaGate API key is stored in the Claude Code settings file you choose:
16
+
17
+ - `~/.claude/settings.json`
18
+ - `.claude/settings.local.json`
19
+
20
+ This repo does not write `.env` files and does not modify shell startup files. It also writes the target settings file with owner-only permissions.
21
+
22
+ ## Local scope hygiene
23
+
24
+ If you choose `local` scope inside a git repository, the installer adds `.claude/settings.local.json` to the repo's `.git/info/exclude` before writing the file so the secret-bearing settings file is not immediately visible to git.
25
+
26
+ If your team already manages ignores another way, that is still fine. The important rule is that `.claude/settings.local.json` must stay uncommitted.
27
+
28
+ ## Backup behavior
29
+
30
+ Before overwriting an existing target settings file, the installer creates a timestamped backup next to it. If something looks wrong afterward, restore from that backup and rerun the installer.
@@ -0,0 +1,74 @@
1
+ # Troubleshooting
2
+
3
+ ## `/status` still shows Anthropic
4
+
5
+ If Claude Code still shows direct Anthropic auth or the wrong upstream after install:
6
+
7
+ 1. Run `claude auth logout`
8
+ 2. Restart `claude`
9
+ 3. Run `/status` again
10
+
11
+ The installer writes Claude Code settings, but an existing direct login can still be what you are seeing until you log out once.
12
+
13
+ ## Model unavailable
14
+
15
+ This installer writes the selected model from its curated GonkaGate-supported registry.
16
+
17
+ Today that curated list contains one option:
18
+
19
+ - `qwen3-235b` -> `qwen/qwen3-235b-a22b-instruct-2507-fp8`
20
+
21
+ If that model is unavailable, the likely cause is a backend deployment or model availability mismatch. This installer does not expose custom base URL or arbitrary custom model overrides, so the right next step is GonkaGate support or the backend troubleshooting docs in `gonka-proxy`.
22
+
23
+ ## Model removed from the curated list later
24
+
25
+ If a model disappears from the curated list in a future release of this installer:
26
+
27
+ 1. Rerun the installer
28
+ 2. Choose from the current curated list, or pass a current key with `--model <model-key>`
29
+
30
+ Manual edits to force an old or unsupported model id are outside the supported setup flow.
31
+
32
+ ## Want to switch models
33
+
34
+ Rerun the installer and choose a different curated model when prompted.
35
+
36
+ You can also skip the interactive model prompt with:
37
+
38
+ ```bash
39
+ npx @gonkagate/claude-code --model <model-key>
40
+ ```
41
+
42
+ Only current curated keys are accepted.
43
+
44
+ ## Corrupted settings file
45
+
46
+ If the target settings file contains invalid JSON, the installer stops without overwriting it.
47
+
48
+ Restore from the timestamped backup next to the settings file, or fix the JSON manually, then rerun the installer.
49
+
50
+ ## Want repo-only setup
51
+
52
+ Rerun the installer and choose `local` scope. That writes `.claude/settings.local.json` in the current repository instead of editing your global `~/.claude/settings.json`.
53
+
54
+ ## Manual settings edits
55
+
56
+ Manual edits to the Claude Code settings file are possible, but they are outside the supported public install flow for this repo.
57
+
58
+ If you want to get back to a supported state, rerun the installer instead of hand-editing model ids or gateway values.
59
+
60
+ ## Want to undo the install
61
+
62
+ You have two safe options:
63
+
64
+ 1. Restore the backup created by the installer.
65
+ 2. Remove the GonkaGate-managed keys from the target settings file:
66
+ - `ANTHROPIC_BASE_URL`
67
+ - `ANTHROPIC_AUTH_TOKEN`
68
+ - `ANTHROPIC_MODEL`
69
+ - `ANTHROPIC_DEFAULT_OPUS_MODEL`
70
+ - `ANTHROPIC_DEFAULT_SONNET_MODEL`
71
+ - `ANTHROPIC_DEFAULT_HAIKU_MODEL`
72
+ - `CLAUDE_CODE_SUBAGENT_MODEL`
73
+
74
+ If you previously removed `ANTHROPIC_API_KEY`, add back whatever auth method you actually want before relaunching Claude Code.
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@gonkagate/claude-code",
3
+ "version": "0.1.0",
4
+ "description": "Connect Claude Code to GonkaGate in one step.",
5
+ "homepage": "https://github.com/GonkaGate/gonkagate-claude-code",
6
+ "bugs": {
7
+ "url": "https://github.com/GonkaGate/gonkagate-claude-code/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/GonkaGate/gonkagate-claude-code.git"
12
+ },
13
+ "type": "module",
14
+ "bin": {
15
+ "gonkagate-claude-code": "./bin/gonkagate-claude-code.js"
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "dist",
20
+ "docs",
21
+ "scripts",
22
+ "README.md",
23
+ "CHANGELOG.md",
24
+ "LICENSE"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsc -p tsconfig.json",
28
+ "dev": "tsx src/cli.ts",
29
+ "prepack": "npm run build",
30
+ "test": "tsx --test test/**/*.test.ts",
31
+ "ci": "npm test && npm run build"
32
+ },
33
+ "engines": {
34
+ "node": ">=18"
35
+ },
36
+ "keywords": [
37
+ "claude-code",
38
+ "gonkagate",
39
+ "anthropic",
40
+ "installer",
41
+ "cli"
42
+ ],
43
+ "license": "Apache-2.0",
44
+ "packageManager": "npm@11.11.1",
45
+ "devDependencies": {
46
+ "@types/node": "^24.5.2",
47
+ "@types/write-file-atomic": "^4.0.3",
48
+ "tsx": "^4.20.6",
49
+ "typescript": "^5.9.2"
50
+ },
51
+ "dependencies": {
52
+ "@inquirer/prompts": "^7.10.1",
53
+ "commander": "^13.1.0",
54
+ "write-file-atomic": "^5.0.1"
55
+ }
56
+ }
@@ -0,0 +1,12 @@
1
+ param(
2
+ [Parameter(ValueFromRemainingArguments = $true)]
3
+ [string[]]$InstallerArgs
4
+ )
5
+
6
+ if (-not (Get-Command npx -ErrorAction SilentlyContinue)) {
7
+ Write-Error "npx is required. Install Node.js 18+ and retry."
8
+ exit 1
9
+ }
10
+
11
+ & npx @gonkagate/claude-code @InstallerArgs
12
+ exit $LASTEXITCODE
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env sh
2
+ set -eu
3
+
4
+ if ! command -v npx >/dev/null 2>&1; then
5
+ echo "npx is required. Install Node.js 18+ and retry." >&2
6
+ exit 1
7
+ fi
8
+
9
+ npx @gonkagate/claude-code "$@"