ccjk 3.0.3 → 3.0.4

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.
@@ -1,17 +1,17 @@
1
+ import { existsSync } from 'node:fs';
1
2
  import ansis from 'ansis';
2
3
  import { version } from './package.mjs';
3
- import { DEFAULT_CODE_TOOL_TYPE, resolveCodeToolType as resolveCodeToolType$1, isCodeToolType } from './constants.mjs';
4
+ import { SETTINGS_FILE, DEFAULT_CODE_TOOL_TYPE, resolveCodeToolType as resolveCodeToolType$1, isCodeToolType } from './constants.mjs';
4
5
  import { i18n } from './index2.mjs';
5
6
  import { f as displayBanner } from '../shared/ccjk.tJ08-yZt.mjs';
6
7
  import { readZcfConfig, updateZcfConfig } from './ccjk-config.mjs';
7
8
  import { C as runCodexUpdate } from './codex.mjs';
8
- import { u as updatePromptOnly, s as selectAndInstallWorkflows } from '../shared/ccjk.BQzWKmC3.mjs';
9
+ import { n as needsMigration, a as migrateSettingsForTokenRetrieval, d as displayMigrationResult, p as promptMigration, u as updatePromptOnly, s as selectAndInstallWorkflows } from '../shared/ccjk.BEEMi_nf.mjs';
9
10
  import { h as handleExitPromptError, a as handleGeneralError } from '../shared/ccjk.DrMygfCF.mjs';
10
11
  import { resolveAiOutputLanguage } from './prompts.mjs';
11
12
  import { checkClaudeCodeVersionAndPrompt } from './version-checker.mjs';
12
13
  import 'node:os';
13
14
  import 'pathe';
14
- import 'node:fs';
15
15
  import 'node:process';
16
16
  import 'node:url';
17
17
  import 'i18next';
@@ -81,6 +81,19 @@ async function update(options = {}) {
81
81
  // Non-interactive mode flag
82
82
  );
83
83
  const aiOutputLang = await resolveAiOutputLanguage(i18n.language, options.aiOutputLang, zcfConfig, options.skipPrompt);
84
+ if (existsSync(SETTINGS_FILE) && needsMigration()) {
85
+ if (options.skipPrompt) {
86
+ console.log(ansis.yellow("\n\u26A0\uFE0F Problematic configuration detected. Auto-fixing...\n"));
87
+ const result = migrateSettingsForTokenRetrieval();
88
+ displayMigrationResult(result);
89
+ } else {
90
+ const shouldMigrate = await promptMigration();
91
+ if (shouldMigrate) {
92
+ const result = migrateSettingsForTokenRetrieval();
93
+ displayMigrationResult(result);
94
+ }
95
+ }
96
+ }
84
97
  console.log(ansis.green(`
85
98
  ${i18n.t("configuration:updatingPrompts")}
86
99
  `));
package/dist/index.mjs CHANGED
@@ -43,7 +43,7 @@ import './chunks/version-checker.mjs';
43
43
  import 'node:path';
44
44
  import 'semver';
45
45
  import './shared/ccjk.CUdzQluX.mjs';
46
- import './shared/ccjk.BQzWKmC3.mjs';
46
+ import './shared/ccjk.BEEMi_nf.mjs';
47
47
  import './shared/ccjk.DrMygfCF.mjs';
48
48
  import './chunks/prompts.mjs';
49
49
  import 'fs-extra';
@@ -1,18 +1,140 @@
1
1
  import ansis from 'ansis';
2
- import inquirer from 'inquirer';
3
- import { CLAUDE_DIR, SETTINGS_FILE } from '../chunks/constants.mjs';
2
+ import { SETTINGS_FILE, CLAUDE_DIR } from '../chunks/constants.mjs';
4
3
  import { ensureI18nInitialized, i18n } from '../chunks/index2.mjs';
5
- import { x as getExistingApiConfig, o as configureApi, z as switchToOfficialLogin, l as backupExistingConfig, y as applyAiLanguageDirective } from '../chunks/config.mjs';
4
+ import { l as backupExistingConfig, x as getExistingApiConfig, o as configureApi, z as switchToOfficialLogin, y as applyAiLanguageDirective } from '../chunks/config.mjs';
5
+ import { exists, removeFile, ensureDir, copyFile } from '../chunks/fs-operations.mjs';
6
+ import { readJsonConfig, writeJsonConfig } from '../chunks/json-config.mjs';
7
+ import inquirer from 'inquirer';
6
8
  import { fileURLToPath } from 'node:url';
7
9
  import { join, dirname } from 'pathe';
8
10
  import { updateZcfConfig } from '../chunks/ccjk-config.mjs';
9
- import { exists, removeFile, ensureDir, copyFile } from '../chunks/fs-operations.mjs';
10
- import { readJsonConfig, writeJsonConfig } from '../chunks/json-config.mjs';
11
11
  import { p as promptBoolean, a as addNumbersToChoices } from './ccjk.DhBeLRzf.mjs';
12
12
  import { existsSync } from 'node:fs';
13
13
  import { rm, mkdir, copyFile as copyFile$1 } from 'node:fs/promises';
14
14
  import { getOrderedWorkflows, getWorkflowConfig, getTagLabel } from '../chunks/workflows2.mjs';
15
15
 
16
+ function migrateSettingsForTokenRetrieval() {
17
+ ensureI18nInitialized();
18
+ const result = {
19
+ success: false,
20
+ changes: [],
21
+ backupPath: null,
22
+ errors: []
23
+ };
24
+ try {
25
+ if (!exists(SETTINGS_FILE)) {
26
+ result.errors.push(i18n.t("common:fileNotFound", { file: "settings.json" }));
27
+ return result;
28
+ }
29
+ const settings = readJsonConfig(SETTINGS_FILE);
30
+ if (!settings) {
31
+ result.errors.push(i18n.t("common:failedToReadFile", { file: "settings.json" }));
32
+ return result;
33
+ }
34
+ let modified = false;
35
+ if (settings.env) {
36
+ if ("CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC" in settings.env) {
37
+ delete settings.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC;
38
+ result.changes.push("Removed CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC (was blocking token retrieval)");
39
+ modified = true;
40
+ }
41
+ if (settings.env.MCP_TIMEOUT) {
42
+ const timeout = Number.parseInt(settings.env.MCP_TIMEOUT, 10);
43
+ if (!Number.isNaN(timeout) && timeout > 2e4) {
44
+ const oldValue = settings.env.MCP_TIMEOUT;
45
+ settings.env.MCP_TIMEOUT = "15000";
46
+ result.changes.push(`Reduced MCP_TIMEOUT from ${oldValue}ms to 15000ms (was causing slow failures)`);
47
+ modified = true;
48
+ }
49
+ }
50
+ }
51
+ if (!modified) {
52
+ result.success = true;
53
+ return result;
54
+ }
55
+ const backupPath = backupExistingConfig();
56
+ if (backupPath) {
57
+ result.backupPath = backupPath;
58
+ } else {
59
+ result.errors.push("Failed to create backup (continuing anyway)");
60
+ }
61
+ writeJsonConfig(SETTINGS_FILE, settings);
62
+ result.success = true;
63
+ return result;
64
+ } catch (error) {
65
+ result.errors.push(`Migration failed: ${error instanceof Error ? error.message : String(error)}`);
66
+ return result;
67
+ }
68
+ }
69
+ function needsMigration() {
70
+ try {
71
+ if (!exists(SETTINGS_FILE)) {
72
+ return false;
73
+ }
74
+ const settings = readJsonConfig(SETTINGS_FILE);
75
+ if (!settings || !settings.env) {
76
+ return false;
77
+ }
78
+ const hasProblematicVar = "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC" in settings.env;
79
+ const hasExcessiveTimeout = settings.env.MCP_TIMEOUT && Number.parseInt(settings.env.MCP_TIMEOUT, 10) > 2e4;
80
+ return Boolean(hasProblematicVar || hasExcessiveTimeout);
81
+ } catch {
82
+ return false;
83
+ }
84
+ }
85
+ function displayMigrationResult(result) {
86
+ ensureI18nInitialized();
87
+ if (result.success) {
88
+ if (result.changes.length > 0) {
89
+ console.log(ansis.green(`
90
+ \u2705 ${i18n.t("common:configurationFixed")}
91
+ `));
92
+ console.log(ansis.bold("Changes made:"));
93
+ for (const change of result.changes) {
94
+ console.log(ansis.gray(` \u2022 ${change}`));
95
+ }
96
+ if (result.backupPath) {
97
+ console.log(ansis.gray(`
98
+ \u{1F4E6} Backup created: ${result.backupPath}`));
99
+ }
100
+ console.log(ansis.yellow("\n\u26A0\uFE0F Please restart Claude Code CLI for changes to take effect.\n"));
101
+ } else {
102
+ console.log(ansis.green(`
103
+ \u2705 ${i18n.t("common:noMigrationNeeded")}
104
+ `));
105
+ }
106
+ } else {
107
+ console.log(ansis.red(`
108
+ \u274C ${i18n.t("common:migrationFailed")}
109
+ `));
110
+ if (result.errors.length > 0) {
111
+ console.log(ansis.bold("Errors:"));
112
+ for (const error of result.errors) {
113
+ console.log(ansis.red(` \u2022 ${error}`));
114
+ }
115
+ }
116
+ if (result.backupPath) {
117
+ console.log(ansis.gray(`
118
+ \u{1F4E6} Backup available at: ${result.backupPath}`));
119
+ console.log(ansis.gray("You can restore with: cp <backup-path>/settings.json ~/.claude/settings.json\n"));
120
+ }
121
+ }
122
+ }
123
+ async function promptMigration() {
124
+ ensureI18nInitialized();
125
+ const inquirer = await import('inquirer');
126
+ console.log(ansis.yellow("\n\u26A0\uFE0F Problematic configuration detected!\n"));
127
+ console.log(ansis.gray("Your settings.json contains configurations that prevent Claude Code"));
128
+ console.log(ansis.gray("from retrieving token counts, causing /compact failures.\n"));
129
+ const { shouldMigrate } = await inquirer.default.prompt({
130
+ type: "confirm",
131
+ name: "shouldMigrate",
132
+ message: "Would you like to fix these issues automatically? (backup will be created)",
133
+ default: true
134
+ });
135
+ return shouldMigrate;
136
+ }
137
+
16
138
  const OUTPUT_STYLES = [
17
139
  // Custom styles (have template files) - Efficiency-focused styles
18
140
  {
@@ -616,4 +738,4 @@ async function cleanupOldVersionFiles() {
616
738
  }
617
739
  }
618
740
 
619
- export { configureOutputStyle as a, configureApiCompletely as c, formatApiKeyDisplay as f, modifyApiConfigPartially as m, selectAndInstallWorkflows as s, updatePromptOnly as u, validateApiKey as v };
741
+ export { migrateSettingsForTokenRetrieval as a, configureOutputStyle as b, configureApiCompletely as c, displayMigrationResult as d, formatApiKeyDisplay as f, modifyApiConfigPartially as m, needsMigration as n, promptMigration as p, selectAndInstallWorkflows as s, updatePromptOnly as u, validateApiKey as v };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ccjk",
3
3
  "type": "module",
4
- "version": "3.0.3",
4
+ "version": "3.0.4",
5
5
  "packageManager": "pnpm@10.17.1",
6
6
  "description": "Claude Code JinKu - Advanced AI-powered development assistant with skills, agents, and LLM-driven audit",
7
7
  "author": {
@@ -3,8 +3,7 @@
3
3
  "env": {
4
4
  "DISABLE_TELEMETRY": "1",
5
5
  "DISABLE_ERROR_REPORTING": "1",
6
- "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
7
- "MCP_TIMEOUT": "60000"
6
+ "MCP_TIMEOUT": "15000"
8
7
  },
9
8
  "includeCoAuthoredBy": false,
10
9
  "permissions": {