zcf 3.1.3 → 3.2.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 (37) hide show
  1. package/README.md +50 -21
  2. package/dist/chunks/claude-code-config-manager.mjs +705 -0
  3. package/dist/chunks/claude-code-incremental-manager.mjs +393 -0
  4. package/dist/chunks/codex-config-switch.mjs +2 -174
  5. package/dist/chunks/codex-provider-manager.mjs +193 -0
  6. package/dist/chunks/codex-uninstaller.mjs +1 -1
  7. package/dist/chunks/commands.mjs +117 -0
  8. package/dist/chunks/simple-config.mjs +578 -193
  9. package/dist/cli.mjs +284 -142
  10. package/dist/i18n/locales/en/api.json +1 -2
  11. package/dist/i18n/locales/en/cli.json +2 -0
  12. package/dist/i18n/locales/en/codex.json +0 -1
  13. package/dist/i18n/locales/en/common.json +2 -2
  14. package/dist/i18n/locales/en/errors.json +1 -0
  15. package/dist/i18n/locales/en/multi-config.json +61 -0
  16. package/dist/i18n/locales/zh-CN/api.json +1 -2
  17. package/dist/i18n/locales/zh-CN/cli.json +2 -0
  18. package/dist/i18n/locales/zh-CN/codex.json +0 -1
  19. package/dist/i18n/locales/zh-CN/common.json +2 -2
  20. package/dist/i18n/locales/zh-CN/errors.json +1 -0
  21. package/dist/i18n/locales/zh-CN/multi-config.json +61 -0
  22. package/dist/index.d.mts +6 -2
  23. package/dist/index.d.ts +6 -2
  24. package/dist/index.mjs +1 -1
  25. package/package.json +1 -1
  26. package/templates/claude-code/en/workflow/git/commands/git-commit.md +1 -0
  27. package/templates/claude-code/zh-CN/workflow/git/commands/git-commit.md +1 -0
  28. package/templates/codex/en/workflow/git/prompts/git-cleanBranches.md +102 -0
  29. package/templates/codex/en/workflow/git/prompts/git-commit.md +158 -0
  30. package/templates/codex/en/workflow/git/prompts/git-rollback.md +90 -0
  31. package/templates/codex/en/workflow/git/prompts/git-worktree.md +276 -0
  32. package/templates/codex/en/workflow/sixStep/prompts/workflow.md +140 -121
  33. package/templates/codex/zh-CN/workflow/git/prompts/git-cleanBranches.md +102 -0
  34. package/templates/codex/zh-CN/workflow/git/prompts/git-commit.md +158 -0
  35. package/templates/codex/zh-CN/workflow/git/prompts/git-rollback.md +90 -0
  36. package/templates/codex/zh-CN/workflow/git/prompts/git-worktree.md +276 -0
  37. package/templates/codex/zh-CN/workflow/sixStep/prompts/workflow.md +16 -33
@@ -0,0 +1,193 @@
1
+ import { ae as readCodexConfig, af as backupCodexComplete, ag as writeCodexConfig, ah as writeAuthFile } from './simple-config.mjs';
2
+ import 'node:fs';
3
+ import 'node:process';
4
+ import 'ansis';
5
+ import 'inquirer';
6
+ import 'node:child_process';
7
+ import 'node:os';
8
+ import 'node:util';
9
+ import 'dayjs';
10
+ import 'pathe';
11
+ import 'node:url';
12
+ import 'ora';
13
+ import 'semver';
14
+ import 'smol-toml';
15
+ import 'tinyexec';
16
+ import 'node:fs/promises';
17
+ import 'i18next';
18
+ import 'i18next-fs-backend';
19
+
20
+ const ERROR_MESSAGES = {
21
+ NO_CONFIG: "No existing configuration found",
22
+ BACKUP_FAILED: "Failed to create backup",
23
+ PROVIDER_EXISTS: (id) => `Provider with ID "${id}" already exists`,
24
+ PROVIDER_NOT_FOUND: (id) => `Provider with ID "${id}" not found`,
25
+ NO_PROVIDERS_SPECIFIED: "No providers specified for deletion",
26
+ PROVIDERS_NOT_FOUND: (providers) => `Some providers not found: ${providers.join(", ")}`,
27
+ CANNOT_DELETE_ALL: "Cannot delete all providers. At least one provider must remain."
28
+ };
29
+ async function addProviderToExisting(provider, apiKey) {
30
+ try {
31
+ const existingConfig = readCodexConfig();
32
+ if (!existingConfig) {
33
+ return {
34
+ success: false,
35
+ error: ERROR_MESSAGES.NO_CONFIG
36
+ };
37
+ }
38
+ const existingProvider = existingConfig.providers.find((p) => p.id === provider.id);
39
+ if (existingProvider) {
40
+ return {
41
+ success: false,
42
+ error: ERROR_MESSAGES.PROVIDER_EXISTS(provider.id)
43
+ };
44
+ }
45
+ const backupPath = backupCodexComplete();
46
+ if (!backupPath) {
47
+ return {
48
+ success: false,
49
+ error: ERROR_MESSAGES.BACKUP_FAILED
50
+ };
51
+ }
52
+ const updatedConfig = {
53
+ ...existingConfig,
54
+ providers: [...existingConfig.providers, provider]
55
+ };
56
+ writeCodexConfig(updatedConfig);
57
+ const authEntries = {};
58
+ authEntries[provider.envKey] = apiKey;
59
+ writeAuthFile(authEntries);
60
+ return {
61
+ success: true,
62
+ backupPath,
63
+ addedProvider: provider
64
+ };
65
+ } catch (error) {
66
+ return {
67
+ success: false,
68
+ error: error instanceof Error ? error.message : "Unknown error"
69
+ };
70
+ }
71
+ }
72
+ async function editExistingProvider(providerId, updates) {
73
+ try {
74
+ const existingConfig = readCodexConfig();
75
+ if (!existingConfig) {
76
+ return {
77
+ success: false,
78
+ error: ERROR_MESSAGES.NO_CONFIG
79
+ };
80
+ }
81
+ const providerIndex = existingConfig.providers.findIndex((p) => p.id === providerId);
82
+ if (providerIndex === -1) {
83
+ return {
84
+ success: false,
85
+ error: ERROR_MESSAGES.PROVIDER_NOT_FOUND(providerId)
86
+ };
87
+ }
88
+ const backupPath = backupCodexComplete();
89
+ if (!backupPath) {
90
+ return {
91
+ success: false,
92
+ error: ERROR_MESSAGES.BACKUP_FAILED
93
+ };
94
+ }
95
+ const updatedProvider = {
96
+ ...existingConfig.providers[providerIndex],
97
+ ...updates.name && { name: updates.name },
98
+ ...updates.baseUrl && { baseUrl: updates.baseUrl },
99
+ ...updates.wireApi && { wireApi: updates.wireApi }
100
+ };
101
+ const updatedProviders = [...existingConfig.providers];
102
+ updatedProviders[providerIndex] = updatedProvider;
103
+ const updatedConfig = {
104
+ ...existingConfig,
105
+ providers: updatedProviders
106
+ };
107
+ writeCodexConfig(updatedConfig);
108
+ if (updates.apiKey) {
109
+ const authEntries = {};
110
+ authEntries[updatedProvider.envKey] = updates.apiKey;
111
+ writeAuthFile(authEntries);
112
+ }
113
+ return {
114
+ success: true,
115
+ backupPath,
116
+ updatedProvider
117
+ };
118
+ } catch (error) {
119
+ return {
120
+ success: false,
121
+ error: error instanceof Error ? error.message : "Unknown error"
122
+ };
123
+ }
124
+ }
125
+ async function deleteProviders(providerIds) {
126
+ try {
127
+ const existingConfig = readCodexConfig();
128
+ if (!existingConfig) {
129
+ return {
130
+ success: false,
131
+ error: ERROR_MESSAGES.NO_CONFIG
132
+ };
133
+ }
134
+ if (!providerIds || providerIds.length === 0) {
135
+ return {
136
+ success: false,
137
+ error: ERROR_MESSAGES.NO_PROVIDERS_SPECIFIED
138
+ };
139
+ }
140
+ const notFoundProviders = providerIds.filter(
141
+ (id) => !existingConfig.providers.some((p) => p.id === id)
142
+ );
143
+ if (notFoundProviders.length > 0) {
144
+ return {
145
+ success: false,
146
+ error: ERROR_MESSAGES.PROVIDERS_NOT_FOUND(notFoundProviders)
147
+ };
148
+ }
149
+ const remainingProviders = existingConfig.providers.filter(
150
+ (p) => !providerIds.includes(p.id)
151
+ );
152
+ if (remainingProviders.length === 0) {
153
+ return {
154
+ success: false,
155
+ error: ERROR_MESSAGES.CANNOT_DELETE_ALL
156
+ };
157
+ }
158
+ const backupPath = backupCodexComplete();
159
+ if (!backupPath) {
160
+ return {
161
+ success: false,
162
+ error: ERROR_MESSAGES.BACKUP_FAILED
163
+ };
164
+ }
165
+ let newDefaultProvider = existingConfig.modelProvider;
166
+ if (providerIds.includes(existingConfig.modelProvider || "")) {
167
+ newDefaultProvider = remainingProviders[0].id;
168
+ }
169
+ const updatedConfig = {
170
+ ...existingConfig,
171
+ modelProvider: newDefaultProvider,
172
+ providers: remainingProviders
173
+ };
174
+ writeCodexConfig(updatedConfig);
175
+ const result = {
176
+ success: true,
177
+ backupPath,
178
+ deletedProviders: providerIds,
179
+ remainingProviders
180
+ };
181
+ if (newDefaultProvider !== existingConfig.modelProvider) {
182
+ result.newDefaultProvider = newDefaultProvider || void 0;
183
+ }
184
+ return result;
185
+ } catch (error) {
186
+ return {
187
+ success: false,
188
+ error: error instanceof Error ? error.message : "Unknown error"
189
+ };
190
+ }
191
+ }
192
+
193
+ export { addProviderToExisting, deleteProviders, editExistingProvider };
@@ -2,7 +2,7 @@ import { homedir } from 'node:os';
2
2
  import { pathExists } from 'fs-extra';
3
3
  import { join } from 'pathe';
4
4
  import { exec } from 'tinyexec';
5
- import { a0 as i18n } from './simple-config.mjs';
5
+ import { a3 as i18n } from './simple-config.mjs';
6
6
  import { m as moveToTrash } from '../shared/zcf.DGjQxTq_.mjs';
7
7
  import 'node:fs';
8
8
  import 'node:process';
@@ -0,0 +1,117 @@
1
+ import { exec } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ import ansis from 'ansis';
4
+ import { a2 as ensureI18nInitialized, a3 as i18n } from './simple-config.mjs';
5
+ import 'node:fs';
6
+ import 'node:process';
7
+ import 'inquirer';
8
+ import 'node:os';
9
+ import 'dayjs';
10
+ import 'pathe';
11
+ import 'node:url';
12
+ import 'ora';
13
+ import 'semver';
14
+ import 'smol-toml';
15
+ import 'tinyexec';
16
+ import 'node:fs/promises';
17
+ import 'i18next';
18
+ import 'i18next-fs-backend';
19
+
20
+ const execAsync = promisify(exec);
21
+ async function runCcrUi(apiKey) {
22
+ ensureI18nInitialized();
23
+ console.log(ansis.cyan(`
24
+ \u{1F5A5}\uFE0F ${i18n.t("ccr:startingCcrUi")}`));
25
+ if (apiKey) {
26
+ console.log(ansis.bold.green(`
27
+ \u{1F511} ${i18n.t("ccr:ccrUiApiKey") || "CCR UI API Key"}: ${apiKey}`));
28
+ console.log(ansis.gray(` ${i18n.t("ccr:ccrUiApiKeyHint") || "Use this API key to login to CCR UI"}
29
+ `));
30
+ }
31
+ try {
32
+ const { stdout, stderr } = await execAsync("ccr ui");
33
+ if (stdout)
34
+ console.log(stdout);
35
+ if (stderr)
36
+ console.error(ansis.yellow(stderr));
37
+ console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrUiStarted")}`));
38
+ } catch (error) {
39
+ console.error(ansis.red(`\u2716 ${i18n.t("ccr:ccrCommandFailed")}: ${error instanceof Error ? error.message : String(error)}`));
40
+ throw error;
41
+ }
42
+ }
43
+ async function runCcrStatus() {
44
+ ensureI18nInitialized();
45
+ console.log(ansis.cyan(`
46
+ \u{1F4CA} ${i18n.t("ccr:checkingCcrStatus")}`));
47
+ try {
48
+ const { stdout, stderr } = await execAsync("ccr status");
49
+ if (stdout) {
50
+ console.log(`
51
+ ${ansis.bold(i18n.t("ccr:ccrStatusTitle"))}`);
52
+ console.log(stdout);
53
+ }
54
+ if (stderr)
55
+ console.error(ansis.yellow(stderr));
56
+ } catch (error) {
57
+ console.error(ansis.red(`\u2716 ${i18n.t("ccr:ccrCommandFailed")}: ${error instanceof Error ? error.message : String(error)}`));
58
+ throw error;
59
+ }
60
+ }
61
+ async function runCcrRestart() {
62
+ ensureI18nInitialized();
63
+ console.log(ansis.cyan(`
64
+ \u{1F504} ${i18n.t("ccr:restartingCcr")}`));
65
+ try {
66
+ const { stdout, stderr } = await execAsync("ccr restart");
67
+ if (stdout)
68
+ console.log(stdout);
69
+ if (stderr)
70
+ console.error(ansis.yellow(stderr));
71
+ console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrRestarted")}`));
72
+ } catch (error) {
73
+ console.error(ansis.red(`\u2716 ${i18n.t("ccr:ccrCommandFailed")}: ${error instanceof Error ? error.message : String(error)}`));
74
+ throw error;
75
+ }
76
+ }
77
+ async function runCcrStart() {
78
+ ensureI18nInitialized();
79
+ console.log(ansis.cyan(`
80
+ \u25B6\uFE0F ${i18n.t("ccr:startingCcr")}`));
81
+ try {
82
+ const { stdout, stderr } = await execAsync("ccr start");
83
+ if (stdout)
84
+ console.log(stdout);
85
+ if (stderr)
86
+ console.error(ansis.yellow(stderr));
87
+ console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrStarted")}`));
88
+ } catch (error) {
89
+ if (error.stdout && error.stdout.includes("Loaded JSON config from:")) {
90
+ console.log(error.stdout);
91
+ if (error.stderr)
92
+ console.error(ansis.yellow(error.stderr));
93
+ console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrStarted")}`));
94
+ } else {
95
+ console.error(ansis.red(`\u2716 ${i18n.t("ccr:ccrCommandFailed")}: ${error instanceof Error ? error.message : String(error)}`));
96
+ throw error;
97
+ }
98
+ }
99
+ }
100
+ async function runCcrStop() {
101
+ ensureI18nInitialized();
102
+ console.log(ansis.cyan(`
103
+ \u23F9\uFE0F ${i18n.t("ccr:stoppingCcr")}`));
104
+ try {
105
+ const { stdout, stderr } = await execAsync("ccr stop");
106
+ if (stdout)
107
+ console.log(stdout);
108
+ if (stderr)
109
+ console.error(ansis.yellow(stderr));
110
+ console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrStopped")}`));
111
+ } catch (error) {
112
+ console.error(ansis.red(`\u2716 ${i18n.t("ccr:ccrCommandFailed")}: ${error instanceof Error ? error.message : String(error)}`));
113
+ throw error;
114
+ }
115
+ }
116
+
117
+ export { runCcrRestart, runCcrStart, runCcrStatus, runCcrStop, runCcrUi };