ccjk 9.14.0 → 9.15.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 (39) hide show
  1. package/dist/chunks/ccjk-all.mjs +6 -6
  2. package/dist/chunks/ccr.mjs +14 -13
  3. package/dist/chunks/check-updates.mjs +1 -1
  4. package/dist/chunks/claude-code-incremental-manager.mjs +1 -1
  5. package/dist/chunks/claude-config.mjs +1 -1
  6. package/dist/chunks/cli-hook.mjs +20 -1
  7. package/dist/chunks/codex-config-switch.mjs +3 -3
  8. package/dist/chunks/codex-provider-manager.mjs +1 -1
  9. package/dist/chunks/codex.mjs +129 -2
  10. package/dist/chunks/config-switch.mjs +1 -1
  11. package/dist/chunks/config.mjs +17 -1
  12. package/dist/chunks/config3.mjs +1 -1
  13. package/dist/chunks/context-loader.mjs +342 -0
  14. package/dist/chunks/context.mjs +59 -758
  15. package/dist/chunks/features.mjs +3 -3
  16. package/dist/chunks/index2.mjs +19 -19
  17. package/dist/chunks/init.mjs +4 -4
  18. package/dist/chunks/installer2.mjs +6 -6
  19. package/dist/chunks/mcp.mjs +10 -339
  20. package/dist/chunks/menu.mjs +17 -0
  21. package/dist/chunks/notification.mjs +27 -27
  22. package/dist/chunks/package.mjs +1 -1
  23. package/dist/chunks/paradigm.mjs +73 -0
  24. package/dist/chunks/platform.mjs +24 -24
  25. package/dist/chunks/quick-provider.mjs +5 -0
  26. package/dist/chunks/quick-setup.mjs +1 -1
  27. package/dist/chunks/sessions.mjs +338 -0
  28. package/dist/chunks/trace.mjs +56 -0
  29. package/dist/chunks/uninstall.mjs +1 -1
  30. package/dist/chunks/update.mjs +44 -10
  31. package/dist/chunks/version-checker.mjs +31 -31
  32. package/dist/cli.mjs +84 -0
  33. package/dist/i18n/locales/en/mcp.json +2 -0
  34. package/dist/i18n/locales/zh-CN/mcp.json +2 -0
  35. package/dist/shared/ccjk.BN90X6oc.mjs +223 -0
  36. package/dist/shared/ccjk.C10pepYx.mjs +243 -0
  37. package/dist/shared/ccjk.ClzTOz9n.mjs +352 -0
  38. package/dist/shared/{ccjk.LsPZ2PYo.mjs → ccjk.CmsW23FN.mjs} +12 -10
  39. package/package.json +3 -1
@@ -1,6 +1,6 @@
1
1
  import ansis from 'ansis';
2
2
  import consola from 'consola';
3
- import fs__default, { readFileSync, promises } from 'node:fs';
3
+ import nodeFs__default, { readFileSync, promises } from 'node:fs';
4
4
  import path__default, { dirname, join } from 'node:path';
5
5
  import { hash } from 'ohash';
6
6
  import { fileURLToPath } from 'node:url';
@@ -53,8 +53,8 @@ class CloudCache {
53
53
  */
54
54
  ensureCacheDir() {
55
55
  try {
56
- if (!fs__default.existsSync(this.cacheDir)) {
57
- fs__default.mkdirSync(this.cacheDir, { recursive: true });
56
+ if (!nodeFs__default.existsSync(this.cacheDir)) {
57
+ nodeFs__default.mkdirSync(this.cacheDir, { recursive: true });
58
58
  consola.debug("Created cache directory:", this.cacheDir);
59
59
  }
60
60
  } catch (error) {
@@ -68,8 +68,8 @@ class CloudCache {
68
68
  loadCacheFromDisk() {
69
69
  try {
70
70
  const cacheFile = path__default.join(this.cacheDir, "cache.json");
71
- if (fs__default.existsSync(cacheFile)) {
72
- const data = fs__default.readFileSync(cacheFile, "utf-8");
71
+ if (nodeFs__default.existsSync(cacheFile)) {
72
+ const data = nodeFs__default.readFileSync(cacheFile, "utf-8");
73
73
  const entries = JSON.parse(data);
74
74
  const now = Date.now();
75
75
  for (const [key, entry] of Object.entries(entries)) {
@@ -90,7 +90,7 @@ class CloudCache {
90
90
  try {
91
91
  const cacheFile = path__default.join(this.cacheDir, "cache.json");
92
92
  const entries = Object.fromEntries(this.memoryCache);
93
- fs__default.writeFileSync(cacheFile, JSON.stringify(entries, null, 2));
93
+ nodeFs__default.writeFileSync(cacheFile, JSON.stringify(entries, null, 2));
94
94
  } catch (error) {
95
95
  consola.warn("Failed to save cache to disk:", error);
96
96
  }
@@ -11,35 +11,35 @@ import 'i18next';
11
11
  import 'i18next-fs-backend';
12
12
  import 'pathe';
13
13
  import 'inquirer';
14
+ import './codex.mjs';
15
+ import 'dayjs';
16
+ import 'ora';
17
+ import 'semver';
18
+ import 'smol-toml';
19
+ import 'tinyexec';
14
20
  import './constants.mjs';
15
21
  import 'node:os';
16
22
  import './ccjk-config.mjs';
17
- import 'smol-toml';
18
23
  import './fs-operations.mjs';
19
24
  import 'node:crypto';
20
25
  import 'node:fs/promises';
21
26
  import './json-config.mjs';
22
- import 'dayjs';
23
- import '../shared/ccjk.Dpw86UX0.mjs';
24
- import './smart-defaults.mjs';
25
- import 'node:child_process';
26
- import './platform.mjs';
27
- import 'tinyexec';
28
- import '../shared/ccjk.DKojSRzw.mjs';
29
- import './features.mjs';
30
- import './codex.mjs';
31
- import 'ora';
32
- import 'semver';
33
27
  import './config.mjs';
34
28
  import './claude-config.mjs';
29
+ import './platform.mjs';
35
30
  import '../shared/ccjk.BFQ7yr5S.mjs';
36
31
  import './prompts.mjs';
37
32
  import '../shared/ccjk.DHbrGcgg.mjs';
38
33
  import 'inquirer-toggle';
34
+ import 'node:child_process';
35
+ import '../shared/ccjk.Dpw86UX0.mjs';
36
+ import './smart-defaults.mjs';
37
+ import '../shared/ccjk.DKojSRzw.mjs';
38
+ import './features.mjs';
39
39
  import './config3.mjs';
40
40
  import 'node:util';
41
41
  import './init.mjs';
42
- import '../shared/ccjk.LsPZ2PYo.mjs';
42
+ import '../shared/ccjk.CmsW23FN.mjs';
43
43
  import './auto-updater.mjs';
44
44
  import './version-checker.mjs';
45
45
  import 'node:path';
@@ -65,6 +65,7 @@ import './uninstall.mjs';
65
65
  import '../shared/ccjk.DntgA8fQ.mjs';
66
66
  import 'trash';
67
67
  import './update.mjs';
68
+ import '../shared/ccjk.ClzTOz9n.mjs';
68
69
 
69
70
  async function ccr(options = {}) {
70
71
  try {
@@ -3,7 +3,7 @@ import ansis from 'ansis';
3
3
  import { ensureI18nInitialized, i18n } from './index.mjs';
4
4
  import { r as resolveCodeType } from '../shared/ccjk.Dpw86UX0.mjs';
5
5
  import { checkAndUpdateTools } from './auto-updater.mjs';
6
- import { d as runCodexUpdate } from './codex.mjs';
6
+ import { a as runCodexUpdate } from './codex.mjs';
7
7
  import 'node:fs';
8
8
  import 'node:url';
9
9
  import 'i18next';
@@ -4,7 +4,7 @@ import { ensureI18nInitialized, i18n } from './index.mjs';
4
4
  import { ClaudeCodeConfigManager } from './claude-code-config-manager.mjs';
5
5
  import { a as addNumbersToChoices } from '../shared/ccjk.BFQ7yr5S.mjs';
6
6
  import { p as promptBoolean } from '../shared/ccjk.DHbrGcgg.mjs';
7
- import { v as validateApiKey } from '../shared/ccjk.LsPZ2PYo.mjs';
7
+ import { v as validateApiKey } from '../shared/ccjk.CmsW23FN.mjs';
8
8
  import 'node:fs';
9
9
  import 'node:process';
10
10
  import 'node:url';
@@ -233,4 +233,4 @@ const claudeConfig = {
233
233
  writeMcpConfig: writeMcpConfig
234
234
  };
235
235
 
236
- export { buildMcpServerConfig as a, backupMcpConfig as b, addCompletedOnboarding as c, deepMerge as d, replaceMcpServers as e, fixWindowsMcpConfig as f, syncMcpPermissions as g, claudeConfig as h, mergeMcpServers as m, readMcpConfig as r, setPrimaryApiKey as s, writeMcpConfig as w };
236
+ export { addCompletedOnboarding as a, backupMcpConfig as b, buildMcpServerConfig as c, replaceMcpServers as d, syncMcpPermissions as e, fixWindowsMcpConfig as f, deepMerge as g, claudeConfig as h, mergeMcpServers as m, readMcpConfig as r, setPrimaryApiKey as s, writeMcpConfig as w };
@@ -3015,12 +3015,14 @@ class BrainCliHook extends EventEmitter {
3015
3015
  }
3016
3016
  if (result.passthrough) {
3017
3017
  this.emit("hook:passthrough", { input: userInput, reason: result.message });
3018
+ const additionalContext = this.config.silent ? void 0 : await this.buildAdditionalContext();
3018
3019
  return {
3019
3020
  intercepted: true,
3020
3021
  handled: false,
3021
3022
  shouldContinue: true,
3022
3023
  // Pass to Claude Code
3023
- message: result.message
3024
+ message: result.message,
3025
+ additionalContext
3024
3026
  };
3025
3027
  }
3026
3028
  return {
@@ -3093,6 +3095,23 @@ ${"=".repeat(60)}`);
3093
3095
  console.log("=".repeat(60));
3094
3096
  console.log();
3095
3097
  }
3098
+ /**
3099
+ * Build additional context string for PreToolUse hook injection.
3100
+ * Provides brain insights (task state, session context) to the model
3101
+ * without blocking tool execution. Claude Code 2.1+ feature.
3102
+ */
3103
+ async buildAdditionalContext() {
3104
+ try {
3105
+ const { loadContextAtDepth } = await import('./context-loader.mjs');
3106
+ const ctx = await loadContextAtDepth("L0");
3107
+ if (ctx.totalTokens > 0) {
3108
+ return `[Brain Context: ${ctx.layers.size} layers, ~${ctx.totalTokens} tokens, depth=${ctx.depth}]`;
3109
+ }
3110
+ return void 0;
3111
+ } catch {
3112
+ return void 0;
3113
+ }
3114
+ }
3096
3115
  /**
3097
3116
  * Enable the hook
3098
3117
  */
@@ -5,7 +5,7 @@ import { ensureI18nInitialized, i18n } from './index.mjs';
5
5
  import { readJsonConfig } from './json-config.mjs';
6
6
  import { a as addNumbersToChoices } from '../shared/ccjk.BFQ7yr5S.mjs';
7
7
  import { p as promptBoolean } from '../shared/ccjk.DHbrGcgg.mjs';
8
- import { k as detectConfigManagementMode } from './codex.mjs';
8
+ import { m as detectConfigManagementMode } from './codex.mjs';
9
9
  import { deleteProviders, addProviderToExisting, editExistingProvider } from './codex-provider-manager.mjs';
10
10
  import 'node:os';
11
11
  import 'pathe';
@@ -178,7 +178,7 @@ async function handleAddProvider() {
178
178
  defaultValue: true
179
179
  });
180
180
  if (setAsDefault) {
181
- const { switchToProvider } = await import('./codex.mjs').then(function (n) { return n.m; });
181
+ const { switchToProvider } = await import('./codex.mjs').then(function (n) { return n.n; });
182
182
  const switched = await switchToProvider(provider.id);
183
183
  if (switched) {
184
184
  console.log(ansis.green(i18n.t("multi-config:profileSetAsDefault", { name: provider.name })));
@@ -373,7 +373,7 @@ ${i18n.t("codex:copyingProvider", { name: provider.name })}`));
373
373
  defaultValue: false
374
374
  });
375
375
  if (setAsDefault) {
376
- const { switchToProvider } = await import('./codex.mjs').then(function (n) { return n.m; });
376
+ const { switchToProvider } = await import('./codex.mjs').then(function (n) { return n.n; });
377
377
  const switched = await switchToProvider(copiedProvider.id);
378
378
  if (switched) {
379
379
  console.log(ansis.green(i18n.t("multi-config:profileSetAsDefault", { name: copiedProvider.name })));
@@ -1,5 +1,5 @@
1
1
  import { ensureI18nInitialized, i18n } from './index.mjs';
2
- import { r as readCodexConfig, i as backupCodexComplete, w as writeCodexConfig, j as writeAuthFile } from './codex.mjs';
2
+ import { c as readCodexConfig, j as backupCodexComplete, w as writeCodexConfig, k as writeAuthFile } from './codex.mjs';
3
3
  import 'node:fs';
4
4
  import 'node:process';
5
5
  import 'node:url';
@@ -120,6 +120,19 @@ const MCP_SERVICE_CONFIGS = [
120
120
  requiresGui: true
121
121
  }
122
122
  },
123
+ // Cross-session Memory Services
124
+ {
125
+ id: "intent-engine",
126
+ requiresApiKey: false,
127
+ defaultSelected: true,
128
+ config: {
129
+ type: "stdio",
130
+ command: "npx",
131
+ args: ["-y", "@origintask/intent-engine@latest", "mcp"],
132
+ env: {}
133
+ }
134
+ // Works on all platforms - no special requirements
135
+ },
123
136
  // Anthropic Official MCP Services - Universal
124
137
  // Note: Removed low-value services: filesystem (buggy), puppeteer (duplicate of Playwright),
125
138
  // memory (Claude has built-in memory), fetch (Claude has WebFetch), sequential-thinking (limited value)
@@ -171,6 +184,12 @@ async function getMcpServices() {
171
184
  name: i18n.t("mcp:services.playwright.name"),
172
185
  description: i18n.t("mcp:services.playwright.description")
173
186
  },
187
+ // Cross-session Memory Services
188
+ {
189
+ id: "intent-engine",
190
+ name: i18n.t("mcp:services.intent-engine.name"),
191
+ description: i18n.t("mcp:services.intent-engine.description")
192
+ },
174
193
  // Anthropic Official MCP Services
175
194
  // Note: Removed low-value services: filesystem (buggy), puppeteer (duplicate),
176
195
  // memory (Claude built-in), fetch (Claude WebFetch), sequential-thinking (limited value)
@@ -199,14 +218,122 @@ async function getMcpService(id) {
199
218
  const services = await getMcpServices();
200
219
  return services.find((service) => service.id === id);
201
220
  }
221
+ const DEFAULT_MCP_TOOL_SEARCH_CONFIG = {
222
+ mcpAutoEnableThreshold: 10,
223
+ excludedServices: ["mcp-search", "context7", "sqlite"]
224
+ };
225
+ function getMcpToolSearchConfig() {
226
+ const env = process__default.env;
227
+ return {
228
+ mcpAutoEnableThreshold: env.MCP_AUTO_THRESHOLD || DEFAULT_MCP_TOOL_SEARCH_CONFIG.mcpAutoEnableThreshold,
229
+ dynamicServiceDiscovery: env.MCP_DYNAMIC_DISCOVERY !== "false",
230
+ listChangedNotifications: env.MCP_LIST_CHANGED !== "false",
231
+ excludedServices: env.MCP_EXCLUDED_SERVICES?.split(",").map((s) => s.trim()).filter(Boolean) || DEFAULT_MCP_TOOL_SEARCH_CONFIG.excludedServices
232
+ };
233
+ }
234
+ class DynamicMcpServiceRegistry {
235
+ _services = /* @__PURE__ */ new Map();
236
+ _listeners = /* @__PURE__ */ new Set();
237
+ _enabled = false;
238
+ /**
239
+ * Enable dynamic service discovery
240
+ */
241
+ enable() {
242
+ this._enabled = true;
243
+ }
244
+ /**
245
+ * Disable dynamic service discovery
246
+ */
247
+ disable() {
248
+ this._enabled = false;
249
+ }
250
+ /**
251
+ * Check if dynamic discovery is enabled
252
+ */
253
+ isEnabled() {
254
+ return this._enabled;
255
+ }
256
+ /**
257
+ * Add a service dynamically
258
+ */
259
+ addService(serviceId, config) {
260
+ if (!this._enabled) {
261
+ return false;
262
+ }
263
+ const isUpdate = this._services.has(serviceId);
264
+ this._services.set(serviceId, config);
265
+ this._notify({
266
+ type: isUpdate ? "updated" : "added",
267
+ serviceId,
268
+ timestamp: Date.now(),
269
+ config
270
+ });
271
+ return true;
272
+ }
273
+ /**
274
+ * Remove a service dynamically
275
+ */
276
+ removeService(serviceId) {
277
+ if (!this._enabled || !this._services.has(serviceId)) {
278
+ return false;
279
+ }
280
+ const config = this._services.get(serviceId);
281
+ this._services.delete(serviceId);
282
+ this._notify({
283
+ type: "removed",
284
+ serviceId,
285
+ timestamp: Date.now(),
286
+ config
287
+ });
288
+ return true;
289
+ }
290
+ /**
291
+ * Get a service configuration
292
+ */
293
+ getService(serviceId) {
294
+ return this._services.get(serviceId);
295
+ }
296
+ /**
297
+ * List all dynamically registered services
298
+ */
299
+ listServices() {
300
+ return new Map(this._services);
301
+ }
302
+ /**
303
+ * Subscribe to list change notifications
304
+ */
305
+ subscribe(listener) {
306
+ this._listeners.add(listener);
307
+ return () => this._listeners.delete(listener);
308
+ }
309
+ /**
310
+ * Notify all listeners of a change
311
+ */
312
+ _notify(notification) {
313
+ const toolSearchConfig = getMcpToolSearchConfig();
314
+ if (toolSearchConfig.listChangedNotifications) {
315
+ for (const listener of Array.from(this._listeners)) {
316
+ try {
317
+ listener(notification);
318
+ } catch (error) {
319
+ console.error("Error notifying MCP list change listener:", error);
320
+ }
321
+ }
322
+ }
323
+ }
324
+ }
325
+ const dynamicMcpRegistry = new DynamicMcpServiceRegistry();
202
326
 
203
327
  async function selectMcpServices() {
204
328
  ensureI18nInitialized();
205
329
  const mcpServices = await getMcpServices();
330
+ const defaultSelectedIds = new Set(
331
+ MCP_SERVICE_CONFIGS.filter((c) => c.defaultSelected).map((c) => c.id)
332
+ );
206
333
  const choices = mcpServices.map((service) => ({
207
334
  name: `${service.name} - ${ansis.gray(service.description)}`,
208
335
  value: service.id,
209
- selected: false
336
+ checked: defaultSelectedIds.has(service.id)
210
337
  }));
211
338
  const { services } = await inquirer.prompt({
212
339
  type: "checkbox",
@@ -1947,4 +2074,4 @@ const codex = {
1947
2074
  writeCodexConfig: writeCodexConfig
1948
2075
  };
1949
2076
 
1950
- export { MCP_SERVICE_CONFIGS as M, applyCodexPlatformCommand as a, runCodexFullInit as b, getMcpServices as c, runCodexUpdate as d, switchCodexProvider as e, switchToOfficialLogin as f, getMcpService as g, switchToProvider as h, backupCodexComplete as i, writeAuthFile as j, detectConfigManagementMode as k, listCodexProviders as l, codex as m, readCodexConfig as r, selectMcpServices as s, writeCodexConfig as w };
2077
+ export { MCP_SERVICE_CONFIGS as M, runCodexUpdate as a, getMcpService as b, readCodexConfig as c, dynamicMcpRegistry as d, applyCodexPlatformCommand as e, switchCodexProvider as f, getMcpServices as g, switchToOfficialLogin as h, switchToProvider as i, backupCodexComplete as j, writeAuthFile as k, listCodexProviders as l, detectConfigManagementMode as m, codex as n, runCodexFullInit as r, selectMcpServices as s, writeCodexConfig as w };
@@ -5,7 +5,7 @@ import { resolveCodeToolType, isCodeToolType, DEFAULT_CODE_TOOL_TYPE } from './c
5
5
  import { ensureI18nInitialized, i18n } from './index.mjs';
6
6
  import { readZcfConfig } from './ccjk-config.mjs';
7
7
  import { ClaudeCodeConfigManager } from './claude-code-config-manager.mjs';
8
- import { e as switchCodexProvider, l as listCodexProviders, r as readCodexConfig, f as switchToOfficialLogin, h as switchToProvider } from './codex.mjs';
8
+ import { f as switchCodexProvider, l as listCodexProviders, c as readCodexConfig, h as switchToOfficialLogin, i as switchToProvider } from './codex.mjs';
9
9
  import { a as handleGeneralError } from '../shared/ccjk.DvIrK0wz.mjs';
10
10
  import { a as addNumbersToChoices } from '../shared/ccjk.BFQ7yr5S.mjs';
11
11
  import 'node:os';
@@ -5,7 +5,7 @@ import inquirer from 'inquirer';
5
5
  import { join, dirname } from 'pathe';
6
6
  import { SETTINGS_FILE, CLAUDE_VSC_CONFIG_FILE, CLAUDE_DIR, AI_OUTPUT_LANGUAGES } from './constants.mjs';
7
7
  import { ensureI18nInitialized, i18n } from './index.mjs';
8
- import { s as setPrimaryApiKey, c as addCompletedOnboarding, d as deepMerge } from './claude-config.mjs';
8
+ import { s as setPrimaryApiKey, a as addCompletedOnboarding, g as deepMerge } from './claude-config.mjs';
9
9
  import { ensureDir, exists, copyDir, writeFileAtomic, copyFile } from './fs-operations.mjs';
10
10
  import { readJsonConfig, writeJsonConfig } from './json-config.mjs';
11
11
 
@@ -72,6 +72,18 @@ function isValidPermission(perm) {
72
72
  }
73
73
  return true;
74
74
  }
75
+ function isCoveredByWildcard(perm, wildcardPerm) {
76
+ const wildcardMatch = wildcardPerm.match(/^(\w+)\((.+)\)$/);
77
+ if (!wildcardMatch) return false;
78
+ const [, tool, wildcardArg] = wildcardMatch;
79
+ if (!wildcardArg.includes("*")) return false;
80
+ const permMatch = perm.match(/^(\w+)\((.+)\)$/);
81
+ if (!permMatch) return false;
82
+ const [, permTool, permArg] = permMatch;
83
+ if (tool !== permTool) return false;
84
+ const regexStr = wildcardArg.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".+");
85
+ return new RegExp(`^${regexStr}$`).test(permArg);
86
+ }
75
87
  function mergeAndCleanPermissions(templatePermissions, userPermissions) {
76
88
  const template = templatePermissions || [];
77
89
  const user = userPermissions || [];
@@ -92,6 +104,10 @@ function mergeAndCleanPermissions(templatePermissions, userPermissions) {
92
104
  isRedundant = true;
93
105
  break;
94
106
  }
107
+ if (isCoveredByWildcard(perm, templatePerm)) {
108
+ isRedundant = true;
109
+ break;
110
+ }
95
111
  }
96
112
  if (!isRedundant) {
97
113
  result.push(perm);
@@ -9,7 +9,7 @@ import inquirer from 'inquirer';
9
9
  import { join } from 'pathe';
10
10
  import { SETTINGS_FILE } from './constants.mjs';
11
11
  import { ensureI18nInitialized, i18n } from './index.mjs';
12
- import { s as setPrimaryApiKey, c as addCompletedOnboarding } from './claude-config.mjs';
12
+ import { s as setPrimaryApiKey, a as addCompletedOnboarding } from './claude-config.mjs';
13
13
  import { b as backupExistingConfig } from './config.mjs';
14
14
  import { readJsonConfig, writeJsonConfig } from './json-config.mjs';
15
15
  import { p as promptBoolean } from '../shared/ccjk.DHbrGcgg.mjs';