ccjk 9.8.2 → 9.10.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.
@@ -88,8 +88,48 @@ async function updateClaudeCode(force = false, skipPrompt = false) {
88
88
  ensureI18nInitialized();
89
89
  const spinner = ora(i18n.t("updater:checkingVersion")).start();
90
90
  try {
91
- const { installed, currentVersion, latestVersion, needsUpdate, isHomebrew, installationSource, isBroken } = await checkClaudeCodeVersion();
91
+ const { installed, currentVersion, latestVersion, needsUpdate, isHomebrew, installationSource, isBroken, hasWrongPackage, wrongPackageName } = await checkClaudeCodeVersion();
92
92
  spinner.stop();
93
+ if (hasWrongPackage && wrongPackageName) {
94
+ console.log(ansis.yellow(`
95
+ \u26A0\uFE0F ${i18n.t("installation:wrongPackageDetected")}`));
96
+ console.log(ansis.red(` ${i18n.t("installation:installedPackage")}: ${wrongPackageName}`));
97
+ console.log(ansis.green(` ${i18n.t("installation:correctPackage")}: @anthropic-ai/claude-code`));
98
+ console.log();
99
+ if (!skipPrompt) {
100
+ const inquirer = (await import('inquirer')).default;
101
+ const { shouldFix } = await inquirer.prompt([
102
+ {
103
+ type: "confirm",
104
+ name: "shouldFix",
105
+ message: i18n.t("installation:confirmFixWrongPackage"),
106
+ default: true
107
+ }
108
+ ]);
109
+ if (!shouldFix) {
110
+ console.log(ansis.gray(i18n.t("installation:wrongPackageSkipped")));
111
+ return false;
112
+ }
113
+ }
114
+ const fixSpinner = ora(i18n.t("installation:fixingWrongPackage")).start();
115
+ try {
116
+ await execWithSudoIfNeeded("npm", ["uninstall", "-g", wrongPackageName]);
117
+ fixSpinner.text = i18n.t("installation:installingCorrectPackage");
118
+ await execWithSudoIfNeeded("npm", ["install", "-g", "@anthropic-ai/claude-code", "--force"]);
119
+ fixSpinner.succeed(ansis.green(`\u2713 ${i18n.t("installation:wrongPackageFixed")}`));
120
+ console.log(ansis.green(`
121
+ \u2713 ${i18n.t("installation:nowUsingCorrectPackage")}`));
122
+ return true;
123
+ } catch (error) {
124
+ fixSpinner.fail(ansis.red(`\u2717 ${i18n.t("installation:wrongPackageFixFailed")}`));
125
+ console.error(ansis.red(error instanceof Error ? error.message : String(error)));
126
+ console.log(ansis.gray(`
127
+ ${i18n.t("installation:manualFixHint")}:`));
128
+ console.log(ansis.gray(` npm uninstall -g ${wrongPackageName}`));
129
+ console.log(ansis.gray(` npm install -g @anthropic-ai/claude-code`));
130
+ return false;
131
+ }
132
+ }
93
133
  if (!installed) {
94
134
  console.log(ansis.yellow(i18n.t("updater:claudeCodeNotInstalled")));
95
135
  return false;
@@ -252,6 +292,17 @@ async function checkAndUpdateTools(skipPrompt = false) {
252
292
  console.warn(ansis.yellow(`\u26A0 Duplicate installation check failed: ${errorMessage}`));
253
293
  }
254
294
  const results = [];
295
+ console.log(ansis.bold("\u{1F4E6} CCJK"));
296
+ try {
297
+ await checkCcjkVersionAndPrompt(skipPrompt);
298
+ results.push({ tool: "CCJK", success: true });
299
+ } catch (error) {
300
+ const errorMessage = error instanceof Error ? error.message : String(error);
301
+ console.error(ansis.red(`\u274C ${format(i18n.t("updater:updateFailed"), { tool: "CCJK" })}: ${errorMessage}`));
302
+ results.push({ tool: "CCJK", success: false, error: errorMessage });
303
+ }
304
+ console.log();
305
+ console.log(ansis.bold("\u{1F500} CCR"));
255
306
  try {
256
307
  const success = await updateCcr(false, skipPrompt);
257
308
  results.push({ tool: "CCR", success });
@@ -290,5 +341,58 @@ async function checkAndUpdateTools(skipPrompt = false) {
290
341
  }
291
342
  }
292
343
  }
344
+ async function checkCcjkVersionAndPrompt(skipPrompt) {
345
+ try {
346
+ const { readFileSync } = await import('node:fs');
347
+ const { fileURLToPath } = await import('node:url');
348
+ const { dirname, join } = await import('pathe');
349
+ const __dirname = dirname(fileURLToPath(import.meta.url));
350
+ const pkgPath = join(__dirname, "..", "..", "package.json");
351
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
352
+ const currentVersion = pkg.version;
353
+ console.log(ansis.cyan(`${i18n.t("updater:currentVersion")} v${currentVersion}`));
354
+ const { stdout } = await exec("npm", ["view", "ccjk", "version"]);
355
+ const latestVersion = stdout.trim();
356
+ console.log(ansis.cyan(`${i18n.t("updater:latestVersion")} v${latestVersion}`));
357
+ if (currentVersion === latestVersion) {
358
+ console.log(ansis.green(`\u2713 ${i18n.t("updater:alreadyLatest")}`));
359
+ return;
360
+ }
361
+ if (!skipPrompt) {
362
+ const inquirer = (await import('inquirer')).default;
363
+ const { shouldUpdate } = await inquirer.prompt([
364
+ {
365
+ type: "confirm",
366
+ name: "shouldUpdate",
367
+ message: format(i18n.t("updater:updatePrompt"), { tool: "CCJK", version: latestVersion }),
368
+ default: true
369
+ }
370
+ ]);
371
+ if (!shouldUpdate) {
372
+ console.log(ansis.gray(i18n.t("updater:updateSkipped")));
373
+ return;
374
+ }
375
+ }
376
+ console.log(ansis.dim("Clearing npx cache..."));
377
+ try {
378
+ await exec("npm", ["cache", "clean", "--force"]);
379
+ } catch {
380
+ }
381
+ const ora2 = (await import('ora')).default;
382
+ const updateSpinner = ora2("Updating CCJK...").start();
383
+ try {
384
+ await execWithSudoIfNeeded("npm", ["install", "-g", "ccjk@latest", "--force"]);
385
+ updateSpinner.succeed(ansis.green(`\u2713 CCJK updated to v${latestVersion}`));
386
+ console.log(ansis.yellow("\n\u26A0 Please restart ccjk to use the new version"));
387
+ process.exit(0);
388
+ } catch (error) {
389
+ updateSpinner.fail(ansis.red("\u2717 CCJK update failed"));
390
+ console.error(ansis.red(error instanceof Error ? error.message : String(error)));
391
+ console.log(ansis.gray("\nTry manually: npm install -g ccjk@latest"));
392
+ }
393
+ } catch (error) {
394
+ console.error(ansis.red(`${i18n.t("updater:checkFailed")} ${error instanceof Error ? error.message : String(error)}`));
395
+ }
396
+ }
293
397
 
294
398
  export { checkAndUpdateTools, execWithSudoIfNeeded, updateCcr, updateClaudeCode, updateCometixLine };
@@ -1,4 +1,4 @@
1
- const version = "9.8.2";
1
+ const version = "9.10.1";
2
2
  const homepage = "https://github.com/miounet11/ccjk";
3
3
 
4
4
  export { homepage, version };
@@ -225,6 +225,31 @@ function findClaudeBinaryInDirectory(dir, depth = 0) {
225
225
  }
226
226
 
227
227
  const execAsync = promisify(exec);
228
+ async function detectWrongClaudeCodePackage() {
229
+ try {
230
+ const { stdout } = await execAsync("npm list -g --depth=0 --json");
231
+ const packages = JSON.parse(stdout);
232
+ const dependencies = packages.dependencies || {};
233
+ if ("claude-code" in dependencies) {
234
+ return {
235
+ hasWrongPackage: true,
236
+ wrongPackageName: "claude-code",
237
+ correctPackageName: "@anthropic-ai/claude-code"
238
+ };
239
+ }
240
+ return {
241
+ hasWrongPackage: false,
242
+ wrongPackageName: null,
243
+ correctPackageName: "@anthropic-ai/claude-code"
244
+ };
245
+ } catch {
246
+ return {
247
+ hasWrongPackage: false,
248
+ wrongPackageName: null,
249
+ correctPackageName: "@anthropic-ai/claude-code"
250
+ };
251
+ }
252
+ }
228
253
  async function getInstalledVersion(command, maxRetries = 3) {
229
254
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
230
255
  try {
@@ -773,6 +798,7 @@ async function checkCcrVersion() {
773
798
  };
774
799
  }
775
800
  async function checkClaudeCodeVersion() {
801
+ const wrongPackageInfo = await detectWrongClaudeCodePackage();
776
802
  let currentVersion = await getInstalledVersion("claude");
777
803
  const initialGetVersionSuccess = currentVersion !== null;
778
804
  let installationInfo = await getClaudeCodeInstallationSource();
@@ -819,7 +845,9 @@ async function checkClaudeCodeVersion() {
819
845
  isHomebrew,
820
846
  commandPath,
821
847
  installationSource,
822
- isBroken: !initialGetVersionSuccess && currentVersion !== null
848
+ isBroken: !initialGetVersionSuccess && currentVersion !== null,
849
+ hasWrongPackage: wrongPackageInfo.hasWrongPackage,
850
+ wrongPackageName: wrongPackageInfo.wrongPackageName
823
851
  };
824
852
  }
825
853
  async function checkCometixLineVersion() {
@@ -846,4 +874,4 @@ async function checkClaudeCodeVersionAndPrompt(skipPrompt = false) {
846
874
  }
847
875
  }
848
876
 
849
- export { checkCcrVersion, checkClaudeCodeVersion, checkClaudeCodeVersionAndPrompt, checkCometixLineVersion, checkDuplicateInstallations, compareVersions, detectAllClaudeCodeInstallations, fixBrokenNpmSymlink, getClaudeCodeInstallationSource, getHomebrewClaudeCodeVersion, getInstalledVersion, getLatestVersion, getSourceDisplayName, handleDuplicateInstallations, shouldUpdate };
877
+ export { checkCcrVersion, checkClaudeCodeVersion, checkClaudeCodeVersionAndPrompt, checkCometixLineVersion, checkDuplicateInstallations, compareVersions, detectAllClaudeCodeInstallations, detectWrongClaudeCodePackage, fixBrokenNpmSymlink, getClaudeCodeInstallationSource, getHomebrewClaudeCodeVersion, getInstalledVersion, getLatestVersion, getSourceDisplayName, handleDuplicateInstallations, shouldUpdate };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ccjk",
3
3
  "type": "module",
4
- "version": "9.8.2",
4
+ "version": "9.10.1",
5
5
  "packageManager": "pnpm@10.17.1",
6
6
  "description": "CCJK v9.0.0 - Revolutionary AI Development Platform with Enterprise Security, Streaming Cloud Sync, CRDT Conflict Resolution, and Unified V3 Architecture",
7
7
  "author": {