claude-code-workflow 6.3.48 → 6.3.49

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 (211) hide show
  1. package/.claude/CLAUDE.md +6 -8
  2. package/.claude/agents/action-planning-agent.md +28 -45
  3. package/.claude/agents/cli-lite-planning-agent.md +93 -1
  4. package/.claude/agents/code-developer.md +144 -27
  5. package/.claude/commands/ccw-coordinator.md +175 -21
  6. package/.claude/commands/ccw-debug.md +832 -0
  7. package/.claude/commands/ccw.md +90 -9
  8. package/.claude/commands/cli/cli-init.md +1 -0
  9. package/.claude/commands/issue/convert-to-plan.md +718 -0
  10. package/.claude/commands/issue/from-brainstorm.md +382 -0
  11. package/.claude/commands/memory/tips.md +332 -0
  12. package/.claude/commands/workflow/analyze-with-file.md +804 -0
  13. package/.claude/commands/workflow/brainstorm/auto-parallel.md +18 -43
  14. package/.claude/commands/workflow/brainstorm/role-analysis.md +705 -0
  15. package/.claude/commands/workflow/brainstorm-with-file.md +1153 -0
  16. package/.claude/commands/workflow/debug-with-file.md +7 -5
  17. package/.claude/commands/workflow/execute.md +6 -4
  18. package/.claude/commands/workflow/lite-plan.md +2 -2
  19. package/.claude/commands/workflow/plan-verify.md +162 -327
  20. package/.claude/commands/workflow/plan.md +162 -26
  21. package/.claude/commands/workflow/replan.md +78 -2
  22. package/.claude/commands/workflow/{review-fix.md → review-cycle-fix.md} +6 -6
  23. package/.claude/commands/workflow/review-module-cycle.md +2 -2
  24. package/.claude/commands/workflow/review-session-cycle.md +2 -2
  25. package/.claude/commands/workflow/tools/conflict-resolution.md +16 -26
  26. package/.claude/commands/workflow/tools/context-gather.md +81 -118
  27. package/.claude/commands/workflow/tools/task-generate-agent.md +94 -10
  28. package/.claude/skills/ccw-help/command.json +4 -4
  29. package/.claude/skills/lite-skill-generator/SKILL.md +650 -0
  30. package/.claude/skills/lite-skill-generator/templates/simple-skill.md +68 -0
  31. package/.claude/skills/lite-skill-generator/templates/style-guide.md +64 -0
  32. package/.claude/skills/skill-generator/SKILL.md +277 -85
  33. package/.claude/skills/skill-generator/phases/01-requirements-discovery.md +4 -15
  34. package/.claude/skills/skill-generator/phases/02-structure-generation.md +72 -17
  35. package/.claude/skills/skill-generator/phases/03-phase-generation.md +218 -51
  36. package/.claude/skills/skill-generator/phases/04-specs-templates.md +111 -41
  37. package/.claude/skills/skill-generator/phases/05-validation.md +139 -56
  38. package/.claude/skills/skill-generator/templates/autonomous-action.md +78 -268
  39. package/.claude/skills/skill-generator/templates/autonomous-orchestrator.md +14 -0
  40. package/.claude/skills/skill-generator/templates/code-analysis-action.md +12 -0
  41. package/.claude/skills/skill-generator/templates/llm-action.md +12 -0
  42. package/.claude/skills/skill-generator/templates/script-template.md +368 -0
  43. package/.claude/skills/skill-generator/templates/sequential-phase.md +14 -0
  44. package/.claude/skills/skill-generator/templates/skill-md.md +14 -0
  45. package/.claude/skills/skill-tuning/SKILL.md +130 -266
  46. package/.claude/skills/skill-tuning/phases/orchestrator.md +95 -283
  47. package/.claude/skills/skill-tuning/specs/problem-taxonomy.md +90 -198
  48. package/.claude/skills/skill-tuning/specs/tuning-strategies.md +193 -1345
  49. package/.claude/workflows/cli-templates/schemas/plan-verify-agent-schema.json +47 -0
  50. package/.claude/workflows/cli-templates/schemas/verify-json-schema.json +158 -0
  51. package/.claude/workflows/cli-tools-usage.md +1 -1
  52. package/.codex/AGENTS.md +1 -3
  53. package/.codex/prompts/analyze-with-file.md +607 -0
  54. package/.codex/prompts/brainstorm-to-cycle.md +455 -0
  55. package/.codex/prompts/brainstorm-with-file.md +933 -0
  56. package/.codex/prompts/debug-with-file.md +15 -20
  57. package/.codex/skills/ccw-cli-tools/SKILL.md +559 -0
  58. package/ccw/dist/commands/cli.d.ts.map +1 -1
  59. package/ccw/dist/commands/cli.js +29 -5
  60. package/ccw/dist/commands/cli.js.map +1 -1
  61. package/ccw/dist/commands/issue.d.ts +2 -0
  62. package/ccw/dist/commands/issue.d.ts.map +1 -1
  63. package/ccw/dist/commands/issue.js +62 -20
  64. package/ccw/dist/commands/issue.js.map +1 -1
  65. package/ccw/dist/config/litellm-api-config-manager.d.ts.map +1 -1
  66. package/ccw/dist/config/litellm-api-config-manager.js +5 -3
  67. package/ccw/dist/config/litellm-api-config-manager.js.map +1 -1
  68. package/ccw/dist/config/litellm-provider-models.d.ts +73 -0
  69. package/ccw/dist/config/litellm-provider-models.d.ts.map +1 -0
  70. package/ccw/dist/config/litellm-provider-models.js +172 -0
  71. package/ccw/dist/config/litellm-provider-models.js.map +1 -0
  72. package/ccw/dist/config/provider-models.d.ts +25 -51
  73. package/ccw/dist/config/provider-models.d.ts.map +1 -1
  74. package/ccw/dist/config/provider-models.js +84 -149
  75. package/ccw/dist/config/provider-models.js.map +1 -1
  76. package/ccw/dist/config/storage-paths.d.ts.map +1 -1
  77. package/ccw/dist/config/storage-paths.js +23 -5
  78. package/ccw/dist/config/storage-paths.js.map +1 -1
  79. package/ccw/dist/core/auth/csrf-middleware.js +3 -3
  80. package/ccw/dist/core/auth/csrf-middleware.js.map +1 -1
  81. package/ccw/dist/core/dashboard-generator.d.ts.map +1 -1
  82. package/ccw/dist/core/dashboard-generator.js +3 -1
  83. package/ccw/dist/core/dashboard-generator.js.map +1 -1
  84. package/ccw/dist/core/routes/claude-routes.d.ts.map +1 -1
  85. package/ccw/dist/core/routes/claude-routes.js +206 -14
  86. package/ccw/dist/core/routes/claude-routes.js.map +1 -1
  87. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  88. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  89. package/ccw/dist/core/routes/commands-routes.d.ts +7 -0
  90. package/ccw/dist/core/routes/commands-routes.d.ts.map +1 -0
  91. package/ccw/dist/core/routes/commands-routes.js +480 -0
  92. package/ccw/dist/core/routes/commands-routes.js.map +1 -0
  93. package/ccw/dist/core/routes/model-routes.d.ts +11 -0
  94. package/ccw/dist/core/routes/model-routes.d.ts.map +1 -0
  95. package/ccw/dist/core/routes/model-routes.js +112 -0
  96. package/ccw/dist/core/routes/model-routes.js.map +1 -0
  97. package/ccw/dist/core/routes/nav-status-routes.d.ts.map +1 -1
  98. package/ccw/dist/core/routes/nav-status-routes.js +84 -1
  99. package/ccw/dist/core/routes/nav-status-routes.js.map +1 -1
  100. package/ccw/dist/core/routes/provider-routes.d.ts +11 -0
  101. package/ccw/dist/core/routes/provider-routes.d.ts.map +1 -0
  102. package/ccw/dist/core/routes/provider-routes.js +67 -0
  103. package/ccw/dist/core/routes/provider-routes.js.map +1 -0
  104. package/ccw/dist/core/routes/skills-routes.d.ts.map +1 -1
  105. package/ccw/dist/core/routes/skills-routes.js +219 -7
  106. package/ccw/dist/core/routes/skills-routes.js.map +1 -1
  107. package/ccw/dist/core/routes/system-routes.d.ts.map +1 -1
  108. package/ccw/dist/core/routes/system-routes.js +58 -6
  109. package/ccw/dist/core/routes/system-routes.js.map +1 -1
  110. package/ccw/dist/core/server.d.ts.map +1 -1
  111. package/ccw/dist/core/server.js +13 -0
  112. package/ccw/dist/core/server.js.map +1 -1
  113. package/ccw/dist/mcp-server/index.js +2 -2
  114. package/ccw/dist/mcp-server/index.js.map +1 -1
  115. package/ccw/dist/tools/claude-cli-tools.d.ts +48 -11
  116. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
  117. package/ccw/dist/tools/claude-cli-tools.js +146 -50
  118. package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
  119. package/ccw/dist/tools/cli-config-manager.d.ts +1 -13
  120. package/ccw/dist/tools/cli-config-manager.d.ts.map +1 -1
  121. package/ccw/dist/tools/cli-config-manager.js +3 -27
  122. package/ccw/dist/tools/cli-config-manager.js.map +1 -1
  123. package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -1
  124. package/ccw/dist/tools/cli-executor-core.js +7 -2
  125. package/ccw/dist/tools/cli-executor-core.js.map +1 -1
  126. package/ccw/dist/tools/cli-executor-state.d.ts.map +1 -1
  127. package/ccw/dist/tools/cli-history-store.d.ts +11 -0
  128. package/ccw/dist/tools/cli-history-store.d.ts.map +1 -1
  129. package/ccw/dist/tools/cli-history-store.js +82 -2
  130. package/ccw/dist/tools/cli-history-store.js.map +1 -1
  131. package/ccw/dist/tools/command-registry.d.ts +7 -0
  132. package/ccw/dist/tools/command-registry.d.ts.map +1 -1
  133. package/ccw/dist/tools/command-registry.js +14 -1
  134. package/ccw/dist/tools/command-registry.js.map +1 -1
  135. package/ccw/dist/tools/generate-module-docs.d.ts.map +1 -1
  136. package/ccw/dist/tools/generate-module-docs.js +11 -7
  137. package/ccw/dist/tools/generate-module-docs.js.map +1 -1
  138. package/ccw/dist/tools/litellm-executor.d.ts +1 -0
  139. package/ccw/dist/tools/litellm-executor.d.ts.map +1 -1
  140. package/ccw/dist/tools/litellm-executor.js +11 -9
  141. package/ccw/dist/tools/litellm-executor.js.map +1 -1
  142. package/ccw/dist/types/skill-types.d.ts +97 -0
  143. package/ccw/dist/types/skill-types.d.ts.map +1 -0
  144. package/ccw/dist/types/skill-types.js +6 -0
  145. package/ccw/dist/types/skill-types.js.map +1 -0
  146. package/ccw/src/commands/cli.ts +36 -5
  147. package/ccw/src/commands/issue.ts +81 -26
  148. package/ccw/src/config/litellm-api-config-manager.ts +5 -3
  149. package/ccw/src/config/litellm-provider-models.ts +222 -0
  150. package/ccw/src/config/provider-models.ts +91 -190
  151. package/ccw/src/config/storage-paths.ts +20 -5
  152. package/ccw/src/core/auth/csrf-middleware.ts +3 -3
  153. package/ccw/src/core/dashboard-generator.ts +3 -1
  154. package/ccw/src/core/routes/claude-routes.ts +233 -15
  155. package/ccw/src/core/routes/cli-routes.ts +2 -3
  156. package/ccw/src/core/routes/commands-routes.ts +620 -0
  157. package/ccw/src/core/routes/nav-status-routes.ts +95 -1
  158. package/ccw/src/core/routes/provider-routes.ts +78 -0
  159. package/ccw/src/core/routes/skills-routes.ts +266 -45
  160. package/ccw/src/core/routes/system-routes.ts +102 -50
  161. package/ccw/src/core/server.ts +13 -0
  162. package/ccw/src/mcp-server/index.ts +2 -2
  163. package/ccw/src/templates/dashboard-css/18-cli-settings.css +35 -0
  164. package/ccw/src/templates/dashboard-css/37-commands.css +193 -0
  165. package/ccw/src/templates/dashboard-js/components/navigation.js +4 -0
  166. package/ccw/src/templates/dashboard-js/i18n.js +116 -0
  167. package/ccw/src/templates/dashboard-js/views/cli-manager.js +249 -4
  168. package/ccw/src/templates/dashboard-js/views/commands-manager.js +503 -0
  169. package/ccw/src/templates/dashboard-js/views/issue-manager.js +7 -7
  170. package/ccw/src/templates/dashboard-js/views/mcp-manager.js +2 -7
  171. package/ccw/src/templates/dashboard-js/views/skills-manager.js +164 -23
  172. package/ccw/src/templates/dashboard.html +7 -0
  173. package/ccw/src/tools/claude-cli-tools.ts +170 -56
  174. package/ccw/src/tools/cli-config-manager.ts +2 -33
  175. package/ccw/src/tools/cli-executor-core.ts +8 -2
  176. package/ccw/src/tools/cli-history-store.ts +92 -2
  177. package/ccw/src/tools/command-registry.ts +16 -1
  178. package/ccw/src/tools/generate-module-docs.ts +11 -7
  179. package/ccw/src/tools/litellm-executor.ts +13 -9
  180. package/ccw/src/types/skill-types.ts +99 -0
  181. package/package.json +1 -1
  182. package/.claude/commands/enhance-prompt.md +0 -93
  183. package/.claude/commands/memory/code-map-memory.md +0 -687
  184. package/.claude/commands/memory/docs.md +0 -615
  185. package/.claude/commands/memory/load-skill-memory.md +0 -182
  186. package/.claude/commands/memory/skill-memory.md +0 -525
  187. package/.claude/commands/memory/swagger-docs.md +0 -773
  188. package/.claude/commands/memory/tech-research-rules.md +0 -310
  189. package/.claude/commands/memory/workflow-skill-memory.md +0 -517
  190. package/.claude/commands/task/breakdown.md +0 -208
  191. package/.claude/commands/task/create.md +0 -152
  192. package/.claude/commands/task/execute.md +0 -270
  193. package/.claude/commands/task/replan.md +0 -441
  194. package/.claude/commands/version.md +0 -254
  195. package/.claude/commands/workflow/action-plan-verify.md +0 -485
  196. package/.claude/commands/workflow/brainstorm/api-designer.md +0 -587
  197. package/.claude/commands/workflow/brainstorm/data-architect.md +0 -220
  198. package/.claude/commands/workflow/brainstorm/product-manager.md +0 -200
  199. package/.claude/commands/workflow/brainstorm/product-owner.md +0 -200
  200. package/.claude/commands/workflow/brainstorm/scrum-master.md +0 -200
  201. package/.claude/commands/workflow/brainstorm/subject-matter-expert.md +0 -200
  202. package/.claude/commands/workflow/brainstorm/system-architect.md +0 -389
  203. package/.claude/commands/workflow/brainstorm/ui-designer.md +0 -221
  204. package/.claude/commands/workflow/brainstorm/ux-expert.md +0 -221
  205. package/.claude/commands/workflow/debug.md +0 -331
  206. package/.claude/commands/workflow/develop-with-file.md +0 -1044
  207. package/.claude/skills/ccw-loop/README.md +0 -303
  208. package/.claude/skills/skill-generator/templates/script-bash.md +0 -277
  209. package/.claude/skills/skill-generator/templates/script-python.md +0 -198
  210. package/.codex/prompts/debug.md +0 -318
  211. package/ccw/src/core/routes/mcp-routes.ts.backup +0 -549
@@ -917,9 +917,12 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
917
917
  const userClaudePath = join(homedir(), '.claude', 'CLAUDE.md');
918
918
  const userCodexPath = join(homedir(), '.codex', 'AGENTS.md');
919
919
  const chineseRefPattern = /@.*chinese-response\.md/i;
920
+ const chineseSectionPattern = /## 中文回复/; // For Codex direct content
921
+ const oldCodexRefPattern = /- \*\*中文回复准则\*\*:\s*@.*chinese-response\.md/i; // Old Codex format
920
922
 
921
923
  let claudeEnabled = false;
922
924
  let codexEnabled = false;
925
+ let codexNeedsMigration = false;
923
926
  let guidelinesPath = '';
924
927
 
925
928
  // Check if user CLAUDE.md exists and contains Chinese response reference
@@ -928,10 +931,15 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
928
931
  claudeEnabled = chineseRefPattern.test(content);
929
932
  }
930
933
 
931
- // Check if user AGENTS.md exists and contains Chinese response reference
934
+ // Check if user AGENTS.md exists and contains Chinese response section
935
+ // Codex uses direct content concatenation, not @ references
932
936
  if (existsSync(userCodexPath)) {
933
937
  const content = readFileSync(userCodexPath, 'utf8');
934
- codexEnabled = chineseRefPattern.test(content);
938
+ codexEnabled = chineseSectionPattern.test(content);
939
+ // Check if Codex has old @ reference format that needs migration
940
+ if (codexEnabled && oldCodexRefPattern.test(content)) {
941
+ codexNeedsMigration = true;
942
+ }
935
943
  }
936
944
 
937
945
  // Find guidelines file path - always use user-level path
@@ -946,6 +954,7 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
946
954
  enabled: claudeEnabled, // backward compatibility
947
955
  claudeEnabled,
948
956
  codexEnabled,
957
+ codexNeedsMigration, // New field: true if Codex has old @ reference format
949
958
  guidelinesPath,
950
959
  guidelinesExists: !!guidelinesPath,
951
960
  userClaudeMdExists: existsSync(userClaudePath),
@@ -983,10 +992,6 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
983
992
  const targetDir = isCodex ? join(homedir(), '.codex') : join(homedir(), '.claude');
984
993
  const targetFile = isCodex ? join(targetDir, 'AGENTS.md') : join(targetDir, 'CLAUDE.md');
985
994
 
986
- const chineseRefLine = `- **中文回复准则**: @${guidelinesRef}`;
987
- const chineseRefPattern = /^- \*\*中文回复准则\*\*:.*chinese-response\.md.*$/gm;
988
- const chineseSectionPattern = /\n*## 中文回复\n+- \*\*中文回复准则\*\*:.*chinese-response\.md.*\n*/gm;
989
-
990
995
  // Ensure target directory exists
991
996
  if (!existsSync(targetDir)) {
992
997
  mkdirSync(targetDir, { recursive: true });
@@ -1001,18 +1006,231 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
1001
1006
  content = headerText;
1002
1007
  }
1003
1008
 
1009
+ if (isCodex) {
1010
+ // Codex: Direct content concatenation (does not support @ references)
1011
+ const chineseSectionPattern = /\n*## 中文回复\n[\s\S]*?(?=\n## |$)/;
1012
+ const oldRefPattern = /- \*\*中文回复准则\*\*:\s*@.*chinese-response\.md/i; // Old @ reference format
1013
+
1014
+ if (enabled) {
1015
+ // Check if section exists and if it needs migration
1016
+ const hasSection = chineseSectionPattern.test(content);
1017
+
1018
+ if (hasSection) {
1019
+ // Check if it's the old format with @ reference
1020
+ const hasOldRef = oldRefPattern.test(content);
1021
+
1022
+ if (hasOldRef) {
1023
+ // Migrate: remove old section and add new content
1024
+ content = content.replace(chineseSectionPattern, '\n');
1025
+ content = content.replace(/\n{3,}/g, '\n\n').trim();
1026
+ if (content) content += '\n';
1027
+
1028
+ // Read chinese-response.md content
1029
+ const chineseResponseContent = readFileSync(userGuidelinesPath, 'utf8');
1030
+
1031
+ // Add new section with direct content
1032
+ const newSection = `\n## 中文回复\n\n${chineseResponseContent}\n`;
1033
+ content = content.trimEnd() + '\n' + newSection;
1034
+
1035
+ writeFileSync(targetFile, content, 'utf8');
1036
+
1037
+ return { success: true, enabled, migrated: true, message: 'Migrated from @ reference to direct content' };
1038
+ }
1039
+
1040
+ // Already has correct format
1041
+ return { success: true, message: 'Already enabled with correct format' };
1042
+ }
1043
+
1044
+ // Read chinese-response.md content
1045
+ const chineseResponseContent = readFileSync(userGuidelinesPath, 'utf8');
1046
+
1047
+ // Add Chinese response section only
1048
+ const newSection = `\n## 中文回复\n\n${chineseResponseContent}\n`;
1049
+ content = content.trimEnd() + '\n' + newSection;
1050
+ } else {
1051
+ // Remove Chinese response section (both old and new format)
1052
+ content = content.replace(chineseSectionPattern, '\n');
1053
+ content = content.replace(/\n{3,}/g, '\n\n').trim();
1054
+ if (content) content += '\n';
1055
+ }
1056
+ } else {
1057
+ // Claude: Use @ reference (original behavior)
1058
+ const chineseRefLine = `- **中文回复准则**: @${guidelinesRef}`;
1059
+ const chineseRefPattern = /^- \*\*中文回复准则\*\*:.*chinese-response\.md.*$/gm;
1060
+ const chineseSectionPattern = /\n*## 中文回复\n+- \*\*中文回复准则\*\*:.*chinese-response\.md.*\n*/gm;
1061
+
1062
+ if (enabled) {
1063
+ // Check if reference already exists
1064
+ if (chineseRefPattern.test(content)) {
1065
+ return { success: true, message: 'Already enabled' };
1066
+ }
1067
+
1068
+ // Add new section at the end of file
1069
+ const newSection = `\n## 中文回复\n\n${chineseRefLine}\n`;
1070
+ content = content.trimEnd() + '\n' + newSection;
1071
+ } else {
1072
+ // Remove the entire section
1073
+ content = content.replace(chineseSectionPattern, '\n').replace(/\n{3,}/g, '\n\n').trim();
1074
+ if (content) content += '\n';
1075
+ }
1076
+ }
1077
+
1078
+ writeFileSync(targetFile, content, 'utf8');
1079
+
1080
+ // Broadcast update
1081
+ broadcastToClients({
1082
+ type: 'LANGUAGE_SETTING_CHANGED',
1083
+ data: { chineseResponse: enabled, target }
1084
+ });
1085
+
1086
+ return { success: true, enabled, target };
1087
+ } catch (error) {
1088
+ return { error: (error as Error).message, status: 500 };
1089
+ }
1090
+ });
1091
+ return true;
1092
+ }
1093
+
1094
+ // API: Get Codex CLI Enhancement setting status
1095
+ if (pathname === '/api/language/codex-cli-enhancement' && req.method === 'GET') {
1096
+ try {
1097
+ const userCodexPath = join(homedir(), '.codex', 'AGENTS.md');
1098
+ const cliEnhancementSectionPattern = /## CLI 工具调用/; // For Codex CLI enhancement
1099
+
1100
+ let enabled = false;
1101
+ let guidelinesPath = '';
1102
+
1103
+ // Check if user AGENTS.md exists and contains CLI enhancement section
1104
+ if (existsSync(userCodexPath)) {
1105
+ const content = readFileSync(userCodexPath, 'utf8');
1106
+ enabled = cliEnhancementSectionPattern.test(content);
1107
+ }
1108
+
1109
+ // Find guidelines file path
1110
+ const userGuidelinesPath = join(homedir(), '.claude', 'workflows', 'cli-tools-usage.md');
1111
+
1112
+ if (existsSync(userGuidelinesPath)) {
1113
+ guidelinesPath = userGuidelinesPath;
1114
+ }
1115
+
1116
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1117
+ res.end(JSON.stringify({
1118
+ enabled,
1119
+ guidelinesPath,
1120
+ guidelinesExists: !!guidelinesPath,
1121
+ userCodexAgentsExists: existsSync(userCodexPath)
1122
+ }));
1123
+ return true;
1124
+ } catch (error) {
1125
+ res.writeHead(500, { 'Content-Type': 'application/json' });
1126
+ res.end(JSON.stringify({ error: (error as Error).message }));
1127
+ return true;
1128
+ }
1129
+ }
1130
+
1131
+ // API: Toggle Codex CLI Enhancement setting
1132
+ if (pathname === '/api/language/codex-cli-enhancement' && req.method === 'POST') {
1133
+ handlePostRequest(req, res, async (body: any) => {
1134
+ const { enabled, action } = body;
1135
+
1136
+ // Support two actions: 'toggle' (default) and 'refresh'
1137
+ const actionType = action || 'toggle';
1138
+
1139
+ if (actionType === 'toggle' && typeof enabled !== 'boolean') {
1140
+ return { error: 'Missing or invalid enabled parameter', status: 400 };
1141
+ }
1142
+
1143
+ try {
1144
+ const targetDir = join(homedir(), '.codex');
1145
+ const targetFile = join(targetDir, 'AGENTS.md');
1146
+
1147
+ // Ensure target directory exists
1148
+ if (!existsSync(targetDir)) {
1149
+ mkdirSync(targetDir, { recursive: true });
1150
+ }
1151
+
1152
+ let content = '';
1153
+ if (existsSync(targetFile)) {
1154
+ content = readFileSync(targetFile, 'utf8');
1155
+ } else {
1156
+ // Create new file with minimal header
1157
+ content = '# Codex Code Guidelines\n\n';
1158
+ }
1159
+
1160
+ const cliEnhancementSectionPattern = /\n*## CLI 工具调用\n[\s\S]*?(?=\n## |$)/;
1161
+ const isCurrentlyEnabled = cliEnhancementSectionPattern.test(content);
1162
+
1163
+ // Handle refresh action
1164
+ if (actionType === 'refresh') {
1165
+ if (!isCurrentlyEnabled) {
1166
+ return { error: 'CLI enhancement is not enabled, cannot refresh', status: 400 };
1167
+ }
1168
+
1169
+ // Remove existing section
1170
+ content = content.replace(cliEnhancementSectionPattern, '\n');
1171
+ content = content.replace(/\n{3,}/g, '\n\n').trim();
1172
+ if (content) content += '\n';
1173
+
1174
+ // Read and add updated section
1175
+ const cliToolsUsagePath = join(homedir(), '.claude', 'workflows', 'cli-tools-usage.md');
1176
+ let cliToolsUsageContent = '';
1177
+ if (existsSync(cliToolsUsagePath)) {
1178
+ cliToolsUsageContent = readFileSync(cliToolsUsagePath, 'utf8');
1179
+ } else {
1180
+ return { error: 'CLI tools usage guidelines file not found at ~/.claude/workflows/cli-tools-usage.md', status: 404 };
1181
+ }
1182
+
1183
+ const cliToolsJsonPath = join(homedir(), '.claude', 'cli-tools.json');
1184
+ let cliToolsJsonContent = '';
1185
+ if (existsSync(cliToolsJsonPath)) {
1186
+ const cliToolsJson = JSON.parse(readFileSync(cliToolsJsonPath, 'utf8'));
1187
+ cliToolsJsonContent = `\n### CLI Tools Configuration\n\n\`\`\`json\n${JSON.stringify(cliToolsJson, null, 2)}\n\`\`\`\n`;
1188
+ }
1189
+
1190
+ const newSection = `\n## CLI 工具调用\n\n${cliToolsUsageContent}\n${cliToolsJsonContent}`;
1191
+ content = content.trimEnd() + '\n' + newSection;
1192
+
1193
+ writeFileSync(targetFile, content, 'utf8');
1194
+
1195
+ broadcastToClients({
1196
+ type: 'CLI_ENHANCEMENT_SETTING_CHANGED',
1197
+ data: { cliEnhancement: true, refreshed: true }
1198
+ });
1199
+
1200
+ return { success: true, refreshed: true };
1201
+ }
1202
+
1203
+ // Handle toggle action
1004
1204
  if (enabled) {
1005
- // Check if reference already exists
1006
- if (chineseRefPattern.test(content)) {
1205
+ // Check if section already exists
1206
+ if (isCurrentlyEnabled) {
1007
1207
  return { success: true, message: 'Already enabled' };
1008
1208
  }
1009
1209
 
1010
- // Add new section at the end of file
1011
- const newSection = `\n## 中文回复\n\n${chineseRefLine}\n`;
1210
+ // Read cli-tools-usage.md content
1211
+ const cliToolsUsagePath = join(homedir(), '.claude', 'workflows', 'cli-tools-usage.md');
1212
+ let cliToolsUsageContent = '';
1213
+ if (existsSync(cliToolsUsagePath)) {
1214
+ cliToolsUsageContent = readFileSync(cliToolsUsagePath, 'utf8');
1215
+ } else {
1216
+ return { error: 'CLI tools usage guidelines file not found at ~/.claude/workflows/cli-tools-usage.md', status: 404 };
1217
+ }
1218
+
1219
+ // Read and format cli-tools.json
1220
+ const cliToolsJsonPath = join(homedir(), '.claude', 'cli-tools.json');
1221
+ let cliToolsJsonContent = '';
1222
+ if (existsSync(cliToolsJsonPath)) {
1223
+ const cliToolsJson = JSON.parse(readFileSync(cliToolsJsonPath, 'utf8'));
1224
+ cliToolsJsonContent = `\n### CLI Tools Configuration\n\n\`\`\`json\n${JSON.stringify(cliToolsJson, null, 2)}\n\`\`\`\n`;
1225
+ }
1226
+
1227
+ // Add CLI enhancement section
1228
+ const newSection = `\n## CLI 工具调用\n\n${cliToolsUsageContent}\n${cliToolsJsonContent}`;
1012
1229
  content = content.trimEnd() + '\n' + newSection;
1013
1230
  } else {
1014
- // Remove the entire section
1015
- content = content.replace(chineseSectionPattern, '\n').replace(/\n{3,}/g, '\n\n').trim();
1231
+ // Remove CLI enhancement section
1232
+ content = content.replace(cliEnhancementSectionPattern, '\n');
1233
+ content = content.replace(/\n{3,}/g, '\n\n').trim();
1016
1234
  if (content) content += '\n';
1017
1235
  }
1018
1236
 
@@ -1020,11 +1238,11 @@ export async function handleClaudeRoutes(ctx: RouteContext): Promise<boolean> {
1020
1238
 
1021
1239
  // Broadcast update
1022
1240
  broadcastToClients({
1023
- type: 'LANGUAGE_SETTING_CHANGED',
1024
- data: { chineseResponse: enabled, target }
1241
+ type: 'CLI_ENHANCEMENT_SETTING_CHANGED',
1242
+ data: { cliEnhancement: enabled }
1025
1243
  });
1026
1244
 
1027
- return { success: true, enabled, target };
1245
+ return { success: true, enabled };
1028
1246
  } catch (error) {
1029
1247
  return { error: (error as Error).message, status: 500 };
1030
1248
  }
@@ -29,8 +29,7 @@ import {
29
29
  loadCliConfig,
30
30
  getToolConfig,
31
31
  updateToolConfig,
32
- getFullConfigResponse,
33
- PREDEFINED_MODELS
32
+ getFullConfigResponse
34
33
  } from '../../tools/cli-config-manager.js';
35
34
  import {
36
35
  loadClaudeCliTools,
@@ -303,7 +302,7 @@ export async function handleCliRoutes(ctx: RouteContext): Promise<boolean> {
303
302
  if (req.method === 'PUT') {
304
303
  handlePostRequest(req, res, async (body: unknown) => {
305
304
  try {
306
- const updates = body as { enabled?: boolean; primaryModel?: string; secondaryModel?: string; tags?: string[]; envFile?: string | null };
305
+ const updates = body as { enabled?: boolean; primaryModel?: string; secondaryModel?: string; availableModels?: string[]; tags?: string[]; envFile?: string | null };
307
306
  const updated = updateToolConfig(initialPath, tool, updates);
308
307
 
309
308
  // Broadcast config updated event