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

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.
package/README.md CHANGED
@@ -122,7 +122,9 @@ accel update
122
122
 
123
123
  - ユーザーが編集したファイルの内容は保持されます。編集箇所と資材の更新が重なった場合はコンフリクトマーカー(git と同じ `<<<<<<<` 形式)が挿入されるので、該当ファイルを手動で解決してください。コンフリクトの発生は正常終了扱いで、終了時に対象ファイルの一覧が表示されます。
124
124
  - 対話モードでは、最初に**既存の設定を利用するか**を確認します(デフォルト: Yes)。利用する場合は各設定の再入力をスキップし、現在の設定(CLIオプションの指定があればその値で上書き)のまま更新に進みます。再入力を選んだ場合は、iAPバージョン・モジュール・機能・エージェントなどの設定を**現在値を初期値として**変更できます。
125
+ - プリセット(後述「[`accel preset`](#accel-preset)」)が登録されている場合は、「既存の設定を利用 / プリセット○○を利用 / 設定を再入力」の選択になります。プリセットを選ぶと、モジュール・機能・エージェントがプリセットの内容に切り替わった状態で更新に進みます(`--preset` 指定時は設定確定済みのため、この確認をスキップして事前サマリーと適用確認に直行します)。
125
126
  - 既存の設定に不正な値やカタログとの不整合がある場合は、対象の項目と理由を通知した上で再入力になります(確認はスキップ)。
127
+ - `--preset` でプリセットを指定すると、モジュール・機能・エージェントをプリセットの内容に一括で変更できます。`--module` / `--feature` / `--agent` との同時指定はエラーになります。
126
128
  - 非対話モードでは `init` と同じオプションで変更を指定でき、未指定の項目は現在の設定を維持します。
127
129
  - IM-Juggling プロジェクトとの連携は、設定の再入力時に IM-Juggling プロジェクトのプロンプトを空にして確定するか、`--juggling-project ""`(空文字)を指定すると解除できます。
128
130
  - `--asset-server-url` / `--asset-ref` で取得元のリポジトリ・ブランチを変更できます(リポジトリの移転やブランチ再編への追従)。変更した取得元は記録され、以降の update の既定になります。
@@ -144,6 +146,7 @@ accel update --non-interactive --module im_workflow,im_activiti
144
146
 
145
147
  | オプション | 型 | 説明 | デフォルト |
146
148
  |---|---|---|---|
149
+ | `--preset` | string | 適用するプリセット名(後述「[`accel preset`](#accel-preset)」)。モジュール・機能・エージェントをプリセットの内容に変更する。`--module` / `--feature` / `--agent` とは同時指定不可 | - |
147
150
  | `--non-interactive` | boolean | 非対話モード | `false` |
148
151
  | `--skip-install` | boolean | 更新後の install / build をスキップ | `false` |
149
152
  | `--asset-server-url` | string | 資材を取得するgitリポジトリのURL(HTTP(S) のみ)を変更する。変更は記録され、以降の既定になる | 記録済みのURL |
@@ -168,12 +171,20 @@ accel switch --feature jssp
168
171
  - **ユーザーが編集したファイルには一切触れません**。切り替えで上書き・削除の対象になった編集済みファイルはそのまま保持してスキップし、終了時に「切り替えが適用されていないファイル」として一覧表示します。`update` と異なり、コンフリクトマーカーの挿入は行いません。
169
172
  - 未編集のファイルは新しい構成の内容で上書きされ、新構成で不要になった資材は削除、新たに必要になった資材は追加されます。
170
173
  - install / build は変更されたファイルに `package.json` またはロックファイル(`bun.lock` 等)が含まれる場合のみ実行します。skills などの切り替えだけであれば実行されず、すぐに完了します。スキップされた編集済みファイルがある状態で install / build が失敗した場合は、スキップしたファイルが原因の可能性がある旨をあわせて表示します。
171
- - 対話モードでは、モジュール・機能・エージェントを現在の設定を初期値として選択し直せます。
174
+ - 対話モードでは、モジュール・機能・エージェントを現在の設定を初期値として選択し直せます。プリセット(後述「[`accel preset`](#accel-preset)」)が登録されている場合は、最初にプリセットを利用するかの選択肢が表示され、プリセットを選ぶと3項目の選択をスキップしてプリセットの内容に切り替わります(`--module` / `--feature` / `--agent` / `--preset` のいずれかを指定した場合は、この選択肢は表示されません)。
175
+ - `--preset` でプリセットを指定して切り替えることもできます(`--module` / `--feature` / `--agent` との同時指定はエラー)。対話モードでも 3 項目の選択はスキップされ、適用確認に直行します。
176
+
177
+ ```bash
178
+ accel switch --preset server-side
179
+ ```
172
180
 
173
181
  #### 非対話モード
174
182
 
175
183
  ```bash
176
184
  accel switch --non-interactive --feature jssp --agent claude-code
185
+
186
+ # プリセットを使う場合
187
+ accel switch --non-interactive --preset server-side
177
188
  ```
178
189
 
179
190
  未指定の項目は現在の設定を維持します。
@@ -185,12 +196,69 @@ accel switch --non-interactive --feature jssp --agent claude-code
185
196
  | `--module` | string | 使用モジュール。カタログの `artifactId`(カンマ区切り) | 現在の設定を維持 |
186
197
  | `--feature` | string | 使用機能。カタログの機能ID(カンマ区切り) | 現在の設定を維持 |
187
198
  | `--agent` | string | エージェント種別(`claude-code`, `codex`, `github-copilot`、カンマ区切り) | 現在の設定を維持 |
199
+ | `--preset` | string | 適用するプリセット名(後述「[`accel preset`](#accel-preset)」)。3項目をプリセットの内容に変更する。`--module` / `--feature` / `--agent` とは同時指定不可 | - |
188
200
  | `--non-interactive` | boolean | 非対話モード | `false` |
189
201
  | `--skip-install` | boolean | 依存関係変更時の install / build をスキップ | `false` |
190
202
 
191
203
  - 切り替えられるのは上記の3項目のみです。iAPバージョンやロケールなど他の設定の変更は `accel update` で行います。
192
204
  - `update` と同様、git ソースから配備されたプロジェクトでのみ利用できます。
193
205
 
206
+ ### `accel preset`
207
+
208
+ モジュール・機能・エージェントの組み合わせを**構成プリセット**として登録・管理します。登録したプリセットは `accel update` / `accel switch` で利用できます。
209
+
210
+ ```bash
211
+ cd my-project
212
+ accel preset create
213
+ ```
214
+
215
+ 実際の開発では、「画面開発用」「サーバサイド開発用」「workflow用」のように、開発対象ごとに使用する skills 等の構成が決まっているケースが多いはずです。プロジェクトでよく使う構成をプリセットとして登録しておくと、チームメンバー全員が同じ構成を名前ひとつで切り替えられるようになります。
216
+
217
+ - プリセットは `.accel/presets/<プリセット名>.json` に1プリセット1ファイルで保存されます。**git 管理対象**なので、コミットすればチームメンバーに共有されます。
218
+ - プリセットの内容は module / feature / agent の3項目(+表示名・説明)です。3項目すべてを保存します。
219
+ - `init` / `attach` 済みのプロジェクト内で実行してください(`.accel` が無い場合はエラー)。`accel detach` は `.accel/` ごと削除するため、プリセットも一緒に削除されます。
220
+ - プリセット名(ID)に使える文字は英数字と `-` `_` のみです。ファイル名や `--preset` での指定に使われます。
221
+ - 日本語などの名前を付けたい場合は**表示名**を設定してください。一覧や選択肢では「表示名 (プリセット名)」の形式で表示されます(表示名が未設定なら プリセット名のみ)。
222
+ - 適用時(`update` / `switch`)には、プリセットの内容が適用時点のiAPバージョン(`update` で `--accelplatform-version` を指定した場合は変更後のバージョン)のカタログに対して検証されます。バージョン変更などでプリセット内のモジュール・機能が存在しなくなった場合はエラーになります。
223
+
224
+ #### `accel preset create [name]`
225
+
226
+ プリセットを対話形式で作成します。名前(ID)・表示名・説明を入力し、モジュール・機能・エージェントを選択して保存します。保存後に続けて次のプリセットを作成できるため、プロジェクト作成直後に複数のプリセットをまとめて登録できます。
227
+
228
+ ```bash
229
+ # 非対話モード(3項目すべての指定が必須)
230
+ accel preset create server-side \
231
+ --non-interactive \
232
+ --module im_workflow \
233
+ --feature jssp \
234
+ --agent claude-code \
235
+ --label "サーバサイド開発用"
236
+ ```
237
+
238
+ | オプション | 型 | 説明 | デフォルト |
239
+ |---|---|---|---|
240
+ | `[name]`(位置引数) | string | プリセット名(ID。英数字と `-` `_` のみ。**非対話モードでは必須**) | 対話で入力 |
241
+ | `--label` | string | 表示名。日本語なども使用可。`preset list` や選択肢に表示される | `""`(プリセット名を表示) |
242
+ | `--description` | string | プリセットの説明。`preset list` や選択肢に表示される | `""` |
243
+ | `--module` | string | 使用モジュール。カタログの `artifactId`(カンマ区切り。**非対話モードでは必須**) | 対話で選択 |
244
+ | `--feature` | string | 使用機能。カタログの機能ID(カンマ区切り。**非対話モードでは必須**。`""` で機能なし) | 対話で選択 |
245
+ | `--agent` | string | エージェント種別(`claude-code`, `codex`, `github-copilot`、カンマ区切り。**非対話モードでは必須**) | 対話で選択 |
246
+ | `--force` | boolean | 同名プリセットが存在する場合に確認なしで上書きする | `false`(対話で確認 / 非対話ではエラー) |
247
+ | `--locale` | string | ロケール(`ja`, `en`, `zh_CN`) | `settings.json` の記録値 |
248
+ | `--non-interactive` | boolean | 非対話モード | `false` |
249
+
250
+ #### `accel preset list`
251
+
252
+ 登録済みプリセットの一覧(名前と説明)を表示します。
253
+
254
+ #### `accel preset show <name>`
255
+
256
+ 指定したプリセットの内容(表示名・説明・モジュール・機能・エージェント)を表示します。名前(ID)で指定します。
257
+
258
+ #### `accel preset delete <name>`
259
+
260
+ 指定したプリセットを削除します。名前(ID)で指定します。対話モードでは削除前に確認します。
261
+
194
262
  ### `accel cache`
195
263
 
196
264
  資材キャッシュを管理します。
@@ -444,6 +512,7 @@ my-project/
444
512
  - `.accel/settings.json` — プロジェクト設定。git管理対象、手動編集可。資材リポジトリのURL・ref・配備時のコミットSHA(`assetSource`)を記録し、`accel update` / `accel switch` が参照
445
513
  - `.accel/hashsum.txt` — 配備ファイルのハッシュ。`update` / `switch` / `detach` 時のユーザー編集検出に使用
446
514
  - `.accel/credentials.json` — iAP接続情報(endpoint / APIキー)。`accel deploy` 初回実行時に生成。APIキーを含むため `.gitignore` 対象(git管理対象外)
515
+ - `.accel/presets/` — 構成プリセット(1プリセット1ファイル)。`accel preset create` で生成。チーム共有のため git 管理対象(詳細は「[`accel preset`](#accel-preset)」)
447
516
  - `.githooks/` — APIキーの誤コミットを防ぐ pre-commit フック。`accel login` / `accel deploy` による接続情報の保存時に配置(詳細は「[pre-commit フックの自動配置](#pre-commit-フックの自動配置)」)
448
517
 
449
518
  `credentials.json` の保存/更新時には、エージェント別の MCP 設定ファイル(`.mcp.json` / `.codex/config.toml` / `.vscode/mcp.json` のうち、存在し、かつ `agents` に含まれるエージェントのもの)に対しても API キーが反映されます。詳細は「[MCP 設定の自動同期](#mcp-設定の自動同期)」を参照してください。
@@ -0,0 +1,31 @@
1
+ import { type Release } from "../core/catalog.js";
2
+ import { promptModules, promptFeatures, promptAgents } from "../interactive/prompts.js";
3
+ import { type PresetSummary } from "../utils/preset-io.js";
4
+ export type PresetCreateCliValues = {
5
+ name?: string;
6
+ label?: string;
7
+ description?: string;
8
+ modules?: string[];
9
+ features?: string[];
10
+ agents?: string[];
11
+ };
12
+ export type PresetCreatePrompts = {
13
+ text: (opts: {
14
+ message: string;
15
+ validate?: (value: string | undefined) => string | undefined;
16
+ }) => Promise<string | symbol>;
17
+ confirm: (opts: {
18
+ message: string;
19
+ initialValue?: boolean;
20
+ }) => Promise<boolean | symbol>;
21
+ modules: typeof promptModules;
22
+ features: typeof promptFeatures;
23
+ agents: typeof promptAgents;
24
+ };
25
+ export declare const runPresetCreateInteractive: (ctx: {
26
+ projectDir: string;
27
+ locale: string;
28
+ }, release: Release, cli: PresetCreateCliValues, force?: boolean, prompts?: PresetCreatePrompts) => Promise<void>;
29
+ export declare const buildPresetListBody: (summaries: PresetSummary[]) => string;
30
+ export declare const buildPresetShowBody: (raw: Record<string, unknown>, locale: string) => string;
31
+ export declare const presetCommand: import("citty").CommandDef<import("citty").ArgsDef>;
@@ -0,0 +1,396 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { defineCommand } from "citty";
3
+ import * as p from "@clack/prompts";
4
+ import { findReleaseById } from "../core/catalog.js";
5
+ import { createPresetNameValidator } from "../core/validators.js";
6
+ import { printIntro, promptModules, promptFeatures, promptAgents, collectSettingsErrors, } from "../interactive/prompts.js";
7
+ import { withHint, displayWidth } from "../interactive/format.js";
8
+ import { getMessage } from "../i18n/index.js";
9
+ import { detectLocale } from "../utils/locale-detect.js";
10
+ import { readSettingsSafe } from "../utils/settings-io.js";
11
+ import { presetPath, writePreset, presetExists, deletePreset, listPresetSummaries, formatPresetDisplayName, } from "../utils/preset-io.js";
12
+ import { sanitizeDisplayText } from "../utils/sanitize-text.js";
13
+ const requirePresetContext = async (argLocale) => {
14
+ const projectDir = process.cwd();
15
+ const fallbackLocale = argLocale ?? detectLocale();
16
+ const settings = await readSettingsSafe(projectDir);
17
+ if (!settings) {
18
+ p.log.error(getMessage("preset.error.noSettings", fallbackLocale));
19
+ process.exit(1);
20
+ }
21
+ return {
22
+ projectDir,
23
+ settings,
24
+ locale: argLocale ?? settings.locale ?? fallbackLocale,
25
+ };
26
+ };
27
+ const resolveRelease = (settings, locale) => {
28
+ const release = findReleaseById(settings.accelplatformVersion.label);
29
+ if (!release) {
30
+ p.log.error(getMessage("error.invalidVersion", locale, {
31
+ version: settings.accelplatformVersion.label,
32
+ }));
33
+ process.exit(1);
34
+ }
35
+ return release;
36
+ };
37
+ const buildPreset = (name, label, description, modules, features, agents) => ({
38
+ name,
39
+ ...(label !== "" ? { label } : {}),
40
+ ...(description !== "" ? { description } : {}),
41
+ modules,
42
+ features,
43
+ agents,
44
+ });
45
+ const defaultPrompts = {
46
+ text: (opts) => p.text(opts),
47
+ confirm: (opts) => p.confirm(opts),
48
+ modules: promptModules,
49
+ features: promptFeatures,
50
+ agents: promptAgents,
51
+ };
52
+ const resolveTextInput = (input) => {
53
+ if (p.isCancel(input))
54
+ process.exit(0);
55
+ return typeof input === "string" ? input.trim() : "";
56
+ };
57
+ const resolveConfirmInput = (input) => {
58
+ if (p.isCancel(input))
59
+ process.exit(0);
60
+ return input === true;
61
+ };
62
+ export const runPresetCreateInteractive = async (ctx, release, cli, force = false, prompts = defaultPrompts) => {
63
+ const { projectDir, locale } = ctx;
64
+ const nameValidator = createPresetNameValidator(locale);
65
+ const allModuleIds = release.modules.map((m) => m.artifactId);
66
+ printIntro("preset", locale);
67
+ let first = true;
68
+ let again = true;
69
+ while (again) {
70
+ let name = first ? cli.name : undefined;
71
+ const nameFromArg = name !== undefined;
72
+ for (;;) {
73
+ if (name === undefined) {
74
+ name = resolveTextInput(await prompts.text({
75
+ message: withHint("preset.prompt.name", locale),
76
+ validate: (value) => nameValidator(value ?? ""),
77
+ }));
78
+ }
79
+ if (!(await presetExists(projectDir, name)))
80
+ break;
81
+ if (first && force)
82
+ break;
83
+ const overwrite = resolveConfirmInput(await prompts.confirm({
84
+ message: getMessage("preset.prompt.overwrite", locale, { name }),
85
+ initialValue: false,
86
+ }));
87
+ if (overwrite)
88
+ break;
89
+ if (nameFromArg) {
90
+ p.log.info(getMessage("preset.cancelled", locale));
91
+ process.exit(0);
92
+ }
93
+ name = undefined;
94
+ }
95
+ const label = first && cli.label !== undefined
96
+ ? cli.label
97
+ : resolveTextInput(await prompts.text({
98
+ message: withHint("preset.prompt.label", locale),
99
+ }));
100
+ const description = first && cli.description !== undefined
101
+ ? cli.description
102
+ : resolveTextInput(await prompts.text({
103
+ message: withHint("preset.prompt.description", locale),
104
+ }));
105
+ const modules = await prompts.modules(release, (first ? cli.modules : undefined) ?? allModuleIds, locale);
106
+ const features = await prompts.features(release, first ? cli.features : undefined, locale);
107
+ const agents = await prompts.agents(first ? cli.agents : undefined, locale);
108
+ await writePreset(projectDir, buildPreset(name, label, description, modules, features, agents));
109
+ p.log.success(getMessage("preset.created", locale, { name }));
110
+ again = resolveConfirmInput(await prompts.confirm({
111
+ message: getMessage("preset.prompt.continue", locale),
112
+ initialValue: false,
113
+ }));
114
+ first = false;
115
+ }
116
+ };
117
+ const createCommand = defineCommand({
118
+ meta: {
119
+ name: "create",
120
+ description: "Create a configuration preset (modules / features / agents)",
121
+ },
122
+ args: {
123
+ name: {
124
+ type: "positional",
125
+ description: "Preset name (ID; alphanumerics, - and _ only)",
126
+ required: false,
127
+ },
128
+ label: {
129
+ type: "string",
130
+ description: "Display name shown in lists and selection prompts",
131
+ },
132
+ description: {
133
+ type: "string",
134
+ description: "Preset description",
135
+ },
136
+ module: {
137
+ type: "string",
138
+ description: "Modules to use (comma-separated artifactIds, e.g., im_workflow)",
139
+ },
140
+ feature: {
141
+ type: "string",
142
+ description: 'Features to use (comma-separated function ids; "" for none)',
143
+ },
144
+ agent: {
145
+ type: "string",
146
+ description: "Agent type",
147
+ },
148
+ force: {
149
+ type: "boolean",
150
+ description: "Overwrite an existing preset without confirmation",
151
+ default: false,
152
+ },
153
+ locale: {
154
+ type: "string",
155
+ description: "Locale (ja, en, zh_CN)",
156
+ },
157
+ "non-interactive": {
158
+ type: "boolean",
159
+ description: "Non-interactive mode",
160
+ default: false,
161
+ },
162
+ },
163
+ run: async ({ args }) => {
164
+ const ctx = await requirePresetContext(args.locale);
165
+ const { projectDir, settings, locale } = ctx;
166
+ const nameArg = args.name;
167
+ const moduleArg = args.module;
168
+ const featureArg = args.feature;
169
+ const agentArg = args.agent;
170
+ const cli = {
171
+ name: nameArg,
172
+ label: args.label,
173
+ description: args.description,
174
+ modules: moduleArg === undefined
175
+ ? undefined
176
+ : moduleArg.split(",").map((m) => m.trim()),
177
+ features: featureArg === undefined
178
+ ? undefined
179
+ : featureArg === ""
180
+ ? []
181
+ : featureArg.split(",").map((f) => f.trim()),
182
+ agents: agentArg === undefined
183
+ ? undefined
184
+ : agentArg.split(",").map((a) => a.trim()),
185
+ };
186
+ const errors = [];
187
+ if (cli.name !== undefined) {
188
+ const nameError = createPresetNameValidator(locale)(cli.name);
189
+ if (nameError)
190
+ errors.push(nameError);
191
+ }
192
+ errors.push(...collectSettingsErrors({
193
+ module: cli.modules,
194
+ feature: cli.features,
195
+ agent: cli.agents,
196
+ locale,
197
+ isInit: false,
198
+ }, locale, settings.accelplatformVersion.label));
199
+ if (errors.length > 0) {
200
+ p.log.error(errors.join("\n"));
201
+ process.exit(1);
202
+ }
203
+ const release = resolveRelease(settings, locale);
204
+ const isInteractive = !args["non-interactive"];
205
+ if (isInteractive) {
206
+ await runPresetCreateInteractive(ctx, release, cli, args.force);
207
+ return;
208
+ }
209
+ const requiredErrors = [];
210
+ if (cli.name === undefined) {
211
+ requiredErrors.push(getMessage("preset.error.missingName", locale, { command: "create" }));
212
+ }
213
+ const missing = [];
214
+ if (cli.modules === undefined)
215
+ missing.push("--module");
216
+ if (cli.features === undefined)
217
+ missing.push("--feature");
218
+ if (cli.agents === undefined)
219
+ missing.push("--agent");
220
+ if (missing.length > 0) {
221
+ requiredErrors.push(getMessage("error.missingRequiredOptions", locale, {
222
+ options: missing.join(", "),
223
+ }));
224
+ }
225
+ if (requiredErrors.length > 0) {
226
+ p.log.error(requiredErrors.join("\n"));
227
+ process.exit(1);
228
+ }
229
+ if ((await presetExists(projectDir, cli.name)) &&
230
+ !args.force) {
231
+ p.log.error(getMessage("preset.error.exists", locale, { name: cli.name }));
232
+ process.exit(1);
233
+ }
234
+ await writePreset(projectDir, buildPreset(cli.name, cli.label ?? "", cli.description ?? "", cli.modules, cli.features, cli.agents));
235
+ p.log.success(getMessage("preset.created", locale, { name: cli.name }));
236
+ },
237
+ });
238
+ export const buildPresetListBody = (summaries) => {
239
+ const displays = summaries.map(formatPresetDisplayName);
240
+ const maxWidth = Math.max(...displays.map((d) => displayWidth(d)));
241
+ return summaries
242
+ .map((summary, i) => {
243
+ const display = displays[i];
244
+ if (!summary.description)
245
+ return display;
246
+ const pad = " ".repeat(Math.max(0, maxWidth - displayWidth(display)));
247
+ return `${display}${pad} — ${sanitizeDisplayText(summary.description)}`;
248
+ })
249
+ .join("\n");
250
+ };
251
+ const listCommand = defineCommand({
252
+ meta: {
253
+ name: "list",
254
+ description: "List registered configuration presets",
255
+ },
256
+ run: async () => {
257
+ const { projectDir, locale } = await requirePresetContext();
258
+ const summaries = await listPresetSummaries(projectDir);
259
+ if (summaries.length === 0) {
260
+ p.log.info(getMessage("preset.list.empty", locale));
261
+ return;
262
+ }
263
+ p.log.info(buildPresetListBody(summaries));
264
+ },
265
+ });
266
+ export const buildPresetShowBody = (raw, locale) => {
267
+ const empty = getMessage("summary.empty", locale);
268
+ const text = (value) => typeof value === "string" && value !== ""
269
+ ? sanitizeDisplayText(value)
270
+ : empty;
271
+ const array = (value) => Array.isArray(value) && value.length > 0
272
+ ? value.map((v) => sanitizeDisplayText(String(v))).join(", ")
273
+ : empty;
274
+ const rows = [
275
+ [getMessage("preset.show.label", locale), text(raw.label)],
276
+ [getMessage("preset.show.description", locale), text(raw.description)],
277
+ [getMessage("preset.show.modules", locale), array(raw.modules)],
278
+ [getMessage("preset.show.features", locale), array(raw.features)],
279
+ [getMessage("preset.show.agents", locale), array(raw.agents)],
280
+ ];
281
+ const maxWidth = Math.max(...rows.map(([label]) => displayWidth(label)));
282
+ return rows
283
+ .map(([label, value]) => {
284
+ const pad = " ".repeat(Math.max(0, maxWidth - displayWidth(label)));
285
+ return `${label}${pad} : ${value}`;
286
+ })
287
+ .join("\n");
288
+ };
289
+ const requirePresetName = (nameArg, command, locale) => {
290
+ if (!nameArg) {
291
+ p.log.error(getMessage("preset.error.missingName", locale, { command }));
292
+ process.exit(1);
293
+ }
294
+ const nameError = createPresetNameValidator(locale)(nameArg);
295
+ if (nameError) {
296
+ p.log.error(nameError);
297
+ process.exit(1);
298
+ }
299
+ return nameArg;
300
+ };
301
+ const showCommand = defineCommand({
302
+ meta: {
303
+ name: "show",
304
+ description: "Show the contents of a configuration preset",
305
+ },
306
+ args: {
307
+ name: {
308
+ type: "positional",
309
+ description: "Preset name (ID)",
310
+ required: false,
311
+ },
312
+ },
313
+ run: async ({ args }) => {
314
+ const { projectDir, locale } = await requirePresetContext();
315
+ const name = requirePresetName(args.name, "show", locale);
316
+ let content;
317
+ try {
318
+ content = await readFile(presetPath(projectDir, name), "utf-8");
319
+ }
320
+ catch {
321
+ p.log.error(getMessage("preset.error.notFound", locale, { name }));
322
+ process.exit(1);
323
+ }
324
+ let raw;
325
+ try {
326
+ const parsed = JSON.parse(content);
327
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
328
+ throw new Error("not an object");
329
+ }
330
+ raw = parsed;
331
+ }
332
+ catch (err) {
333
+ p.log.error(getMessage("preset.error.invalid", locale, {
334
+ name,
335
+ errors: ` - ${getMessage("preset.error.parse", locale, {
336
+ message: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
337
+ })}`,
338
+ }));
339
+ process.exit(1);
340
+ }
341
+ p.note(buildPresetShowBody(raw, locale), formatPresetDisplayName({
342
+ name,
343
+ label: typeof raw.label === "string" ? raw.label : undefined,
344
+ }));
345
+ },
346
+ });
347
+ const deleteCommand = defineCommand({
348
+ meta: {
349
+ name: "delete",
350
+ description: "Delete a configuration preset",
351
+ },
352
+ args: {
353
+ name: {
354
+ type: "positional",
355
+ description: "Preset name (ID)",
356
+ required: false,
357
+ },
358
+ "non-interactive": {
359
+ type: "boolean",
360
+ description: "Non-interactive mode (delete without confirmation)",
361
+ default: false,
362
+ },
363
+ },
364
+ run: async ({ args }) => {
365
+ const { projectDir, locale } = await requirePresetContext();
366
+ const name = requirePresetName(args.name, "delete", locale);
367
+ if (!(await presetExists(projectDir, name))) {
368
+ p.log.error(getMessage("preset.error.notFound", locale, { name }));
369
+ process.exit(1);
370
+ }
371
+ if (!args["non-interactive"]) {
372
+ const ok = await p.confirm({
373
+ message: getMessage("preset.prompt.delete", locale, { name }),
374
+ initialValue: false,
375
+ });
376
+ if (p.isCancel(ok) || ok !== true) {
377
+ p.log.info(getMessage("preset.cancelled", locale));
378
+ process.exit(0);
379
+ }
380
+ }
381
+ await deletePreset(projectDir, name);
382
+ p.log.success(getMessage("preset.deleted", locale, { name }));
383
+ },
384
+ });
385
+ export const presetCommand = defineCommand({
386
+ meta: {
387
+ name: "preset",
388
+ description: "Manage configuration presets shared via .accel/presets/ (create / list / show / delete)",
389
+ },
390
+ subCommands: {
391
+ create: createCommand,
392
+ list: listCommand,
393
+ show: showCommand,
394
+ delete: deleteCommand,
395
+ },
396
+ });
@@ -11,6 +11,10 @@ export declare const switchCommand: import("citty").CommandDef<{
11
11
  type: "string";
12
12
  description: string;
13
13
  };
14
+ preset: {
15
+ type: "string";
16
+ description: string;
17
+ };
14
18
  "non-interactive": {
15
19
  type: "boolean";
16
20
  description: string;
@@ -9,6 +9,7 @@ import { createMessageCollector } from "../asset/messages.js";
9
9
  import { printAssetMessages } from "../interactive/asset-messages.js";
10
10
  import { installTriggerChanged, runInstallBuild } from "../asset/installer.js";
11
11
  import { readSettingsSafe, readHashsum, writeSettings, writeHashsum, } from "../utils/settings-io.js";
12
+ import { loadAndValidatePreset, listPresetSummaries, buildPresetSelectOptions, parsePresetChoice, } from "../utils/preset-io.js";
12
13
  import { getMessage } from "../i18n/index.js";
13
14
  import { detectLocale } from "../utils/locale-detect.js";
14
15
  import { printSummary } from "../interactive/summary.js";
@@ -78,6 +79,10 @@ export const switchCommand = defineCommand({
78
79
  type: "string",
79
80
  description: "Agent type",
80
81
  },
82
+ preset: {
83
+ type: "string",
84
+ description: "Configuration preset name to apply (mutually exclusive with --module / --feature / --agent)",
85
+ },
81
86
  "non-interactive": {
82
87
  type: "boolean",
83
88
  description: "Non-interactive mode",
@@ -113,16 +118,31 @@ export const switchCommand = defineCommand({
113
118
  ref: assetSource.ref,
114
119
  };
115
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
+ }
116
139
  const cliOnlyOpts = {
117
- module: args.module
118
- ?.split(",")
119
- .map((m) => m.trim()),
120
- feature: args.feature
121
- ?.split(",")
122
- .map((f) => f.trim()),
123
- agent: args.agent
124
- ?.split(",")
125
- .map((a) => a.trim()),
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()),
126
146
  locale,
127
147
  isInit: false,
128
148
  };
@@ -143,9 +163,48 @@ export const switchCommand = defineCommand({
143
163
  }));
144
164
  process.exit(1);
145
165
  }
146
- modules = await promptModules(release, modules, locale);
147
- features = await promptFeatures(release, features, locale);
148
- agents = await promptAgents(agents, locale);
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
+ }
149
208
  }
150
209
  const newSettings = {
151
210
  ...settings,
@@ -43,6 +43,10 @@ export declare const updateCommand: import("citty").CommandDef<{
43
43
  type: "string";
44
44
  description: string;
45
45
  };
46
+ preset: {
47
+ type: "string";
48
+ description: string;
49
+ };
46
50
  locale: {
47
51
  type: "string";
48
52
  description: string;
@@ -14,6 +14,7 @@ import { printAssetMessages } from "../interactive/asset-messages.js";
14
14
  import { mergeFile } from "../utils/merge-file.js";
15
15
  import { getInstallCmds, runInstallBuild } from "../asset/installer.js";
16
16
  import { readSettingsSafe, readHashsum, writeSettings, writeHashsum, } from "../utils/settings-io.js";
17
+ import { loadAndValidatePreset, listPresetSummaries, buildPresetSelectOptions, parsePresetChoice, } from "../utils/preset-io.js";
17
18
  import { getMessage } from "../i18n/index.js";
18
19
  import { detectLocale } from "../utils/locale-detect.js";
19
20
  import { printSummary } from "../interactive/summary.js";
@@ -74,7 +75,7 @@ const resolveFallbackMode = async (opts) => {
74
75
  }
75
76
  return { keepEdited: choice === "keep" };
76
77
  };
77
- const resolveInteractiveSettings = async (promptOpts, cliOnlyOpts, releaseIdFallback) => {
78
+ const resolveInteractiveSettings = async (promptOpts, cliOnlyOpts, releaseIdFallback, presets, projectDir, presetSpecified) => {
78
79
  const locale = promptOpts.locale;
79
80
  const cliErrors = collectSettingsErrors(cliOnlyOpts, locale, releaseIdFallback);
80
81
  if (cliErrors.length > 0) {
@@ -88,20 +89,51 @@ const resolveInteractiveSettings = async (promptOpts, cliOnlyOpts, releaseIdFall
88
89
  }));
89
90
  return runPrompts({ ...promptOpts, skipIntro: true, skipValidation: true });
90
91
  }
91
- const useExisting = await p.confirm({
92
- message: withHint("prompt.useExistingSettings", locale),
93
- initialValue: true,
92
+ const useExistingPath = (overrides = {}) => runPrompts({
93
+ ...promptOpts,
94
+ jugglingProject: cliOnlyOpts.jugglingProject,
95
+ noInteraction: true,
96
+ ...overrides,
94
97
  });
95
- if (p.isCancel(useExisting))
98
+ const reenterPath = () => runPrompts({ ...promptOpts, skipIntro: true });
99
+ if (presetSpecified)
100
+ return useExistingPath();
101
+ if (presets.length === 0) {
102
+ const useExisting = await p.confirm({
103
+ message: withHint("prompt.useExistingSettings", locale),
104
+ initialValue: true,
105
+ });
106
+ if (p.isCancel(useExisting))
107
+ process.exit(0);
108
+ return useExisting ? useExistingPath() : reenterPath();
109
+ }
110
+ const choice = await p.select({
111
+ message: getMessage("preset.prompt.updateSelect", locale),
112
+ options: [
113
+ {
114
+ value: "__existing__",
115
+ label: getMessage("preset.prompt.updateSelect.existing", locale),
116
+ },
117
+ ...buildPresetSelectOptions(presets, locale),
118
+ {
119
+ value: "__reenter__",
120
+ label: getMessage("preset.prompt.updateSelect.reenter", locale),
121
+ },
122
+ ],
123
+ initialValue: "__existing__",
124
+ });
125
+ if (p.isCancel(choice))
96
126
  process.exit(0);
97
- return useExisting
98
- ?
99
- runPrompts({
100
- ...promptOpts,
101
- jugglingProject: cliOnlyOpts.jugglingProject,
102
- noInteraction: true,
103
- })
104
- : runPrompts({ ...promptOpts, skipIntro: true });
127
+ const presetName = parsePresetChoice(choice);
128
+ if (presetName === undefined) {
129
+ return choice === "__reenter__" ? reenterPath() : useExistingPath();
130
+ }
131
+ const preset = await loadAndValidatePreset(projectDir, presetName, promptOpts.accelplatformVersion ?? releaseIdFallback, locale);
132
+ return useExistingPath({
133
+ module: preset.modules,
134
+ feature: preset.features,
135
+ agent: preset.agents,
136
+ });
105
137
  };
106
138
  const printResult = (summary, locale, installGuide) => {
107
139
  const lines = [
@@ -210,6 +242,10 @@ export const updateCommand = defineCommand({
210
242
  type: "string",
211
243
  description: "Agent type",
212
244
  },
245
+ preset: {
246
+ type: "string",
247
+ description: "Configuration preset name to apply (mutually exclusive with --module / --feature / --agent)",
248
+ },
213
249
  locale: {
214
250
  type: "string",
215
251
  description: "Locale (ja, en, zh_CN)",
@@ -266,6 +302,14 @@ export const updateCommand = defineCommand({
266
302
  p.log.error(getMessage("update.error.keepEditedWithoutAllow", locale));
267
303
  process.exit(1);
268
304
  }
305
+ const presetArg = args.preset;
306
+ if (presetArg !== undefined &&
307
+ (args.module !== undefined ||
308
+ args.feature !== undefined ||
309
+ args.agent !== undefined)) {
310
+ p.log.error(getMessage("preset.error.conflictingFlags", locale));
311
+ process.exit(1);
312
+ }
269
313
  const assetSource = settings.assetSource;
270
314
  if (!assetSource) {
271
315
  p.log.error(getMessage("update.error.legacyProject", locale));
@@ -283,6 +327,17 @@ export const updateCommand = defineCommand({
283
327
  const targetUrl = args["asset-server-url"] ?? source.url;
284
328
  const targetRef = args["asset-ref"] ?? source.ref;
285
329
  const isInteractive = !args["non-interactive"];
330
+ let presetValues;
331
+ if (presetArg !== undefined) {
332
+ try {
333
+ presetValues = await loadAndValidatePreset(projectDir, presetArg, args["accelplatform-version"] ??
334
+ settings.accelplatformVersion.label, locale);
335
+ }
336
+ catch (err) {
337
+ p.log.error(err instanceof Error ? err.message : String(err));
338
+ process.exit(1);
339
+ }
340
+ }
286
341
  if (!(await confirmDirtyWorktree(projectDir, locale, isInteractive))) {
287
342
  p.log.info(getMessage("update.cancelled", locale));
288
343
  process.exit(0);
@@ -292,20 +347,17 @@ export const updateCommand = defineCommand({
292
347
  artifactId: args["artifact-id"],
293
348
  jugglingProject: args["juggling-project"],
294
349
  accelplatformVersion: args["accelplatform-version"],
295
- module: args.module
296
- ?.split(",")
297
- .map((m) => m.trim()),
298
- feature: args.feature
299
- ?.split(",")
300
- .map((f) => f.trim()),
350
+ module: presetValues?.modules ??
351
+ args.module?.split(",").map((m) => m.trim()),
352
+ feature: presetValues?.features ??
353
+ args.feature?.split(",").map((f) => f.trim()),
301
354
  group: args.group,
302
355
  projectVersion: args["project-version"],
303
356
  description: args.description,
304
357
  database: args.database,
305
358
  javascript: args.javascript,
306
- agent: args.agent
307
- ?.split(",")
308
- .map((a) => a.trim()),
359
+ agent: presetValues?.agents ??
360
+ args.agent?.split(",").map((a) => a.trim()),
309
361
  packageManager: args["package-manager"],
310
362
  locale,
311
363
  isInit: false,
@@ -333,7 +385,7 @@ export const updateCommand = defineCommand({
333
385
  let resolved;
334
386
  try {
335
387
  resolved = isInteractive
336
- ? await resolveInteractiveSettings(promptOpts, cliOnlyOpts, settings.accelplatformVersion.label)
388
+ ? await resolveInteractiveSettings(promptOpts, cliOnlyOpts, settings.accelplatformVersion.label, presetArg !== undefined ? [] : await listPresetSummaries(projectDir), projectDir, presetArg !== undefined)
337
389
  : await runPrompts(promptOpts);
338
390
  }
339
391
  catch (err) {
@@ -112,6 +112,14 @@ export type AccelSettings = {
112
112
  assetSource?: AssetSourceInfo;
113
113
  deployedAssets: Record<string, string>;
114
114
  };
115
+ export type AccelPreset = {
116
+ name: string;
117
+ label?: string;
118
+ description?: string;
119
+ modules: string[];
120
+ features: string[];
121
+ agents: string[];
122
+ };
115
123
  export type HashsumEntry = {
116
124
  filePath: string;
117
125
  version: string;
@@ -15,4 +15,6 @@ export type ReleaseValidators = {
15
15
  feature: Validator;
16
16
  };
17
17
  export declare const createValidators: (locale: string) => Validators;
18
+ export declare const PRESET_NAME_PATTERN: RegExp;
19
+ export declare const createPresetNameValidator: (locale: string) => Validator;
18
20
  export declare const createReleaseValidators: (locale: string, release: Release) => ReleaseValidators;
@@ -75,6 +75,13 @@ export const createValidators = (locale) => ({
75
75
  });
76
76
  },
77
77
  });
78
+ export const PRESET_NAME_PATTERN = /^[A-Za-z0-9_-]+$/;
79
+ export const createPresetNameValidator = (locale) => (value) => {
80
+ const v = value ?? "";
81
+ return PRESET_NAME_PATTERN.test(v)
82
+ ? undefined
83
+ : getMessage("preset.error.invalidName", locale, { value: v });
84
+ };
78
85
  export const createReleaseValidators = (locale, release) => ({
79
86
  module: (value) => {
80
87
  const v = value ?? "";
package/dist/i18n/en.js CHANGED
@@ -113,6 +113,41 @@ export const messages = {
113
113
  "cache.info.empty": "The cache is empty.",
114
114
  "cache.clear.done": "Cache cleared. Freed {size}.",
115
115
  "cache.clear.empty": "There is no cache to clear.",
116
+ "intro.preset": "Register combinations of modules, features, and agents as configuration presets.\nPresets are saved under .accel/presets/ and shared with your team once committed.\nRegistered presets can be used with accel update / accel switch.",
117
+ "preset.prompt.name": "Enter preset name (ID)",
118
+ "preset.prompt.name.hint": "Used as the file name (.accel/presets/<name>.json) and as the value for --preset\nOnly alphanumerics, - and _ are allowed (e.g. server-side, ui, workflow)",
119
+ "preset.prompt.label": "Enter display name (optional)",
120
+ "preset.prompt.label.hint": "Shown in lists and selection prompts; any characters (e.g. Japanese) are allowed\nLeave empty to display the preset name (ID) as is",
121
+ "preset.prompt.description": "Enter preset description (optional)",
122
+ "preset.prompt.description.hint": "A short note on which development case this preset is for. Shown in lists and selection prompts",
123
+ "preset.prompt.overwrite": "Preset {name} already exists. Overwrite?",
124
+ "preset.prompt.continue": "Create another preset?",
125
+ "preset.prompt.delete": "Delete preset {name}. Are you sure?",
126
+ "preset.prompt.updateSelect": "How would you like to determine the settings?",
127
+ "preset.prompt.updateSelect.existing": "Use the existing settings",
128
+ "preset.prompt.updateSelect.reenter": "Re-enter the settings",
129
+ "preset.prompt.switchSelect": "Use a preset?",
130
+ "preset.prompt.switchSelect.none": "Do not use a preset (select individually)",
131
+ "preset.prompt.select.usePreset": "Use preset {name}",
132
+ "preset.created": "Saved preset {name}.",
133
+ "preset.deleted": "Deleted preset {name}.",
134
+ "preset.cancelled": "Cancelled.",
135
+ "preset.list.empty": "No presets registered. Create one with accel preset create.",
136
+ "preset.show.label": "Display name",
137
+ "preset.show.description": "Description",
138
+ "preset.show.modules": "Modules",
139
+ "preset.show.features": "Features",
140
+ "preset.show.agents": "Agents",
141
+ "preset.error.noSettings": ".accel directory not found. Run this inside a project that has been initialized with init or attach.",
142
+ "preset.error.missingName": "Preset name is not specified. Provide it as an argument (e.g., accel preset {command} my-preset)",
143
+ "preset.error.notFound": "Preset not found: {name}",
144
+ "preset.error.exists": "Preset {name} already exists. Pass --force to overwrite it.",
145
+ "preset.error.invalidName": "Preset names may only contain alphanumerics, - and _: {value}",
146
+ "preset.error.invalid": "Preset {name} is invalid:\n{errors}",
147
+ "preset.error.parse": "Cannot be parsed as JSON: {message}",
148
+ "preset.error.field": "Field {field} is missing or is not an array of strings",
149
+ "preset.error.nameMismatch": "The name value ({value}) does not match the file name ({name})",
150
+ "preset.error.conflictingFlags": "--preset cannot be combined with --module / --feature / --agent.",
116
151
  "error.directoryExists": "Directory already exists: {path}",
117
152
  "error.accelExists": ".accel directory already exists",
118
153
  "error.accelNotFound": ".accel directory not found",
package/dist/i18n/ja.js CHANGED
@@ -113,6 +113,41 @@ export const messages = {
113
113
  "cache.info.empty": "キャッシュは空です。",
114
114
  "cache.clear.done": "キャッシュを削除しました。{size} を解放しました。",
115
115
  "cache.clear.empty": "削除対象のキャッシュはありません。",
116
+ "intro.preset": "モジュール・機能・エージェントの組み合わせを構成プリセットとして登録します。\nプリセットは .accel/presets/ に保存され、コミットするとチームで共有できます。\n登録したプリセットは accel update / accel switch で利用できます。",
117
+ "preset.prompt.name": "プリセット名(ID)を入力してください",
118
+ "preset.prompt.name.hint": "ファイル名(.accel/presets/<名前>.json)と --preset での指定に使われます\n英数字と - _ のみ使用できます(例: server-side, ui, workflow)",
119
+ "preset.prompt.label": "表示名を入力してください(省略可)",
120
+ "preset.prompt.label.hint": "一覧や選択肢に表示される名前。日本語なども使用できます\n空のまま確定するとプリセット名(ID)をそのまま表示します",
121
+ "preset.prompt.description": "プリセットの説明を入力してください(省略可)",
122
+ "preset.prompt.description.hint": "このプリセットがどの開発ケース向けかの簡潔な説明。一覧や選択肢に表示されます",
123
+ "preset.prompt.overwrite": "プリセット {name} は既に存在します。上書きしますか?",
124
+ "preset.prompt.continue": "続けて別のプリセットを作成しますか?",
125
+ "preset.prompt.delete": "プリセット {name} を削除します。よろしいですか?",
126
+ "preset.prompt.updateSelect": "設定の決め方を選択してください",
127
+ "preset.prompt.updateSelect.existing": "既存の設定を利用する",
128
+ "preset.prompt.updateSelect.reenter": "設定を再入力する",
129
+ "preset.prompt.switchSelect": "プリセットを利用しますか?",
130
+ "preset.prompt.switchSelect.none": "プリセットを使わない(個別に選択する)",
131
+ "preset.prompt.select.usePreset": "プリセット {name} を利用する",
132
+ "preset.created": "プリセット {name} を保存しました。",
133
+ "preset.deleted": "プリセット {name} を削除しました。",
134
+ "preset.cancelled": "キャンセルしました。",
135
+ "preset.list.empty": "プリセットはありません。accel preset create で作成できます。",
136
+ "preset.show.label": "表示名",
137
+ "preset.show.description": "説明",
138
+ "preset.show.modules": "モジュール",
139
+ "preset.show.features": "機能",
140
+ "preset.show.agents": "エージェント",
141
+ "preset.error.noSettings": ".accelディレクトリが見つかりません。init または attach 済みのプロジェクト内で実行してください。",
142
+ "preset.error.missingName": "プリセット名が指定されていません。引数で指定してください(例: accel preset {command} my-preset)",
143
+ "preset.error.notFound": "プリセットが見つかりません: {name}",
144
+ "preset.error.exists": "プリセット {name} は既に存在します。上書きするには --force を指定してください。",
145
+ "preset.error.invalidName": "プリセット名に使用できるのは英数字と - _ のみです: {value}",
146
+ "preset.error.invalid": "プリセット {name} が不正です:\n{errors}",
147
+ "preset.error.parse": "JSONとして解析できません: {message}",
148
+ "preset.error.field": "フィールド {field} が存在しないか、文字列の配列ではありません",
149
+ "preset.error.nameMismatch": "name の値 ({value}) がファイル名 ({name}) と一致しません",
150
+ "preset.error.conflictingFlags": "--preset と --module / --feature / --agent は同時に指定できません。",
116
151
  "error.directoryExists": "ディレクトリが既に存在します: {path}",
117
152
  "error.accelExists": ".accelディレクトリが既に存在します",
118
153
  "error.accelNotFound": ".accelディレクトリが見つかりません",
@@ -113,6 +113,41 @@ export const messages = {
113
113
  "cache.info.empty": "缓存为空。",
114
114
  "cache.clear.done": "缓存已删除。释放了 {size}。",
115
115
  "cache.clear.empty": "没有可删除的缓存。",
116
+ "intro.preset": "将模块・功能・代理的组合注册为配置预设。\n预设保存在 .accel/presets/ 中,提交后即可与团队共享。\n注册的预设可在 accel update / accel switch 中使用。",
117
+ "preset.prompt.name": "请输入预设名称(ID)",
118
+ "preset.prompt.name.hint": "用作文件名(.accel/presets/<名称>.json)以及 --preset 的指定值\n仅可使用字母数字和 - _(例如: server-side, ui, workflow)",
119
+ "preset.prompt.label": "请输入显示名称(可选)",
120
+ "preset.prompt.label.hint": "在列表和选项中显示的名称,可使用中文等任意字符\n留空确认则直接显示预设名称(ID)",
121
+ "preset.prompt.description": "请输入预设的描述(可选)",
122
+ "preset.prompt.description.hint": "简要说明此预设适用于哪种开发场景。会显示在列表和选项中",
123
+ "preset.prompt.overwrite": "预设 {name} 已存在。要覆盖吗?",
124
+ "preset.prompt.continue": "继续创建另一个预设吗?",
125
+ "preset.prompt.delete": "将删除预设 {name}。确定吗?",
126
+ "preset.prompt.updateSelect": "请选择设置的确定方式",
127
+ "preset.prompt.updateSelect.existing": "使用现有设置",
128
+ "preset.prompt.updateSelect.reenter": "重新输入设置",
129
+ "preset.prompt.switchSelect": "要使用预设吗?",
130
+ "preset.prompt.switchSelect.none": "不使用预设(逐项选择)",
131
+ "preset.prompt.select.usePreset": "使用预设 {name}",
132
+ "preset.created": "已保存预设 {name}。",
133
+ "preset.deleted": "已删除预设 {name}。",
134
+ "preset.cancelled": "已取消。",
135
+ "preset.list.empty": "没有预设。可通过 accel preset create 创建。",
136
+ "preset.show.label": "显示名称",
137
+ "preset.show.description": "描述",
138
+ "preset.show.modules": "模块",
139
+ "preset.show.features": "功能",
140
+ "preset.show.agents": "代理",
141
+ "preset.error.noSettings": "未找到.accel目录。请在已执行 init 或 attach 的项目内运行。",
142
+ "preset.error.missingName": "未指定预设名称。请作为参数指定(例如: accel preset {command} my-preset)",
143
+ "preset.error.notFound": "未找到预设: {name}",
144
+ "preset.error.exists": "预设 {name} 已存在。要覆盖请指定 --force。",
145
+ "preset.error.invalidName": "预设名称仅可使用字母数字和 - _: {value}",
146
+ "preset.error.invalid": "预设 {name} 无效:\n{errors}",
147
+ "preset.error.parse": "无法解析为JSON: {message}",
148
+ "preset.error.field": "字段 {field} 不存在或不是字符串数组",
149
+ "preset.error.nameMismatch": "name 的值 ({value}) 与文件名 ({name}) 不一致",
150
+ "preset.error.conflictingFlags": "--preset 不能与 --module / --feature / --agent 同时指定。",
116
151
  "error.directoryExists": "目录已存在: {path}",
117
152
  "error.accelExists": ".accel目录已存在",
118
153
  "error.accelNotFound": "未找到.accel目录",
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ import { attachCommand } from "./commands/attach.js";
5
5
  import { detachCommand } from "./commands/detach.js";
6
6
  import { updateCommand } from "./commands/update.js";
7
7
  import { switchCommand } from "./commands/switch.js";
8
+ import { presetCommand } from "./commands/preset.js";
8
9
  import { cacheCommand } from "./commands/cache.js";
9
10
  import { loginCommand } from "./commands/login.js";
10
11
  import { deployCommand } from "./commands/deploy.js";
@@ -21,6 +22,7 @@ const main = defineCommand({
21
22
  detach: detachCommand,
22
23
  update: updateCommand,
23
24
  switch: switchCommand,
25
+ preset: presetCommand,
24
26
  cache: cacheCommand,
25
27
  login: loginCommand,
26
28
  deploy: deployCommand,
@@ -31,7 +31,7 @@ export declare const validateNonInteractive: (opts: PromptOptions) => string[];
31
31
  export declare const validateCliValues: (opts: PromptOptions, validators: Validators) => void;
32
32
  export declare const validateCatalogValues: (opts: PromptOptions, release: Release, locale: string) => void;
33
33
  export declare const collectSettingsErrors: (opts: PromptOptions, locale: string, releaseIdFallback?: string) => string[];
34
- export declare const printIntro: (mode: "init" | "attach" | "update" | "switch", locale: string) => void;
34
+ export declare const printIntro: (mode: "init" | "attach" | "update" | "switch" | "preset", locale: string) => void;
35
35
  export declare const promptModules: (release: Release, initialValues: string[], locale: string) => Promise<string[]>;
36
36
  export declare const promptFeatures: (release: Release, initialValues: string[] | undefined, locale: string) => Promise<string[]>;
37
37
  export declare const promptAgents: (initialValues: string[] | undefined, locale: string) => Promise<string[]>;
@@ -0,0 +1,23 @@
1
+ import type { AccelPreset } from "../core/types.js";
2
+ import { type Release } from "../core/catalog.js";
3
+ export declare const presetsDir: (projectDir: string) => string;
4
+ export declare const presetPath: (projectDir: string, name: string) => string;
5
+ export declare const writePreset: (projectDir: string, preset: AccelPreset) => Promise<void>;
6
+ export declare const presetExists: (projectDir: string, name: string) => Promise<boolean>;
7
+ export declare const deletePreset: (projectDir: string, name: string) => Promise<void>;
8
+ export type PresetSummary = {
9
+ name: string;
10
+ label?: string;
11
+ description?: string;
12
+ };
13
+ export declare const listPresetSummaries: (projectDir: string) => Promise<PresetSummary[]>;
14
+ export declare const formatPresetDisplayName: (summary: PresetSummary) => string;
15
+ export declare const buildPresetSelectOptions: (presets: PresetSummary[], locale: string) => Array<{
16
+ value: string;
17
+ label: string;
18
+ hint?: string;
19
+ }>;
20
+ export declare const parsePresetChoice: (choice: string) => string | undefined;
21
+ export declare const validatePresetSchema: (raw: unknown, expectedName: string, locale: string) => string[];
22
+ export declare const collectPresetCatalogErrors: (preset: AccelPreset, release: Release, locale: string) => string[];
23
+ export declare const loadAndValidatePreset: (projectDir: string, name: string, releaseId: string, locale: string) => Promise<AccelPreset>;
@@ -0,0 +1,164 @@
1
+ import { readFile, writeFile, mkdir, readdir, rm, stat } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { PRESET_NAME_PATTERN, createPresetNameValidator, createReleaseValidators, createValidators, } from "../core/validators.js";
4
+ import { findReleaseById } from "../core/catalog.js";
5
+ import { getMessage } from "../i18n/index.js";
6
+ import { ACCEL_DIR } from "./settings-io.js";
7
+ import { sanitizeDisplayText } from "./sanitize-text.js";
8
+ import { mapWithConcurrency, FS_CONCURRENCY } from "./concurrency.js";
9
+ const PRESETS_DIR = "presets";
10
+ const PRESET_EXT = ".json";
11
+ export const presetsDir = (projectDir) => join(projectDir, ACCEL_DIR, PRESETS_DIR);
12
+ export const presetPath = (projectDir, name) => {
13
+ if (!PRESET_NAME_PATTERN.test(name)) {
14
+ throw new Error(`Invalid preset name: ${name}`);
15
+ }
16
+ return join(presetsDir(projectDir), `${name}${PRESET_EXT}`);
17
+ };
18
+ export const writePreset = async (projectDir, preset) => {
19
+ const filePath = presetPath(projectDir, preset.name);
20
+ await mkdir(presetsDir(projectDir), { recursive: true });
21
+ await writeFile(filePath, JSON.stringify(preset, null, 2) + "\n", "utf-8");
22
+ };
23
+ export const presetExists = async (projectDir, name) => {
24
+ try {
25
+ await stat(presetPath(projectDir, name));
26
+ return true;
27
+ }
28
+ catch {
29
+ return false;
30
+ }
31
+ };
32
+ export const deletePreset = async (projectDir, name) => {
33
+ await rm(presetPath(projectDir, name));
34
+ };
35
+ export const listPresetSummaries = async (projectDir) => {
36
+ let entries;
37
+ try {
38
+ entries = await readdir(presetsDir(projectDir));
39
+ }
40
+ catch {
41
+ return [];
42
+ }
43
+ const names = entries
44
+ .filter((f) => f.endsWith(PRESET_EXT))
45
+ .map((f) => f.slice(0, -PRESET_EXT.length))
46
+ .filter((n) => PRESET_NAME_PATTERN.test(n))
47
+ .sort((a, b) => a.localeCompare(b));
48
+ return mapWithConcurrency(names, FS_CONCURRENCY, async (name) => {
49
+ const summary = { name };
50
+ try {
51
+ const raw = JSON.parse(await readFile(presetPath(projectDir, name), "utf-8"));
52
+ if (typeof raw.label === "string" && raw.label.length > 0) {
53
+ summary.label = raw.label;
54
+ }
55
+ if (typeof raw.description === "string" && raw.description.length > 0) {
56
+ summary.description = raw.description;
57
+ }
58
+ }
59
+ catch {
60
+ }
61
+ return summary;
62
+ });
63
+ };
64
+ export const formatPresetDisplayName = (summary) => summary.label
65
+ ? `${sanitizeDisplayText(summary.label)} (${summary.name})`
66
+ : summary.name;
67
+ const PRESET_CHOICE_PREFIX = "preset:";
68
+ export const buildPresetSelectOptions = (presets, locale) => presets.map((summary) => ({
69
+ value: `${PRESET_CHOICE_PREFIX}${summary.name}`,
70
+ label: getMessage("preset.prompt.select.usePreset", locale, {
71
+ name: formatPresetDisplayName(summary),
72
+ }),
73
+ ...(summary.description
74
+ ? { hint: sanitizeDisplayText(summary.description) }
75
+ : {}),
76
+ }));
77
+ export const parsePresetChoice = (choice) => choice.startsWith(PRESET_CHOICE_PREFIX)
78
+ ? choice.slice(PRESET_CHOICE_PREFIX.length)
79
+ : undefined;
80
+ const isStringArray = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
81
+ export const validatePresetSchema = (raw, expectedName, locale) => {
82
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
83
+ return [
84
+ getMessage("preset.error.parse", locale, { message: "not an object" }),
85
+ ];
86
+ }
87
+ const obj = raw;
88
+ const errors = [];
89
+ for (const field of ["modules", "features", "agents"]) {
90
+ if (!isStringArray(obj[field])) {
91
+ errors.push(getMessage("preset.error.field", locale, { field }));
92
+ }
93
+ }
94
+ if (obj.name !== expectedName) {
95
+ errors.push(getMessage("preset.error.nameMismatch", locale, {
96
+ value: sanitizeDisplayText(typeof obj.name === "string" ? obj.name : String(obj.name)),
97
+ name: expectedName,
98
+ }));
99
+ }
100
+ return errors;
101
+ };
102
+ export const collectPresetCatalogErrors = (preset, release, locale) => {
103
+ const releaseValidators = createReleaseValidators(locale, release);
104
+ const agentValidator = createValidators(locale).agent;
105
+ const errors = [];
106
+ for (const module of preset.modules) {
107
+ const error = releaseValidators.module(module);
108
+ if (error)
109
+ errors.push(error);
110
+ }
111
+ for (const feature of preset.features) {
112
+ const error = releaseValidators.feature(feature);
113
+ if (error)
114
+ errors.push(error);
115
+ }
116
+ for (const agent of preset.agents) {
117
+ const error = agentValidator(agent);
118
+ if (error)
119
+ errors.push(error);
120
+ }
121
+ return errors.map((error) => sanitizeDisplayText(error));
122
+ };
123
+ const invalidPresetError = (name, errors, locale) => new Error(getMessage("preset.error.invalid", locale, {
124
+ name,
125
+ errors: errors.map((e) => ` - ${e}`).join("\n"),
126
+ }));
127
+ export const loadAndValidatePreset = async (projectDir, name, releaseId, locale) => {
128
+ const nameError = createPresetNameValidator(locale)(name);
129
+ if (nameError) {
130
+ throw new Error(nameError);
131
+ }
132
+ let content;
133
+ try {
134
+ content = await readFile(presetPath(projectDir, name), "utf-8");
135
+ }
136
+ catch {
137
+ throw new Error(getMessage("preset.error.notFound", locale, { name }));
138
+ }
139
+ let raw;
140
+ try {
141
+ raw = JSON.parse(content);
142
+ }
143
+ catch (err) {
144
+ throw invalidPresetError(name, [
145
+ getMessage("preset.error.parse", locale, {
146
+ message: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
147
+ }),
148
+ ], locale);
149
+ }
150
+ const schemaErrors = validatePresetSchema(raw, name, locale);
151
+ if (schemaErrors.length > 0) {
152
+ throw invalidPresetError(name, schemaErrors, locale);
153
+ }
154
+ const preset = raw;
155
+ const release = findReleaseById(releaseId);
156
+ if (!release) {
157
+ throw new Error(getMessage("error.invalidVersion", locale, { version: releaseId }));
158
+ }
159
+ const catalogErrors = collectPresetCatalogErrors(preset, release, locale);
160
+ if (catalogErrors.length > 0) {
161
+ throw invalidPresetError(name, catalogErrors, locale);
162
+ }
163
+ return preset;
164
+ };
@@ -1,4 +1,5 @@
1
1
  import type { AccelSettings, HashsumEntry } from "../core/types.js";
2
+ export declare const ACCEL_DIR = ".accel";
2
3
  export declare const writeSettings: (projectDir: string, settings: AccelSettings) => Promise<void>;
3
4
  export declare const readSettings: (projectDir: string) => Promise<AccelSettings>;
4
5
  export declare const readSettingsSafe: (projectDir: string) => Promise<AccelSettings | null>;
@@ -1,7 +1,7 @@
1
1
  import { readFile, writeFile, mkdir } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { isSafeRelPath } from "./safe-rel-path.js";
4
- const ACCEL_DIR = ".accel";
4
+ export const ACCEL_DIR = ".accel";
5
5
  const SETTINGS_FILE = "settings.json";
6
6
  const HASHSUM_FILE = "hashsum.txt";
7
7
  const ensureAccelDir = async (projectDir) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intra-mart/accel",
3
- "version": "0.5.0-dev.202608030656",
3
+ "version": "0.5.0-dev.202608040843",
4
4
  "type": "module",
5
5
  "description": "CLI tool for intra-mart Accel Platform development",
6
6
  "author": "NTT DATA INTRAMART",