ccjk 3.7.3 → 3.8.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 (107) hide show
  1. package/README.md +103 -896
  2. package/dist/chunks/ccr.mjs +1 -0
  3. package/dist/chunks/doctor.mjs +58 -0
  4. package/dist/chunks/index.mjs +6 -0
  5. package/dist/chunks/package.mjs +1 -1
  6. package/dist/chunks/permissions.mjs +164 -342
  7. package/dist/chunks/thinking.mjs +615 -0
  8. package/dist/chunks/vim.mjs +891 -0
  9. package/dist/cli.mjs +49 -0
  10. package/dist/i18n/locales/en/configuration.json +97 -1
  11. package/dist/i18n/locales/en/lsp.json +78 -0
  12. package/dist/i18n/locales/en/mcp.json +11 -0
  13. package/dist/i18n/locales/en/permissions.json +53 -1
  14. package/dist/i18n/locales/en/thinking.json +65 -0
  15. package/dist/i18n/locales/en/vim.json +169 -0
  16. package/dist/i18n/locales/zh-CN/configuration.json +97 -1
  17. package/dist/i18n/locales/zh-CN/lsp.json +78 -0
  18. package/dist/i18n/locales/zh-CN/mcp.json +11 -0
  19. package/dist/i18n/locales/zh-CN/permissions.json +53 -1
  20. package/dist/i18n/locales/zh-CN/thinking.json +65 -0
  21. package/dist/i18n/locales/zh-CN/vim.json +169 -0
  22. package/dist/shared/ccjk.pi0nsyn3.mjs +1242 -0
  23. package/package.json +55 -55
  24. package/templates/claude-code/common/settings.json +63 -30
  25. package/templates/CLAUDE.md +0 -219
  26. package/templates/claude-code/CLAUDE.md +0 -250
  27. package/templates/claude-code/en/workflow/bmad/commands/bmad-init.md +0 -165
  28. package/templates/claude-code/en/workflow/common/agents/get-current-datetime.md +0 -29
  29. package/templates/claude-code/en/workflow/common/agents/init-architect.md +0 -114
  30. package/templates/claude-code/en/workflow/common/commands/init-project.md +0 -53
  31. package/templates/claude-code/en/workflow/essential/agents/get-current-datetime.md +0 -29
  32. package/templates/claude-code/en/workflow/essential/agents/init-architect.md +0 -114
  33. package/templates/claude-code/en/workflow/essential/agents/planner.md +0 -116
  34. package/templates/claude-code/en/workflow/essential/agents/ui-ux-designer.md +0 -91
  35. package/templates/claude-code/en/workflow/essential/commands/feat.md +0 -250
  36. package/templates/claude-code/en/workflow/essential/commands/init-project.md +0 -53
  37. package/templates/claude-code/en/workflow/plan/agents/planner.md +0 -116
  38. package/templates/claude-code/en/workflow/plan/agents/ui-ux-designer.md +0 -91
  39. package/templates/claude-code/en/workflow/plan/commands/feat.md +0 -105
  40. package/templates/claude-code/zh-CN/workflow/bmad/commands/bmad-init.md +0 -172
  41. package/templates/claude-code/zh-CN/workflow/common/agents/get-current-datetime.md +0 -29
  42. package/templates/claude-code/zh-CN/workflow/common/agents/init-architect.md +0 -114
  43. package/templates/claude-code/zh-CN/workflow/common/commands/init-project.md +0 -53
  44. package/templates/claude-code/zh-CN/workflow/essential/agents/get-current-datetime.md +0 -29
  45. package/templates/claude-code/zh-CN/workflow/essential/agents/init-architect.md +0 -114
  46. package/templates/claude-code/zh-CN/workflow/essential/agents/planner.md +0 -116
  47. package/templates/claude-code/zh-CN/workflow/essential/agents/ui-ux-designer.md +0 -91
  48. package/templates/claude-code/zh-CN/workflow/essential/commands/feat.md +0 -248
  49. package/templates/claude-code/zh-CN/workflow/essential/commands/init-project.md +0 -53
  50. package/templates/claude-code/zh-CN/workflow/plan/agents/planner.md +0 -116
  51. package/templates/claude-code/zh-CN/workflow/plan/agents/ui-ux-designer.md +0 -91
  52. package/templates/claude-code/zh-CN/workflow/plan/commands/feat.md +0 -105
  53. package/templates/codex/common/config.toml +0 -0
  54. package/templates/common/output-styles/en/casual-friendly.md +0 -97
  55. package/templates/common/output-styles/en/expert-concise.md +0 -93
  56. package/templates/common/output-styles/en/pair-programmer.md +0 -177
  57. package/templates/common/output-styles/en/senior-architect.md +0 -121
  58. package/templates/common/output-styles/en/speed-coder.md +0 -185
  59. package/templates/common/output-styles/en/teaching-mode.md +0 -102
  60. package/templates/common/output-styles/en/technical-precise.md +0 -101
  61. package/templates/common/output-styles/zh-CN/pair-programmer.md +0 -177
  62. package/templates/common/output-styles/zh-CN/senior-architect.md +0 -297
  63. package/templates/common/output-styles/zh-CN/speed-coder.md +0 -185
  64. package/templates/common/skills/code-review.md +0 -343
  65. package/templates/common/skills/en/agent-browser.md +0 -258
  66. package/templates/common/skills/en/brainstorming.md +0 -64
  67. package/templates/common/skills/en/code-review.md +0 -81
  68. package/templates/common/skills/en/documentation-gen.md +0 -808
  69. package/templates/common/skills/en/executing-plans.md +0 -75
  70. package/templates/common/skills/en/git-commit.md +0 -216
  71. package/templates/common/skills/en/interview.md +0 -223
  72. package/templates/common/skills/en/migration-assistant.md +0 -312
  73. package/templates/common/skills/en/performance-profiling.md +0 -576
  74. package/templates/common/skills/en/pr-review.md +0 -341
  75. package/templates/common/skills/en/refactoring.md +0 -384
  76. package/templates/common/skills/en/security-audit.md +0 -462
  77. package/templates/common/skills/en/systematic-debugging.md +0 -82
  78. package/templates/common/skills/en/tdd-workflow.md +0 -93
  79. package/templates/common/skills/en/verification.md +0 -81
  80. package/templates/common/skills/en/workflow.md +0 -370
  81. package/templates/common/skills/en/writing-plans.md +0 -78
  82. package/templates/common/skills/summarize.md +0 -312
  83. package/templates/common/skills/translate.md +0 -202
  84. package/templates/common/skills/zh-CN/agent-browser.md +0 -260
  85. package/templates/common/skills/zh-CN/documentation-gen.md +0 -807
  86. package/templates/common/skills/zh-CN/migration-assistant.md +0 -318
  87. package/templates/common/skills/zh-CN/performance-profiling.md +0 -746
  88. package/templates/common/skills/zh-CN/pr-review.md +0 -341
  89. package/templates/common/skills/zh-CN/refactoring.md +0 -384
  90. package/templates/common/skills/zh-CN/security-audit.md +0 -462
  91. package/templates/common/smart-guide/en/smart-guide.md +0 -72
  92. package/templates/common/smart-guide/zh-CN/smart-guide.md +0 -72
  93. package/templates/common/workflow/git/en/git-cleanBranches.md +0 -102
  94. package/templates/common/workflow/git/en/git-commit.md +0 -205
  95. package/templates/common/workflow/git/en/git-rollback.md +0 -90
  96. package/templates/common/workflow/git/en/git-worktree.md +0 -276
  97. package/templates/common/workflow/git/zh-CN/git-cleanBranches.md +0 -102
  98. package/templates/common/workflow/git/zh-CN/git-commit.md +0 -205
  99. package/templates/common/workflow/git/zh-CN/git-rollback.md +0 -90
  100. package/templates/common/workflow/git/zh-CN/git-worktree.md +0 -276
  101. package/templates/common/workflow/interview/en/interview.md +0 -212
  102. package/templates/common/workflow/interview/zh-CN/interview.md +0 -212
  103. package/templates/common/workflow/sixStep/en/workflow.md +0 -357
  104. package/templates/common/workflow/sixStep/zh-CN/workflow.md +0 -357
  105. package/templates/industry/devops/en/ci-cd-pipeline.md +0 -410
  106. package/templates/industry/web-dev/en/api-design.md +0 -299
  107. package/templates/industry/web-dev/en/react-nextjs-setup.md +0 -236
@@ -0,0 +1,615 @@
1
+ import ansis from 'ansis';
2
+ import inquirer from 'inquirer';
3
+ import { SETTINGS_FILE } from './constants.mjs';
4
+ import { i18n } from './index.mjs';
5
+ import { readJsonConfig, writeJsonConfig } from './json-config.mjs';
6
+ import { h as handleExitPromptError, a as handleGeneralError } from '../shared/ccjk.DvIrK0wz.mjs';
7
+ import 'node:os';
8
+ import 'pathe';
9
+ import 'node:fs';
10
+ import 'node:process';
11
+ import 'node:url';
12
+ import 'i18next';
13
+ import 'i18next-fs-backend';
14
+ import 'dayjs';
15
+ import './fs-operations.mjs';
16
+ import 'node:crypto';
17
+ import 'node:fs/promises';
18
+
19
+ const DEFAULT_BUDGET_TOKENS = 2e4;
20
+ const MIN_BUDGET_TOKENS = 1e3;
21
+ const MAX_BUDGET_TOKENS = 2e5;
22
+ const THINKING_SUPPORTED_MODELS = [
23
+ "claude-3-5-sonnet-20241022",
24
+ "claude-3-5-sonnet-20240620",
25
+ "claude-3-5-sonnet-20250114",
26
+ "claude-3-7-opus-20250219",
27
+ // Opus 4.5 - default enabled
28
+ "claude-opus-4",
29
+ "opus-4"
30
+ ];
31
+ const DEFAULT_THINKING_CONFIG = {
32
+ enabled: true,
33
+ budgetTokens: DEFAULT_BUDGET_TOKENS,
34
+ inheritForSubAgents: true,
35
+ subAgentReduction: 0.5,
36
+ // Sub-agents get 50% of parent budget
37
+ alwaysUseThinking: false
38
+ // Only for complex tasks
39
+ };
40
+ class ThinkingModeManager {
41
+ config;
42
+ configPath;
43
+ constructor(configPath = SETTINGS_FILE) {
44
+ this.configPath = configPath;
45
+ this.config = this.loadConfig();
46
+ }
47
+ /**
48
+ * Load thinking mode configuration from settings.json
49
+ */
50
+ loadConfig() {
51
+ const settings = readJsonConfig(this.configPath);
52
+ const thinkingConfig = settings?.thinking || {};
53
+ return {
54
+ enabled: thinkingConfig.enabled ?? DEFAULT_THINKING_CONFIG.enabled,
55
+ budgetTokens: thinkingConfig.budgetTokens ?? DEFAULT_THINKING_CONFIG.budgetTokens,
56
+ inheritForSubAgents: thinkingConfig.inheritForSubAgents ?? DEFAULT_THINKING_CONFIG.inheritForSubAgents,
57
+ subAgentReduction: thinkingConfig.subAgentReduction ?? DEFAULT_THINKING_CONFIG.subAgentReduction,
58
+ alwaysUseThinking: thinkingConfig.alwaysUseThinking ?? DEFAULT_THINKING_CONFIG.alwaysUseThinking
59
+ };
60
+ }
61
+ /**
62
+ * Save thinking mode configuration to settings.json
63
+ */
64
+ saveConfig() {
65
+ const settings = readJsonConfig(this.configPath) || {};
66
+ settings.thinking = this.config;
67
+ writeJsonConfig(this.configPath, settings);
68
+ }
69
+ /**
70
+ * Get current thinking mode configuration
71
+ */
72
+ getConfig() {
73
+ return { ...this.config };
74
+ }
75
+ /**
76
+ * Check if thinking mode is enabled
77
+ */
78
+ isEnabled() {
79
+ return this.config.enabled;
80
+ }
81
+ /**
82
+ * Enable or disable thinking mode
83
+ */
84
+ setEnabled(enabled) {
85
+ this.config.enabled = enabled;
86
+ this.saveConfig();
87
+ }
88
+ /**
89
+ * Get budget tokens
90
+ */
91
+ getBudgetTokens() {
92
+ return this.config.budgetTokens;
93
+ }
94
+ /**
95
+ * Set budget tokens with validation
96
+ */
97
+ setBudgetTokens(tokens) {
98
+ if (tokens < MIN_BUDGET_TOKENS) {
99
+ return {
100
+ success: false,
101
+ error: `Budget tokens must be at least ${MIN_BUDGET_TOKENS}`
102
+ };
103
+ }
104
+ if (tokens > MAX_BUDGET_TOKENS) {
105
+ return {
106
+ success: false,
107
+ error: `Budget tokens cannot exceed ${MAX_BUDGET_TOKENS}`
108
+ };
109
+ }
110
+ this.config.budgetTokens = tokens;
111
+ this.saveConfig();
112
+ return { success: true };
113
+ }
114
+ /**
115
+ * Check if sub-agents should inherit thinking mode
116
+ */
117
+ isInheritForSubAgents() {
118
+ return this.config.inheritForSubAgents;
119
+ }
120
+ /**
121
+ * Enable or disable sub-agent inheritance
122
+ */
123
+ setInheritForSubAgents(inherit) {
124
+ this.config.inheritForSubAgents = inherit;
125
+ this.saveConfig();
126
+ }
127
+ /**
128
+ * Get sub-agent budget reduction factor
129
+ */
130
+ getSubAgentReduction() {
131
+ return this.config.subAgentReduction;
132
+ }
133
+ /**
134
+ * Set sub-agent budget reduction factor (0.1 - 1.0)
135
+ */
136
+ setSubAgentReduction(reduction) {
137
+ if (reduction < 0.1 || reduction > 1) {
138
+ return {
139
+ success: false,
140
+ error: "Reduction factor must be between 0.1 and 1.0"
141
+ };
142
+ }
143
+ this.config.subAgentReduction = reduction;
144
+ this.saveConfig();
145
+ return { success: true };
146
+ }
147
+ /**
148
+ * Calculate budget for sub-agent based on reduction factor
149
+ */
150
+ calculateSubAgentBudget() {
151
+ return Math.floor(this.config.budgetTokens * this.config.subAgentReduction);
152
+ }
153
+ /**
154
+ * Check if always using thinking mode (even for simple tasks)
155
+ */
156
+ isAlwaysUseThinking() {
157
+ return this.config.alwaysUseThinking;
158
+ }
159
+ /**
160
+ * Set always use thinking mode
161
+ */
162
+ setAlwaysUseThinking(always) {
163
+ this.config.alwaysUseThinking = always;
164
+ this.saveConfig();
165
+ }
166
+ /**
167
+ * Check if thinking mode is supported for the given model
168
+ */
169
+ isModelSupported(model) {
170
+ return THINKING_SUPPORTED_MODELS.some((m) => model.includes(m));
171
+ }
172
+ /**
173
+ * Generate thinking mode flags for Claude Code CLI
174
+ */
175
+ generateCliFlags() {
176
+ if (!this.config.enabled) {
177
+ return [];
178
+ }
179
+ const flags = [];
180
+ flags.push(`--thinking-budget-tokens=${this.config.budgetTokens}`);
181
+ flags.push("--thinking=true");
182
+ return flags;
183
+ }
184
+ /**
185
+ * Get thinking mode status for display
186
+ */
187
+ getStatus(enabledOnly = false) {
188
+ const isZh = i18n.language === "zh-CN";
189
+ return {
190
+ enabled: this.config.enabled,
191
+ budgetTokens: this.config.budgetTokens,
192
+ inheritForSubAgents: this.config.inheritForSubAgents,
193
+ subAgentBudget: this.calculateSubAgentBudget(),
194
+ alwaysUseThinking: this.config.alwaysUseThinking,
195
+ supportedModels: THINKING_SUPPORTED_MODELS,
196
+ summary: this.config.enabled ? isZh ? `Thinking Mode \u5DF2\u542F\u7528 (${this.config.budgetTokens} tokens)` : `Thinking Mode enabled (${this.config.budgetTokens} tokens)` : isZh ? "Thinking Mode \u5DF2\u7981\u7528" : "Thinking Mode disabled"
197
+ };
198
+ }
199
+ /**
200
+ * Reset to default configuration
201
+ */
202
+ resetToDefaults() {
203
+ this.config = { ...DEFAULT_THINKING_CONFIG };
204
+ this.saveConfig();
205
+ }
206
+ /**
207
+ * Merge configuration with existing settings
208
+ */
209
+ mergeConfig(partial) {
210
+ this.config = {
211
+ ...this.config,
212
+ ...partial
213
+ };
214
+ this.saveConfig();
215
+ }
216
+ }
217
+ let globalThinkingManager = null;
218
+ function getThinkingManager(configPath) {
219
+ if (!globalThinkingManager) {
220
+ globalThinkingManager = new ThinkingModeManager(configPath);
221
+ }
222
+ return globalThinkingManager;
223
+ }
224
+ function shouldUseThinkingMode(taskComplexity, model) {
225
+ const manager = getThinkingManager();
226
+ if (!manager.isEnabled()) {
227
+ return false;
228
+ }
229
+ if (manager.isAlwaysUseThinking()) {
230
+ return true;
231
+ }
232
+ return taskComplexity === "medium" || taskComplexity === "complex";
233
+ }
234
+
235
+ async function thinkingStatus(options = {}) {
236
+ const isZh = i18n.language === "zh-CN";
237
+ console.log("");
238
+ console.log(ansis.bold.cyan(isZh ? "\u{1F9E0} Thinking Mode Status" : "\u{1F9E0} Thinking Mode Status"));
239
+ console.log(ansis.dim("\u2500".repeat(60)));
240
+ const manager = getThinkingManager();
241
+ const status = manager.getStatus();
242
+ console.log("");
243
+ const statusIcon = status.enabled ? ansis.green("\u25CF") : ansis.gray("\u25CB");
244
+ const statusText = status.enabled ? isZh ? "Enabled" : "Enabled" : isZh ? "Disabled" : "Disabled";
245
+ console.log(` ${statusIcon} ${ansis.bold(isZh ? "Status:" : "Status:")} ${statusText}`);
246
+ console.log("");
247
+ console.log(` ${ansis.green("\u{1F4B0}")} ${ansis.bold(isZh ? "Budget Tokens:" : "Budget Tokens:")} ${ansis.yellow(status.budgetTokens.toLocaleString())}`);
248
+ const inheritIcon = status.inheritForSubAgents ? ansis.green("\u2713") : ansis.gray("\u25CB");
249
+ console.log(` ${inheritIcon} ${ansis.bold(isZh ? "Sub-agent Inheritance:" : "Sub-agent Inheritance:")} ${status.inheritForSubAgents ? isZh ? "Enabled" : "Enabled" : isZh ? "Disabled" : "Disabled"}`);
250
+ if (status.inheritForSubAgents) {
251
+ console.log(` ${ansis.dim(isZh ? `\u2192 Sub-agents get ${status.subAgentBudget.toLocaleString()} tokens` : `\u2192 Sub-agents get ${status.subAgentBudget.toLocaleString()} tokens`)}`);
252
+ }
253
+ const alwaysIcon = status.alwaysUseThinking ? ansis.green("\u2713") : ansis.gray("\u25CB");
254
+ console.log(` ${alwaysIcon} ${ansis.bold(isZh ? "Always Use Thinking:" : "Always Use Thinking:")} ${status.alwaysUseThinking ? isZh ? "Yes" : "Yes" : isZh ? "No (medium/complex only)" : "No (medium/complex only)"}`);
255
+ console.log("");
256
+ console.log(ansis.green(isZh ? "\u{1F4CB} Supported Models:" : "\u{1F4CB} Supported Models:"));
257
+ for (const model of status.supportedModels) {
258
+ console.log(` ${ansis.dim("\u2022")} ${model}`);
259
+ }
260
+ console.log("");
261
+ console.log(ansis.dim(isZh ? '\u{1F4A1} Tip: Use "ccjk thinking enable/disable" to toggle thinking mode' : '\u{1F4A1} Tip: Use "ccjk thinking enable/disable" to toggle thinking mode'));
262
+ console.log("");
263
+ }
264
+ async function thinkingEnable(options = {}) {
265
+ const isZh = i18n.language === "zh-CN";
266
+ const manager = getThinkingManager();
267
+ if (manager.isEnabled()) {
268
+ console.log("");
269
+ console.log(ansis.yellow(isZh ? "\u26A0\uFE0F Thinking Mode is already enabled" : "\u26A0\uFE0F Thinking Mode is already enabled"));
270
+ console.log("");
271
+ return;
272
+ }
273
+ manager.setEnabled(true);
274
+ console.log("");
275
+ console.log(ansis.green(isZh ? "\u2705 Thinking Mode enabled" : "\u2705 Thinking Mode enabled"));
276
+ console.log(ansis.dim(isZh ? `Budget: ${manager.getBudgetTokens().toLocaleString()} tokens` : `Budget: ${manager.getBudgetTokens().toLocaleString()} tokens`));
277
+ console.log("");
278
+ }
279
+ async function thinkingDisable(options = {}) {
280
+ const isZh = i18n.language === "zh-CN";
281
+ const manager = getThinkingManager();
282
+ if (!manager.isEnabled()) {
283
+ console.log("");
284
+ console.log(ansis.yellow(isZh ? "\u26A0\uFE0F Thinking Mode is already disabled" : "\u26A0\uFE0F Thinking Mode is already disabled"));
285
+ console.log("");
286
+ return;
287
+ }
288
+ manager.setEnabled(false);
289
+ console.log("");
290
+ console.log(ansis.green(isZh ? "\u2705 Thinking Mode disabled" : "\u2705 Thinking Mode disabled"));
291
+ console.log("");
292
+ }
293
+ async function thinkingToggle(options = {}) {
294
+ const isZh = i18n.language === "zh-CN";
295
+ const manager = getThinkingManager();
296
+ const newState = !manager.isEnabled();
297
+ manager.setEnabled(newState);
298
+ console.log("");
299
+ console.log(ansis.green(newState ? isZh ? "\u2705 Thinking Mode enabled" : "\u2705 Thinking Mode enabled" : isZh ? "\u2705 Thinking Mode disabled" : "\u2705 Thinking Mode disabled"));
300
+ console.log("");
301
+ }
302
+ async function thinkingBudget(tokens, options = {}) {
303
+ const isZh = i18n.language === "zh-CN";
304
+ const tokenValue = Number.parseInt(tokens, 10);
305
+ if (Number.isNaN(tokenValue)) {
306
+ console.log("");
307
+ console.log(ansis.red(isZh ? "\u274C Invalid token value" : "\u274C Invalid token value"));
308
+ console.log(ansis.dim(isZh ? `Budget must be a number between ${MIN_BUDGET_TOKENS} and ${MAX_BUDGET_TOKENS}` : `Budget must be a number between ${MIN_BUDGET_TOKENS} and ${MAX_BUDGET_TOKENS}`));
309
+ console.log("");
310
+ return;
311
+ }
312
+ const manager = getThinkingManager();
313
+ const result = manager.setBudgetTokens(tokenValue);
314
+ if (!result.success) {
315
+ console.log("");
316
+ console.log(ansis.red(isZh ? "\u274C Failed to set budget" : "\u274C Failed to set budget"));
317
+ console.log(ansis.dim(result.error));
318
+ console.log("");
319
+ return;
320
+ }
321
+ console.log("");
322
+ console.log(ansis.green(isZh ? "\u2705 Budget tokens updated" : "\u2705 Budget tokens updated"));
323
+ console.log(ansis.dim(isZh ? `New budget: ${tokenValue.toLocaleString()} tokens` : `New budget: ${tokenValue.toLocaleString()} tokens`));
324
+ if (manager.isInheritForSubAgents()) {
325
+ console.log(ansis.dim(isZh ? `Sub-agent budget: ${manager.calculateSubAgentBudget().toLocaleString()} tokens` : `Sub-agent budget: ${manager.calculateSubAgentBudget().toLocaleString()} tokens`));
326
+ }
327
+ console.log("");
328
+ }
329
+ async function thinkingInheritance(enabled, options = {}) {
330
+ const isZh = i18n.language === "zh-CN";
331
+ const manager = getThinkingManager();
332
+ manager.setInheritForSubAgents(enabled);
333
+ console.log("");
334
+ console.log(ansis.green(enabled ? isZh ? "\u2705 Sub-agent inheritance enabled" : "\u2705 Sub-agent inheritance enabled" : isZh ? "\u2705 Sub-agent inheritance disabled" : "\u2705 Sub-agent inheritance disabled"));
335
+ if (enabled) {
336
+ console.log(ansis.dim(isZh ? `Sub-agents will receive ${manager.calculateSubAgentBudget().toLocaleString()} tokens` : `Sub-agents will receive ${manager.calculateSubAgentBudget().toLocaleString()} tokens`));
337
+ }
338
+ console.log("");
339
+ }
340
+ async function thinkingReset(options = {}) {
341
+ const isZh = i18n.language === "zh-CN";
342
+ const { confirm } = await inquirer.prompt({
343
+ type: "confirm",
344
+ name: "confirm",
345
+ message: isZh ? "Reset thinking mode to default settings?" : "Reset thinking mode to default settings?",
346
+ default: false
347
+ });
348
+ if (!confirm) {
349
+ console.log("");
350
+ console.log(ansis.yellow(isZh ? "Cancelled" : "Cancelled"));
351
+ console.log("");
352
+ return;
353
+ }
354
+ const manager = getThinkingManager();
355
+ manager.resetToDefaults();
356
+ console.log("");
357
+ console.log(ansis.green(isZh ? "\u2705 Thinking mode reset to defaults" : "\u2705 Thinking mode reset to defaults"));
358
+ console.log(ansis.dim(isZh ? `Enabled: ${manager.isEnabled()}` : `Enabled: ${manager.isEnabled()}`));
359
+ console.log(ansis.dim(isZh ? `Budget: ${manager.getBudgetTokens().toLocaleString()} tokens` : `Budget: ${manager.getBudgetTokens().toLocaleString()} tokens`));
360
+ console.log("");
361
+ }
362
+ async function thinkingConfig(options = {}) {
363
+ const isZh = i18n.language === "zh-CN";
364
+ const manager = getThinkingManager();
365
+ const currentConfig = manager.getConfig();
366
+ console.log("");
367
+ console.log(ansis.bold.cyan(isZh ? "\u{1F9E0} Thinking Mode Configuration" : "\u{1F9E0} Thinking Mode Configuration"));
368
+ console.log(ansis.dim("\u2500".repeat(60)));
369
+ console.log("");
370
+ const { action } = await inquirer.prompt({
371
+ type: "list",
372
+ name: "action",
373
+ message: isZh ? "Select configuration option:" : "Select configuration option:",
374
+ choices: [
375
+ {
376
+ name: `${currentConfig.enabled ? ansis.red("[Disable]") : ansis.green("[Enable]")} ${isZh ? "Toggle thinking mode" : "Toggle thinking mode"}`,
377
+ value: "toggle",
378
+ short: isZh ? "Toggle" : "Toggle"
379
+ },
380
+ {
381
+ name: `${isZh ? "Set budget tokens" : "Set budget tokens"} (${currentConfig.budgetTokens.toLocaleString()})`,
382
+ value: "budget",
383
+ short: isZh ? "Budget" : "Budget"
384
+ },
385
+ {
386
+ name: `${currentConfig.inheritForSubAgents ? ansis.red("[Disable]") : ansis.green("[Enable]")} ${isZh ? "Sub-agent inheritance" : "Sub-agent inheritance"}`,
387
+ value: "inheritance",
388
+ short: isZh ? "Inheritance" : "Inheritance"
389
+ },
390
+ {
391
+ name: `${isZh ? "Sub-agent reduction factor" : "Sub-agent reduction factor"} (${(currentConfig.subAgentReduction * 100).toFixed(0)}%)`,
392
+ value: "reduction",
393
+ short: isZh ? "Reduction" : "Reduction"
394
+ },
395
+ {
396
+ name: `${currentConfig.alwaysUseThinking ? ansis.red("[Disable]") : ansis.green("[Enable]")} ${isZh ? "Always use thinking" : "Always use thinking"}`,
397
+ value: "always",
398
+ short: isZh ? "Always" : "Always"
399
+ },
400
+ {
401
+ name: isZh ? "Reset to defaults" : "Reset to defaults",
402
+ value: "reset",
403
+ short: isZh ? "Reset" : "Reset"
404
+ },
405
+ new inquirer.Separator(),
406
+ {
407
+ name: isZh ? "Done" : "Done",
408
+ value: "done",
409
+ short: isZh ? "Done" : "Done"
410
+ }
411
+ ]
412
+ });
413
+ if (action === "done") {
414
+ await thinkingStatus(options);
415
+ return;
416
+ }
417
+ if (action === "toggle") {
418
+ await thinkingToggle(options);
419
+ } else if (action === "budget") {
420
+ const { tokens } = await inquirer.prompt({
421
+ type: "input",
422
+ name: "tokens",
423
+ message: isZh ? `Enter budget tokens (${MIN_BUDGET_TOKENS} - ${MAX_BUDGET_TOKENS}):` : `Enter budget tokens (${MIN_BUDGET_TOKENS} - ${MAX_BUDGET_TOKENS}):`,
424
+ default: currentConfig.budgetTokens.toString(),
425
+ validate: (value) => {
426
+ const num = Number.parseInt(value, 10);
427
+ if (Number.isNaN(num)) {
428
+ return isZh ? "Please enter a valid number" : "Please enter a valid number";
429
+ }
430
+ if (num < MIN_BUDGET_TOKENS || num > MAX_BUDGET_TOKENS) {
431
+ return isZh ? `Must be between ${MIN_BUDGET_TOKENS} and ${MAX_BUDGET_TOKENS}` : `Must be between ${MIN_BUDGET_TOKENS} and ${MAX_BUDGET_TOKENS}`;
432
+ }
433
+ return true;
434
+ }
435
+ });
436
+ await thinkingBudget(tokens, options);
437
+ } else if (action === "inheritance") {
438
+ const { enabled } = await inquirer.prompt({
439
+ type: "confirm",
440
+ name: "enabled",
441
+ message: isZh ? "Enable sub-agent inheritance?" : "Enable sub-agent inheritance?",
442
+ default: currentConfig.inheritForSubAgents
443
+ });
444
+ await thinkingInheritance(enabled, options);
445
+ } else if (action === "reduction") {
446
+ const { reduction } = await inquirer.prompt({
447
+ type: "input",
448
+ name: "reduction",
449
+ message: isZh ? "Enter reduction factor (0.1 - 1.0):" : "Enter reduction factor (0.1 - 1.0):",
450
+ default: currentConfig.subAgentReduction.toString(),
451
+ validate: (value) => {
452
+ const num = Number.parseFloat(value);
453
+ if (Number.isNaN(num)) {
454
+ return isZh ? "Please enter a valid number" : "Please enter a valid number";
455
+ }
456
+ if (num < 0.1 || num > 1) {
457
+ return isZh ? "Must be between 0.1 and 1.0" : "Must be between 0.1 and 1.0";
458
+ }
459
+ return true;
460
+ }
461
+ });
462
+ const manager2 = getThinkingManager();
463
+ const result = manager2.setSubAgentReduction(Number.parseFloat(reduction));
464
+ if (!result.success) {
465
+ console.log("");
466
+ console.log(ansis.red(result.error));
467
+ console.log("");
468
+ return;
469
+ }
470
+ console.log("");
471
+ console.log(ansis.green(isZh ? "\u2705 Reduction factor updated" : "\u2705 Reduction factor updated"));
472
+ console.log(ansis.dim(isZh ? `New reduction: ${(Number.parseFloat(reduction) * 100).toFixed(0)}%` : `New reduction: ${(Number.parseFloat(reduction) * 100).toFixed(0)}%`));
473
+ console.log(ansis.dim(isZh ? `Sub-agent budget: ${manager2.calculateSubAgentBudget().toLocaleString()} tokens` : `Sub-agent budget: ${manager2.calculateSubAgentBudget().toLocaleString()} tokens`));
474
+ console.log("");
475
+ } else if (action === "always") {
476
+ const { always } = await inquirer.prompt({
477
+ type: "confirm",
478
+ name: "always",
479
+ message: isZh ? "Always use thinking mode (even for simple tasks)?" : "Always use thinking mode (even for simple tasks)?",
480
+ default: currentConfig.alwaysUseThinking
481
+ });
482
+ const manager2 = getThinkingManager();
483
+ manager2.setAlwaysUseThinking(always);
484
+ console.log("");
485
+ console.log(ansis.green(always ? isZh ? "\u2705 Always use thinking enabled" : "\u2705 Always use thinking enabled" : isZh ? "\u2705 Always use thinking disabled" : "\u2705 Always use thinking disabled"));
486
+ console.log("");
487
+ } else if (action === "reset") {
488
+ await thinkingReset(options);
489
+ }
490
+ await thinkingConfig(options);
491
+ }
492
+ function thinkingCheck(complexity, model) {
493
+ const isZh = i18n.language === "zh-CN";
494
+ const useThinking = shouldUseThinkingMode(complexity);
495
+ const complexityText = {
496
+ simple: isZh ? "\u7B80\u5355" : "simple",
497
+ medium: isZh ? "\u4E2D\u7B49" : "medium",
498
+ complex: isZh ? "\u590D\u6742" : "complex"
499
+ }[complexity];
500
+ console.log("");
501
+ console.log(ansis.bold(isZh ? "\u{1F9E0} Thinking Mode Check" : "\u{1F9E0} Thinking Mode Check"));
502
+ console.log(ansis.dim("\u2500".repeat(60)));
503
+ console.log("");
504
+ console.log(` ${isZh ? "\u4EFB\u52A1\u590D\u6742\u5EA6" : "Task Complexity"}: ${complexityText}`);
505
+ console.log(` ${isZh ? "\u4F7F\u7528 Thinking Mode" : "Use Thinking Mode"}: ${useThinking ? ansis.green("Yes") : ansis.yellow("No")}`);
506
+ console.log("");
507
+ }
508
+ function thinkingHelp(options = {}) {
509
+ const isZh = i18n.language === "zh-CN";
510
+ console.log("");
511
+ console.log(ansis.bold.cyan(isZh ? "\u{1F9E0} Thinking Mode Commands" : "\u{1F9E0} Thinking Mode Commands"));
512
+ console.log(ansis.dim("\u2500".repeat(60)));
513
+ console.log("");
514
+ const commands = [
515
+ {
516
+ cmd: "ccjk thinking",
517
+ desc: isZh ? "Display thinking mode status" : "Display thinking mode status"
518
+ },
519
+ {
520
+ cmd: "ccjk thinking enable",
521
+ desc: isZh ? "Enable thinking mode" : "Enable thinking mode"
522
+ },
523
+ {
524
+ cmd: "ccjk thinking disable",
525
+ desc: isZh ? "Disable thinking mode" : "Disable thinking mode"
526
+ },
527
+ {
528
+ cmd: "ccjk thinking toggle",
529
+ desc: isZh ? "Toggle thinking mode on/off" : "Toggle thinking mode on/off"
530
+ },
531
+ {
532
+ cmd: "ccjk thinking budget <tokens>",
533
+ desc: isZh ? "Set budget tokens (1000-200000)" : "Set budget tokens (1000-200000)"
534
+ },
535
+ {
536
+ cmd: "ccjk thinking config",
537
+ desc: isZh ? "Interactive configuration menu" : "Interactive configuration menu"
538
+ },
539
+ {
540
+ cmd: "ccjk thinking check <complexity>",
541
+ desc: isZh ? "Check if thinking will be used" : "Check if thinking will be used"
542
+ },
543
+ {
544
+ cmd: "ccjk thinking reset",
545
+ desc: isZh ? "Reset to default settings" : "Reset to default settings"
546
+ }
547
+ ];
548
+ for (const { cmd, desc } of commands) {
549
+ console.log(` ${ansis.green(cmd)}`);
550
+ console.log(` ${ansis.dim(desc)}`);
551
+ console.log("");
552
+ }
553
+ console.log(ansis.dim(isZh ? "\u{1F4A1} Thinking Mode is enabled by default for Opus 4.5" : "\u{1F4A1} Thinking Mode is enabled by default for Opus 4.5"));
554
+ console.log(ansis.dim(isZh ? " It provides extended reasoning for complex tasks." : " It provides extended reasoning for complex tasks."));
555
+ console.log("");
556
+ }
557
+ async function thinking(action, args = [], options = {}) {
558
+ try {
559
+ switch (action) {
560
+ case "enable":
561
+ await thinkingEnable(options);
562
+ break;
563
+ case "disable":
564
+ await thinkingDisable(options);
565
+ break;
566
+ case "toggle":
567
+ await thinkingToggle(options);
568
+ break;
569
+ case "budget":
570
+ if (args.length === 0) {
571
+ const isZh = i18n.language === "zh-CN";
572
+ console.log("");
573
+ console.log(ansis.yellow(isZh ? "\u26A0\uFE0F Please specify token amount" : "\u26A0\uFE0F Please specify token amount"));
574
+ console.log(ansis.dim(isZh ? "Usage: ccjk thinking budget <tokens>" : "Usage: ccjk thinking budget <tokens>"));
575
+ console.log("");
576
+ return;
577
+ }
578
+ await thinkingBudget(args[0], options);
579
+ break;
580
+ case "inherit":
581
+ await thinkingInheritance(true, options);
582
+ break;
583
+ case "no-inherit":
584
+ await thinkingInheritance(false, options);
585
+ break;
586
+ case "config":
587
+ await thinkingConfig(options);
588
+ break;
589
+ case "check":
590
+ if (args.length === 0) {
591
+ thinkingCheck("complex");
592
+ } else {
593
+ const complexity = ["simple", "medium", "complex"].includes(args[0]) ? args[0] : "complex";
594
+ thinkingCheck(complexity);
595
+ }
596
+ break;
597
+ case "reset":
598
+ await thinkingReset(options);
599
+ break;
600
+ case "help":
601
+ thinkingHelp(options);
602
+ break;
603
+ case "status":
604
+ default:
605
+ await thinkingStatus(options);
606
+ break;
607
+ }
608
+ } catch (error) {
609
+ if (!handleExitPromptError(error)) {
610
+ handleGeneralError(error);
611
+ }
612
+ }
613
+ }
614
+
615
+ export { thinking, thinkingBudget, thinkingCheck, thinkingConfig, thinkingDisable, thinkingEnable, thinkingHelp, thinkingInheritance, thinkingReset, thinkingStatus, thinkingToggle };