ccjk 14.1.7 → 14.1.8

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 (68) hide show
  1. package/bin/ccjk.mjs +3 -2
  2. package/bin/ccjk.ts +104 -104
  3. package/dist/chunks/agent.mjs +2 -2
  4. package/dist/chunks/api-cli.mjs +2 -2
  5. package/dist/chunks/api-config-selector.mjs +5 -6
  6. package/dist/chunks/auto-updater.mjs +1 -1
  7. package/dist/chunks/brain-config.mjs +1 -1
  8. package/dist/chunks/brain-status.mjs +13 -7
  9. package/dist/chunks/ccjk-all.mjs +3 -3
  10. package/dist/chunks/ccjk-mcp.mjs +2 -2
  11. package/dist/chunks/ccjk-setup.mjs +1 -1
  12. package/dist/chunks/ccjk-skills.mjs +1 -1
  13. package/dist/chunks/ccr.mjs +11 -12
  14. package/dist/chunks/check-updates.mjs +1 -2
  15. package/dist/chunks/claude-code-incremental-manager.mjs +9 -9
  16. package/dist/chunks/claude-config.mjs +2 -2
  17. package/dist/chunks/code-type-resolver.mjs +2 -4
  18. package/dist/chunks/codex-config-switch.mjs +3 -4
  19. package/dist/chunks/codex-provider-manager.mjs +1 -2
  20. package/dist/chunks/codex.mjs +2 -33
  21. package/dist/chunks/config-switch.mjs +8 -5
  22. package/dist/chunks/config.mjs +382 -19
  23. package/dist/chunks/config2.mjs +3 -3
  24. package/dist/chunks/config3.mjs +1 -1
  25. package/dist/chunks/context.mjs +2 -2
  26. package/dist/chunks/doctor.mjs +4 -5
  27. package/dist/chunks/evolution.mjs +10 -6
  28. package/dist/chunks/features.mjs +13 -14
  29. package/dist/chunks/index10.mjs +4 -4
  30. package/dist/chunks/init.mjs +556 -557
  31. package/dist/chunks/installer.mjs +2 -2
  32. package/dist/chunks/mcp-cli.mjs +6 -7
  33. package/dist/chunks/mcp.mjs +6 -7
  34. package/dist/chunks/memory-check.mjs +2 -2
  35. package/dist/chunks/memory-paths.mjs +1 -1
  36. package/dist/chunks/memory-sync.mjs +2 -2
  37. package/dist/chunks/memory.mjs +7 -7
  38. package/dist/chunks/notification.mjs +1 -1
  39. package/dist/chunks/package.mjs +1 -1
  40. package/dist/chunks/quick-provider.mjs +37 -7
  41. package/dist/chunks/quick-setup.mjs +6 -7
  42. package/dist/chunks/remote.mjs +1 -1
  43. package/dist/chunks/research.mjs +118 -118
  44. package/dist/chunks/simple-config.mjs +4 -4
  45. package/dist/chunks/skill2.mjs +129 -80
  46. package/dist/chunks/skills-sync.mjs +1 -1
  47. package/dist/chunks/slash-commands.mjs +1 -1
  48. package/dist/chunks/uninstall.mjs +1 -1
  49. package/dist/chunks/update.mjs +10 -11
  50. package/dist/chunks/zero-config.mjs +8 -9
  51. package/dist/cli.mjs +1 -1
  52. package/dist/index.d.mts +3 -3
  53. package/dist/index.d.ts +3 -3
  54. package/dist/index.mjs +7 -7
  55. package/dist/shared/{ccjk.QNhw2Y_5.mjs → ccjk.B9OuS4xZ.mjs} +3 -3
  56. package/dist/shared/{ccjk.DqlzNDEQ.mjs → ccjk.BEiR3L4C.mjs} +2 -3
  57. package/dist/shared/{ccjk.4iw1XCF3.mjs → ccjk.BJ3Zpjo5.mjs} +1 -1
  58. package/dist/shared/{ccjk.Nwf9bR70.mjs → ccjk.BzxpiEPF.mjs} +2 -2
  59. package/dist/shared/{ccjk.BI-hdI7P.mjs → ccjk.CbWVbtb9.mjs} +1 -1
  60. package/dist/shared/{ccjk.UhjQ1seV.mjs → ccjk.DMV3x5Sd.mjs} +1 -1
  61. package/dist/shared/{ccjk.DQXk596F.mjs → ccjk.DuzJZlgj.mjs} +107 -103
  62. package/dist/shared/{ccjk.DTdjs-qK.mjs → ccjk.MwtjAULc.mjs} +1 -1
  63. package/dist/shared/{ccjk.DsYaCCx4.mjs → ccjk.i_vn-9C3.mjs} +2 -2
  64. package/dist/shared/{ccjk.kAZkKbGW.mjs → ccjk.tI_s2uSh.mjs} +2 -3
  65. package/package.json +5 -5
  66. package/dist/shared/ccjk.DKXs7Fbm.mjs +0 -361
  67. package/dist/shared/{ccjk.BBizCO6_.mjs → ccjk.DcMvE7lf.mjs} +1 -1
  68. package/dist/shared/{ccjk.Dhu8ia5S.mjs → ccjk.zFGcZT7Y.mjs} +1 -1
@@ -223,7 +223,7 @@ async function getInstallationStatus(codeType = "claude-code") {
223
223
  async function getInstallMethodFromConfig(codeType) {
224
224
  try {
225
225
  if (isClaudeFamilyCodeTool(codeType)) {
226
- const { readMcpConfig } = await import('./config.mjs').then(function (n) { return n.J; });
226
+ const { readMcpConfig } = await import('./config.mjs').then(function (n) { return n.P; });
227
227
  const config = readMcpConfig();
228
228
  return config?.installMethod || null;
229
229
  }
@@ -352,7 +352,7 @@ async function setInstallMethod(method, codeType = "claude-code") {
352
352
  readMcpConfig,
353
353
  writeClavueConfig,
354
354
  writeMcpConfig
355
- } = await import('./config.mjs').then(function (n) { return n.J; });
355
+ } = await import('./config.mjs').then(function (n) { return n.P; });
356
356
  const readConfig = codeType === "clavue" ? readClavueConfig : readMcpConfig;
357
357
  const writeConfig = codeType === "clavue" ? writeClavueConfig : writeMcpConfig;
358
358
  let config = readConfig();
@@ -1,19 +1,15 @@
1
1
  import a from './index5.mjs';
2
- import { g as getMcpServices } from '../shared/ccjk.DKXs7Fbm.mjs';
2
+ import { g as getMcpServices, r as readMcpConfig } from './config.mjs';
3
3
  import { i18n } from './index2.mjs';
4
- import { r as readMcpConfig } from './config.mjs';
5
- import { i as installMcpService, u as uninstallMcpService } from '../shared/ccjk.kAZkKbGW.mjs';
4
+ import { i as installMcpService, u as uninstallMcpService } from '../shared/ccjk.tI_s2uSh.mjs';
6
5
  import '../shared/ccjk.BAGoDD49.mjs';
7
- import 'node:child_process';
8
- import 'node:process';
9
- import 'node:fs';
10
6
  import 'node:url';
11
- import '../shared/ccjk.bQ7Dh1g4.mjs';
12
7
  import '../shared/ccjk.RyizuzOI.mjs';
13
8
  import './index6.mjs';
14
9
  import 'node:readline';
15
10
  import 'stream';
16
11
  import 'node:tty';
12
+ import 'node:process';
17
13
  import 'node:async_hooks';
18
14
  import '../shared/ccjk.Cjgrln_h.mjs';
19
15
  import 'node:util';
@@ -26,6 +22,9 @@ import 'node:crypto';
26
22
  import 'buffer';
27
23
  import 'string_decoder';
28
24
  import './constants.mjs';
25
+ import '../shared/ccjk.bQ7Dh1g4.mjs';
26
+ import 'node:fs';
27
+ import 'node:child_process';
29
28
  import './ccjk-config.mjs';
30
29
  import '../shared/ccjk.BBtCGd_g.mjs';
31
30
  import './index3.mjs';
@@ -5,10 +5,9 @@ import { readZcfConfig } from './ccjk-config.mjs';
5
5
  import 'node:child_process';
6
6
  import 'node:process';
7
7
  import { M as MCP_SERVICE_TIERS, i as isCoreService, g as getServicesByTier, c as checkMcpPerformance, f as formatPerformanceWarning, a as calculateResourceUsage, b as getOptimizationSuggestions, d as getMcpTierConfig } from './mcp-performance.mjs';
8
- import { r as readMcpConfig, d as backupMcpConfig, w as writeMcpConfig } from './config.mjs';
9
- export { m as mcpInstall, a as mcpList, b as mcpSearch, c as mcpUninstall } from '../shared/ccjk.QNhw2Y_5.mjs';
10
- import { M as MCP_SERVICE_CONFIGS } from '../shared/ccjk.DKXs7Fbm.mjs';
11
- import { r as readCodexConfig, f as backupCodexComplete, w as writeCodexConfig, d as applyCodexPlatformCommand } from './codex.mjs';
8
+ import { r as readMcpConfig, e as backupMcpConfig, w as writeMcpConfig, M as MCP_SERVICE_CONFIGS } from './config.mjs';
9
+ export { m as mcpInstall, a as mcpList, b as mcpSearch, c as mcpUninstall } from '../shared/ccjk.B9OuS4xZ.mjs';
10
+ import { r as readCodexConfig, d as backupCodexComplete, w as writeCodexConfig, c as applyCodexPlatformCommand } from './codex.mjs';
12
11
  import { i as isWindows, k as getSystemRoot } from './platform.mjs';
13
12
  import '../shared/ccjk.BAGoDD49.mjs';
14
13
  import 'node:os';
@@ -36,7 +35,7 @@ import 'node:path';
36
35
  import 'buffer';
37
36
  import 'string_decoder';
38
37
  import '../shared/ccjk.Di1IYU3u.mjs';
39
- import '../shared/ccjk.kAZkKbGW.mjs';
38
+ import '../shared/ccjk.tI_s2uSh.mjs';
40
39
  import './index8.mjs';
41
40
  import '../shared/ccjk.DeWpAShp.mjs';
42
41
  import '../shared/ccjk.CxpGa6MC.mjs';
@@ -579,8 +578,8 @@ function getServiceTier(serviceId, tiers) {
579
578
  return caseInsensitiveMatch?.[1] || "ondemand";
580
579
  }
581
580
  async function mcpStatus(options = {}) {
582
- const { readMcpConfig } = await import('./config.mjs').then(function (n) { return n.J; });
583
- const { readCodexConfig } = await import('./codex.mjs').then(function (n) { return n.u; });
581
+ const { readMcpConfig } = await import('./config.mjs').then(function (n) { return n.P; });
582
+ const { readCodexConfig } = await import('./codex.mjs').then(function (n) { return n.t; });
584
583
  const { checkMcpPerformance, formatPerformanceWarning } = await import('./mcp-performance.mjs').then(function (n) { return n.e; });
585
584
  const { MCP_SERVICE_TIERS } = await import('./mcp-performance.mjs').then(function (n) { return n.m; });
586
585
  const lang = options.lang || i18n.language || "en";
@@ -7,6 +7,8 @@ import require$$4 from 'util';
7
7
  import require$$5 from 'assert';
8
8
  import sysPath from 'path';
9
9
  import { getConfiguredMemoryDirectories, getClaudeProjectsDir } from './memory-paths.mjs';
10
+ import '../shared/ccjk.BBtCGd_g.mjs';
11
+ import './index3.mjs';
10
12
  import './constants.mjs';
11
13
  import 'node:os';
12
14
  import './index2.mjs';
@@ -14,8 +16,6 @@ import 'node:fs';
14
16
  import 'node:process';
15
17
  import 'node:url';
16
18
  import '../shared/ccjk.bQ7Dh1g4.mjs';
17
- import '../shared/ccjk.BBtCGd_g.mjs';
18
- import './index3.mjs';
19
19
  import './fs-operations.mjs';
20
20
  import 'node:crypto';
21
21
  import 'node:fs/promises';
@@ -1,7 +1,7 @@
1
1
  import { resolve } from 'node:path';
2
- import { CCJK_CONFIG_FILE, SUPPORTED_LANGS, DEFAULT_CODE_TOOL_TYPE, CCJK_CONFIG_DIR, CLAUDE_DIR } from './constants.mjs';
3
2
  import { p as parse } from '../shared/ccjk.BBtCGd_g.mjs';
4
3
  import { stringify } from './index3.mjs';
4
+ import { CCJK_CONFIG_FILE, SUPPORTED_LANGS, DEFAULT_CODE_TOOL_TYPE, CCJK_CONFIG_DIR, CLAUDE_DIR } from './constants.mjs';
5
5
  import { exists, readFile, ensureDir, writeFileAtomic } from './fs-operations.mjs';
6
6
  import { d as dirname, j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
7
7
  import 'node:os';
@@ -2,14 +2,14 @@ import { readFileSync, existsSync, statSync, mkdirSync, writeFileSync } from 'no
2
2
  import { dirname } from 'node:path';
3
3
  import 'node:fs/promises';
4
4
  import { normalizeProjectPath, getCcjkMemoryPath, getClaudeMemoryPath } from './memory-paths.mjs';
5
+ import '../shared/ccjk.BBtCGd_g.mjs';
6
+ import './index3.mjs';
5
7
  import './constants.mjs';
6
8
  import 'node:os';
7
9
  import './index2.mjs';
8
10
  import 'node:process';
9
11
  import 'node:url';
10
12
  import '../shared/ccjk.bQ7Dh1g4.mjs';
11
- import '../shared/ccjk.BBtCGd_g.mjs';
12
- import './index3.mjs';
13
13
  import './fs-operations.mjs';
14
14
  import 'node:crypto';
15
15
 
@@ -2,8 +2,8 @@ import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
2
2
  import a from './index5.mjs';
3
3
  import { i as inquirer } from './index6.mjs';
4
4
  import { x as K } from './main.mjs';
5
- import { getClaudeMemoryPath } from './memory-paths.mjs';
6
5
  import { memoryCheck } from './memory-check.mjs';
6
+ import { getClaudeMemoryPath } from './memory-paths.mjs';
7
7
  import { inspectMemoryFiles, syncMemoryFiles } from './memory-sync.mjs';
8
8
  import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
9
9
  import '../shared/ccjk.BAGoDD49.mjs';
@@ -25,17 +25,17 @@ import 'string_decoder';
25
25
  import 'module';
26
26
  import 'node:child_process';
27
27
  import 'node:stream';
28
+ import 'constants';
29
+ import 'util';
30
+ import 'assert';
31
+ import 'path';
32
+ import '../shared/ccjk.BBtCGd_g.mjs';
33
+ import './index3.mjs';
28
34
  import './constants.mjs';
29
35
  import './index2.mjs';
30
36
  import 'node:url';
31
- import '../shared/ccjk.BBtCGd_g.mjs';
32
- import './index3.mjs';
33
37
  import './fs-operations.mjs';
34
38
  import 'node:fs/promises';
35
- import 'constants';
36
- import 'util';
37
- import 'assert';
38
- import 'path';
39
39
 
40
40
  function formatTimestamp(timestampMs) {
41
41
  if (!timestampMs) {
@@ -1,7 +1,7 @@
1
1
  import a from './index5.mjs';
2
2
  import { i as inquirer } from './index6.mjs';
3
3
  import { i18n } from './index2.mjs';
4
- import { m as maskToken, a as isValidTokenFormat, c as generateDeviceToken, d as decryptToken, e as encryptToken, f as getDeviceInfo, i as isDeviceBound, g as getBindingStatus, u as unbindDevice, b as bindDevice, s as sendNotification } from '../shared/ccjk.BBizCO6_.mjs';
4
+ import { m as maskToken, a as isValidTokenFormat, c as generateDeviceToken, d as decryptToken, e as encryptToken, f as getDeviceInfo, i as isDeviceBound, g as getBindingStatus, u as unbindDevice, b as bindDevice, s as sendNotification } from '../shared/ccjk.DcMvE7lf.mjs';
5
5
  import { exec } from 'node:child_process';
6
6
  import * as fs from 'node:fs';
7
7
  import fs__default from 'node:fs';
@@ -1,3 +1,3 @@
1
- const version = "14.1.7";
1
+ const version = "14.1.8";
2
2
 
3
3
  export { version };
@@ -4,9 +4,11 @@ import ora from './index8.mjs';
4
4
  import { CLOUD_ENDPOINTS, getCodeToolRuntimeCommand, isCodeToolType, resolveCodeToolType } from './constants.mjs';
5
5
  import { c as createApiClient } from '../shared/ccjk.D6ycHbak.mjs';
6
6
  import { readZcfConfig } from './ccjk-config.mjs';
7
- import { r as resolveClaudeFamilySettingsTarget, n as normalizeClaudeFamilySettings } from '../shared/ccjk.Di1IYU3u.mjs';
8
- import { A as setMyclaudeProviderProfiles, i as configureApi, B as overwriteModelSettings } from './config.mjs';
7
+ import { E as setMyclaudeProviderProfiles, j as configureApi, F as overwriteModelSettings } from './config.mjs';
9
8
  import { r as resolveClaudeFamilyModelSlots } from '../shared/ccjk.B2U7DsPy.mjs';
9
+ import { r as resolveClaudeFamilySettingsTarget, n as normalizeClaudeFamilySettings } from '../shared/ccjk.Di1IYU3u.mjs';
10
+ import { a as switchToProvider } from './codex.mjs';
11
+ import { addProviderToExisting } from './codex-provider-manager.mjs';
10
12
  import { readJsonConfig, writeJsonConfig } from './json-config.mjs';
11
13
  import '../shared/ccjk.BAGoDD49.mjs';
12
14
  import 'node:readline';
@@ -34,11 +36,16 @@ import './index3.mjs';
34
36
  import './fs-operations.mjs';
35
37
  import 'node:fs/promises';
36
38
  import '../shared/ccjk.RyizuzOI.mjs';
39
+ import 'node:child_process';
37
40
  import './platform.mjs';
38
41
  import './main.mjs';
39
42
  import 'module';
40
- import 'node:child_process';
41
43
  import 'node:stream';
44
+ import '../shared/ccjk.CxpGa6MC.mjs';
45
+ import '../shared/ccjk.BFQ7yr5S.mjs';
46
+ import './prompts.mjs';
47
+ import '../shared/ccjk.gDEDGD_t.mjs';
48
+ import '../shared/ccjk.DZ2LLOa-.mjs';
42
49
 
43
50
  const CLOUD_API_BASE_URL = `${CLOUD_ENDPOINTS.MAIN.BASE_URL}${CLOUD_ENDPOINTS.MAIN.API_VERSION}`;
44
51
  const REQUEST_TIMEOUT = 1e4;
@@ -409,13 +416,16 @@ const KNOWN_COMMANDS = /* @__PURE__ */ new Set([
409
416
  ]);
410
417
  function resolveQuickProviderCodeTool(config) {
411
418
  if (isCodeToolType(config.codeTool)) {
412
- return config.codeTool === "clavue" ? "clavue" : "claude-code";
419
+ return config.codeTool;
413
420
  }
414
421
  const savedCodeTool = readZcfConfig()?.codeToolType;
415
422
  if (isCodeToolType(savedCodeTool)) {
416
- return savedCodeTool === "clavue" ? "clavue" : "claude-code";
423
+ return savedCodeTool;
417
424
  }
418
- return resolveCodeToolType(config.codeTool) === "clavue" ? "clavue" : "claude-code";
425
+ return resolveCodeToolType(config.codeTool);
426
+ }
427
+ function sanitizeCodexProviderId(input) {
428
+ return input.trim().toLowerCase().replace(/\./g, "-").replace(/\s+/g, "-").replace(/[^a-z0-9\-]/g, "") || "custom";
419
429
  }
420
430
  function isKnownCommand(arg) {
421
431
  if (!arg)
@@ -683,6 +693,26 @@ async function saveProviderConfig(config) {
683
693
  spinner.succeed(a.green("\u914D\u7F6E\u5DF2\u4FDD\u5B58"));
684
694
  return;
685
695
  }
696
+ if (codeTool === "codex") {
697
+ const providerId = sanitizeCodexProviderId(config.shortcode || config.provider.name);
698
+ const tempEnvKey = `${providerId.toUpperCase().replace(/-/g, "_")}_API_KEY`;
699
+ const provider = {
700
+ id: providerId,
701
+ name: config.provider.name,
702
+ baseUrl: config.provider.apiUrl,
703
+ wireApi: "responses",
704
+ tempEnvKey,
705
+ requiresOpenaiAuth: false,
706
+ model: config.model
707
+ };
708
+ const result = await addProviderToExisting(provider, config.apiKey, true);
709
+ if (!result.success) {
710
+ throw new Error(result.error || "Failed to save Codex provider");
711
+ }
712
+ await switchToProvider(providerId);
713
+ spinner.succeed(a.green("\u914D\u7F6E\u5DF2\u4FDD\u5B58"));
714
+ return;
715
+ }
686
716
  configureApi({
687
717
  url: config.provider.apiUrl,
688
718
  key: config.apiKey,
@@ -707,7 +737,7 @@ async function saveProviderConfig(config) {
707
737
  function showSuccessMessage(config) {
708
738
  const codeTool = resolveQuickProviderCodeTool(config);
709
739
  const runtimeCommand = getCodeToolRuntimeCommand(codeTool);
710
- const runtimeName = codeTool === "clavue" ? "Clavue" : "Claude Code";
740
+ const runtimeName = codeTool === "clavue" ? "Clavue" : codeTool === "codex" ? "Codex" : "Claude Code";
711
741
  console.log();
712
742
  console.log(a.green.bold("\u2705 \u914D\u7F6E\u5B8C\u6210!"));
713
743
  console.log(a.gray("\u2500".repeat(40)));
@@ -36,11 +36,10 @@ import 'node:stream';
36
36
  import 'node:url';
37
37
  import '../shared/ccjk.BBtCGd_g.mjs';
38
38
  import './index3.mjs';
39
- import '../shared/ccjk.DKXs7Fbm.mjs';
40
- import './banner.mjs';
41
- import './config2.mjs';
42
39
  import './config.mjs';
43
40
  import '../shared/ccjk.Di1IYU3u.mjs';
41
+ import './banner.mjs';
42
+ import './config2.mjs';
44
43
  import '../shared/ccjk.DZ2LLOa-.mjs';
45
44
  import '../shared/ccjk.DeWpAShp.mjs';
46
45
  import '../shared/ccjk.DFRPtmK_.mjs';
@@ -52,14 +51,14 @@ import './codex.mjs';
52
51
  import '../shared/ccjk.BFQ7yr5S.mjs';
53
52
  import './prompts.mjs';
54
53
  import '../shared/ccjk.Hwoicrh8.mjs';
55
- import '../shared/ccjk.Nwf9bR70.mjs';
56
- import '../shared/ccjk.4iw1XCF3.mjs';
54
+ import '../shared/ccjk.BzxpiEPF.mjs';
55
+ import '../shared/ccjk.BJ3Zpjo5.mjs';
57
56
  import '../shared/ccjk.DGllfVCZ.mjs';
58
57
  import './installer.mjs';
59
- import '../shared/ccjk.BI-hdI7P.mjs';
58
+ import '../shared/ccjk.CbWVbtb9.mjs';
60
59
  import '../shared/ccjk.B8oqkakg.mjs';
61
- import '../shared/ccjk.Bq8TqZG_.mjs';
62
60
  import '../shared/ccjk.B2U7DsPy.mjs';
61
+ import '../shared/ccjk.Bq8TqZG_.mjs';
63
62
 
64
63
  const ccjkVersion = getRuntimeVersion();
65
64
  function displayHeader() {
@@ -5,7 +5,7 @@ import { join } from 'node:path';
5
5
  import { i as inquirer } from './index6.mjs';
6
6
  import ora from './index8.mjs';
7
7
  import { i18n } from './index2.mjs';
8
- import { i as isDeviceBound, g as getBindingStatus, b as bindDevice } from '../shared/ccjk.BBizCO6_.mjs';
8
+ import { i as isDeviceBound, g as getBindingStatus, b as bindDevice } from '../shared/ccjk.DcMvE7lf.mjs';
9
9
  import { l as logger } from '../shared/ccjk.8oaxX4iR.mjs';
10
10
  import 'node:readline';
11
11
  import '../shared/ccjk.BAGoDD49.mjs';
@@ -1,20 +1,132 @@
1
1
  import a from './index5.mjs';
2
- import { existsSync, readFileSync, appendFileSync, writeFileSync, mkdirSync } from 'node:fs';
3
- import { homedir } from 'node:os';
4
2
  import { n as nanoid } from '../shared/ccjk.BoApaI4j.mjs';
5
3
  import { T as TaskPersistence } from '../shared/ccjk.CNhnT6uQ.mjs';
6
- import { e as executeCommand } from '../shared/ccjk.BnsY5WxD.mjs';
7
- import { j as join, d as dirname } from '../shared/ccjk.bQ7Dh1g4.mjs';
8
4
  import { m as matter } from '../shared/ccjk.y-a_1vK4.mjs';
9
5
  import { writeFile, readFile } from './fs-operations.mjs';
6
+ import { j as join, d as dirname } from '../shared/ccjk.bQ7Dh1g4.mjs';
7
+ import { existsSync, readFileSync, appendFileSync, writeFileSync, mkdirSync } from 'node:fs';
8
+ import { homedir } from 'node:os';
9
+ import { e as executeCommand } from '../shared/ccjk.BnsY5WxD.mjs';
10
10
  import '../shared/ccjk.BAGoDD49.mjs';
11
11
  import 'node:crypto';
12
12
  import 'better-sqlite3';
13
- import 'node:child_process';
14
- import 'node:util';
15
13
  import 'fs';
16
14
  import '../shared/ccjk.COweQ1RR.mjs';
17
15
  import 'node:fs/promises';
16
+ import 'node:child_process';
17
+ import 'node:util';
18
+
19
+ const DEFAULT_RESEARCH_PROGRAM_PATH = ".ccjk/research/program.md";
20
+ const DEFAULT_RESEARCH_MAX_ROUNDS = 10;
21
+ const DEFAULT_RESEARCH_MAX_NO_IMPROVE_ROUNDS = 3;
22
+ const DEFAULT_RESEARCH_BUDGET_MS = 5 * 60 * 1e3;
23
+ function normalizePositiveInteger(value, fallback) {
24
+ if (typeof value === "number" && Number.isInteger(value) && value > 0) {
25
+ return value;
26
+ }
27
+ if (typeof value === "string" && value.trim()) {
28
+ const parsed = Number.parseInt(value.trim(), 10);
29
+ if (Number.isInteger(parsed) && parsed > 0) {
30
+ return parsed;
31
+ }
32
+ }
33
+ return fallback;
34
+ }
35
+ function normalizeOptionalNumber(value) {
36
+ if (typeof value === "number" && Number.isFinite(value)) {
37
+ return value;
38
+ }
39
+ if (typeof value === "string" && value.trim()) {
40
+ const parsed = Number.parseFloat(value.trim());
41
+ if (Number.isFinite(parsed)) {
42
+ return parsed;
43
+ }
44
+ }
45
+ return void 0;
46
+ }
47
+ function normalizeObjective(value) {
48
+ return value === "maximize" || value === "minimize" || value === "auto" ? value : "auto";
49
+ }
50
+ function normalizeString(value) {
51
+ if (typeof value !== "string") {
52
+ return void 0;
53
+ }
54
+ const trimmed = value.trim();
55
+ return trimmed || void 0;
56
+ }
57
+ function resolveResearchProgramPath(programPath, cwd) {
58
+ return programPath ? join(cwd || process.cwd(), programPath) : join(cwd || process.cwd(), DEFAULT_RESEARCH_PROGRAM_PATH);
59
+ }
60
+ function createDefaultResearchProgramTemplate(cwd) {
61
+ const workingDirectory = cwd || process.cwd();
62
+ return `---
63
+ name: repo-research
64
+ metric: test_pass_rate
65
+ objective: maximize
66
+ baselineCommand: pnpm test:run
67
+ candidateCommand: pnpm test:run
68
+ cwd: ${workingDirectory}
69
+ maxRounds: ${DEFAULT_RESEARCH_MAX_ROUNDS}
70
+ maxNoImproveRounds: ${DEFAULT_RESEARCH_MAX_NO_IMPROVE_ROUNDS}
71
+ budgetMs: ${DEFAULT_RESEARCH_BUDGET_MS}
72
+ targetMetric:
73
+ ---
74
+
75
+ # Research Goal
76
+
77
+ Describe the optimization target for this repository.
78
+
79
+ ## Guardrails
80
+
81
+ - Keep changes scoped and measurable.
82
+ - Prefer one candidate change per round.
83
+ - Stop when the target metric is reached or repeated no-improvement rounds occur.
84
+
85
+ ## Notes
86
+
87
+ Document hypotheses, constraints, and any files or modules that must not change.
88
+ `;
89
+ }
90
+ function parseResearchProgram(content, programPath = DEFAULT_RESEARCH_PROGRAM_PATH) {
91
+ const parsed = matter(content);
92
+ const data = parsed.data || {};
93
+ const baselineCommand = normalizeString(data.baselineCommand);
94
+ if (!baselineCommand) {
95
+ throw new Error(`Missing required 'baselineCommand' in ${programPath}`);
96
+ }
97
+ const candidateCommand = normalizeString(data.candidateCommand);
98
+ if (!candidateCommand) {
99
+ throw new Error(`Missing required 'candidateCommand' in ${programPath}`);
100
+ }
101
+ return {
102
+ name: normalizeString(data.name) || "repo-research",
103
+ metric: normalizeString(data.metric),
104
+ objective: normalizeObjective(data.objective),
105
+ baselineCommand,
106
+ candidateCommand,
107
+ cwd: normalizeString(data.cwd) || process.cwd(),
108
+ maxRounds: normalizePositiveInteger(data.maxRounds, DEFAULT_RESEARCH_MAX_ROUNDS),
109
+ maxNoImproveRounds: normalizePositiveInteger(data.maxNoImproveRounds, DEFAULT_RESEARCH_MAX_NO_IMPROVE_ROUNDS),
110
+ budgetMs: normalizePositiveInteger(data.budgetMs, DEFAULT_RESEARCH_BUDGET_MS),
111
+ targetMetric: normalizeOptionalNumber(data.targetMetric),
112
+ notes: parsed.content.trim(),
113
+ programPath
114
+ };
115
+ }
116
+ function readResearchProgram(programPath, cwd) {
117
+ const resolvedPath = resolveResearchProgramPath(programPath, cwd);
118
+ const content = readFile(resolvedPath);
119
+ return parseResearchProgram(content, resolvedPath);
120
+ }
121
+ function initResearchProgram(programPath, cwd) {
122
+ const resolvedPath = resolveResearchProgramPath(programPath, cwd);
123
+ const content = createDefaultResearchProgramTemplate(cwd);
124
+ writeFile(resolvedPath, content);
125
+ return {
126
+ programPath: resolvedPath,
127
+ content
128
+ };
129
+ }
18
130
 
19
131
  class TaskQueue {
20
132
  queue = [];
@@ -931,118 +1043,6 @@ function getResearchReport(sessionId, dbPath) {
931
1043
  };
932
1044
  }
933
1045
 
934
- const DEFAULT_RESEARCH_PROGRAM_PATH = ".ccjk/research/program.md";
935
- const DEFAULT_RESEARCH_MAX_ROUNDS = 10;
936
- const DEFAULT_RESEARCH_MAX_NO_IMPROVE_ROUNDS = 3;
937
- const DEFAULT_RESEARCH_BUDGET_MS = 5 * 60 * 1e3;
938
- function normalizePositiveInteger(value, fallback) {
939
- if (typeof value === "number" && Number.isInteger(value) && value > 0) {
940
- return value;
941
- }
942
- if (typeof value === "string" && value.trim()) {
943
- const parsed = Number.parseInt(value.trim(), 10);
944
- if (Number.isInteger(parsed) && parsed > 0) {
945
- return parsed;
946
- }
947
- }
948
- return fallback;
949
- }
950
- function normalizeOptionalNumber(value) {
951
- if (typeof value === "number" && Number.isFinite(value)) {
952
- return value;
953
- }
954
- if (typeof value === "string" && value.trim()) {
955
- const parsed = Number.parseFloat(value.trim());
956
- if (Number.isFinite(parsed)) {
957
- return parsed;
958
- }
959
- }
960
- return void 0;
961
- }
962
- function normalizeObjective(value) {
963
- return value === "maximize" || value === "minimize" || value === "auto" ? value : "auto";
964
- }
965
- function normalizeString(value) {
966
- if (typeof value !== "string") {
967
- return void 0;
968
- }
969
- const trimmed = value.trim();
970
- return trimmed || void 0;
971
- }
972
- function resolveResearchProgramPath(programPath, cwd) {
973
- return programPath ? join(cwd || process.cwd(), programPath) : join(cwd || process.cwd(), DEFAULT_RESEARCH_PROGRAM_PATH);
974
- }
975
- function createDefaultResearchProgramTemplate(cwd) {
976
- const workingDirectory = cwd || process.cwd();
977
- return `---
978
- name: repo-research
979
- metric: test_pass_rate
980
- objective: maximize
981
- baselineCommand: pnpm test:run
982
- candidateCommand: pnpm test:run
983
- cwd: ${workingDirectory}
984
- maxRounds: ${DEFAULT_RESEARCH_MAX_ROUNDS}
985
- maxNoImproveRounds: ${DEFAULT_RESEARCH_MAX_NO_IMPROVE_ROUNDS}
986
- budgetMs: ${DEFAULT_RESEARCH_BUDGET_MS}
987
- targetMetric:
988
- ---
989
-
990
- # Research Goal
991
-
992
- Describe the optimization target for this repository.
993
-
994
- ## Guardrails
995
-
996
- - Keep changes scoped and measurable.
997
- - Prefer one candidate change per round.
998
- - Stop when the target metric is reached or repeated no-improvement rounds occur.
999
-
1000
- ## Notes
1001
-
1002
- Document hypotheses, constraints, and any files or modules that must not change.
1003
- `;
1004
- }
1005
- function parseResearchProgram(content, programPath = DEFAULT_RESEARCH_PROGRAM_PATH) {
1006
- const parsed = matter(content);
1007
- const data = parsed.data || {};
1008
- const baselineCommand = normalizeString(data.baselineCommand);
1009
- if (!baselineCommand) {
1010
- throw new Error(`Missing required 'baselineCommand' in ${programPath}`);
1011
- }
1012
- const candidateCommand = normalizeString(data.candidateCommand);
1013
- if (!candidateCommand) {
1014
- throw new Error(`Missing required 'candidateCommand' in ${programPath}`);
1015
- }
1016
- return {
1017
- name: normalizeString(data.name) || "repo-research",
1018
- metric: normalizeString(data.metric),
1019
- objective: normalizeObjective(data.objective),
1020
- baselineCommand,
1021
- candidateCommand,
1022
- cwd: normalizeString(data.cwd) || process.cwd(),
1023
- maxRounds: normalizePositiveInteger(data.maxRounds, DEFAULT_RESEARCH_MAX_ROUNDS),
1024
- maxNoImproveRounds: normalizePositiveInteger(data.maxNoImproveRounds, DEFAULT_RESEARCH_MAX_NO_IMPROVE_ROUNDS),
1025
- budgetMs: normalizePositiveInteger(data.budgetMs, DEFAULT_RESEARCH_BUDGET_MS),
1026
- targetMetric: normalizeOptionalNumber(data.targetMetric),
1027
- notes: parsed.content.trim(),
1028
- programPath
1029
- };
1030
- }
1031
- function readResearchProgram(programPath, cwd) {
1032
- const resolvedPath = resolveResearchProgramPath(programPath, cwd);
1033
- const content = readFile(resolvedPath);
1034
- return parseResearchProgram(content, resolvedPath);
1035
- }
1036
- function initResearchProgram(programPath, cwd) {
1037
- const resolvedPath = resolveResearchProgramPath(programPath, cwd);
1038
- const content = createDefaultResearchProgramTemplate(cwd);
1039
- writeFile(resolvedPath, content);
1040
- return {
1041
- programPath: resolvedPath,
1042
- content
1043
- };
1044
- }
1045
-
1046
1046
  const RESEARCH_LOOP_SESSION_KIND = "research-loop";
1047
1047
  const DEFAULT_FAILURE_STREAK_LIMIT = 2;
1048
1048
  function createPersistence(dbPath) {
@@ -1,9 +1,9 @@
1
1
  import { readFileSync, existsSync } from 'node:fs';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import { exec as q } from './main.mjs';
4
- import { ensureDir, writeFileAtomic } from './fs-operations.mjs';
5
4
  import { r as resolveClaudeFamilySettingsTarget, n as normalizeClaudeFamilySettings } from '../shared/ccjk.Di1IYU3u.mjs';
6
- import { n as mergeAndCleanPermissions } from './config.mjs';
5
+ import { ensureDir, writeFileAtomic } from './fs-operations.mjs';
6
+ import { o as mergeAndCleanPermissions } from './config.mjs';
7
7
  import { g as getPlatform } from './platform.mjs';
8
8
  import { j as join, d as dirname } from '../shared/ccjk.bQ7Dh1g4.mjs';
9
9
  import 'module';
@@ -12,8 +12,6 @@ import 'node:path';
12
12
  import 'node:process';
13
13
  import 'node:stream';
14
14
  import 'node:readline';
15
- import 'node:crypto';
16
- import 'node:fs/promises';
17
15
  import './constants.mjs';
18
16
  import 'node:os';
19
17
  import './index2.mjs';
@@ -23,6 +21,8 @@ import './index3.mjs';
23
21
  import './json-config.mjs';
24
22
  import '../shared/ccjk.RyizuzOI.mjs';
25
23
  import '../shared/ccjk.BAGoDD49.mjs';
24
+ import 'node:crypto';
25
+ import 'node:fs/promises';
26
26
  import './index5.mjs';
27
27
  import './index6.mjs';
28
28
  import 'stream';