ccjk 14.0.0 → 14.0.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/dist/chunks/ccr.mjs +2 -3
- package/dist/chunks/check-updates.mjs +1 -3
- package/dist/chunks/code-type-resolver.mjs +878 -0
- package/dist/chunks/config.mjs +41 -1
- package/dist/chunks/index10.mjs +55 -6
- package/dist/chunks/init.mjs +38 -10
- package/dist/chunks/package.mjs +1 -1
- package/dist/chunks/quick-setup.mjs +1 -3
- package/dist/chunks/status.mjs +63 -16
- package/dist/chunks/uninstall.mjs +1 -3
- package/dist/cli.mjs +58 -17
- package/dist/i18n/locales/en/configuration.json +6 -2
- package/dist/i18n/locales/zh-CN/configuration.json +6 -2
- package/dist/index.d.mts +64 -17
- package/dist/index.d.ts +64 -17
- package/dist/index.mjs +9 -718
- package/dist/shared/ccjk.BO45TPXJ.mjs +807 -0
- package/package.json +1 -1
- package/dist/chunks/intent-engine.mjs +0 -142
- package/dist/chunks/smart-defaults.mjs +0 -425
- package/dist/shared/ccjk.DJuyfrlL.mjs +0 -348
- package/dist/shared/ccjk.yYQMbHH3.mjs +0 -115
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process';
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
-
import process__default from 'node:process';
|
|
4
|
-
import { j as join } from './ccjk.bQ7Dh1g4.mjs';
|
|
5
|
-
|
|
6
|
-
function scanProject(cwd) {
|
|
7
|
-
const root = cwd || process__default.cwd();
|
|
8
|
-
const pkg = readPackageJson(root);
|
|
9
|
-
const language = detectLanguage(root, pkg);
|
|
10
|
-
const secondaryLanguages = detectSecondaryLanguages(root, pkg, language);
|
|
11
|
-
return {
|
|
12
|
-
language,
|
|
13
|
-
secondaryLanguages,
|
|
14
|
-
framework: detectFramework(root, pkg),
|
|
15
|
-
testRunner: detectTestRunner(root, pkg),
|
|
16
|
-
packageManager: detectPackageManager(root),
|
|
17
|
-
linter: detectLinter(root, pkg),
|
|
18
|
-
formatter: detectFormatter(root, pkg),
|
|
19
|
-
database: detectDatabase(root),
|
|
20
|
-
runtime: detectRuntime(),
|
|
21
|
-
isMonorepo: detectMonorepo(root, pkg),
|
|
22
|
-
usesConventionalCommits: detectConventionalCommits(root, pkg),
|
|
23
|
-
hasGitHooks: detectGitHooks(root, pkg),
|
|
24
|
-
hasDocker: existsSync(join(root, "Dockerfile")) || existsSync(join(root, "docker-compose.yml")) || existsSync(join(root, "docker-compose.yaml")),
|
|
25
|
-
hasCI: detectCI(root),
|
|
26
|
-
root
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function readPackageJson(root) {
|
|
30
|
-
const p = join(root, "package.json");
|
|
31
|
-
if (!existsSync(p))
|
|
32
|
-
return null;
|
|
33
|
-
try {
|
|
34
|
-
return JSON.parse(readFileSync(p, "utf-8"));
|
|
35
|
-
} catch {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function hasDep(pkg, name) {
|
|
40
|
-
if (!pkg)
|
|
41
|
-
return false;
|
|
42
|
-
return !!(pkg.dependencies?.[name] || pkg.devDependencies?.[name] || pkg.peerDependencies?.[name]);
|
|
43
|
-
}
|
|
44
|
-
function detectLanguage(root, pkg) {
|
|
45
|
-
if (existsSync(join(root, "tsconfig.json")) || hasDep(pkg, "typescript")) {
|
|
46
|
-
return "typescript";
|
|
47
|
-
}
|
|
48
|
-
if (existsSync(join(root, "pyproject.toml")) || existsSync(join(root, "setup.py")) || existsSync(join(root, "requirements.txt")) || existsSync(join(root, "Pipfile"))) {
|
|
49
|
-
return "python";
|
|
50
|
-
}
|
|
51
|
-
if (existsSync(join(root, "go.mod"))) {
|
|
52
|
-
return "go";
|
|
53
|
-
}
|
|
54
|
-
if (existsSync(join(root, "Cargo.toml"))) {
|
|
55
|
-
return "rust";
|
|
56
|
-
}
|
|
57
|
-
if (existsSync(join(root, "pom.xml")) || existsSync(join(root, "build.gradle")) || existsSync(join(root, "build.gradle.kts"))) {
|
|
58
|
-
return "java";
|
|
59
|
-
}
|
|
60
|
-
if (existsSync(join(root, "Gemfile"))) {
|
|
61
|
-
return "ruby";
|
|
62
|
-
}
|
|
63
|
-
if (existsSync(join(root, "composer.json"))) {
|
|
64
|
-
return "php";
|
|
65
|
-
}
|
|
66
|
-
if (existsSync(join(root, "Package.swift"))) {
|
|
67
|
-
return "swift";
|
|
68
|
-
}
|
|
69
|
-
if (existsSync(join(root, "*.csproj")) || existsSync(join(root, "*.sln"))) {
|
|
70
|
-
return "csharp";
|
|
71
|
-
}
|
|
72
|
-
if (pkg) {
|
|
73
|
-
return "javascript";
|
|
74
|
-
}
|
|
75
|
-
return "unknown";
|
|
76
|
-
}
|
|
77
|
-
function detectSecondaryLanguages(root, pkg, primary) {
|
|
78
|
-
const langs = [];
|
|
79
|
-
const checks = [
|
|
80
|
-
["typescript", () => existsSync(join(root, "tsconfig.json")) || hasDep(pkg, "typescript")],
|
|
81
|
-
["javascript", () => !!pkg],
|
|
82
|
-
["python", () => existsSync(join(root, "pyproject.toml")) || existsSync(join(root, "requirements.txt"))],
|
|
83
|
-
["go", () => existsSync(join(root, "go.mod"))],
|
|
84
|
-
["rust", () => existsSync(join(root, "Cargo.toml"))]
|
|
85
|
-
];
|
|
86
|
-
for (const [lang, check] of checks) {
|
|
87
|
-
if (lang !== primary && check())
|
|
88
|
-
langs.push(lang);
|
|
89
|
-
}
|
|
90
|
-
return langs;
|
|
91
|
-
}
|
|
92
|
-
function detectFramework(root, pkg) {
|
|
93
|
-
if (!pkg) {
|
|
94
|
-
if (existsSync(join(root, "pyproject.toml"))) {
|
|
95
|
-
const content = safeRead(join(root, "pyproject.toml"));
|
|
96
|
-
if (content.includes("fastapi"))
|
|
97
|
-
return "fastapi";
|
|
98
|
-
if (content.includes("django"))
|
|
99
|
-
return "django";
|
|
100
|
-
if (content.includes("flask"))
|
|
101
|
-
return "flask";
|
|
102
|
-
}
|
|
103
|
-
if (existsSync(join(root, "requirements.txt"))) {
|
|
104
|
-
const content = safeRead(join(root, "requirements.txt"));
|
|
105
|
-
if (content.includes("fastapi"))
|
|
106
|
-
return "fastapi";
|
|
107
|
-
if (content.includes("django"))
|
|
108
|
-
return "django";
|
|
109
|
-
if (content.includes("flask"))
|
|
110
|
-
return "flask";
|
|
111
|
-
}
|
|
112
|
-
return "none";
|
|
113
|
-
}
|
|
114
|
-
if (hasDep(pkg, "next"))
|
|
115
|
-
return "next";
|
|
116
|
-
if (hasDep(pkg, "nuxt"))
|
|
117
|
-
return "nuxt";
|
|
118
|
-
if (hasDep(pkg, "@angular/core"))
|
|
119
|
-
return "angular";
|
|
120
|
-
if (hasDep(pkg, "svelte") || hasDep(pkg, "@sveltejs/kit"))
|
|
121
|
-
return "svelte";
|
|
122
|
-
if (hasDep(pkg, "@nestjs/core"))
|
|
123
|
-
return "nest";
|
|
124
|
-
if (hasDep(pkg, "@tauri-apps/api") || hasDep(pkg, "@tauri-apps/cli"))
|
|
125
|
-
return "tauri";
|
|
126
|
-
if (hasDep(pkg, "electron"))
|
|
127
|
-
return "electron";
|
|
128
|
-
if (hasDep(pkg, "vue"))
|
|
129
|
-
return "vue";
|
|
130
|
-
if (hasDep(pkg, "react"))
|
|
131
|
-
return "react";
|
|
132
|
-
if (hasDep(pkg, "fastify"))
|
|
133
|
-
return "fastify";
|
|
134
|
-
if (hasDep(pkg, "express"))
|
|
135
|
-
return "express";
|
|
136
|
-
return "none";
|
|
137
|
-
}
|
|
138
|
-
function detectTestRunner(root, pkg) {
|
|
139
|
-
if (hasDep(pkg, "vitest"))
|
|
140
|
-
return "vitest";
|
|
141
|
-
if (hasDep(pkg, "jest") || hasDep(pkg, "@jest/core"))
|
|
142
|
-
return "jest";
|
|
143
|
-
if (hasDep(pkg, "mocha"))
|
|
144
|
-
return "mocha";
|
|
145
|
-
if (existsSync(join(root, "pytest.ini")) || existsSync(join(root, "conftest.py")))
|
|
146
|
-
return "pytest";
|
|
147
|
-
if (existsSync(join(root, "pyproject.toml"))) {
|
|
148
|
-
const content = safeRead(join(root, "pyproject.toml"));
|
|
149
|
-
if (content.includes("[tool.pytest") || content.includes("pytest"))
|
|
150
|
-
return "pytest";
|
|
151
|
-
}
|
|
152
|
-
if (existsSync(join(root, "go.mod")))
|
|
153
|
-
return "go-test";
|
|
154
|
-
if (existsSync(join(root, "Cargo.toml")))
|
|
155
|
-
return "cargo-test";
|
|
156
|
-
if (existsSync(join(root, "pom.xml")) || existsSync(join(root, "build.gradle")))
|
|
157
|
-
return "junit";
|
|
158
|
-
if (existsSync(join(root, "Gemfile"))) {
|
|
159
|
-
const content = safeRead(join(root, "Gemfile"));
|
|
160
|
-
if (content.includes("rspec"))
|
|
161
|
-
return "rspec";
|
|
162
|
-
}
|
|
163
|
-
if (hasDep(pkg, "phpunit") || existsSync(join(root, "phpunit.xml")))
|
|
164
|
-
return "phpunit";
|
|
165
|
-
return "none";
|
|
166
|
-
}
|
|
167
|
-
function detectPackageManager(root) {
|
|
168
|
-
if (existsSync(join(root, "pnpm-lock.yaml")) || existsSync(join(root, "pnpm-workspace.yaml")))
|
|
169
|
-
return "pnpm";
|
|
170
|
-
if (existsSync(join(root, "bun.lockb")) || existsSync(join(root, "bun.lock")))
|
|
171
|
-
return "bun";
|
|
172
|
-
if (existsSync(join(root, "yarn.lock")))
|
|
173
|
-
return "yarn";
|
|
174
|
-
if (existsSync(join(root, "package-lock.json")))
|
|
175
|
-
return "npm";
|
|
176
|
-
if (existsSync(join(root, "poetry.lock")))
|
|
177
|
-
return "poetry";
|
|
178
|
-
if (existsSync(join(root, "Pipfile.lock")) || existsSync(join(root, "requirements.txt")))
|
|
179
|
-
return "pip";
|
|
180
|
-
if (existsSync(join(root, "Cargo.lock")))
|
|
181
|
-
return "cargo";
|
|
182
|
-
if (existsSync(join(root, "go.sum")))
|
|
183
|
-
return "go";
|
|
184
|
-
if (existsSync(join(root, "pom.xml")))
|
|
185
|
-
return "maven";
|
|
186
|
-
if (existsSync(join(root, "build.gradle")) || existsSync(join(root, "build.gradle.kts")))
|
|
187
|
-
return "gradle";
|
|
188
|
-
return "none";
|
|
189
|
-
}
|
|
190
|
-
function detectLinter(root, pkg) {
|
|
191
|
-
if (hasDep(pkg, "@biomejs/biome") || existsSync(join(root, "biome.json")) || existsSync(join(root, "biome.jsonc")))
|
|
192
|
-
return "biome";
|
|
193
|
-
if (hasDep(pkg, "oxlint") || hasDep(pkg, "oxc"))
|
|
194
|
-
return "oxlint";
|
|
195
|
-
if (hasDep(pkg, "eslint") || existsSync(join(root, ".eslintrc.json")) || existsSync(join(root, ".eslintrc.js")) || existsSync(join(root, "eslint.config.js")) || existsSync(join(root, "eslint.config.mjs")))
|
|
196
|
-
return "eslint";
|
|
197
|
-
if (existsSync(join(root, "ruff.toml")) || existsSync(join(root, ".ruff.toml")))
|
|
198
|
-
return "ruff";
|
|
199
|
-
if (existsSync(join(root, "pyproject.toml"))) {
|
|
200
|
-
const content = safeRead(join(root, "pyproject.toml"));
|
|
201
|
-
if (content.includes("[tool.ruff"))
|
|
202
|
-
return "ruff";
|
|
203
|
-
if (content.includes("[tool.pylint") || content.includes("pylint"))
|
|
204
|
-
return "pylint";
|
|
205
|
-
if (content.includes("flake8"))
|
|
206
|
-
return "flake8";
|
|
207
|
-
}
|
|
208
|
-
if (existsSync(join(root, ".golangci.yml")) || existsSync(join(root, ".golangci.yaml")))
|
|
209
|
-
return "golangci-lint";
|
|
210
|
-
if (existsSync(join(root, "Cargo.toml")))
|
|
211
|
-
return "clippy";
|
|
212
|
-
if (existsSync(join(root, ".rubocop.yml")))
|
|
213
|
-
return "rubocop";
|
|
214
|
-
return "none";
|
|
215
|
-
}
|
|
216
|
-
function detectFormatter(root, pkg) {
|
|
217
|
-
if (hasDep(pkg, "@biomejs/biome") || existsSync(join(root, "biome.json")))
|
|
218
|
-
return "biome";
|
|
219
|
-
if (hasDep(pkg, "prettier") || existsSync(join(root, ".prettierrc")) || existsSync(join(root, ".prettierrc.json")) || existsSync(join(root, "prettier.config.js")) || existsSync(join(root, "prettier.config.mjs")))
|
|
220
|
-
return "prettier";
|
|
221
|
-
if (existsSync(join(root, "pyproject.toml"))) {
|
|
222
|
-
const content = safeRead(join(root, "pyproject.toml"));
|
|
223
|
-
if (content.includes("[tool.ruff") && content.includes("format"))
|
|
224
|
-
return "ruff";
|
|
225
|
-
if (content.includes("[tool.black") || content.includes("black"))
|
|
226
|
-
return "black";
|
|
227
|
-
}
|
|
228
|
-
if (existsSync(join(root, "go.mod")))
|
|
229
|
-
return "gofmt";
|
|
230
|
-
if (existsSync(join(root, "Cargo.toml")))
|
|
231
|
-
return "rustfmt";
|
|
232
|
-
return "none";
|
|
233
|
-
}
|
|
234
|
-
function detectDatabase(root) {
|
|
235
|
-
for (const f of ["docker-compose.yml", "docker-compose.yaml", "compose.yml", "compose.yaml"]) {
|
|
236
|
-
const content = safeRead(join(root, f));
|
|
237
|
-
if (!content)
|
|
238
|
-
continue;
|
|
239
|
-
if (content.includes("postgres"))
|
|
240
|
-
return "postgresql";
|
|
241
|
-
if (content.includes("mysql") || content.includes("mariadb"))
|
|
242
|
-
return "mysql";
|
|
243
|
-
if (content.includes("mongo"))
|
|
244
|
-
return "mongodb";
|
|
245
|
-
if (content.includes("redis"))
|
|
246
|
-
return "redis";
|
|
247
|
-
}
|
|
248
|
-
for (const f of [".env", ".env.local", ".env.development"]) {
|
|
249
|
-
const content = safeRead(join(root, f));
|
|
250
|
-
if (!content)
|
|
251
|
-
continue;
|
|
252
|
-
if (content.includes("postgres"))
|
|
253
|
-
return "postgresql";
|
|
254
|
-
if (content.includes("mysql"))
|
|
255
|
-
return "mysql";
|
|
256
|
-
if (content.includes("mongodb") || content.includes("mongo+srv"))
|
|
257
|
-
return "mongodb";
|
|
258
|
-
if (content.includes("redis://"))
|
|
259
|
-
return "redis";
|
|
260
|
-
}
|
|
261
|
-
if (existsSync(join(root, "prisma", "schema.prisma"))) {
|
|
262
|
-
const content = safeRead(join(root, "prisma", "schema.prisma"));
|
|
263
|
-
if (content.includes("postgresql"))
|
|
264
|
-
return "postgresql";
|
|
265
|
-
if (content.includes("mysql"))
|
|
266
|
-
return "mysql";
|
|
267
|
-
if (content.includes("sqlite"))
|
|
268
|
-
return "sqlite";
|
|
269
|
-
if (content.includes("mongodb"))
|
|
270
|
-
return "mongodb";
|
|
271
|
-
}
|
|
272
|
-
for (const f of ["*.db", "*.sqlite", "*.sqlite3"]) {
|
|
273
|
-
if (existsSync(join(root, "db.sqlite")) || existsSync(join(root, "database.sqlite")) || existsSync(join(root, "dev.db"))) {
|
|
274
|
-
return "sqlite";
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return "none";
|
|
278
|
-
}
|
|
279
|
-
function detectRuntime() {
|
|
280
|
-
const isContainer = existsSync("/.dockerenv") || existsSync("/run/.containerenv") || safeRead("/proc/1/cgroup").includes("docker");
|
|
281
|
-
const isSSH = !!process__default.env.SSH_CLIENT || !!process__default.env.SSH_TTY || !!process__default.env.SSH_CONNECTION;
|
|
282
|
-
const isCI = !!(process__default.env.CI || process__default.env.GITHUB_ACTIONS || process__default.env.GITLAB_CI || process__default.env.JENKINS_URL || process__default.env.CIRCLECI || process__default.env.TRAVIS || process__default.env.BUILDKITE);
|
|
283
|
-
const isWSL = safeRead("/proc/version").toLowerCase().includes("microsoft");
|
|
284
|
-
const isMac = process__default.platform === "darwin";
|
|
285
|
-
const hasDisplay = !!(process__default.env.DISPLAY || process__default.env.WAYLAND_DISPLAY || process__default.env.TERM_PROGRAM);
|
|
286
|
-
const isHeadless = !isMac && !hasDisplay && !isWSL;
|
|
287
|
-
const hasBrowser = isMac || hasDisplay || isWSL;
|
|
288
|
-
return {
|
|
289
|
-
isContainer,
|
|
290
|
-
isHeadless,
|
|
291
|
-
isSSH,
|
|
292
|
-
isCI,
|
|
293
|
-
isWSL,
|
|
294
|
-
hasBrowser
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
function detectMonorepo(root, pkg) {
|
|
298
|
-
if (pkg?.workspaces)
|
|
299
|
-
return true;
|
|
300
|
-
if (existsSync(join(root, "pnpm-workspace.yaml")))
|
|
301
|
-
return true;
|
|
302
|
-
if (existsSync(join(root, "lerna.json")))
|
|
303
|
-
return true;
|
|
304
|
-
if (existsSync(join(root, "nx.json")))
|
|
305
|
-
return true;
|
|
306
|
-
if (existsSync(join(root, "turbo.json")))
|
|
307
|
-
return true;
|
|
308
|
-
return false;
|
|
309
|
-
}
|
|
310
|
-
function detectConventionalCommits(root, pkg) {
|
|
311
|
-
if (existsSync(join(root, ".commitlintrc.json")) || existsSync(join(root, ".commitlintrc.js")) || existsSync(join(root, "commitlint.config.js")) || existsSync(join(root, "commitlint.config.mjs"))) {
|
|
312
|
-
return true;
|
|
313
|
-
}
|
|
314
|
-
if (hasDep(pkg, "@commitlint/cli") || hasDep(pkg, "@commitlint/config-conventional"))
|
|
315
|
-
return true;
|
|
316
|
-
try {
|
|
317
|
-
const log = execSync("git log --oneline -10 2>/dev/null", { cwd: root, encoding: "utf-8", timeout: 3e3 });
|
|
318
|
-
const conventionalPattern = /^[a-f0-9]+ (feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)(\(.+\))?!?:/m;
|
|
319
|
-
const lines = log.trim().split("\n").filter(Boolean);
|
|
320
|
-
const matches = lines.filter((l) => conventionalPattern.test(l));
|
|
321
|
-
return lines.length > 0 && matches.length / lines.length > 0.5;
|
|
322
|
-
} catch {
|
|
323
|
-
return false;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
function detectGitHooks(root, pkg) {
|
|
327
|
-
if (existsSync(join(root, ".husky")))
|
|
328
|
-
return true;
|
|
329
|
-
if (hasDep(pkg, "husky") || hasDep(pkg, "simple-git-hooks") || hasDep(pkg, "lefthook"))
|
|
330
|
-
return true;
|
|
331
|
-
if (existsSync(join(root, ".lefthook.yml")))
|
|
332
|
-
return true;
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
function detectCI(root) {
|
|
336
|
-
return existsSync(join(root, ".github", "workflows")) || existsSync(join(root, ".gitlab-ci.yml")) || existsSync(join(root, ".circleci")) || existsSync(join(root, "Jenkinsfile")) || existsSync(join(root, ".travis.yml")) || existsSync(join(root, "bitbucket-pipelines.yml"));
|
|
337
|
-
}
|
|
338
|
-
function safeRead(path) {
|
|
339
|
-
try {
|
|
340
|
-
if (!existsSync(path))
|
|
341
|
-
return "";
|
|
342
|
-
return readFileSync(path, "utf-8");
|
|
343
|
-
} catch {
|
|
344
|
-
return "";
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
export { scanProject as s };
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { i as inquirer } from '../chunks/index6.mjs';
|
|
2
|
-
import { a as detectCodeToolType } from '../chunks/smart-defaults.mjs';
|
|
3
|
-
import { CODE_TOOL_ALIASES, DEFAULT_CODE_TOOL_TYPE, isCodeToolType } from '../chunks/constants.mjs';
|
|
4
|
-
import { i18n } from '../chunks/index2.mjs';
|
|
5
|
-
import { readZcfConfigAsync, updateZcfConfig } from '../chunks/ccjk-config.mjs';
|
|
6
|
-
|
|
7
|
-
const CODE_TYPE_ABBREVIATIONS = {
|
|
8
|
-
cc: "claude-code",
|
|
9
|
-
mc: "myclaude",
|
|
10
|
-
mycode: "myclaude",
|
|
11
|
-
cx: "codex"
|
|
12
|
-
};
|
|
13
|
-
const STARTUP_CODE_TOOL_CHOICES = ["myclaude", "claude-code", "codex"];
|
|
14
|
-
async function resolveCodeType(codeTypeParam) {
|
|
15
|
-
if (codeTypeParam) {
|
|
16
|
-
const normalizedParam = codeTypeParam.toLowerCase().trim();
|
|
17
|
-
if (normalizedParam in CODE_TYPE_ABBREVIATIONS) {
|
|
18
|
-
return CODE_TYPE_ABBREVIATIONS[normalizedParam];
|
|
19
|
-
}
|
|
20
|
-
if (normalizedParam in CODE_TOOL_ALIASES) {
|
|
21
|
-
return CODE_TOOL_ALIASES[normalizedParam];
|
|
22
|
-
}
|
|
23
|
-
if (isValidCodeType(normalizedParam)) {
|
|
24
|
-
return normalizedParam;
|
|
25
|
-
}
|
|
26
|
-
const validAbbreviations = Object.keys(CODE_TYPE_ABBREVIATIONS);
|
|
27
|
-
const validFullTypes = Object.values(CODE_TYPE_ABBREVIATIONS);
|
|
28
|
-
const validOptions = [...validAbbreviations, ...validFullTypes].join(", ");
|
|
29
|
-
let defaultValue = DEFAULT_CODE_TOOL_TYPE;
|
|
30
|
-
try {
|
|
31
|
-
const config = await readZcfConfigAsync();
|
|
32
|
-
if (config?.codeToolType && isValidCodeType(config.codeToolType)) {
|
|
33
|
-
defaultValue = config.codeToolType;
|
|
34
|
-
}
|
|
35
|
-
} catch {
|
|
36
|
-
}
|
|
37
|
-
throw new Error(
|
|
38
|
-
i18n.t("errors:invalidCodeType", { value: codeTypeParam, validOptions, defaultValue })
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
const storedType = await getStoredCodeType();
|
|
42
|
-
if (storedType) {
|
|
43
|
-
return storedType;
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
const freshDetected = detectCodeToolType();
|
|
47
|
-
if (isValidCodeType(freshDetected)) {
|
|
48
|
-
return freshDetected;
|
|
49
|
-
}
|
|
50
|
-
} catch {
|
|
51
|
-
}
|
|
52
|
-
return DEFAULT_CODE_TOOL_TYPE;
|
|
53
|
-
}
|
|
54
|
-
function isValidCodeType(value) {
|
|
55
|
-
return isCodeToolType(value);
|
|
56
|
-
}
|
|
57
|
-
async function getStoredCodeType() {
|
|
58
|
-
try {
|
|
59
|
-
const config = await readZcfConfigAsync();
|
|
60
|
-
if (config?.codeToolType && isValidCodeType(config.codeToolType)) {
|
|
61
|
-
return config.codeToolType;
|
|
62
|
-
}
|
|
63
|
-
} catch {
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
function persistCodeType(codeToolType) {
|
|
68
|
-
updateZcfConfig({ codeToolType });
|
|
69
|
-
}
|
|
70
|
-
async function promptStartupCodeType() {
|
|
71
|
-
const isZh = i18n.language === "zh-CN";
|
|
72
|
-
const { codeToolType } = await inquirer.prompt({
|
|
73
|
-
type: "list",
|
|
74
|
-
name: "codeToolType",
|
|
75
|
-
message: isZh ? "\u9009\u62E9\u4EE3\u7801\u5DE5\u5177" : "Choose your code tool",
|
|
76
|
-
choices: STARTUP_CODE_TOOL_CHOICES.map((tool) => {
|
|
77
|
-
if (tool === "myclaude") {
|
|
78
|
-
return {
|
|
79
|
-
name: isZh ? `${tool} - Provider-first \u63A7\u5236\u4E2D\u5FC3\uFF08\u9ED8\u8BA4\u63A8\u8350\uFF09` : `${tool} - Provider-first control center (recommended default)`,
|
|
80
|
-
value: tool
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
if (tool === "claude-code") {
|
|
84
|
-
return {
|
|
85
|
-
name: isZh ? "Claude Code - Claude \u5BB6\u65CF\u7ECF\u5178\u63A7\u5236\u4E2D\u5FC3" : "Claude Code - Classic Claude-family control center",
|
|
86
|
-
value: tool
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
name: isZh ? "Codex - Codex \u4E13\u5C5E\u63A7\u5236\u4E2D\u5FC3\u3001Provider / MCP / Memory \u914D\u7F6E" : "Codex - Codex-specific control center for provider, MCP, and memory setup",
|
|
91
|
-
value: tool
|
|
92
|
-
};
|
|
93
|
-
}),
|
|
94
|
-
default: 0
|
|
95
|
-
});
|
|
96
|
-
persistCodeType(codeToolType);
|
|
97
|
-
return codeToolType;
|
|
98
|
-
}
|
|
99
|
-
async function resolveStartupCodeType(options = {}) {
|
|
100
|
-
if (options.codeTypeParam) {
|
|
101
|
-
const resolvedType = await resolveCodeType(options.codeTypeParam);
|
|
102
|
-
persistCodeType(resolvedType);
|
|
103
|
-
return resolvedType;
|
|
104
|
-
}
|
|
105
|
-
const storedType = await getStoredCodeType();
|
|
106
|
-
if (storedType) {
|
|
107
|
-
return storedType;
|
|
108
|
-
}
|
|
109
|
-
if (options.interactive) {
|
|
110
|
-
return await promptStartupCodeType();
|
|
111
|
-
}
|
|
112
|
-
return await resolveCodeType();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export { STARTUP_CODE_TOOL_CHOICES as S, resolveStartupCodeType as a, resolveCodeType as r };
|