@intra-mart/accel 0.5.0-dev.202608030656 → 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.
- package/README.md +103 -32
- package/dist/asset/deployer.d.ts +2 -0
- package/dist/asset/deployer.js +11 -9
- package/dist/asset/git-provider.d.ts +1 -0
- package/dist/asset/git-provider.js +20 -9
- package/dist/asset/updater.d.ts +9 -2
- package/dist/asset/updater.js +12 -6
- package/dist/asset/walker.d.ts +2 -1
- package/dist/asset/walker.js +36 -0
- package/dist/commands/asset-provider.d.ts +1 -1
- package/dist/commands/asset-provider.js +2 -2
- package/dist/commands/attach.d.ts +116 -82
- package/dist/commands/attach.js +176 -145
- package/dist/commands/cache.js +11 -19
- package/dist/commands/deploy.d.ts +53 -32
- package/dist/commands/deploy.js +112 -75
- package/dist/commands/detach.d.ts +18 -0
- package/dist/commands/detach.js +69 -54
- package/dist/commands/init.d.ts +117 -83
- package/dist/commands/init.js +119 -98
- package/dist/commands/login.d.ts +12 -10
- package/dist/commands/login.js +14 -10
- package/dist/commands/preset.d.ts +31 -0
- package/dist/commands/preset.js +389 -0
- package/dist/commands/run-wrapper.d.ts +15 -0
- package/dist/commands/run-wrapper.js +62 -0
- package/dist/commands/switch.d.ts +49 -17
- package/dist/commands/switch.js +206 -122
- package/dist/commands/update.d.ts +142 -83
- package/dist/commands/update.js +359 -261
- package/dist/core/color-env.d.ts +1 -0
- package/dist/core/color-env.js +6 -0
- package/dist/core/constants.d.ts +0 -1
- package/dist/core/constants.js +0 -3
- package/dist/core/errors.d.ts +6 -0
- package/dist/core/errors.js +16 -0
- package/dist/core/logger.d.ts +15 -0
- package/dist/core/logger.js +1 -0
- package/dist/core/paths.d.ts +6 -0
- package/dist/core/paths.js +22 -0
- package/dist/core/types.d.ts +14 -1
- package/dist/core/validation.d.ts +34 -0
- package/dist/core/validation.js +87 -0
- package/dist/core/validators.d.ts +2 -0
- package/dist/core/validators.js +7 -0
- package/dist/deploy/api-client.d.ts +1 -0
- package/dist/deploy/api-client.js +7 -1
- package/dist/git/config-file.d.ts +3 -0
- package/dist/git/config-file.js +178 -0
- package/dist/git/errors.d.ts +5 -0
- package/dist/git/errors.js +21 -2
- package/dist/git/git-objects.d.ts +11 -0
- package/dist/git/git-objects.js +49 -0
- package/dist/git/http.d.ts +2 -2
- package/dist/git/http.js +22 -10
- package/dist/git/index-file.d.ts +17 -0
- package/dist/git/index-file.js +111 -0
- package/dist/git/object-cache.d.ts +1 -0
- package/dist/git/object-cache.js +11 -15
- package/dist/git/object-store.d.ts +4 -0
- package/dist/git/object-store.js +82 -107
- package/dist/git/pack-parse.d.ts +19 -0
- package/dist/git/pack-parse.js +261 -0
- package/dist/git/pack-store.d.ts +20 -0
- package/dist/git/pack-store.js +144 -0
- package/dist/git/read-capped.d.ts +1 -0
- package/dist/git/read-capped.js +26 -0
- package/dist/git/redact-url.d.ts +1 -0
- package/dist/git/redact-url.js +14 -0
- package/dist/git/repo-layout.d.ts +5 -0
- package/dist/git/repo-layout.js +44 -0
- package/dist/git/smart-http.d.ts +3 -2
- package/dist/git/smart-http.js +5 -5
- package/dist/git/untracked.d.ts +11 -0
- package/dist/git/untracked.js +93 -0
- package/dist/git/worktree-status.d.ts +4 -0
- package/dist/git/worktree-status.js +140 -0
- package/dist/git/zlib-inflate.d.ts +7 -0
- package/dist/git/zlib-inflate.js +78 -0
- package/dist/i18n/en.js +47 -0
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/ja.js +47 -0
- package/dist/i18n/zh_CN.js +47 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -2
- package/dist/interactive/asset-messages.d.ts +2 -1
- package/dist/interactive/asset-messages.js +4 -4
- package/dist/interactive/clack-logger.d.ts +2 -0
- package/dist/interactive/clack-logger.js +11 -0
- package/dist/interactive/credential-auth.d.ts +2 -0
- package/dist/interactive/credential-auth.js +7 -6
- package/dist/interactive/credentials-prompts.js +10 -6
- package/dist/interactive/next-steps.d.ts +2 -1
- package/dist/interactive/next-steps.js +3 -3
- package/dist/interactive/progress.d.ts +8 -1
- package/dist/interactive/progress.js +0 -0
- package/dist/interactive/prompts.d.ts +3 -33
- package/dist/interactive/prompts.js +23 -111
- package/dist/interactive/summary.d.ts +2 -1
- package/dist/interactive/summary.js +3 -3
- package/dist/juggling/resolve.d.ts +7 -0
- package/dist/juggling/resolve.js +18 -0
- package/dist/lib.d.ts +34 -0
- package/dist/lib.js +29 -0
- package/dist/utils/args.d.ts +4 -1
- package/dist/utils/args.js +26 -3
- package/dist/utils/githooks-sync.d.ts +3 -1
- package/dist/utils/githooks-sync.js +37 -37
- package/dist/utils/mcp-generate.d.ts +26 -0
- package/dist/utils/mcp-generate.js +313 -0
- package/dist/utils/preset-io.d.ts +24 -0
- package/dist/utils/preset-io.js +167 -0
- package/dist/utils/settings-io.d.ts +2 -0
- package/dist/utils/settings-io.js +2 -2
- package/package.json +20 -13
- package/dist/utils/mcp-sync.d.ts +0 -4
- package/dist/utils/mcp-sync.js +0 -103
package/dist/commands/login.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { defineCommand } from "citty";
|
|
2
|
-
import
|
|
2
|
+
import { createClackLogger } from "../interactive/clack-logger.js";
|
|
3
3
|
import { detectLocale } from "../utils/locale-detect.js";
|
|
4
4
|
import { readSettingsSafe } from "../utils/settings-io.js";
|
|
5
5
|
import { readCredentials as defaultReadCredentials, resolveCredentialInputs, } from "../utils/credentials.js";
|
|
6
|
-
import {
|
|
6
|
+
import { createPersistCredentialsWithMcp } from "../utils/mcp-generate.js";
|
|
7
7
|
import { repromptCredentials as defaultRepromptCredentials, resolveCredentialsOrThrow as defaultResolveCredentialsOrThrow, } from "../interactive/credentials-prompts.js";
|
|
8
8
|
import { verifyCredentialsLoop } from "../interactive/credential-auth.js";
|
|
9
9
|
import { createApiClient as defaultApiClientFactory, } from "../deploy/api-client.js";
|
|
10
10
|
import { getMessage } from "../i18n/index.js";
|
|
11
11
|
import { lastFlagValue } from "../utils/args.js";
|
|
12
|
+
import { markReported } from "../core/errors.js";
|
|
13
|
+
import { withExitCode } from "./run-wrapper.js";
|
|
12
14
|
const resolveLocale = async (projectDir) => {
|
|
13
15
|
const settings = await readSettingsSafe(projectDir);
|
|
14
16
|
return settings?.locale ?? detectLocale();
|
|
@@ -16,14 +18,15 @@ const resolveLocale = async (projectDir) => {
|
|
|
16
18
|
export const runLogin = async (deps) => {
|
|
17
19
|
const { projectDir } = deps;
|
|
18
20
|
const locale = deps.locale ?? (await resolveLocale(projectDir));
|
|
21
|
+
const logger = deps.logger ?? createClackLogger();
|
|
19
22
|
const read = deps.readCredentials ?? defaultReadCredentials;
|
|
20
23
|
const reprompt = deps.repromptCredentials ?? defaultRepromptCredentials;
|
|
21
24
|
const resolveOrThrow = deps.resolveCredentialsOrThrow ?? defaultResolveCredentialsOrThrow;
|
|
22
|
-
const persist = deps.persistCredentials ??
|
|
25
|
+
const persist = deps.persistCredentials ?? createPersistCredentialsWithMcp(logger);
|
|
23
26
|
const apiClientFactory = deps.apiClientFactory ?? defaultApiClientFactory;
|
|
24
27
|
const env = deps.env ?? process.env;
|
|
25
28
|
const seed = resolveCredentialInputs({ endpoint: deps.endpoint, apiKey: deps.apiKey }, env);
|
|
26
|
-
|
|
29
|
+
logger.intro(getMessage("login.intro", locale));
|
|
27
30
|
let initial;
|
|
28
31
|
if (deps.nonInteractive) {
|
|
29
32
|
initial = await resolveOrThrow(projectDir, locale, seed);
|
|
@@ -36,9 +39,10 @@ export const runLogin = async (deps) => {
|
|
|
36
39
|
apiClientFactory,
|
|
37
40
|
repromptCredentials: reprompt,
|
|
38
41
|
persistCredentials: persist,
|
|
42
|
+
logger,
|
|
39
43
|
});
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
logger.success(`endpoint: ${creds.endpoint}`);
|
|
45
|
+
logger.outro(getMessage("login.complete", locale));
|
|
42
46
|
};
|
|
43
47
|
export const loginCommand = defineCommand({
|
|
44
48
|
meta: {
|
|
@@ -60,7 +64,7 @@ export const loginCommand = defineCommand({
|
|
|
60
64
|
default: false,
|
|
61
65
|
},
|
|
62
66
|
},
|
|
63
|
-
run: async ({ args }) => {
|
|
67
|
+
run: withExitCode(async ({ args }) => {
|
|
64
68
|
try {
|
|
65
69
|
await runLogin({
|
|
66
70
|
projectDir: process.cwd(),
|
|
@@ -69,8 +73,8 @@ export const loginCommand = defineCommand({
|
|
|
69
73
|
apiKey: lastFlagValue(args["api-key"]),
|
|
70
74
|
});
|
|
71
75
|
}
|
|
72
|
-
catch {
|
|
73
|
-
|
|
76
|
+
catch (err) {
|
|
77
|
+
throw markReported(err);
|
|
74
78
|
}
|
|
75
|
-
},
|
|
79
|
+
}),
|
|
76
80
|
});
|
|
@@ -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,389 @@
|
|
|
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, } from "../interactive/prompts.js";
|
|
7
|
+
import { collectSettingsErrors } from "../core/validation.js";
|
|
8
|
+
import { withHint, displayWidth } from "../interactive/format.js";
|
|
9
|
+
import { createCancelledError } from "../core/errors.js";
|
|
10
|
+
import { withExitCode } from "./run-wrapper.js";
|
|
11
|
+
import { getMessage } from "../i18n/index.js";
|
|
12
|
+
import { detectLocale } from "../utils/locale-detect.js";
|
|
13
|
+
import { readSettingsSafe } from "../utils/settings-io.js";
|
|
14
|
+
import { presetPath, writePreset, presetExists, deletePreset, listPresetSummaries, formatPresetDisplayName, } from "../utils/preset-io.js";
|
|
15
|
+
import { sanitizeDisplayText } from "../utils/sanitize-text.js";
|
|
16
|
+
const requirePresetContext = async (argLocale) => {
|
|
17
|
+
const projectDir = process.cwd();
|
|
18
|
+
const fallbackLocale = argLocale ?? detectLocale();
|
|
19
|
+
const settings = await readSettingsSafe(projectDir);
|
|
20
|
+
if (!settings) {
|
|
21
|
+
throw new Error(getMessage("preset.error.noSettings", fallbackLocale));
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
projectDir,
|
|
25
|
+
settings,
|
|
26
|
+
locale: argLocale ?? settings.locale ?? fallbackLocale,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const resolveRelease = (settings, locale) => {
|
|
30
|
+
const release = findReleaseById(settings.accelplatformVersion.label);
|
|
31
|
+
if (!release) {
|
|
32
|
+
throw new Error(getMessage("error.invalidVersion", locale, {
|
|
33
|
+
version: settings.accelplatformVersion.label,
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
return release;
|
|
37
|
+
};
|
|
38
|
+
const buildPreset = (name, label, description, modules, features, agents) => ({
|
|
39
|
+
name,
|
|
40
|
+
...(label !== "" ? { label } : {}),
|
|
41
|
+
...(description !== "" ? { description } : {}),
|
|
42
|
+
modules,
|
|
43
|
+
features,
|
|
44
|
+
agents,
|
|
45
|
+
});
|
|
46
|
+
const defaultPrompts = {
|
|
47
|
+
text: (opts) => p.text(opts),
|
|
48
|
+
confirm: (opts) => p.confirm(opts),
|
|
49
|
+
modules: promptModules,
|
|
50
|
+
features: promptFeatures,
|
|
51
|
+
agents: promptAgents,
|
|
52
|
+
};
|
|
53
|
+
const resolveTextInput = (input) => {
|
|
54
|
+
if (p.isCancel(input))
|
|
55
|
+
throw createCancelledError();
|
|
56
|
+
return typeof input === "string" ? input.trim() : "";
|
|
57
|
+
};
|
|
58
|
+
const resolveConfirmInput = (input) => {
|
|
59
|
+
if (p.isCancel(input))
|
|
60
|
+
throw createCancelledError();
|
|
61
|
+
return input === true;
|
|
62
|
+
};
|
|
63
|
+
export const runPresetCreateInteractive = async (ctx, release, cli, force = false, prompts = defaultPrompts) => {
|
|
64
|
+
const { projectDir, locale } = ctx;
|
|
65
|
+
const nameValidator = createPresetNameValidator(locale);
|
|
66
|
+
const allModuleIds = release.modules.map((m) => m.artifactId);
|
|
67
|
+
printIntro("preset", locale);
|
|
68
|
+
let first = true;
|
|
69
|
+
let again = true;
|
|
70
|
+
while (again) {
|
|
71
|
+
let name = first ? cli.name : undefined;
|
|
72
|
+
const nameFromArg = name !== undefined;
|
|
73
|
+
for (;;) {
|
|
74
|
+
if (name === undefined) {
|
|
75
|
+
name = resolveTextInput(await prompts.text({
|
|
76
|
+
message: withHint("preset.prompt.name", locale),
|
|
77
|
+
validate: (value) => nameValidator(value ?? ""),
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
if (!(await presetExists(projectDir, name)))
|
|
81
|
+
break;
|
|
82
|
+
if (first && force)
|
|
83
|
+
break;
|
|
84
|
+
const overwrite = resolveConfirmInput(await prompts.confirm({
|
|
85
|
+
message: getMessage("preset.prompt.overwrite", locale, { name }),
|
|
86
|
+
initialValue: false,
|
|
87
|
+
}));
|
|
88
|
+
if (overwrite)
|
|
89
|
+
break;
|
|
90
|
+
if (nameFromArg) {
|
|
91
|
+
p.log.info(getMessage("preset.cancelled", locale));
|
|
92
|
+
throw createCancelledError();
|
|
93
|
+
}
|
|
94
|
+
name = undefined;
|
|
95
|
+
}
|
|
96
|
+
const label = first && cli.label !== undefined
|
|
97
|
+
? cli.label
|
|
98
|
+
: resolveTextInput(await prompts.text({
|
|
99
|
+
message: withHint("preset.prompt.label", locale),
|
|
100
|
+
}));
|
|
101
|
+
const description = first && cli.description !== undefined
|
|
102
|
+
? cli.description
|
|
103
|
+
: resolveTextInput(await prompts.text({
|
|
104
|
+
message: withHint("preset.prompt.description", locale),
|
|
105
|
+
}));
|
|
106
|
+
const modules = await prompts.modules(release, (first ? cli.modules : undefined) ?? allModuleIds, locale);
|
|
107
|
+
const features = await prompts.features(release, first ? cli.features : undefined, locale);
|
|
108
|
+
const agents = await prompts.agents(first ? cli.agents : undefined, locale);
|
|
109
|
+
await writePreset(projectDir, buildPreset(name, label, description, modules, features, agents));
|
|
110
|
+
p.log.success(getMessage("preset.created", locale, { name }));
|
|
111
|
+
again = resolveConfirmInput(await prompts.confirm({
|
|
112
|
+
message: getMessage("preset.prompt.continue", locale),
|
|
113
|
+
initialValue: false,
|
|
114
|
+
}));
|
|
115
|
+
first = false;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const createCommand = defineCommand({
|
|
119
|
+
meta: {
|
|
120
|
+
name: "create",
|
|
121
|
+
description: "Create a configuration preset (modules / features / agents)",
|
|
122
|
+
},
|
|
123
|
+
args: {
|
|
124
|
+
name: {
|
|
125
|
+
type: "positional",
|
|
126
|
+
description: "Preset name (ID; alphanumerics, - and _ only)",
|
|
127
|
+
required: false,
|
|
128
|
+
},
|
|
129
|
+
label: {
|
|
130
|
+
type: "string",
|
|
131
|
+
description: "Display name shown in lists and selection prompts",
|
|
132
|
+
},
|
|
133
|
+
description: {
|
|
134
|
+
type: "string",
|
|
135
|
+
description: "Preset description",
|
|
136
|
+
},
|
|
137
|
+
module: {
|
|
138
|
+
type: "string",
|
|
139
|
+
description: "Modules to use (comma-separated artifactIds, e.g., im_workflow)",
|
|
140
|
+
},
|
|
141
|
+
feature: {
|
|
142
|
+
type: "string",
|
|
143
|
+
description: 'Features to use (comma-separated function ids; "" for none)',
|
|
144
|
+
},
|
|
145
|
+
agent: {
|
|
146
|
+
type: "string",
|
|
147
|
+
description: "Agent type",
|
|
148
|
+
},
|
|
149
|
+
force: {
|
|
150
|
+
type: "boolean",
|
|
151
|
+
description: "Overwrite an existing preset without confirmation",
|
|
152
|
+
default: false,
|
|
153
|
+
},
|
|
154
|
+
locale: {
|
|
155
|
+
type: "string",
|
|
156
|
+
description: "Locale (ja, en, zh_CN)",
|
|
157
|
+
},
|
|
158
|
+
"non-interactive": {
|
|
159
|
+
type: "boolean",
|
|
160
|
+
description: "Non-interactive mode",
|
|
161
|
+
default: false,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
run: withExitCode(async ({ args }) => {
|
|
165
|
+
const ctx = await requirePresetContext(args.locale);
|
|
166
|
+
const { projectDir, settings, locale } = ctx;
|
|
167
|
+
const nameArg = args.name;
|
|
168
|
+
const moduleArg = args.module;
|
|
169
|
+
const featureArg = args.feature;
|
|
170
|
+
const agentArg = args.agent;
|
|
171
|
+
const cli = {
|
|
172
|
+
name: nameArg,
|
|
173
|
+
label: args.label,
|
|
174
|
+
description: args.description,
|
|
175
|
+
modules: moduleArg === undefined
|
|
176
|
+
? undefined
|
|
177
|
+
: moduleArg.split(",").map((m) => m.trim()),
|
|
178
|
+
features: featureArg === undefined
|
|
179
|
+
? undefined
|
|
180
|
+
: featureArg === ""
|
|
181
|
+
? []
|
|
182
|
+
: featureArg.split(",").map((f) => f.trim()),
|
|
183
|
+
agents: agentArg === undefined
|
|
184
|
+
? undefined
|
|
185
|
+
: agentArg.split(",").map((a) => a.trim()),
|
|
186
|
+
};
|
|
187
|
+
const errors = [];
|
|
188
|
+
if (cli.name !== undefined) {
|
|
189
|
+
const nameError = createPresetNameValidator(locale)(cli.name);
|
|
190
|
+
if (nameError)
|
|
191
|
+
errors.push(nameError);
|
|
192
|
+
}
|
|
193
|
+
errors.push(...collectSettingsErrors({
|
|
194
|
+
module: cli.modules,
|
|
195
|
+
feature: cli.features,
|
|
196
|
+
agent: cli.agents,
|
|
197
|
+
locale,
|
|
198
|
+
isInit: false,
|
|
199
|
+
}, locale, settings.accelplatformVersion.label));
|
|
200
|
+
if (errors.length > 0) {
|
|
201
|
+
throw new Error(errors.join("\n"));
|
|
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
|
+
throw new Error(requiredErrors.join("\n"));
|
|
227
|
+
}
|
|
228
|
+
if ((await presetExists(projectDir, cli.name)) &&
|
|
229
|
+
!args.force) {
|
|
230
|
+
throw new Error(getMessage("preset.error.exists", locale, { name: cli.name }));
|
|
231
|
+
}
|
|
232
|
+
await writePreset(projectDir, buildPreset(cli.name, cli.label ?? "", cli.description ?? "", cli.modules, cli.features, cli.agents));
|
|
233
|
+
p.log.success(getMessage("preset.created", locale, { name: cli.name }));
|
|
234
|
+
}),
|
|
235
|
+
});
|
|
236
|
+
export const buildPresetListBody = (summaries) => {
|
|
237
|
+
const displays = summaries.map(formatPresetDisplayName);
|
|
238
|
+
const maxWidth = Math.max(...displays.map((d) => displayWidth(d)));
|
|
239
|
+
return summaries
|
|
240
|
+
.map((summary, i) => {
|
|
241
|
+
const display = displays[i];
|
|
242
|
+
if (!summary.description)
|
|
243
|
+
return display;
|
|
244
|
+
const pad = " ".repeat(Math.max(0, maxWidth - displayWidth(display)));
|
|
245
|
+
return `${display}${pad} — ${sanitizeDisplayText(summary.description)}`;
|
|
246
|
+
})
|
|
247
|
+
.join("\n");
|
|
248
|
+
};
|
|
249
|
+
const listCommand = defineCommand({
|
|
250
|
+
meta: {
|
|
251
|
+
name: "list",
|
|
252
|
+
description: "List registered configuration presets",
|
|
253
|
+
},
|
|
254
|
+
run: withExitCode(async () => {
|
|
255
|
+
const { projectDir, locale } = await requirePresetContext();
|
|
256
|
+
const summaries = await listPresetSummaries(projectDir);
|
|
257
|
+
if (summaries.length === 0) {
|
|
258
|
+
p.log.info(getMessage("preset.list.empty", locale));
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
p.log.info(buildPresetListBody(summaries));
|
|
262
|
+
}),
|
|
263
|
+
});
|
|
264
|
+
export const buildPresetShowBody = (raw, locale) => {
|
|
265
|
+
const empty = getMessage("summary.empty", locale);
|
|
266
|
+
const text = (value) => typeof value === "string" && value !== ""
|
|
267
|
+
? sanitizeDisplayText(value)
|
|
268
|
+
: empty;
|
|
269
|
+
const array = (value) => Array.isArray(value) && value.length > 0
|
|
270
|
+
? value.map((v) => sanitizeDisplayText(String(v))).join(", ")
|
|
271
|
+
: empty;
|
|
272
|
+
const rows = [
|
|
273
|
+
[getMessage("preset.show.label", locale), text(raw.label)],
|
|
274
|
+
[getMessage("preset.show.description", locale), text(raw.description)],
|
|
275
|
+
[getMessage("preset.show.modules", locale), array(raw.modules)],
|
|
276
|
+
[getMessage("preset.show.features", locale), array(raw.features)],
|
|
277
|
+
[getMessage("preset.show.agents", locale), array(raw.agents)],
|
|
278
|
+
];
|
|
279
|
+
const maxWidth = Math.max(...rows.map(([label]) => displayWidth(label)));
|
|
280
|
+
return rows
|
|
281
|
+
.map(([label, value]) => {
|
|
282
|
+
const pad = " ".repeat(Math.max(0, maxWidth - displayWidth(label)));
|
|
283
|
+
return `${label}${pad} : ${value}`;
|
|
284
|
+
})
|
|
285
|
+
.join("\n");
|
|
286
|
+
};
|
|
287
|
+
const requirePresetName = (nameArg, command, locale) => {
|
|
288
|
+
if (!nameArg) {
|
|
289
|
+
throw new Error(getMessage("preset.error.missingName", locale, { command }));
|
|
290
|
+
}
|
|
291
|
+
const nameError = createPresetNameValidator(locale)(nameArg);
|
|
292
|
+
if (nameError) {
|
|
293
|
+
throw new Error(nameError);
|
|
294
|
+
}
|
|
295
|
+
return nameArg;
|
|
296
|
+
};
|
|
297
|
+
const showCommand = defineCommand({
|
|
298
|
+
meta: {
|
|
299
|
+
name: "show",
|
|
300
|
+
description: "Show the contents of a configuration preset",
|
|
301
|
+
},
|
|
302
|
+
args: {
|
|
303
|
+
name: {
|
|
304
|
+
type: "positional",
|
|
305
|
+
description: "Preset name (ID)",
|
|
306
|
+
required: false,
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
run: withExitCode(async ({ args }) => {
|
|
310
|
+
const { projectDir, locale } = await requirePresetContext();
|
|
311
|
+
const name = requirePresetName(args.name, "show", locale);
|
|
312
|
+
let content;
|
|
313
|
+
try {
|
|
314
|
+
content = await readFile(presetPath(projectDir, name), "utf-8");
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
throw new Error(getMessage("preset.error.notFound", locale, { name }));
|
|
318
|
+
}
|
|
319
|
+
let raw;
|
|
320
|
+
try {
|
|
321
|
+
const parsed = JSON.parse(content);
|
|
322
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
323
|
+
throw new Error("not an object");
|
|
324
|
+
}
|
|
325
|
+
raw = parsed;
|
|
326
|
+
}
|
|
327
|
+
catch (err) {
|
|
328
|
+
throw new Error(getMessage("preset.error.invalid", locale, {
|
|
329
|
+
name,
|
|
330
|
+
errors: ` - ${getMessage("preset.error.parse", locale, {
|
|
331
|
+
message: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
|
|
332
|
+
})}`,
|
|
333
|
+
}));
|
|
334
|
+
}
|
|
335
|
+
p.note(buildPresetShowBody(raw, locale), formatPresetDisplayName({
|
|
336
|
+
name,
|
|
337
|
+
label: typeof raw.label === "string" ? raw.label : undefined,
|
|
338
|
+
}));
|
|
339
|
+
}),
|
|
340
|
+
});
|
|
341
|
+
const deleteCommand = defineCommand({
|
|
342
|
+
meta: {
|
|
343
|
+
name: "delete",
|
|
344
|
+
description: "Delete a configuration preset",
|
|
345
|
+
},
|
|
346
|
+
args: {
|
|
347
|
+
name: {
|
|
348
|
+
type: "positional",
|
|
349
|
+
description: "Preset name (ID)",
|
|
350
|
+
required: false,
|
|
351
|
+
},
|
|
352
|
+
"non-interactive": {
|
|
353
|
+
type: "boolean",
|
|
354
|
+
description: "Non-interactive mode (delete without confirmation)",
|
|
355
|
+
default: false,
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
run: withExitCode(async ({ args }) => {
|
|
359
|
+
const { projectDir, locale } = await requirePresetContext();
|
|
360
|
+
const name = requirePresetName(args.name, "delete", locale);
|
|
361
|
+
if (!(await presetExists(projectDir, name))) {
|
|
362
|
+
throw new Error(getMessage("preset.error.notFound", locale, { name }));
|
|
363
|
+
}
|
|
364
|
+
if (!args["non-interactive"]) {
|
|
365
|
+
const ok = await p.confirm({
|
|
366
|
+
message: getMessage("preset.prompt.delete", locale, { name }),
|
|
367
|
+
initialValue: false,
|
|
368
|
+
});
|
|
369
|
+
if (p.isCancel(ok) || ok !== true) {
|
|
370
|
+
p.log.info(getMessage("preset.cancelled", locale));
|
|
371
|
+
throw createCancelledError();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
await deletePreset(projectDir, name);
|
|
375
|
+
p.log.success(getMessage("preset.deleted", locale, { name }));
|
|
376
|
+
}),
|
|
377
|
+
});
|
|
378
|
+
export const presetCommand = defineCommand({
|
|
379
|
+
meta: {
|
|
380
|
+
name: "preset",
|
|
381
|
+
description: "Manage configuration presets shared via .accel/presets/ (create / list / show / delete)",
|
|
382
|
+
},
|
|
383
|
+
subCommands: {
|
|
384
|
+
create: createCommand,
|
|
385
|
+
list: listCommand,
|
|
386
|
+
show: showCommand,
|
|
387
|
+
delete: deleteCommand,
|
|
388
|
+
},
|
|
389
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type ArgDef = {
|
|
2
|
+
type?: string;
|
|
3
|
+
alias?: string | string[];
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
};
|
|
6
|
+
type FlagContext = {
|
|
7
|
+
args?: Record<string, unknown>;
|
|
8
|
+
rawArgs?: readonly string[];
|
|
9
|
+
cmd?: {
|
|
10
|
+
args?: Record<string, ArgDef | undefined>;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const findUnknownFlags: (ctx: FlagContext) => string[];
|
|
14
|
+
export declare const withExitCode: <C>(run: (ctx: C) => void | Promise<void>) => ((ctx: C) => Promise<void>);
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
2
|
+
import { isCancelledError, isReportedError } from "../core/errors.js";
|
|
3
|
+
import { getMessage } from "../i18n/index.js";
|
|
4
|
+
import { toCamelCase, toKebabCase } from "../utils/args.js";
|
|
5
|
+
import { detectLocale } from "../utils/locale-detect.js";
|
|
6
|
+
import { sanitizeDisplayText } from "../utils/sanitize-text.js";
|
|
7
|
+
export const findUnknownFlags = (ctx) => {
|
|
8
|
+
const declared = new Set(["_", "--"]);
|
|
9
|
+
const positionals = new Set();
|
|
10
|
+
const markDeclared = (key, into = declared) => {
|
|
11
|
+
into.add(key);
|
|
12
|
+
into.add(toCamelCase(key));
|
|
13
|
+
into.add(toKebabCase(key));
|
|
14
|
+
};
|
|
15
|
+
for (const [key, def] of Object.entries(ctx.cmd?.args ?? {})) {
|
|
16
|
+
markDeclared(key);
|
|
17
|
+
if (def?.type === "positional")
|
|
18
|
+
markDeclared(key, positionals);
|
|
19
|
+
const alias = def?.alias;
|
|
20
|
+
for (const a of Array.isArray(alias) ? alias : alias ? [alias] : []) {
|
|
21
|
+
markDeclared(a);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const unknown = new Set();
|
|
25
|
+
for (const key of Object.keys(ctx.args ?? {})) {
|
|
26
|
+
if (declared.has(key))
|
|
27
|
+
continue;
|
|
28
|
+
unknown.add(key.length === 1 ? `-${key}` : `--${toKebabCase(toCamelCase(key))}`);
|
|
29
|
+
}
|
|
30
|
+
for (const token of ctx.rawArgs ?? []) {
|
|
31
|
+
if (token === "--")
|
|
32
|
+
break;
|
|
33
|
+
if (!token.startsWith("--"))
|
|
34
|
+
continue;
|
|
35
|
+
const flagName = token.slice(2).split("=", 1)[0];
|
|
36
|
+
if (positionals.has(flagName)) {
|
|
37
|
+
unknown.add(`--${toKebabCase(toCamelCase(flagName))}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return [...unknown];
|
|
41
|
+
};
|
|
42
|
+
export const withExitCode = (run) => async (ctx) => {
|
|
43
|
+
const unknown = findUnknownFlags(ctx);
|
|
44
|
+
if (unknown.length > 0) {
|
|
45
|
+
p.log.error(getMessage("error.unknownFlags", detectLocale(), {
|
|
46
|
+
flags: sanitizeDisplayText(unknown.join(", ")),
|
|
47
|
+
}));
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
await run(ctx);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
if (isCancelledError(err)) {
|
|
55
|
+
process.exit(0);
|
|
56
|
+
}
|
|
57
|
+
if (!isReportedError(err)) {
|
|
58
|
+
p.log.error(err instanceof Error ? err.message : String(err));
|
|
59
|
+
}
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
@@ -1,24 +1,56 @@
|
|
|
1
|
+
import type { Logger } from "../core/logger.js";
|
|
2
|
+
import { type Release } from "../core/catalog.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 type SwitchPrompts = {
|
|
7
|
+
selectPreset: (presets: PresetSummary[], locale: string) => Promise<string | undefined>;
|
|
8
|
+
selectModules: (release: Release, initial: string[], locale: string) => Promise<string[]>;
|
|
9
|
+
selectFeatures: (release: Release, initial: string[], locale: string) => Promise<string[]>;
|
|
10
|
+
selectAgents: (initial: string[], locale: string) => Promise<string[]>;
|
|
11
|
+
confirmApply: (locale: string) => Promise<boolean>;
|
|
12
|
+
};
|
|
13
|
+
export type RunSwitchDeps = {
|
|
14
|
+
projectDir: string;
|
|
15
|
+
locale?: string;
|
|
16
|
+
nonInteractive?: boolean;
|
|
17
|
+
modules?: string[];
|
|
18
|
+
features?: string[];
|
|
19
|
+
agents?: string[];
|
|
20
|
+
preset?: string;
|
|
21
|
+
skipInstall?: boolean;
|
|
22
|
+
logger?: Logger;
|
|
23
|
+
prompts?: SwitchPrompts;
|
|
24
|
+
progress?: UpdaterProgressCallbacks;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
generateMcpConfigs?: typeof generateMcpConfigs;
|
|
27
|
+
};
|
|
28
|
+
export declare const runSwitch: (deps: RunSwitchDeps) => Promise<void>;
|
|
1
29
|
export declare const switchCommand: import("citty").CommandDef<{
|
|
2
|
-
module: {
|
|
3
|
-
type: "string";
|
|
4
|
-
description:
|
|
30
|
+
readonly module: {
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly description: "Modules to use (comma-separated artifactIds, e.g., im_workflow)";
|
|
5
33
|
};
|
|
6
|
-
feature: {
|
|
7
|
-
type: "string";
|
|
8
|
-
description:
|
|
34
|
+
readonly feature: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
readonly description: "Features to use (comma-separated function ids, e.g., jssp)";
|
|
9
37
|
};
|
|
10
|
-
agent: {
|
|
11
|
-
type: "string";
|
|
12
|
-
description:
|
|
38
|
+
readonly agent: {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
readonly description: "Agent type";
|
|
13
41
|
};
|
|
14
|
-
|
|
15
|
-
type: "
|
|
16
|
-
description:
|
|
17
|
-
default: false;
|
|
42
|
+
readonly preset: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly description: "Configuration preset name to apply (mutually exclusive with --module / --feature / --agent)";
|
|
18
45
|
};
|
|
19
|
-
"
|
|
20
|
-
type: "boolean";
|
|
21
|
-
description:
|
|
22
|
-
default: false;
|
|
46
|
+
readonly "non-interactive": {
|
|
47
|
+
readonly type: "boolean";
|
|
48
|
+
readonly description: "Non-interactive mode";
|
|
49
|
+
readonly default: false;
|
|
50
|
+
};
|
|
51
|
+
readonly "skip-install": {
|
|
52
|
+
readonly type: "boolean";
|
|
53
|
+
readonly description: "Skip install / build even when dependency files changed";
|
|
54
|
+
readonly default: false;
|
|
23
55
|
};
|
|
24
56
|
}>;
|