zcf 2.12.13 → 3.0.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 (67) hide show
  1. package/README.md +90 -3
  2. package/dist/chunks/codex-config-switch.mjs +419 -0
  3. package/dist/chunks/codex-uninstaller.mjs +404 -0
  4. package/dist/chunks/simple-config.mjs +1861 -374
  5. package/dist/cli.mjs +672 -206
  6. package/dist/i18n/locales/en/cli.json +1 -0
  7. package/dist/i18n/locales/en/codex.json +102 -0
  8. package/dist/i18n/locales/en/common.json +4 -1
  9. package/dist/i18n/locales/en/configuration.json +10 -4
  10. package/dist/i18n/locales/en/language.json +8 -2
  11. package/dist/i18n/locales/en/mcp.json +4 -3
  12. package/dist/i18n/locales/en/menu.json +20 -0
  13. package/dist/i18n/locales/en/uninstall.json +0 -4
  14. package/dist/i18n/locales/zh-CN/cli.json +1 -0
  15. package/dist/i18n/locales/zh-CN/codex.json +102 -0
  16. package/dist/i18n/locales/zh-CN/common.json +4 -1
  17. package/dist/i18n/locales/zh-CN/configuration.json +10 -4
  18. package/dist/i18n/locales/zh-CN/language.json +8 -2
  19. package/dist/i18n/locales/zh-CN/mcp.json +4 -3
  20. package/dist/i18n/locales/zh-CN/menu.json +20 -0
  21. package/dist/i18n/locales/zh-CN/uninstall.json +0 -4
  22. package/dist/index.d.mts +11 -3
  23. package/dist/index.d.ts +11 -3
  24. package/dist/index.mjs +2 -1
  25. package/dist/shared/zcf.DGjQxTq_.mjs +34 -0
  26. package/package.json +11 -10
  27. package/templates/{common → claude-code/common}/settings.json +2 -1
  28. package/templates/codex/common/config.toml +0 -0
  29. package/templates/codex/en/system-prompt/engineer-professional.md +87 -0
  30. package/templates/codex/en/system-prompt/laowang-engineer.md +126 -0
  31. package/templates/codex/en/system-prompt/nekomata-engineer.md +119 -0
  32. package/templates/codex/en/workflow/sixStep/prompts/workflow.md +211 -0
  33. package/templates/codex/zh-CN/system-prompt/engineer-professional.md +88 -0
  34. package/templates/codex/zh-CN/system-prompt/laowang-engineer.md +126 -0
  35. package/templates/codex/zh-CN/system-prompt/nekomata-engineer.md +119 -0
  36. package/templates/codex/zh-CN/workflow/sixStep/prompts/workflow.md +211 -0
  37. /package/templates/{CLAUDE.md → claude-code/CLAUDE.md} +0 -0
  38. /package/templates/{en → claude-code/en}/output-styles/engineer-professional.md +0 -0
  39. /package/templates/{en → claude-code/en}/output-styles/laowang-engineer.md +0 -0
  40. /package/templates/{en → claude-code/en}/output-styles/nekomata-engineer.md +0 -0
  41. /package/templates/{en → claude-code/en}/workflow/bmad/commands/bmad-init.md +0 -0
  42. /package/templates/{en → claude-code/en}/workflow/common/agents/get-current-datetime.md +0 -0
  43. /package/templates/{en → claude-code/en}/workflow/common/agents/init-architect.md +0 -0
  44. /package/templates/{en → claude-code/en}/workflow/common/commands/init-project.md +0 -0
  45. /package/templates/{en → claude-code/en}/workflow/git/commands/git-cleanBranches.md +0 -0
  46. /package/templates/{en → claude-code/en}/workflow/git/commands/git-commit.md +0 -0
  47. /package/templates/{en → claude-code/en}/workflow/git/commands/git-rollback.md +0 -0
  48. /package/templates/{en → claude-code/en}/workflow/git/commands/git-worktree.md +0 -0
  49. /package/templates/{en → claude-code/en}/workflow/plan/agents/planner.md +0 -0
  50. /package/templates/{en → claude-code/en}/workflow/plan/agents/ui-ux-designer.md +0 -0
  51. /package/templates/{en → claude-code/en}/workflow/plan/commands/feat.md +0 -0
  52. /package/templates/{en → claude-code/en}/workflow/sixStep/commands/workflow.md +0 -0
  53. /package/templates/{zh-CN → claude-code/zh-CN}/output-styles/engineer-professional.md +0 -0
  54. /package/templates/{zh-CN → claude-code/zh-CN}/output-styles/laowang-engineer.md +0 -0
  55. /package/templates/{zh-CN → claude-code/zh-CN}/output-styles/nekomata-engineer.md +0 -0
  56. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/bmad/commands/bmad-init.md +0 -0
  57. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/common/agents/get-current-datetime.md +0 -0
  58. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/common/agents/init-architect.md +0 -0
  59. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/common/commands/init-project.md +0 -0
  60. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/git/commands/git-cleanBranches.md +0 -0
  61. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/git/commands/git-commit.md +0 -0
  62. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/git/commands/git-rollback.md +0 -0
  63. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/git/commands/git-worktree.md +0 -0
  64. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/plan/agents/planner.md +0 -0
  65. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/plan/agents/ui-ux-designer.md +0 -0
  66. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/plan/commands/feat.md +0 -0
  67. /package/templates/{zh-CN → claude-code/zh-CN}/workflow/sixStep/commands/workflow.md +0 -0
@@ -0,0 +1,404 @@
1
+ import { homedir } from 'node:os';
2
+ import { pathExists } from 'fs-extra';
3
+ import { join } from 'pathe';
4
+ import { exec } from 'tinyexec';
5
+ import { W as i18n } from './simple-config.mjs';
6
+ import { m as moveToTrash } from '../shared/zcf.DGjQxTq_.mjs';
7
+ import 'node:fs';
8
+ import 'node:process';
9
+ import 'ansis';
10
+ import 'inquirer';
11
+ import 'node:child_process';
12
+ import 'node:util';
13
+ import 'dayjs';
14
+ import 'node:url';
15
+ import 'ora';
16
+ import 'semver';
17
+ import 'smol-toml';
18
+ import 'node:fs/promises';
19
+ import 'i18next';
20
+ import 'i18next-fs-backend';
21
+ import 'trash';
22
+
23
+ class CodexUninstaller {
24
+ _lang;
25
+ conflictResolution = /* @__PURE__ */ new Map();
26
+ CODEX_DIR = join(homedir(), ".codex");
27
+ CODEX_CONFIG_FILE = join(this.CODEX_DIR, "config.toml");
28
+ CODEX_AUTH_FILE = join(this.CODEX_DIR, "auth.json");
29
+ CODEX_AGENTS_FILE = join(this.CODEX_DIR, "AGENTS.md");
30
+ CODEX_PROMPTS_DIR = join(this.CODEX_DIR, "prompts");
31
+ CODEX_BACKUP_DIR = join(this.CODEX_DIR, "backup");
32
+ constructor(lang = "en") {
33
+ this._lang = lang;
34
+ this.conflictResolution.set("cli-package", ["config", "auth"]);
35
+ this.conflictResolution.set("config", ["api-config", "mcp-config"]);
36
+ void this._lang;
37
+ }
38
+ /**
39
+ * Remove config file (config.toml)
40
+ */
41
+ async removeConfig() {
42
+ const result = {
43
+ success: false,
44
+ removed: [],
45
+ removedConfigs: [],
46
+ errors: [],
47
+ warnings: []
48
+ };
49
+ try {
50
+ if (await pathExists(this.CODEX_CONFIG_FILE)) {
51
+ const trashResult = await moveToTrash(this.CODEX_CONFIG_FILE);
52
+ if (!trashResult[0]?.success) {
53
+ result.warnings.push(trashResult[0]?.error || "Failed to move to trash");
54
+ }
55
+ result.removed.push("config.toml");
56
+ result.success = true;
57
+ } else {
58
+ result.warnings.push(i18n.t("codex:configNotFound"));
59
+ result.success = true;
60
+ }
61
+ } catch (error) {
62
+ result.errors.push(`Failed to remove config: ${error.message}`);
63
+ }
64
+ return result;
65
+ }
66
+ /**
67
+ * Remove auth file (auth.json)
68
+ */
69
+ async removeAuth() {
70
+ const result = {
71
+ success: false,
72
+ removed: [],
73
+ removedConfigs: [],
74
+ errors: [],
75
+ warnings: []
76
+ };
77
+ try {
78
+ if (await pathExists(this.CODEX_AUTH_FILE)) {
79
+ const trashResult = await moveToTrash(this.CODEX_AUTH_FILE);
80
+ if (!trashResult[0]?.success) {
81
+ result.warnings.push(trashResult[0]?.error || "Failed to move to trash");
82
+ }
83
+ result.removed.push("auth.json");
84
+ result.success = true;
85
+ } else {
86
+ result.warnings.push(i18n.t("codex:authNotFound"));
87
+ result.success = true;
88
+ }
89
+ } catch (error) {
90
+ result.errors.push(`Failed to remove auth: ${error.message}`);
91
+ }
92
+ return result;
93
+ }
94
+ /**
95
+ * Remove system prompt file (AGENTS.md)
96
+ */
97
+ async removeSystemPrompt() {
98
+ const result = {
99
+ success: false,
100
+ removed: [],
101
+ removedConfigs: [],
102
+ errors: [],
103
+ warnings: []
104
+ };
105
+ try {
106
+ if (await pathExists(this.CODEX_AGENTS_FILE)) {
107
+ const trashResult = await moveToTrash(this.CODEX_AGENTS_FILE);
108
+ if (!trashResult[0]?.success) {
109
+ result.warnings.push(trashResult[0]?.error || "Failed to move to trash");
110
+ }
111
+ result.removed.push("AGENTS.md");
112
+ result.success = true;
113
+ } else {
114
+ result.warnings.push(i18n.t("codex:systemPromptNotFound"));
115
+ result.success = true;
116
+ }
117
+ } catch (error) {
118
+ result.errors.push(`Failed to remove system prompt: ${error.message}`);
119
+ }
120
+ return result;
121
+ }
122
+ /**
123
+ * Remove workflow directory (prompts/)
124
+ */
125
+ async removeWorkflow() {
126
+ const result = {
127
+ success: false,
128
+ removed: [],
129
+ removedConfigs: [],
130
+ errors: [],
131
+ warnings: []
132
+ };
133
+ try {
134
+ if (await pathExists(this.CODEX_PROMPTS_DIR)) {
135
+ const trashResult = await moveToTrash(this.CODEX_PROMPTS_DIR);
136
+ if (!trashResult[0]?.success) {
137
+ result.warnings.push(trashResult[0]?.error || "Failed to move to trash");
138
+ }
139
+ result.removed.push("prompts/");
140
+ result.success = true;
141
+ } else {
142
+ result.warnings.push(i18n.t("codex:workflowNotFound"));
143
+ result.success = true;
144
+ }
145
+ } catch (error) {
146
+ result.errors.push(`Failed to remove workflow: ${error.message}`);
147
+ }
148
+ return result;
149
+ }
150
+ /**
151
+ * Uninstall Codex CLI package
152
+ */
153
+ async uninstallCliPackage() {
154
+ const result = {
155
+ success: false,
156
+ removed: [],
157
+ removedConfigs: [],
158
+ errors: [],
159
+ warnings: []
160
+ };
161
+ try {
162
+ await exec("npm", ["uninstall", "-g", "@openai/codex"]);
163
+ result.removed.push("@openai/codex package");
164
+ result.success = true;
165
+ } catch (error) {
166
+ if (error.message.includes("not found") || error.message.includes("not installed")) {
167
+ result.warnings.push(i18n.t("codex:packageNotFound"));
168
+ result.success = true;
169
+ } else {
170
+ result.errors.push(`Failed to uninstall Codex package: ${error.message}`);
171
+ }
172
+ }
173
+ return result;
174
+ }
175
+ /**
176
+ * Remove API configuration from config.toml
177
+ */
178
+ async removeApiConfig() {
179
+ const result = {
180
+ success: false,
181
+ removed: [],
182
+ removedConfigs: [],
183
+ errors: [],
184
+ warnings: []
185
+ };
186
+ try {
187
+ if (await pathExists(this.CODEX_CONFIG_FILE)) {
188
+ const { readFileSync, writeFileSync } = await import('node:fs');
189
+ const content = readFileSync(this.CODEX_CONFIG_FILE, "utf-8");
190
+ const lines = content.split("\n");
191
+ const newLines = [];
192
+ let inProviderSection = false;
193
+ let configModified = false;
194
+ for (const line of lines) {
195
+ if (line.trim().match(/^\[model_providers\./)) {
196
+ inProviderSection = true;
197
+ configModified = true;
198
+ continue;
199
+ }
200
+ if (inProviderSection && line.trim().startsWith("[") && !line.trim().match(/^\[model_providers\./)) {
201
+ inProviderSection = false;
202
+ }
203
+ if (inProviderSection) {
204
+ continue;
205
+ }
206
+ if (line.trim().startsWith("model_provider")) {
207
+ configModified = true;
208
+ continue;
209
+ }
210
+ newLines.push(line);
211
+ }
212
+ if (configModified) {
213
+ writeFileSync(this.CODEX_CONFIG_FILE, newLines.join("\n"));
214
+ result.removedConfigs.push(i18n.t("codex:apiConfigRemoved"));
215
+ }
216
+ result.success = true;
217
+ } else {
218
+ result.warnings.push(i18n.t("codex:configNotFound"));
219
+ result.success = true;
220
+ }
221
+ } catch (error) {
222
+ result.errors.push(`Failed to remove API config: ${error.message}`);
223
+ }
224
+ return result;
225
+ }
226
+ /**
227
+ * Remove backup directory (~/.codex/backup/)
228
+ */
229
+ async removeBackups() {
230
+ const result = {
231
+ success: false,
232
+ removed: [],
233
+ removedConfigs: [],
234
+ errors: [],
235
+ warnings: []
236
+ };
237
+ try {
238
+ if (await pathExists(this.CODEX_BACKUP_DIR)) {
239
+ const trashResult = await moveToTrash(this.CODEX_BACKUP_DIR);
240
+ if (!trashResult[0]?.success) {
241
+ result.warnings.push(trashResult[0]?.error || "Failed to move backup directory to trash");
242
+ }
243
+ result.removed.push("backup/");
244
+ result.success = true;
245
+ } else {
246
+ result.warnings.push(i18n.t("codex:backupNotFound"));
247
+ result.success = true;
248
+ }
249
+ } catch (error) {
250
+ result.errors.push(`Failed to remove backups: ${error.message}`);
251
+ }
252
+ return result;
253
+ }
254
+ /**
255
+ * Remove MCP configuration from config.toml
256
+ */
257
+ async removeMcpConfig() {
258
+ const result = {
259
+ success: false,
260
+ removed: [],
261
+ removedConfigs: [],
262
+ errors: [],
263
+ warnings: []
264
+ };
265
+ try {
266
+ if (await pathExists(this.CODEX_CONFIG_FILE)) {
267
+ const { readFileSync, writeFileSync } = await import('node:fs');
268
+ const content = readFileSync(this.CODEX_CONFIG_FILE, "utf-8");
269
+ const lines = content.split("\n");
270
+ const newLines = [];
271
+ let inMcpSection = false;
272
+ let configModified = false;
273
+ for (const line of lines) {
274
+ if (line.trim().match(/^\[mcp_servers\./)) {
275
+ inMcpSection = true;
276
+ configModified = true;
277
+ continue;
278
+ }
279
+ if (inMcpSection && line.trim().startsWith("[") && !line.trim().match(/^\[mcp_servers\./)) {
280
+ inMcpSection = false;
281
+ }
282
+ if (inMcpSection) {
283
+ continue;
284
+ }
285
+ newLines.push(line);
286
+ }
287
+ if (configModified) {
288
+ writeFileSync(this.CODEX_CONFIG_FILE, newLines.join("\n"));
289
+ result.removedConfigs.push(i18n.t("codex:mcpConfigRemoved"));
290
+ }
291
+ result.success = true;
292
+ } else {
293
+ result.warnings.push(i18n.t("codex:configNotFound"));
294
+ result.success = true;
295
+ }
296
+ } catch (error) {
297
+ result.errors.push(`Failed to remove MCP config: ${error.message}`);
298
+ }
299
+ return result;
300
+ }
301
+ /**
302
+ * Complete uninstall - remove all directories and packages
303
+ */
304
+ async completeUninstall() {
305
+ const result = {
306
+ success: true,
307
+ removed: [],
308
+ removedConfigs: [],
309
+ errors: [],
310
+ warnings: []
311
+ };
312
+ try {
313
+ if (await pathExists(this.CODEX_DIR)) {
314
+ const trashResult = await moveToTrash(this.CODEX_DIR);
315
+ if (!trashResult[0]?.success) {
316
+ result.warnings.push(`Failed to move ~/.codex/ to trash: ${trashResult[0]?.error || "Unknown error"}`);
317
+ }
318
+ result.removed.push("~/.codex/");
319
+ }
320
+ const cliUninstallResult = await this.uninstallCliPackage();
321
+ result.removed.push(...cliUninstallResult.removed);
322
+ result.removedConfigs.push(...cliUninstallResult.removedConfigs);
323
+ result.errors.push(...cliUninstallResult.errors);
324
+ result.warnings.push(...cliUninstallResult.warnings);
325
+ result.success = result.success && cliUninstallResult.success;
326
+ } catch (error) {
327
+ result.errors.push(`Complete uninstall failed: ${error.message}`);
328
+ result.success = false;
329
+ }
330
+ return result;
331
+ }
332
+ /**
333
+ * Custom uninstall with conflict resolution
334
+ */
335
+ async customUninstall(selectedItems) {
336
+ const resolvedItems = this.resolveConflicts(selectedItems);
337
+ const results = [];
338
+ for (const item of resolvedItems) {
339
+ try {
340
+ const result = await this.executeUninstallItem(item);
341
+ results.push(result);
342
+ } catch (error) {
343
+ results.push({
344
+ success: false,
345
+ removed: [],
346
+ removedConfigs: [],
347
+ errors: [`Failed to execute ${item}: ${error.message}`],
348
+ warnings: []
349
+ });
350
+ }
351
+ }
352
+ return results;
353
+ }
354
+ /**
355
+ * Resolve conflicts between uninstall items
356
+ */
357
+ resolveConflicts(items) {
358
+ const resolved = [...items];
359
+ for (const [primary, conflicts] of this.conflictResolution) {
360
+ if (resolved.includes(primary)) {
361
+ conflicts.forEach((conflict) => {
362
+ const index = resolved.indexOf(conflict);
363
+ if (index > -1) {
364
+ resolved.splice(index, 1);
365
+ }
366
+ });
367
+ }
368
+ }
369
+ return resolved;
370
+ }
371
+ /**
372
+ * Execute uninstall for a specific item
373
+ */
374
+ async executeUninstallItem(item) {
375
+ switch (item) {
376
+ case "config":
377
+ return await this.removeConfig();
378
+ case "auth":
379
+ return await this.removeAuth();
380
+ case "system-prompt":
381
+ return await this.removeSystemPrompt();
382
+ case "workflow":
383
+ return await this.removeWorkflow();
384
+ case "cli-package":
385
+ return await this.uninstallCliPackage();
386
+ case "api-config":
387
+ return await this.removeApiConfig();
388
+ case "mcp-config":
389
+ return await this.removeMcpConfig();
390
+ case "backups":
391
+ return await this.removeBackups();
392
+ default:
393
+ return {
394
+ success: false,
395
+ removed: [],
396
+ removedConfigs: [],
397
+ errors: [`Unknown uninstall item: ${item}`],
398
+ warnings: []
399
+ };
400
+ }
401
+ }
402
+ }
403
+
404
+ export { CodexUninstaller };