@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,85 +1,119 @@
1
+ import type { Logger } from "../core/logger.js";
2
+ import type { PromptOptions, ResolvedOptions } from "../core/validation.js";
3
+ import { type DeployResult, type ExistingFileHandler, type ProgressCallbacks } from "../asset/deployer.js";
4
+ import { type generateMcpConfigs } from "../utils/mcp-generate.js";
5
+ export type RunAttachDeps = {
6
+ projectDir: string;
7
+ locale?: string;
8
+ nonInteractive?: boolean;
9
+ name?: string;
10
+ artifactId?: string;
11
+ jugglingProject?: string;
12
+ accelplatformVersion?: string;
13
+ modules?: string[];
14
+ features?: string[];
15
+ group?: string;
16
+ projectVersion?: string;
17
+ description?: string;
18
+ database?: string;
19
+ javascript?: boolean;
20
+ agents?: string[];
21
+ packageManager?: string;
22
+ overwrite?: boolean;
23
+ skipInstall?: boolean;
24
+ assetServerUrl?: string;
25
+ assetRef?: string;
26
+ assetSource?: string;
27
+ logger?: Logger;
28
+ progress?: ProgressCallbacks;
29
+ signal?: AbortSignal;
30
+ resolveOptions?: (opts: PromptOptions) => Promise<ResolvedOptions>;
31
+ onExistingFile?: ExistingFileHandler;
32
+ generateMcpConfigs?: typeof generateMcpConfigs;
33
+ };
34
+ export declare const runAttach: (deps: RunAttachDeps) => Promise<DeployResult>;
1
35
  export declare const attachCommand: 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
- locale: {
47
- type: "string";
48
- description: string;
49
- };
50
- "artifact-id": {
51
- type: "string";
52
- description: string;
53
- };
54
- "package-manager": {
55
- type: "string";
56
- description: string;
57
- };
58
- overwrite: {
59
- type: "boolean";
60
- description: string;
61
- default: false;
62
- };
63
- "skip-install": {
64
- type: "boolean";
65
- description: string;
66
- default: false;
67
- };
68
- "non-interactive": {
69
- type: "boolean";
70
- description: string;
71
- default: false;
72
- };
73
- "asset-server-url": {
74
- type: "string";
75
- description: string;
76
- };
77
- "asset-ref": {
78
- type: "string";
79
- description: string;
80
- };
81
- "asset-source": {
82
- type: "string";
83
- description: string;
36
+ readonly "juggling-project": {
37
+ readonly type: "string";
38
+ readonly description: "Path to IM-Juggling project";
39
+ };
40
+ readonly "accelplatform-version": {
41
+ readonly type: "string";
42
+ readonly description: "iAP version (e.g., 2026-spring)";
43
+ };
44
+ readonly module: {
45
+ readonly type: "string";
46
+ readonly description: "Modules to use (comma-separated artifactIds, e.g., im_workflow)";
47
+ };
48
+ readonly feature: {
49
+ readonly type: "string";
50
+ readonly description: "Features to use (comma-separated function ids, e.g., jssp)";
51
+ };
52
+ readonly name: {
53
+ readonly type: "string";
54
+ readonly description: "Project name";
55
+ };
56
+ readonly group: {
57
+ readonly type: "string";
58
+ readonly description: "Group name";
59
+ };
60
+ readonly "project-version": {
61
+ readonly type: "string";
62
+ readonly description: "Project version";
63
+ };
64
+ readonly description: {
65
+ readonly type: "string";
66
+ readonly description: "Project description";
67
+ };
68
+ readonly database: {
69
+ readonly type: "string";
70
+ readonly description: "Database type";
71
+ };
72
+ readonly javascript: {
73
+ readonly type: "boolean";
74
+ readonly description: "Use JavaScript";
75
+ };
76
+ readonly agent: {
77
+ readonly type: "string";
78
+ readonly description: "Agent type";
79
+ };
80
+ readonly locale: {
81
+ readonly type: "string";
82
+ readonly description: "Locale (ja, en, zh_CN)";
83
+ };
84
+ readonly "artifact-id": {
85
+ readonly type: "string";
86
+ readonly description: "Maven artifactId (defaults to project name)";
87
+ };
88
+ readonly "package-manager": {
89
+ readonly type: "string";
90
+ readonly description: "Package manager (bun, npm, yarn, pnpm). Default: bun";
91
+ };
92
+ readonly overwrite: {
93
+ readonly type: "boolean";
94
+ readonly description: "Overwrite existing files without per-file confirmation";
95
+ readonly default: false;
96
+ };
97
+ readonly "skip-install": {
98
+ readonly type: "boolean";
99
+ readonly description: "Skip dependency installation";
100
+ readonly default: false;
101
+ };
102
+ readonly "non-interactive": {
103
+ readonly type: "boolean";
104
+ readonly description: "Non-interactive mode";
105
+ readonly default: false;
106
+ };
107
+ readonly "asset-server-url": {
108
+ readonly type: "string";
109
+ readonly description: "Git repository URL to fetch assets from (overrides the default repository)";
110
+ };
111
+ readonly "asset-ref": {
112
+ readonly type: "string";
113
+ readonly description: "Git branch/tag to fetch from the asset repository. Default: experiment";
114
+ };
115
+ readonly "asset-source": {
116
+ readonly type: "string";
117
+ readonly description: "(debug) Local asset source directory";
84
118
  };
85
119
  }>;
@@ -2,15 +2,177 @@ import { defineCommand } from "citty";
2
2
  import * as p from "@clack/prompts";
3
3
  import { stat } from "node:fs/promises";
4
4
  import { basename, join } from "node:path";
5
- import { CLI_VERSION } from "../core/constants.js";
5
+ import { createCancelledError, normalizeAbort } from "../core/errors.js";
6
+ import { getCliVersion } from "../core/paths.js";
6
7
  import { runPrompts } from "../interactive/prompts.js";
7
8
  import { deployAssets, } from "../asset/deployer.js";
8
9
  import { selectAssetProvider } from "./asset-provider.js";
10
+ import { withExitCode } from "./run-wrapper.js";
9
11
  import { getMessage } from "../i18n/index.js";
10
12
  import { detectLocale } from "../utils/locale-detect.js";
13
+ import { generateMcpConfigsBestEffort, } from "../utils/mcp-generate.js";
14
+ import { splitList } from "../utils/args.js";
15
+ import { createClackLogger } from "../interactive/clack-logger.js";
11
16
  import { printSummary } from "../interactive/summary.js";
12
17
  import { printNextSteps } from "../interactive/next-steps.js";
13
18
  import { buildProgressCallbacks } from "../interactive/progress.js";
19
+ import { sanitizeDisplayText } from "../utils/sanitize-text.js";
20
+ const createDefaultExistingFileHandler = (locale) => {
21
+ let sticky;
22
+ return async (path) => {
23
+ if (sticky === "all")
24
+ return "overwrite";
25
+ if (sticky === "skipAll")
26
+ return "skip";
27
+ const choice = await p.select({
28
+ message: getMessage("attach.overwritePrompt", locale, { path }),
29
+ options: [
30
+ {
31
+ value: "yes",
32
+ label: getMessage("attach.overwritePrompt.yes", locale),
33
+ },
34
+ {
35
+ value: "no",
36
+ label: getMessage("attach.overwritePrompt.no", locale),
37
+ },
38
+ {
39
+ value: "all",
40
+ label: getMessage("attach.overwritePrompt.all", locale),
41
+ },
42
+ {
43
+ value: "skipAll",
44
+ label: getMessage("attach.overwritePrompt.skipAll", locale),
45
+ },
46
+ ],
47
+ });
48
+ if (p.isCancel(choice))
49
+ throw createCancelledError();
50
+ if (choice === "all") {
51
+ sticky = "all";
52
+ return "overwrite";
53
+ }
54
+ if (choice === "skipAll") {
55
+ sticky = "skipAll";
56
+ return "skip";
57
+ }
58
+ return choice === "yes" ? "overwrite" : "skip";
59
+ };
60
+ };
61
+ export const runAttach = async (deps) => {
62
+ try {
63
+ return await runAttachInner(deps);
64
+ }
65
+ catch (err) {
66
+ throw normalizeAbort(err, deps.signal);
67
+ }
68
+ };
69
+ const runAttachInner = async (deps) => {
70
+ const locale = deps.locale ?? detectLocale();
71
+ const logger = deps.logger ?? createClackLogger();
72
+ const resolveOptions = deps.resolveOptions ?? runPrompts;
73
+ const { projectDir } = deps;
74
+ const accelExists = await stat(join(projectDir, ".accel")).then(() => true, () => false);
75
+ if (accelExists) {
76
+ throw new Error(getMessage("error.accelExists", locale));
77
+ }
78
+ const promptOpts = {
79
+ name: deps.name ?? basename(projectDir),
80
+ artifactId: deps.artifactId,
81
+ jugglingProject: deps.jugglingProject,
82
+ accelplatformVersion: deps.accelplatformVersion,
83
+ module: deps.modules,
84
+ feature: deps.features,
85
+ group: deps.group,
86
+ projectVersion: deps.projectVersion,
87
+ description: deps.description,
88
+ database: deps.database,
89
+ javascript: deps.javascript,
90
+ agent: deps.agents,
91
+ packageManager: deps.packageManager,
92
+ locale,
93
+ noInteraction: deps.nonInteractive,
94
+ isInit: false,
95
+ };
96
+ const resolved = await resolveOptions(promptOpts);
97
+ const settings = {
98
+ cliVersion: getCliVersion(),
99
+ createdAt: new Date().toISOString(),
100
+ name: resolved.name,
101
+ artifactId: resolved.artifactId,
102
+ group: resolved.group,
103
+ projectVersion: resolved.projectVersion,
104
+ description: resolved.description,
105
+ accelplatformVersion: resolved.accelplatformVersion,
106
+ modules: resolved.modules,
107
+ features: resolved.features,
108
+ database: resolved.database,
109
+ agents: resolved.agents,
110
+ javascript: resolved.javascript,
111
+ locale: resolved.locale,
112
+ packageManager: resolved.packageManager,
113
+ jugglingProject: resolved.jugglingProject ?? null,
114
+ deployedAssets: {},
115
+ };
116
+ const provider = await selectAssetProvider({
117
+ assetSource: deps.assetSource,
118
+ assetServerUrl: deps.assetServerUrl,
119
+ assetRef: deps.assetRef,
120
+ }, locale, deps.signal);
121
+ if (!deps.nonInteractive) {
122
+ printSummary(settings, projectDir, locale, logger);
123
+ }
124
+ const overwrite = deps.overwrite ?? false;
125
+ let skipExistingFiles;
126
+ let onExistingFile;
127
+ if (!overwrite) {
128
+ onExistingFile =
129
+ deps.onExistingFile ??
130
+ (deps.nonInteractive
131
+ ? undefined
132
+ : createDefaultExistingFileHandler(locale));
133
+ if (!onExistingFile)
134
+ skipExistingFiles = true;
135
+ }
136
+ const result = await deployAssets({
137
+ projectDir,
138
+ settings,
139
+ provider,
140
+ noInstall: deps.skipInstall ?? false,
141
+ skipExistingFiles,
142
+ onExistingFile,
143
+ progress: deps.progress ?? buildProgressCallbacks(locale, logger),
144
+ signal: deps.signal,
145
+ });
146
+ for (const path of result.overwrittenFiles) {
147
+ logger.info(getMessage("attach.overwritten", locale, {
148
+ path: sanitizeDisplayText(path),
149
+ }));
150
+ }
151
+ for (const path of result.skippedFiles) {
152
+ logger.warn(getMessage("warning.fileExists", locale, {
153
+ path: sanitizeDisplayText(path),
154
+ }));
155
+ }
156
+ if (result.overwrittenFiles.length > 0) {
157
+ logger.info(getMessage("attach.overwriteSummary", locale, {
158
+ count: String(result.overwrittenFiles.length),
159
+ }));
160
+ }
161
+ if (result.skippedFiles.length > 0) {
162
+ logger.info(getMessage("attach.skipSummary", locale, {
163
+ count: String(result.skippedFiles.length),
164
+ }));
165
+ }
166
+ await generateMcpConfigsBestEffort(projectDir, logger, deps.generateMcpConfigs);
167
+ logger.success(getMessage("progress.complete", locale));
168
+ printNextSteps({
169
+ projectDir,
170
+ agents: resolved.agents,
171
+ isInit: false,
172
+ locale,
173
+ }, logger);
174
+ return result;
175
+ };
14
176
  export const attachCommand = defineCommand({
15
177
  meta: {
16
178
  name: "attach",
@@ -101,160 +263,29 @@ export const attachCommand = defineCommand({
101
263
  description: "(debug) Local asset source directory",
102
264
  },
103
265
  },
104
- run: async ({ args }) => {
105
- const locale = args.locale ?? detectLocale();
106
- const projectDir = process.cwd();
107
- try {
108
- await stat(join(projectDir, ".accel"));
109
- p.log.error(getMessage("error.accelExists", locale));
110
- process.exit(1);
111
- }
112
- catch {
113
- }
114
- const moduleArg = args.module;
115
- const modules = moduleArg
116
- ? moduleArg.split(",").map((m) => m.trim())
117
- : undefined;
118
- const featureArg = args.feature;
119
- const features = featureArg
120
- ? featureArg.split(",").map((f) => f.trim())
121
- : undefined;
122
- const agentArg = args.agent;
123
- const promptOpts = {
124
- name: args.name ?? basename(projectDir),
266
+ run: withExitCode(async ({ args }) => {
267
+ await runAttach({
268
+ projectDir: process.cwd(),
269
+ locale: args.locale,
270
+ nonInteractive: args["non-interactive"],
271
+ name: args.name,
125
272
  artifactId: args["artifact-id"],
126
273
  jugglingProject: args["juggling-project"],
127
274
  accelplatformVersion: args["accelplatform-version"],
128
- module: modules,
129
- feature: features,
275
+ modules: splitList(args.module),
276
+ features: splitList(args.feature),
130
277
  group: args.group,
131
278
  projectVersion: args["project-version"],
132
279
  description: args.description,
133
280
  database: args.database,
134
281
  javascript: args.javascript,
135
- agent: agentArg
136
- ? agentArg.split(",").map((a) => a.trim())
137
- : undefined,
282
+ agents: splitList(args.agent),
138
283
  packageManager: args["package-manager"],
139
- locale,
140
- noInteraction: args["non-interactive"],
141
- isInit: false,
142
- };
143
- let resolved;
144
- try {
145
- resolved = await runPrompts(promptOpts);
146
- }
147
- catch (err) {
148
- p.log.error(err instanceof Error ? err.message : String(err));
149
- process.exit(1);
150
- }
151
- const settings = {
152
- cliVersion: CLI_VERSION,
153
- createdAt: new Date().toISOString(),
154
- name: resolved.name,
155
- artifactId: resolved.artifactId,
156
- group: resolved.group,
157
- projectVersion: resolved.projectVersion,
158
- description: resolved.description,
159
- accelplatformVersion: resolved.accelplatformVersion,
160
- modules: resolved.modules,
161
- features: resolved.features,
162
- database: resolved.database,
163
- agents: resolved.agents,
164
- javascript: resolved.javascript,
165
- locale: resolved.locale,
166
- packageManager: resolved.packageManager,
167
- jugglingProject: resolved.jugglingProject ?? null,
168
- deployedAssets: {},
169
- };
170
- const isInteractive = !args["non-interactive"];
171
- const provider = await selectAssetProvider({
172
- assetSource: args["asset-source"],
284
+ overwrite: args.overwrite,
285
+ skipInstall: args["skip-install"],
173
286
  assetServerUrl: args["asset-server-url"],
174
287
  assetRef: args["asset-ref"],
175
- }, locale);
176
- const overwriteFlag = args.overwrite;
177
- if (isInteractive) {
178
- printSummary(settings, projectDir, locale);
179
- }
180
- let skipAll = false;
181
- let onExistingFile;
182
- if (!isInteractive) {
183
- if (!overwriteFlag)
184
- skipAll = true;
185
- }
186
- else if (!overwriteFlag) {
187
- let sticky;
188
- onExistingFile = async (path) => {
189
- if (sticky === "all")
190
- return "overwrite";
191
- if (sticky === "skipAll")
192
- return "skip";
193
- const choice = await p.select({
194
- message: getMessage("attach.overwritePrompt", locale, { path }),
195
- options: [
196
- {
197
- value: "yes",
198
- label: getMessage("attach.overwritePrompt.yes", locale),
199
- },
200
- {
201
- value: "no",
202
- label: getMessage("attach.overwritePrompt.no", locale),
203
- },
204
- {
205
- value: "all",
206
- label: getMessage("attach.overwritePrompt.all", locale),
207
- },
208
- {
209
- value: "skipAll",
210
- label: getMessage("attach.overwritePrompt.skipAll", locale),
211
- },
212
- ],
213
- });
214
- if (p.isCancel(choice))
215
- process.exit(0);
216
- if (choice === "all") {
217
- sticky = "all";
218
- return "overwrite";
219
- }
220
- if (choice === "skipAll") {
221
- sticky = "skipAll";
222
- return "skip";
223
- }
224
- return choice === "yes" ? "overwrite" : "skip";
225
- };
226
- }
227
- const result = await deployAssets({
228
- projectDir,
229
- settings,
230
- provider,
231
- noInstall: args["skip-install"],
232
- skipExistingFiles: skipAll || undefined,
233
- onExistingFile,
234
- progress: buildProgressCallbacks(locale),
235
- });
236
- for (const path of result.overwrittenFiles) {
237
- p.log.info(getMessage("attach.overwritten", locale, { path }));
238
- }
239
- for (const path of result.skippedFiles) {
240
- p.log.warn(getMessage("warning.fileExists", locale, { path }));
241
- }
242
- if (result.overwrittenFiles.length > 0) {
243
- p.log.info(getMessage("attach.overwriteSummary", locale, {
244
- count: String(result.overwrittenFiles.length),
245
- }));
246
- }
247
- if (result.skippedFiles.length > 0) {
248
- p.log.info(getMessage("attach.skipSummary", locale, {
249
- count: String(result.skippedFiles.length),
250
- }));
251
- }
252
- p.log.success(getMessage("progress.complete", locale));
253
- printNextSteps({
254
- projectDir,
255
- agents: resolved.agents,
256
- isInit: false,
257
- locale,
288
+ assetSource: args["asset-source"],
258
289
  });
259
- },
290
+ }),
260
291
  });
@@ -1,10 +1,10 @@
1
- import { rm } from "node:fs/promises";
2
1
  import { defineCommand } from "citty";
3
2
  import * as p from "@clack/prompts";
4
- import { cacheReposDir, directorySize, listCacheRepos, resolveCacheRoot, } from "../git/object-cache.js";
3
+ import { clearCacheRepos, listCacheRepos, resolveCacheRoot, } from "../git/object-cache.js";
5
4
  import { getMessage } from "../i18n/index.js";
6
5
  import { detectLocale } from "../utils/locale-detect.js";
7
6
  import { sanitizeDisplayText } from "../utils/sanitize-text.js";
7
+ import { withExitCode } from "./run-wrapper.js";
8
8
  const formatBytes = (bytes) => {
9
9
  if (bytes >= 1024 ** 3)
10
10
  return `${(bytes / 1024 ** 3).toFixed(1)} GB`;
@@ -19,7 +19,7 @@ const infoCommand = defineCommand({
19
19
  name: "info",
20
20
  description: "Show the asset cache location and disk usage",
21
21
  },
22
- run: async () => {
22
+ run: withExitCode(async () => {
23
23
  const locale = detectLocale();
24
24
  const root = resolveCacheRoot();
25
25
  let dirLine = getMessage("cache.info.dir", locale, { path: root });
@@ -37,30 +37,22 @@ const infoCommand = defineCommand({
37
37
  for (const repo of repos) {
38
38
  p.log.info(` ${sanitizeDisplayText(repo.url ?? repo.dir)} — ${formatBytes(repo.size)}`);
39
39
  }
40
- },
40
+ }),
41
41
  });
42
42
  const clearCommand = defineCommand({
43
43
  meta: {
44
44
  name: "clear",
45
45
  description: "Delete the asset cache (it will be re-downloaded on demand)",
46
46
  },
47
- run: async () => {
47
+ run: withExitCode(async () => {
48
48
  const locale = detectLocale();
49
- const reposDir = cacheReposDir(resolveCacheRoot());
50
- try {
51
- const size = await directorySize(reposDir);
52
- if (size === 0) {
53
- p.log.info(getMessage("cache.clear.empty", locale));
54
- return;
55
- }
56
- await rm(reposDir, { recursive: true, force: true });
57
- p.log.success(getMessage("cache.clear.done", locale, { size: formatBytes(size) }));
58
- }
59
- catch (err) {
60
- p.log.error(err instanceof Error ? err.message : String(err));
61
- process.exit(1);
49
+ const size = await clearCacheRepos(resolveCacheRoot());
50
+ if (size === 0) {
51
+ p.log.info(getMessage("cache.clear.empty", locale));
52
+ return;
62
53
  }
63
- },
54
+ p.log.success(getMessage("cache.clear.done", locale, { size: formatBytes(size) }));
55
+ }),
64
56
  });
65
57
  export const cacheCommand = defineCommand({
66
58
  meta: {