@intra-mart/accel 0.5.0-dev.202608040843 → 0.5.0-dev.202608180918

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 (114) hide show
  1. package/README.md +33 -31
  2. package/dist/asset/deployer.d.ts +2 -0
  3. package/dist/asset/deployer.js +11 -9
  4. package/dist/asset/git-provider.d.ts +1 -0
  5. package/dist/asset/git-provider.js +20 -9
  6. package/dist/asset/updater.d.ts +9 -2
  7. package/dist/asset/updater.js +12 -6
  8. package/dist/asset/walker.d.ts +2 -1
  9. package/dist/asset/walker.js +36 -0
  10. package/dist/commands/asset-provider.d.ts +1 -1
  11. package/dist/commands/asset-provider.js +2 -2
  12. package/dist/commands/attach.d.ts +116 -82
  13. package/dist/commands/attach.js +176 -145
  14. package/dist/commands/cache.js +11 -19
  15. package/dist/commands/deploy.d.ts +53 -32
  16. package/dist/commands/deploy.js +112 -75
  17. package/dist/commands/detach.d.ts +18 -0
  18. package/dist/commands/detach.js +69 -54
  19. package/dist/commands/init.d.ts +117 -83
  20. package/dist/commands/init.js +119 -98
  21. package/dist/commands/login.d.ts +12 -10
  22. package/dist/commands/login.js +14 -10
  23. package/dist/commands/preset.js +26 -33
  24. package/dist/commands/run-wrapper.d.ts +15 -0
  25. package/dist/commands/run-wrapper.js +62 -0
  26. package/dist/commands/switch.d.ts +48 -20
  27. package/dist/commands/switch.js +201 -176
  28. package/dist/commands/update.d.ts +142 -87
  29. package/dist/commands/update.js +342 -296
  30. package/dist/core/color-env.d.ts +1 -0
  31. package/dist/core/color-env.js +6 -0
  32. package/dist/core/constants.d.ts +0 -1
  33. package/dist/core/constants.js +0 -3
  34. package/dist/core/errors.d.ts +6 -0
  35. package/dist/core/errors.js +16 -0
  36. package/dist/core/logger.d.ts +15 -0
  37. package/dist/core/logger.js +1 -0
  38. package/dist/core/paths.d.ts +6 -0
  39. package/dist/core/paths.js +22 -0
  40. package/dist/core/types.d.ts +6 -1
  41. package/dist/core/validation.d.ts +34 -0
  42. package/dist/core/validation.js +87 -0
  43. package/dist/deploy/api-client.d.ts +1 -0
  44. package/dist/deploy/api-client.js +7 -1
  45. package/dist/git/config-file.d.ts +3 -0
  46. package/dist/git/config-file.js +178 -0
  47. package/dist/git/errors.d.ts +5 -0
  48. package/dist/git/errors.js +21 -2
  49. package/dist/git/git-objects.d.ts +11 -0
  50. package/dist/git/git-objects.js +49 -0
  51. package/dist/git/http.d.ts +2 -2
  52. package/dist/git/http.js +22 -10
  53. package/dist/git/index-file.d.ts +17 -0
  54. package/dist/git/index-file.js +111 -0
  55. package/dist/git/object-cache.d.ts +1 -0
  56. package/dist/git/object-cache.js +11 -15
  57. package/dist/git/object-store.d.ts +4 -0
  58. package/dist/git/object-store.js +82 -107
  59. package/dist/git/pack-parse.d.ts +19 -0
  60. package/dist/git/pack-parse.js +261 -0
  61. package/dist/git/pack-store.d.ts +20 -0
  62. package/dist/git/pack-store.js +144 -0
  63. package/dist/git/read-capped.d.ts +1 -0
  64. package/dist/git/read-capped.js +26 -0
  65. package/dist/git/redact-url.d.ts +1 -0
  66. package/dist/git/redact-url.js +14 -0
  67. package/dist/git/repo-layout.d.ts +5 -0
  68. package/dist/git/repo-layout.js +44 -0
  69. package/dist/git/smart-http.d.ts +3 -2
  70. package/dist/git/smart-http.js +5 -5
  71. package/dist/git/untracked.d.ts +11 -0
  72. package/dist/git/untracked.js +93 -0
  73. package/dist/git/worktree-status.d.ts +4 -0
  74. package/dist/git/worktree-status.js +140 -0
  75. package/dist/git/zlib-inflate.d.ts +7 -0
  76. package/dist/git/zlib-inflate.js +78 -0
  77. package/dist/i18n/en.js +12 -0
  78. package/dist/i18n/index.js +1 -1
  79. package/dist/i18n/ja.js +12 -0
  80. package/dist/i18n/zh_CN.js +12 -0
  81. package/dist/index.d.ts +1 -1
  82. package/dist/index.js +3 -2
  83. package/dist/interactive/asset-messages.d.ts +2 -1
  84. package/dist/interactive/asset-messages.js +4 -4
  85. package/dist/interactive/clack-logger.d.ts +2 -0
  86. package/dist/interactive/clack-logger.js +11 -0
  87. package/dist/interactive/credential-auth.d.ts +2 -0
  88. package/dist/interactive/credential-auth.js +7 -6
  89. package/dist/interactive/credentials-prompts.js +10 -6
  90. package/dist/interactive/next-steps.d.ts +2 -1
  91. package/dist/interactive/next-steps.js +3 -3
  92. package/dist/interactive/progress.d.ts +8 -1
  93. package/dist/interactive/progress.js +0 -0
  94. package/dist/interactive/prompts.d.ts +3 -33
  95. package/dist/interactive/prompts.js +23 -111
  96. package/dist/interactive/summary.d.ts +2 -1
  97. package/dist/interactive/summary.js +3 -3
  98. package/dist/juggling/resolve.d.ts +7 -0
  99. package/dist/juggling/resolve.js +18 -0
  100. package/dist/lib.d.ts +34 -0
  101. package/dist/lib.js +29 -0
  102. package/dist/utils/args.d.ts +4 -1
  103. package/dist/utils/args.js +26 -3
  104. package/dist/utils/githooks-sync.d.ts +3 -1
  105. package/dist/utils/githooks-sync.js +37 -37
  106. package/dist/utils/mcp-generate.d.ts +26 -0
  107. package/dist/utils/mcp-generate.js +313 -0
  108. package/dist/utils/preset-io.d.ts +1 -0
  109. package/dist/utils/preset-io.js +5 -2
  110. package/dist/utils/settings-io.d.ts +1 -0
  111. package/dist/utils/settings-io.js +1 -1
  112. package/package.json +20 -13
  113. package/dist/utils/mcp-sync.d.ts +0 -4
  114. package/dist/utils/mcp-sync.js +0 -103
@@ -1,8 +1,12 @@
1
1
  import { defineCommand } from "citty";
2
2
  import * as p from "@clack/prompts";
3
- import { CLI_VERSION } from "../core/constants.js";
3
+ import { createCancelledError, normalizeAbort } from "../core/errors.js";
4
+ import { getCliVersion } from "../core/paths.js";
4
5
  import { findReleaseById } from "../core/catalog.js";
5
- import { collectSettingsErrors, printIntro, promptAgents, promptFeatures, promptModules, } from "../interactive/prompts.js";
6
+ import { printIntro, promptAgents, promptFeatures, promptModules, } from "../interactive/prompts.js";
7
+ import { collectSettingsErrors, } from "../core/validation.js";
8
+ import { createClackLogger } from "../interactive/clack-logger.js";
9
+ import { withExitCode } from "./run-wrapper.js";
6
10
  import { createGitAssetProvider } from "../asset/git-provider.js";
7
11
  import { applyUpdateActions, buildRenderedPlan, buildUpdatedRecords, classifySwitch, collectFileStates, } from "../asset/updater.js";
8
12
  import { createMessageCollector } from "../asset/messages.js";
@@ -12,8 +16,11 @@ import { readSettingsSafe, readHashsum, writeSettings, writeHashsum, } from "../
12
16
  import { loadAndValidatePreset, listPresetSummaries, buildPresetSelectOptions, parsePresetChoice, } from "../utils/preset-io.js";
13
17
  import { getMessage } from "../i18n/index.js";
14
18
  import { detectLocale } from "../utils/locale-detect.js";
19
+ import { generateMcpConfigsBestEffort, } from "../utils/mcp-generate.js";
20
+ import { splitList } from "../utils/args.js";
15
21
  import { printSummary } from "../interactive/summary.js";
16
- import { buildProgressCallbacks } from "../interactive/progress.js";
22
+ import { buildProgressCallbacks, resolvePathRejected, } from "../interactive/progress.js";
23
+ import { sanitizeDisplayText } from "../utils/sanitize-text.js";
17
24
  const shortSha = (sha) => sha.slice(0, 7);
18
25
  const SKIP_MESSAGE_KEYS = {
19
26
  edited: "switch.result.skippedEdited",
@@ -21,7 +28,7 @@ const SKIP_MESSAGE_KEYS = {
21
28
  "out-of-scope": "switch.result.skippedOutOfScope",
22
29
  unmanaged: "switch.result.skippedUnmanaged",
23
30
  };
24
- const printSwitchResult = (summary, actions, locale) => {
31
+ const printSwitchResult = (summary, actions, locale, logger) => {
25
32
  const lines = [
26
33
  [summary.updated, "switch.result.updated"],
27
34
  [summary.added, "switch.result.added"],
@@ -30,14 +37,14 @@ const printSwitchResult = (summary, actions, locale) => {
30
37
  ];
31
38
  for (const [paths, key] of lines) {
32
39
  for (const path of paths) {
33
- p.log.info(getMessage(key, locale, { path }));
40
+ logger.info(getMessage(key, locale, { path: sanitizeDisplayText(path) }));
34
41
  }
35
42
  }
36
43
  for (const action of actions) {
37
44
  if (action.outcome !== "skipped-switch" || !action.skipReason)
38
45
  continue;
39
- p.log.info(getMessage(SKIP_MESSAGE_KEYS[action.skipReason], locale, {
40
- path: action.relativePath,
46
+ logger.info(getMessage(SKIP_MESSAGE_KEYS[action.skipReason], locale, {
47
+ path: sanitizeDisplayText(action.relativePath),
41
48
  }));
42
49
  }
43
50
  const changedCount = summary.updated.length +
@@ -45,22 +52,194 @@ const printSwitchResult = (summary, actions, locale) => {
45
52
  summary.adopted.length +
46
53
  summary.deleted.length;
47
54
  if (changedCount === 0 && summary.skippedSwitch.length === 0) {
48
- p.log.success(getMessage("switch.upToDate", locale));
55
+ logger.success(getMessage("switch.upToDate", locale));
49
56
  }
50
57
  else {
51
- p.log.success(getMessage("switch.complete", locale, {
58
+ logger.success(getMessage("switch.complete", locale, {
52
59
  updated: String(summary.updated.length),
53
60
  added: String(summary.added.length),
54
61
  deleted: String(summary.deleted.length),
55
62
  }));
56
63
  }
57
64
  if (summary.skippedSwitch.length > 0) {
58
- const list = summary.skippedSwitch.map((c) => ` - ${c}`).join("\n");
59
- p.log.warning(`${getMessage("switch.skippedSummary", locale, {
65
+ const list = summary.skippedSwitch
66
+ .map((c) => ` - ${sanitizeDisplayText(c)}`)
67
+ .join("\n");
68
+ logger.warn(`${getMessage("switch.skippedSummary", locale, {
60
69
  count: String(summary.skippedSwitch.length),
61
70
  })}\n${list}`);
62
71
  }
63
72
  };
73
+ const defaultPrompts = {
74
+ selectPreset: async (presets, locale) => {
75
+ const choice = await p.select({
76
+ message: getMessage("preset.prompt.switchSelect", locale),
77
+ options: [
78
+ {
79
+ value: "__none__",
80
+ label: getMessage("preset.prompt.switchSelect.none", locale),
81
+ },
82
+ ...buildPresetSelectOptions(presets, locale),
83
+ ],
84
+ initialValue: "__none__",
85
+ });
86
+ if (p.isCancel(choice))
87
+ throw createCancelledError();
88
+ return parsePresetChoice(choice);
89
+ },
90
+ selectModules: promptModules,
91
+ selectFeatures: promptFeatures,
92
+ selectAgents: promptAgents,
93
+ confirmApply: async (locale) => {
94
+ const ok = await p.confirm({
95
+ message: getMessage("switch.confirmApply", locale),
96
+ });
97
+ return !p.isCancel(ok) && ok === true;
98
+ },
99
+ };
100
+ export const runSwitch = async (deps) => {
101
+ try {
102
+ await runSwitchInner(deps);
103
+ }
104
+ catch (err) {
105
+ throw normalizeAbort(err, deps.signal);
106
+ }
107
+ };
108
+ const runSwitchInner = async (deps) => {
109
+ const { projectDir } = deps;
110
+ const logger = deps.logger ?? createClackLogger();
111
+ const prompts = deps.prompts ?? defaultPrompts;
112
+ let locale = deps.locale ?? detectLocale();
113
+ const settings = await readSettingsSafe(projectDir);
114
+ if (!settings) {
115
+ throw new Error(getMessage("error.accelNotFound", locale));
116
+ }
117
+ locale = deps.locale ?? settings.locale ?? locale;
118
+ const assetSource = settings.assetSource;
119
+ if (!assetSource) {
120
+ throw new Error(getMessage("switch.error.legacyProject", locale));
121
+ }
122
+ if (assetSource.type !== "git" || !assetSource.commit || !assetSource.ref) {
123
+ throw new Error(getMessage("switch.error.notGitSource", locale));
124
+ }
125
+ const source = {
126
+ ...assetSource,
127
+ commit: assetSource.commit,
128
+ ref: assetSource.ref,
129
+ };
130
+ const isInteractive = !deps.nonInteractive;
131
+ const presetArg = deps.preset;
132
+ if (presetArg !== undefined &&
133
+ (deps.modules !== undefined ||
134
+ deps.features !== undefined ||
135
+ deps.agents !== undefined)) {
136
+ throw new Error(getMessage("preset.error.conflictingFlags", locale));
137
+ }
138
+ let presetValues;
139
+ if (presetArg !== undefined) {
140
+ presetValues = await loadAndValidatePreset(projectDir, presetArg, settings.accelplatformVersion.label, locale);
141
+ }
142
+ const cliOnlyOpts = {
143
+ module: presetValues?.modules ?? deps.modules,
144
+ feature: presetValues?.features ?? deps.features,
145
+ agent: presetValues?.agents ?? deps.agents,
146
+ locale,
147
+ isInit: false,
148
+ };
149
+ const cliErrors = collectSettingsErrors(cliOnlyOpts, locale, settings.accelplatformVersion.label);
150
+ if (cliErrors.length > 0) {
151
+ throw new Error(cliErrors.join("\n"));
152
+ }
153
+ let modules = cliOnlyOpts.module ?? settings.modules;
154
+ let features = cliOnlyOpts.feature ?? settings.features ?? [];
155
+ let agents = cliOnlyOpts.agent ?? settings.agents;
156
+ if (isInteractive) {
157
+ printIntro("switch", locale, logger);
158
+ const release = findReleaseById(settings.accelplatformVersion.label);
159
+ if (!release) {
160
+ throw new Error(getMessage("error.invalidVersion", locale, {
161
+ version: settings.accelplatformVersion.label,
162
+ }));
163
+ }
164
+ let presetSelected = presetArg !== undefined;
165
+ const cliSpecified = presetSelected ||
166
+ deps.modules !== undefined ||
167
+ deps.features !== undefined ||
168
+ deps.agents !== undefined;
169
+ if (!cliSpecified) {
170
+ const presets = await listPresetSummaries(projectDir);
171
+ if (presets.length > 0) {
172
+ const presetName = await prompts.selectPreset(presets, locale);
173
+ if (presetName !== undefined) {
174
+ const preset = await loadAndValidatePreset(projectDir, presetName, settings.accelplatformVersion.label, locale);
175
+ modules = preset.modules;
176
+ features = preset.features;
177
+ agents = preset.agents;
178
+ presetSelected = true;
179
+ }
180
+ }
181
+ }
182
+ if (!presetSelected) {
183
+ modules = await prompts.selectModules(release, modules, locale);
184
+ features = await prompts.selectFeatures(release, features, locale);
185
+ agents = await prompts.selectAgents(agents, locale);
186
+ }
187
+ }
188
+ const newSettings = {
189
+ ...settings,
190
+ cliVersion: getCliVersion(),
191
+ modules,
192
+ features,
193
+ agents,
194
+ };
195
+ if (isInteractive) {
196
+ printSummary(newSettings, projectDir, locale, logger);
197
+ if (!(await prompts.confirmApply(locale))) {
198
+ logger.info(getMessage("switch.cancelled", locale));
199
+ throw createCancelledError();
200
+ }
201
+ }
202
+ const provider = createGitAssetProvider(source.url, source.ref, {
203
+ locale,
204
+ signal: deps.signal,
205
+ });
206
+ try {
207
+ logger.info(getMessage("switch.progress", locale, { sha: shortSha(source.commit) }));
208
+ const tree = await provider.openCommit(source.commit);
209
+ const messageCollector = createMessageCollector();
210
+ const onPathRejected = resolvePathRejected(deps.progress, locale, logger);
211
+ deps.progress?.onRenderStart?.("theirs");
212
+ const theirsPlan = await buildRenderedPlan(tree, newSettings, tree.materialize, messageCollector.collect, onPathRejected);
213
+ deps.progress?.onRenderStart?.("base");
214
+ const basePlan = await buildRenderedPlan(tree, settings, tree.materialize, undefined, onPathRejected);
215
+ const oldHashsum = await readHashsum(projectDir);
216
+ const states = await collectFileStates(projectDir, basePlan, theirsPlan, oldHashsum);
217
+ deps.progress?.onClassifyStart?.(states.length);
218
+ const actions = classifySwitch(states);
219
+ const summary = await applyUpdateActions(projectDir, actions, deps.progress);
220
+ const { hashEntries, deployedAssets } = buildUpdatedRecords(oldHashsum, actions);
221
+ await writeSettings(projectDir, { ...newSettings, deployedAssets });
222
+ await writeHashsum(projectDir, hashEntries);
223
+ await generateMcpConfigsBestEffort(projectDir, logger, deps.generateMcpConfigs);
224
+ printAssetMessages(messageCollector.drain(), logger);
225
+ const changedPaths = actions
226
+ .filter((a) => a.op !== "none")
227
+ .map((a) => a.relativePath);
228
+ if (!deps.skipInstall && installTriggerChanged(changedPaths)) {
229
+ const { success } = runInstallBuild(projectDir, newSettings.packageManager, buildProgressCallbacks(locale, logger));
230
+ if (!success && summary.skippedSwitch.length > 0) {
231
+ const list = summary.skippedSwitch
232
+ .map((c) => ` - ${sanitizeDisplayText(c)}`)
233
+ .join("\n");
234
+ logger.warn(`${getMessage("switch.installFailedHint", locale)}\n${list}`);
235
+ }
236
+ }
237
+ printSwitchResult(summary, actions, locale, logger);
238
+ }
239
+ finally {
240
+ await provider.cleanup().catch(() => { });
241
+ }
242
+ };
64
243
  export const switchCommand = defineCommand({
65
244
  meta: {
66
245
  name: "switch",
@@ -94,169 +273,15 @@ export const switchCommand = defineCommand({
94
273
  default: false,
95
274
  },
96
275
  },
97
- run: async ({ args }) => {
98
- const projectDir = process.cwd();
99
- let locale = detectLocale();
100
- const settings = await readSettingsSafe(projectDir);
101
- if (!settings) {
102
- p.log.error(getMessage("error.accelNotFound", locale));
103
- process.exit(1);
104
- }
105
- locale = settings.locale ?? locale;
106
- const assetSource = settings.assetSource;
107
- if (!assetSource) {
108
- p.log.error(getMessage("switch.error.legacyProject", locale));
109
- process.exit(1);
110
- }
111
- if (assetSource.type !== "git" || !assetSource.commit || !assetSource.ref) {
112
- p.log.error(getMessage("switch.error.notGitSource", locale));
113
- process.exit(1);
114
- }
115
- const source = {
116
- ...assetSource,
117
- commit: assetSource.commit,
118
- ref: assetSource.ref,
119
- };
120
- const isInteractive = !args["non-interactive"];
121
- const presetArg = args.preset;
122
- if (presetArg !== undefined &&
123
- (args.module !== undefined ||
124
- args.feature !== undefined ||
125
- args.agent !== undefined)) {
126
- p.log.error(getMessage("preset.error.conflictingFlags", locale));
127
- process.exit(1);
128
- }
129
- let presetValues;
130
- if (presetArg !== undefined) {
131
- try {
132
- presetValues = await loadAndValidatePreset(projectDir, presetArg, settings.accelplatformVersion.label, locale);
133
- }
134
- catch (err) {
135
- p.log.error(err instanceof Error ? err.message : String(err));
136
- process.exit(1);
137
- }
138
- }
139
- const cliOnlyOpts = {
140
- module: presetValues?.modules ??
141
- args.module?.split(",").map((m) => m.trim()),
142
- feature: presetValues?.features ??
143
- args.feature?.split(",").map((f) => f.trim()),
144
- agent: presetValues?.agents ??
145
- args.agent?.split(",").map((a) => a.trim()),
146
- locale,
147
- isInit: false,
148
- };
149
- const cliErrors = collectSettingsErrors(cliOnlyOpts, locale, settings.accelplatformVersion.label);
150
- if (cliErrors.length > 0) {
151
- p.log.error(cliErrors.join("\n"));
152
- process.exit(1);
153
- }
154
- let modules = cliOnlyOpts.module ?? settings.modules;
155
- let features = cliOnlyOpts.feature ?? settings.features ?? [];
156
- let agents = cliOnlyOpts.agent ?? settings.agents;
157
- if (isInteractive) {
158
- printIntro("switch", locale);
159
- const release = findReleaseById(settings.accelplatformVersion.label);
160
- if (!release) {
161
- p.log.error(getMessage("error.invalidVersion", locale, {
162
- version: settings.accelplatformVersion.label,
163
- }));
164
- process.exit(1);
165
- }
166
- let presetSelected = presetArg !== undefined;
167
- const cliSpecified = presetSelected ||
168
- args.module !== undefined ||
169
- args.feature !== undefined ||
170
- args.agent !== undefined;
171
- if (!cliSpecified) {
172
- const presets = await listPresetSummaries(projectDir);
173
- if (presets.length > 0) {
174
- const choice = await p.select({
175
- message: getMessage("preset.prompt.switchSelect", locale),
176
- options: [
177
- {
178
- value: "__none__",
179
- label: getMessage("preset.prompt.switchSelect.none", locale),
180
- },
181
- ...buildPresetSelectOptions(presets, locale),
182
- ],
183
- initialValue: "__none__",
184
- });
185
- if (p.isCancel(choice))
186
- process.exit(0);
187
- const presetName = parsePresetChoice(choice);
188
- if (presetName !== undefined) {
189
- try {
190
- const preset = await loadAndValidatePreset(projectDir, presetName, settings.accelplatformVersion.label, locale);
191
- modules = preset.modules;
192
- features = preset.features;
193
- agents = preset.agents;
194
- presetSelected = true;
195
- }
196
- catch (err) {
197
- p.log.error(err instanceof Error ? err.message : String(err));
198
- process.exit(1);
199
- }
200
- }
201
- }
202
- }
203
- if (!presetSelected) {
204
- modules = await promptModules(release, modules, locale);
205
- features = await promptFeatures(release, features, locale);
206
- agents = await promptAgents(agents, locale);
207
- }
208
- }
209
- const newSettings = {
210
- ...settings,
211
- cliVersion: CLI_VERSION,
212
- modules,
213
- features,
214
- agents,
215
- };
216
- if (isInteractive) {
217
- printSummary(newSettings, projectDir, locale);
218
- const ok = await p.confirm({
219
- message: getMessage("switch.confirmApply", locale),
220
- });
221
- if (p.isCancel(ok) || ok !== true) {
222
- p.log.info(getMessage("switch.cancelled", locale));
223
- process.exit(0);
224
- }
225
- }
226
- const provider = createGitAssetProvider(source.url, source.ref, { locale });
227
- try {
228
- p.log.info(getMessage("switch.progress", locale, { sha: shortSha(source.commit) }));
229
- const tree = await provider.openCommit(source.commit);
230
- const messageCollector = createMessageCollector();
231
- const theirsPlan = await buildRenderedPlan(tree, newSettings, tree.materialize, messageCollector.collect);
232
- const basePlan = await buildRenderedPlan(tree, settings, tree.materialize);
233
- const oldHashsum = await readHashsum(projectDir);
234
- const states = await collectFileStates(projectDir, basePlan, theirsPlan, oldHashsum);
235
- const actions = classifySwitch(states);
236
- const summary = await applyUpdateActions(projectDir, actions);
237
- const { hashEntries, deployedAssets } = buildUpdatedRecords(oldHashsum, actions);
238
- await writeSettings(projectDir, { ...newSettings, deployedAssets });
239
- await writeHashsum(projectDir, hashEntries);
240
- printAssetMessages(messageCollector.drain());
241
- const skipInstall = args["skip-install"];
242
- const changedPaths = actions
243
- .filter((a) => a.op !== "none")
244
- .map((a) => a.relativePath);
245
- if (!skipInstall && installTriggerChanged(changedPaths)) {
246
- const { success } = runInstallBuild(projectDir, newSettings.packageManager, buildProgressCallbacks(locale));
247
- if (!success && summary.skippedSwitch.length > 0) {
248
- const list = summary.skippedSwitch.map((c) => ` - ${c}`).join("\n");
249
- p.log.warning(`${getMessage("switch.installFailedHint", locale)}\n${list}`);
250
- }
251
- }
252
- printSwitchResult(summary, actions, locale);
253
- }
254
- catch (err) {
255
- p.log.error(err instanceof Error ? err.message : String(err));
256
- process.exit(1);
257
- }
258
- finally {
259
- await provider.cleanup().catch(() => { });
260
- }
261
- },
276
+ run: withExitCode(async ({ args }) => {
277
+ await runSwitch({
278
+ projectDir: process.cwd(),
279
+ nonInteractive: args["non-interactive"],
280
+ modules: splitList(args.module),
281
+ features: splitList(args.feature),
282
+ agents: splitList(args.agent),
283
+ preset: args.preset,
284
+ skipInstall: args["skip-install"],
285
+ });
286
+ }),
262
287
  });
@@ -1,90 +1,145 @@
1
+ import { type PromptOptions, type ResolvedOptions } from "../core/validation.js";
2
+ import type { Logger } from "../core/logger.js";
3
+ import { type UpdaterProgressCallbacks } from "../asset/updater.js";
4
+ import { type PresetSummary } from "../utils/preset-io.js";
5
+ import { type generateMcpConfigs } from "../utils/mcp-generate.js";
6
+ export declare const createUpdateFallbackAbortedError: () => Error;
7
+ export declare const isUpdateFallbackAbortedError: (err: unknown) => err is Error;
8
+ export type FallbackMode = "abort" | "conflict" | "keep";
9
+ export type SettingsSourceChoice = {
10
+ kind: "existing";
11
+ } | {
12
+ kind: "reenter";
13
+ } | {
14
+ kind: "preset";
15
+ name: string;
16
+ };
17
+ export type UpdatePrompts = {
18
+ confirmDirtyWorktree: (locale: string) => Promise<boolean>;
19
+ selectFallbackMode: (info: {
20
+ editedCount: number;
21
+ }, locale: string) => Promise<FallbackMode>;
22
+ selectSettingsSource: (presets: PresetSummary[], locale: string) => Promise<SettingsSourceChoice>;
23
+ confirmApply: (locale: string) => Promise<boolean>;
24
+ reenterSettings: (opts: PromptOptions) => Promise<ResolvedOptions>;
25
+ };
26
+ export type RunUpdateDeps = {
27
+ projectDir: string;
28
+ locale?: string;
29
+ nonInteractive?: boolean;
30
+ name?: string;
31
+ artifactId?: string;
32
+ jugglingProject?: string;
33
+ accelplatformVersion?: string;
34
+ modules?: string[];
35
+ features?: string[];
36
+ agents?: string[];
37
+ group?: string;
38
+ projectVersion?: string;
39
+ description?: string;
40
+ database?: string;
41
+ javascript?: boolean;
42
+ packageManager?: string;
43
+ preset?: string;
44
+ skipInstall?: boolean;
45
+ assetServerUrl?: string;
46
+ assetRef?: string;
47
+ allowMissingBase?: boolean;
48
+ keepEdited?: boolean;
49
+ logger?: Logger;
50
+ prompts?: UpdatePrompts;
51
+ progress?: UpdaterProgressCallbacks;
52
+ signal?: AbortSignal;
53
+ generateMcpConfigs?: typeof generateMcpConfigs;
54
+ };
55
+ export declare const runUpdate: (deps: RunUpdateDeps) => Promise<void>;
1
56
  export declare const updateCommand: import("citty").CommandDef<{
2
- "juggling-project": {
3
- type: "string";
4
- description: string;
5
- };
6
- "accelplatform-version": {
7
- type: "string";
8
- description: string;
9
- };
10
- module: {
11
- type: "string";
12
- description: string;
13
- };
14
- feature: {
15
- type: "string";
16
- description: string;
17
- };
18
- name: {
19
- type: "string";
20
- description: string;
21
- };
22
- group: {
23
- type: "string";
24
- description: string;
25
- };
26
- "project-version": {
27
- type: "string";
28
- description: string;
29
- };
30
- description: {
31
- type: "string";
32
- description: string;
33
- };
34
- database: {
35
- type: "string";
36
- description: string;
37
- };
38
- javascript: {
39
- type: "boolean";
40
- description: string;
41
- };
42
- agent: {
43
- type: "string";
44
- description: string;
45
- };
46
- preset: {
47
- type: "string";
48
- description: string;
49
- };
50
- locale: {
51
- type: "string";
52
- description: string;
53
- };
54
- "artifact-id": {
55
- type: "string";
56
- description: string;
57
- };
58
- "package-manager": {
59
- type: "string";
60
- description: string;
61
- };
62
- "skip-install": {
63
- type: "boolean";
64
- description: string;
65
- default: false;
66
- };
67
- "non-interactive": {
68
- type: "boolean";
69
- description: string;
70
- default: false;
71
- };
72
- "asset-server-url": {
73
- type: "string";
74
- description: string;
75
- };
76
- "asset-ref": {
77
- type: "string";
78
- description: string;
79
- };
80
- "allow-missing-base": {
81
- type: "boolean";
82
- description: string;
83
- default: false;
84
- };
85
- "keep-edited": {
86
- type: "boolean";
87
- description: string;
88
- default: false;
57
+ readonly "juggling-project": {
58
+ readonly type: "string";
59
+ readonly description: "Path to IM-Juggling project";
60
+ };
61
+ readonly "accelplatform-version": {
62
+ readonly type: "string";
63
+ readonly description: "iAP version (e.g., 2026-spring)";
64
+ };
65
+ readonly module: {
66
+ readonly type: "string";
67
+ readonly description: "Modules to use (comma-separated artifactIds, e.g., im_workflow)";
68
+ };
69
+ readonly feature: {
70
+ readonly type: "string";
71
+ readonly description: "Features to use (comma-separated function ids, e.g., jssp)";
72
+ };
73
+ readonly name: {
74
+ readonly type: "string";
75
+ readonly description: "Project name";
76
+ };
77
+ readonly group: {
78
+ readonly type: "string";
79
+ readonly description: "Group name";
80
+ };
81
+ readonly "project-version": {
82
+ readonly type: "string";
83
+ readonly description: "Project version";
84
+ };
85
+ readonly description: {
86
+ readonly type: "string";
87
+ readonly description: "Project description";
88
+ };
89
+ readonly database: {
90
+ readonly type: "string";
91
+ readonly description: "Database type";
92
+ };
93
+ readonly javascript: {
94
+ readonly type: "boolean";
95
+ readonly description: "Use JavaScript";
96
+ };
97
+ readonly agent: {
98
+ readonly type: "string";
99
+ readonly description: "Agent type";
100
+ };
101
+ readonly preset: {
102
+ readonly type: "string";
103
+ readonly description: "Configuration preset name to apply (mutually exclusive with --module / --feature / --agent)";
104
+ };
105
+ readonly locale: {
106
+ readonly type: "string";
107
+ readonly description: "Locale (ja, en, zh_CN)";
108
+ };
109
+ readonly "artifact-id": {
110
+ readonly type: "string";
111
+ readonly description: "Maven artifactId";
112
+ };
113
+ readonly "package-manager": {
114
+ readonly type: "string";
115
+ readonly description: "Package manager (bun, npm, yarn, pnpm)";
116
+ };
117
+ readonly "skip-install": {
118
+ readonly type: "boolean";
119
+ readonly description: "Skip dependency installation after the update";
120
+ readonly default: false;
121
+ };
122
+ readonly "non-interactive": {
123
+ readonly type: "boolean";
124
+ readonly description: "Non-interactive mode";
125
+ readonly default: false;
126
+ };
127
+ readonly "asset-server-url": {
128
+ readonly type: "string";
129
+ readonly description: "Git repository URL to fetch assets from (overrides the recorded assetSource)";
130
+ };
131
+ readonly "asset-ref": {
132
+ readonly type: "string";
133
+ readonly description: "Git branch/tag to fetch from the asset repository (overrides the recorded assetSource)";
134
+ };
135
+ readonly "allow-missing-base": {
136
+ readonly type: "boolean";
137
+ readonly description: "Continue in fallback mode when the recorded base commit cannot be fetched";
138
+ readonly default: false;
139
+ };
140
+ readonly "keep-edited": {
141
+ readonly type: "boolean";
142
+ readonly description: "In fallback mode, keep edited files and skip them instead of inserting conflict markers (requires --allow-missing-base)";
143
+ readonly default: false;
89
144
  };
90
145
  }>;