@kodly.dev/kodly-cli 1.0.19 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +131 -39
  2. package/dist/bin/kodly.js +23 -38
  3. package/dist/commands/auth.js +73 -78
  4. package/dist/commands/code.js +238 -0
  5. package/dist/commands/completion.js +33 -76
  6. package/dist/commands/delivery.js +218 -0
  7. package/dist/commands/harness.js +68 -0
  8. package/dist/commands/local-qa.js +96 -0
  9. package/dist/commands/mcp.js +399 -0
  10. package/dist/commands/misc.js +58 -0
  11. package/dist/commands/org.js +43 -100
  12. package/dist/commands/plan.js +157 -0
  13. package/dist/commands/project.js +88 -86
  14. package/dist/commands/review.js +237 -0
  15. package/dist/commands/scaffold.js +20 -230
  16. package/dist/commands/story-write.js +210 -0
  17. package/dist/commands/story.js +154 -0
  18. package/dist/core/api.js +89 -0
  19. package/dist/core/browser.js +17 -0
  20. package/dist/core/checkout.js +58 -0
  21. package/dist/core/config.js +36 -0
  22. package/dist/core/confirm.js +36 -0
  23. package/dist/core/context.js +64 -0
  24. package/dist/core/credentials.js +62 -0
  25. package/dist/core/device-login.js +44 -0
  26. package/dist/core/errors.js +32 -0
  27. package/dist/core/format.js +32 -0
  28. package/dist/core/git.js +29 -0
  29. package/dist/core/keychain.js +9 -0
  30. package/dist/core/memberships.js +10 -0
  31. package/dist/core/output.js +31 -0
  32. package/dist/core/prompt.js +47 -0
  33. package/dist/core/push-checks.js +60 -0
  34. package/dist/core/story-file.js +120 -0
  35. package/dist/core/story.js +34 -0
  36. package/dist/program.js +48 -0
  37. package/dist/utils/update-check.js +9 -9
  38. package/llm.txt +47 -83
  39. package/package.json +16 -11
  40. package/dist/api/client.js +0 -96
  41. package/dist/commands/docs.js +0 -152
  42. package/dist/commands/man.js +0 -93
  43. package/dist/commands/push.js +0 -51
  44. package/dist/commands/status.js +0 -52
  45. package/dist/commands/task.js +0 -155
  46. package/dist/utils/changes.js +0 -90
  47. package/dist/utils/checkout.js +0 -168
  48. package/dist/utils/config.js +0 -34
  49. package/dist/utils/org.js +0 -138
  50. package/dist/utils/project.js +0 -21
  51. package/dist/utils/session.js +0 -28
  52. package/dist/utils/task.js +0 -25
@@ -0,0 +1,237 @@
1
+ import chalk from 'chalk';
2
+ import { Option } from 'commander';
3
+ import path from 'node:path';
4
+ import { checkoutOf } from '../core/checkout.js';
5
+ import { buildContext } from '../core/context.js';
6
+ import { git } from '../core/git.js';
7
+ import { CliError, ExitCode } from '../core/errors.js';
8
+ import { ago, storyPath, table } from '../core/format.js';
9
+ import { emit, run } from '../core/output.js';
10
+ import { deliveryOf, findStory, requestId, requireBuild, requireTestRun } from '../core/story.js';
11
+ const label = (item) => item.identifier ?? item.slug;
12
+ /** Checks that each codebase of a checkout is clean and at the current build, so that a local review reads the code that Kodly pinned. */
13
+ export const requireCurrentCheckout = async (root, context, name) => {
14
+ const problems = [];
15
+ for (const codebase of context.codebases) {
16
+ const dir = path.join(root, codebase.dir);
17
+ await git(dir, ['fetch', '--quiet', 'origin', 'main']);
18
+ // New files count too: an application can load an untracked file that the build does not have. Files that git ignores do not count.
19
+ if ((await git(dir, ['status', '--porcelain', '--untracked-files=normal'])).trim())
20
+ problems.push(`${codebase.codebase} has changes or new files that are not committed.`);
21
+ else if ((await git(dir, ['rev-parse', 'HEAD'])).trim() !== (await git(dir, ['rev-parse', 'origin/main'])).trim()) {
22
+ problems.push(`${codebase.codebase} is not at the current build.`);
23
+ }
24
+ }
25
+ if (problems.length) {
26
+ throw new CliError(`The checkout must be the current build of ${name}:\n ${problems.join('\n ')}\nCommit, remove or put aside the changes and new files, then run kodly pull.`, ExitCode.USAGE);
27
+ }
28
+ };
29
+ /** Submits a code review of the current build. A decision other than a comment needs your approval in the browser. */
30
+ const submit = async (ctx, id, decision, summary, comments) => {
31
+ const project = ctx.project();
32
+ const item = await findStory(ctx.api, project, id);
33
+ const path = storyPath(project, item.slug, '/peer-reviews');
34
+ const view = await ctx.api.request(path);
35
+ if (!view?.codeReady || !view.buildId || !view.sourceVersion) {
36
+ throw new CliError('The build is not ready for a code review. It must be in the review stage, with a finished build.', ExitCode.CONFLICT);
37
+ }
38
+ const body = { requestId: requestId(), target: 'CODE', artifactId: view.buildId, decision, summary, comments, sourceVersion: view.sourceVersion };
39
+ const result = await ctx.api.request(path, { method: 'POST', body });
40
+ return { item, result };
41
+ };
42
+ export const reviewCommands = (program, cliVersion) => {
43
+ const review = program.command('review').description('Code review of a story');
44
+ review
45
+ .command('request')
46
+ .argument('<story>', 'the story identifier or slug')
47
+ .description('Send the build and its passed QA run to review')
48
+ .action(run(async (id, _options, command) => {
49
+ const ctx = buildContext(command, cliVersion);
50
+ const project = ctx.project();
51
+ const item = await findStory(ctx.api, project, id);
52
+ const delivery = await deliveryOf(ctx.api, project, item.slug);
53
+ if (!delivery.workflow?.canSendToReview)
54
+ throw new CliError('The story cannot go to review now. QA must pass first.', ExitCode.CONFLICT);
55
+ const view = await ctx.api.request(storyPath(project, item.slug, '/delivery/handoffs'), {
56
+ method: 'POST', body: { destination: 'REVIEW', buildId: requireBuild(delivery).id, testRunId: requireTestRun(delivery).id },
57
+ });
58
+ emit(ctx.json, view, () => console.log(`Sent ${label(item)} to review.`));
59
+ }));
60
+ review
61
+ .command('local')
62
+ .argument('<story>', 'the story identifier or slug')
63
+ .option('--dir <path>', 'the folder of the checkout')
64
+ .description('Review the current build with your local agent. Its report is evidence for the reviewers, never a decision')
65
+ .action(run(async (id, options, command) => {
66
+ const ctx = buildContext(command, cliVersion);
67
+ const found = checkoutOf(id, options.dir);
68
+ if (!found)
69
+ throw new CliError(`Run this inside a checkout of ${id}. Get one with: kodly checkout ${id}`, ExitCode.USAGE);
70
+ const name = found.context.identifier ?? found.context.story;
71
+ await requireCurrentCheckout(found.root, found.context, name);
72
+ emit(ctx.json, { root: found.root, prompt: `/mcp__kodly__code_review ${name}` }, () => {
73
+ console.log(`The checkout of ${name} is the current build. Your agent reviews it and saves a report.`);
74
+ console.log('Next:');
75
+ console.log(` cd ${found.root}`);
76
+ console.log(` claude "/mcp__kodly__code_review ${name}"`);
77
+ console.log('The report is evidence. A person still approves or requests changes: kodly review approve or request-changes.');
78
+ });
79
+ }));
80
+ review
81
+ .command('show')
82
+ .argument('<story>', 'the story identifier or slug')
83
+ .description('The reviews of the current build')
84
+ .action(run(async (id, _options, command) => {
85
+ const ctx = buildContext(command, cliVersion);
86
+ const project = ctx.project();
87
+ const item = await findStory(ctx.api, project, id);
88
+ const view = await ctx.api.request(storyPath(project, item.slug, '/peer-reviews'));
89
+ const reports = (await ctx.api.request(storyPath(project, item.slug, '/peer-reviews/agent')).catch(() => [])) ?? [];
90
+ emit(ctx.json, { ...view, aiReports: reports }, () => {
91
+ for (const report of reports.slice(0, 3)) {
92
+ const local = report.origin?.agentName?.startsWith('local:');
93
+ const source = local ? `local · ${report.origin?.agentName?.slice(6)} · by ${report.origin?.initiatedByEmail ?? '?'}` : 'Kodly Lens';
94
+ const counts = ['BLOCKER', 'MAJOR', 'MINOR', 'INFO'].map((s) => [s, (report.findings ?? []).filter((f) => f.severity === s).length])
95
+ .filter(([, n]) => n > 0).map(([s, n]) => `${n} ${s.toLowerCase()}`).join(', ') || 'no findings';
96
+ const older = report.buildId && view?.buildId && report.buildId !== view.buildId ? chalk.dim(' (older build)') : '';
97
+ console.log(`${chalk.bold('AI review')} (${source}) ${ago(report.publishedAt)}: ${counts}${older} ${chalk.dim('not a review decision')}`);
98
+ if (report.summary)
99
+ console.log(` ${report.summary}`);
100
+ for (const f of report.findings ?? []) {
101
+ const where = f.anchor?.path ? chalk.cyan(`${f.anchor.path}:${f.anchor.line ?? ''}`) + ' ' : f.anchor?.testId ? chalk.cyan(`scenario ${f.anchor.testId}`) + ' ' : '';
102
+ console.log(` - ${(f.severity ?? '').toLowerCase()}: ${where}${f.title ?? ''}`);
103
+ }
104
+ }
105
+ const entries = view?.entries ?? [];
106
+ if (entries.length === 0)
107
+ console.log(view?.codeReady ? 'No reviews yet.' : 'The build is not in review yet.');
108
+ for (const entry of entries) {
109
+ const r = entry.review;
110
+ console.log(`${chalk.bold((r.decision ?? '').toLowerCase())} by ${r.authorEmail ?? '?'} ${ago(r.createdAt)}${entry.current ? '' : chalk.dim(' (older build)')} ${chalk.dim(`review ${r.id}`)}`);
111
+ if (r.summary)
112
+ console.log(` ${r.summary}`);
113
+ (r.comments ?? []).forEach((c, i) => {
114
+ const where = c.anchor?.path ? chalk.cyan(`${c.anchor.path}:${c.anchor.line ?? ''}`) + ' ' : '';
115
+ const thread = entry.discussions?.[i];
116
+ const state = thread?.resolved ? chalk.green(' [resolved]') : '';
117
+ console.log(` [${i}] ${where}${c.body ?? ''}${state}`);
118
+ for (const reply of thread?.replies ?? [])
119
+ console.log(chalk.dim(` ${reply.authorEmail ?? reply.author ?? '?'}: ${reply.body ?? ''}`));
120
+ });
121
+ }
122
+ });
123
+ }));
124
+ review
125
+ .command('comment')
126
+ .argument('<story>', 'the story identifier or slug')
127
+ .requiredOption('-m, --message <text>', 'the comment')
128
+ .option('--file <path>', 'the file of a line comment')
129
+ .option('--line <n>', 'the line of a line comment, in the new version of the file')
130
+ .description('Comment on the current build')
131
+ .action(run(async (id, options, command) => {
132
+ const ctx = buildContext(command, cliVersion);
133
+ if (!!options.file !== !!options.line)
134
+ throw new CliError('A line comment needs both --file and --line.', ExitCode.USAGE);
135
+ const comments = options.file
136
+ ? [{ body: options.message, anchor: { path: options.file, line: Number(options.line), side: 'MODIFIED', comparison: 'BASE_CODE' } }]
137
+ : [];
138
+ const { item, result } = await submit(ctx, id, 'COMMENTED', options.file ? undefined : options.message, comments);
139
+ emit(ctx.json, result, () => console.log(`Commented on ${label(item)}.`));
140
+ }));
141
+ review
142
+ .command('reply')
143
+ .argument('<story>', 'the story identifier or slug')
144
+ .argument('<review>', 'the review id (see kodly review show)')
145
+ .option('--index <n>', 'the comment number in the review; leave it out for the review summary')
146
+ .option('-m, --message <text>', 'the reply')
147
+ .option('--resolve', 'mark the thread resolved')
148
+ .description('Reply to a review comment, or resolve its thread')
149
+ .action(run(async (id, reviewId, options, command) => {
150
+ const ctx = buildContext(command, cliVersion);
151
+ if (!options.message && !options.resolve)
152
+ throw new CliError('Give --message, --resolve or both.', ExitCode.USAGE);
153
+ const project = ctx.project();
154
+ const item = await findStory(ctx.api, project, id);
155
+ const path = storyPath(project, item.slug, '/peer-reviews');
156
+ const view = await ctx.api.request(path);
157
+ const entry = view?.entries?.find((e) => e.review.id === reviewId);
158
+ if (!entry)
159
+ throw new CliError(`No review "${reviewId}" on ${label(item)}. Run "kodly review show".`, ExitCode.USAGE);
160
+ const index = options.index === undefined ? (entry.review.comments ?? []).length : Number(options.index);
161
+ const discussion = entry.discussions?.[index];
162
+ const result = await ctx.api.request(`${path}/discussion`, {
163
+ method: 'POST',
164
+ query: { reviewId, index },
165
+ body: { revision: discussion?.revision ?? -1, requestId: requestId(), body: options.message, resolved: options.resolve ? true : undefined },
166
+ });
167
+ emit(ctx.json, result, () => console.log(options.resolve ? 'Resolved the thread.' : 'Replied.'));
168
+ }));
169
+ review
170
+ .command('approve')
171
+ .argument('<story>', 'the story identifier or slug')
172
+ .option('-m, --message <text>', 'a summary')
173
+ .description('Approve the code of the current build (needs your approval in the browser)')
174
+ .action(run(async (id, options, command) => {
175
+ const ctx = buildContext(command, cliVersion);
176
+ const { item, result } = await submit(ctx, id, 'APPROVED', options.message, []);
177
+ emit(ctx.json, result, () => console.log(chalk.green(`Approved the code of ${label(item)}.`)));
178
+ }));
179
+ review
180
+ .command('request-changes')
181
+ .argument('<story>', 'the story identifier or slug')
182
+ .requiredOption('-m, --message <text>', 'what must change')
183
+ .description('Ask for changes to the current build (needs your approval in the browser)')
184
+ .action(run(async (id, options, command) => {
185
+ const ctx = buildContext(command, cliVersion);
186
+ const { item, result } = await submit(ctx, id, 'CHANGES_REQUESTED', options.message, []);
187
+ emit(ctx.json, result, () => console.log(`Asked for changes on ${label(item)}.`));
188
+ }));
189
+ program
190
+ .command('release')
191
+ .argument('<story>', 'the story identifier or slug')
192
+ .option('--notes <text>', 'release notes')
193
+ .addOption(new Option('--send-back <notes>', 'do not release; send the story back with these notes'))
194
+ .description('Approve the release and merge the story into main (needs your approval in the browser)')
195
+ .action(run(async (id, options, command) => {
196
+ const ctx = buildContext(command, cliVersion);
197
+ const project = ctx.project();
198
+ const item = await findStory(ctx.api, project, id);
199
+ const delivery = await deliveryOf(ctx.api, project, item.slug);
200
+ const testRun = requireTestRun(delivery);
201
+ if (!delivery.canReview) {
202
+ const reasons = [...(delivery.reviewBlockers ?? []), ...(delivery.readiness?.release?.reasons ?? [])].join(' ');
203
+ throw new CliError(`The story cannot be released now. ${reasons}`.trim(), ExitCode.CONFLICT);
204
+ }
205
+ const approve = options.sendBack === undefined;
206
+ const body = {
207
+ testRunId: testRun.id,
208
+ revision: delivery.review?.revision ?? -1,
209
+ decision: approve ? 'APPROVED' : 'CHANGES_REQUESTED',
210
+ notes: approve ? undefined : options.sendBack,
211
+ releaseNotes: options.notes,
212
+ sourceVersion: approve ? delivery.sourceVersion : undefined,
213
+ };
214
+ const view = await ctx.api.request(storyPath(project, item.slug, '/delivery/review'), { method: 'POST', body });
215
+ emit(ctx.json, view, () => console.log(approve ? chalk.green(`Released ${label(item)}: it is merged into main.`) : `Sent ${label(item)} back.`));
216
+ }));
217
+ program
218
+ .command('brief')
219
+ .argument('<story>', 'the story identifier or slug')
220
+ .description('The release brief: what the build covers and what QA proved')
221
+ .action(run(async (id, _options, command) => {
222
+ const ctx = buildContext(command, cliVersion);
223
+ const project = ctx.project();
224
+ const item = await findStory(ctx.api, project, id);
225
+ const brief = await ctx.api.request(storyPath(project, item.slug, '/delivery/brief'));
226
+ emit(ctx.json, brief, () => {
227
+ if (brief?.summary)
228
+ console.log(brief.summary);
229
+ if (brief?.completion)
230
+ console.log(chalk.dim(brief.completion));
231
+ table((brief?.coverage ?? []).map((c) => [`${c.criterion ?? ''}`, c.text ?? '',
232
+ `${c.passed ?? 0} passed, ${c.failed ?? 0} failed, ${c.unverified ?? 0} unverified`]), ['#', 'CRITERION', 'QA']);
233
+ if (brief && !brief.evidenceCurrent)
234
+ console.log(chalk.yellow('The QA evidence is older than the current build.'));
235
+ });
236
+ }));
237
+ };
@@ -1,235 +1,25 @@
1
- import { Command } from 'commander';
2
1
  import chalk from 'chalk';
3
- import ora from 'ora';
4
- import { scaffold, scaffoldInit, listRecipes, resolveScaffoldVersions, ScaffoldError, } from '@kodly.dev/scaffolder';
5
- function errorMessage(error) {
6
- if (error instanceof ScaffoldError)
7
- return error.message;
8
- if (error instanceof Error)
9
- return error.message;
10
- return 'Unknown error';
11
- }
12
- async function runInit(opts) {
13
- const spinner = ora(`Initializing project ${opts.name}...`).start();
14
- try {
15
- const result = await scaffoldInit({
16
- targetDir: opts.path,
17
- group: opts.group,
18
- projectName: opts.name,
19
- prefix: opts.prefix,
20
- version: opts.version,
21
- dryRun: opts.dryRun,
22
- });
23
- if (opts.dryRun) {
24
- spinner.succeed(chalk.green(`Dry run for skeleton init (${result.version})`));
25
- }
26
- else {
27
- spinner.succeed(chalk.green(`Initialized project ${result.projectName} (skeleton@${result.version})`));
28
- }
29
- console.log(chalk.dim(` ${result.filesAdded.length} files created (${result.durationMs}ms)`));
30
- for (const file of result.filesAdded) {
31
- console.log(chalk.green(` + ${file}`));
32
- }
33
- return true;
34
- }
35
- catch (error) {
36
- spinner.fail(chalk.red(errorMessage(error)));
37
- return false;
38
- }
39
- }
40
- async function runApply(recipe, opts) {
41
- const spinner = ora(`Applying recipe ${recipe}...`).start();
42
- try {
43
- const result = await scaffold({
44
- recipe,
45
- workspaceDir: opts.path,
46
- tokens: {
47
- targetGroup: opts.group,
48
- targetPrefix: opts.prefix,
49
- },
50
- dryRun: opts.dryRun,
51
- });
52
- if (opts.dryRun) {
53
- spinner.succeed(chalk.green(`Dry run for recipe ${result.recipe}`));
54
- }
55
- else {
56
- spinner.succeed(chalk.green(`Applied recipe ${result.recipe}`));
57
- }
58
- console.log(chalk.dim(` ${result.filesAdded.length} files added, ${result.filesModified.length} files modified (${result.durationMs}ms)`));
59
- for (const file of result.filesAdded) {
60
- console.log(chalk.green(` + ${file}`));
61
- }
62
- for (const file of result.filesModified) {
63
- console.log(chalk.yellow(` ~ ${file}`));
64
- }
65
- return true;
66
- }
67
- catch (error) {
68
- spinner.fail(chalk.red(errorMessage(error)));
69
- return false;
70
- }
71
- }
72
- async function runCreate(opts) {
73
- let resolved;
74
- try {
75
- resolved = await resolveScaffoldVersions(opts.recipes, opts.version);
76
- }
77
- catch (error) {
78
- console.error(chalk.red(errorMessage(error)));
79
- process.exitCode = 1;
80
- return;
81
- }
82
- const ok = await runInit({
83
- path: opts.path,
84
- group: opts.group,
85
- name: opts.name,
86
- prefix: opts.prefix,
87
- version: resolved.version,
88
- dryRun: opts.dryRun,
89
- });
90
- if (!ok) {
91
- process.exitCode = 1;
92
- return;
93
- }
94
- if (resolved.recipes.length === 0) {
95
- console.log(chalk.dim('\nNo recipes requested. Skeleton is ready.'));
96
- return;
97
- }
98
- console.log(chalk.bold(`\nApplying ${resolved.recipes.length} recipe(s)…\n`));
99
- for (const recipe of resolved.recipes) {
100
- const applied = await runApply(recipe, {
101
- path: opts.path,
102
- group: opts.group,
103
- prefix: opts.prefix,
104
- dryRun: opts.dryRun,
105
- });
106
- if (!applied) {
107
- console.error(chalk.red(`\nStopped after failing to apply ${recipe}. Earlier steps (init / previous recipes) were already applied.`));
108
- process.exitCode = 1;
109
- return;
110
- }
111
- }
112
- console.log(chalk.green(`\nDone. Project ready at ${opts.path}`));
113
- }
114
- async function printRecipes() {
115
- const spinner = ora('Fetching recipes...').start();
116
- try {
117
- const recipes = await listRecipes();
118
- spinner.stop();
119
- if (recipes.length === 0) {
120
- console.log(chalk.yellow('No recipes found.'));
121
- return;
122
- }
123
- console.log(chalk.bold('\nAvailable Recipes\n'));
124
- for (const item of recipes) {
125
- console.log(` ${chalk.cyan(item.name)}@${item.version}`);
126
- }
127
- console.log('');
128
- }
129
- catch (error) {
130
- spinner.fail(chalk.red(errorMessage(error)));
131
- process.exitCode = 1;
132
- }
133
- }
134
- function registerApplyOptions(cmd) {
135
- return cmd
136
- .option('-p, --path <dir>', 'Target workspace directory', process.cwd())
137
- .option('-g, --group <group>', 'Override Java package group (e.g. com.rental.app)')
138
- .option('--prefix <prefix>', 'Override class prefix (e.g. RentalApp)')
139
- .option('--dry-run', 'Show what would change without writing');
140
- }
141
- function collectRecipe(value, previous) {
142
- return [...previous, value];
143
- }
144
- const SCAFFOLD_SUBCOMMANDS = new Set(['init', 'create', 'list', 'apply', 'cache']);
145
- /** Rewrite `scaffold <recipe>` to `scaffold apply <recipe>` for shorthand. */
146
- export function normalizeScaffoldArgv(argv) {
147
- const scaffoldIdx = argv.indexOf('scaffold');
148
- if (scaffoldIdx < 0)
149
- return argv;
150
- const next = argv[scaffoldIdx + 1];
151
- if (!next || next.startsWith('-') || SCAFFOLD_SUBCOMMANDS.has(next)) {
152
- return argv;
153
- }
154
- const normalized = [...argv];
155
- normalized.splice(scaffoldIdx + 1, 0, 'apply');
156
- return normalized;
157
- }
2
+ import { runScaffoldCli } from '@kodly.dev/scaffolder';
3
+ /**
4
+ * `kodly scaffold ...` runs the same code as the `kodly-scaffold` bin of @kodly.dev/scaffolder,
5
+ * with colours. Servers run these command lines (kodly-api, the sandbox image, the harness CI),
6
+ * and test/scaffold-contract.test.ts pins them for both bins.
7
+ */
8
+ export const runScaffold = (args) => runScaffoldCli(args, {
9
+ program: 'kodly scaffold',
10
+ style: { ok: chalk.green, warn: chalk.yellow, error: chalk.red, dim: chalk.dim, bold: chalk.bold, name: chalk.cyan },
11
+ });
12
+ /** The command for the help and the completion. bin/kodly.ts calls runScaffold before commander. */
158
13
  export const scaffoldCommands = (program) => {
159
- const scaffoldCmd = program.command('scaffold').description('Scaffold Spring Boot projects and apply recipes');
160
- scaffoldCmd
161
- .command('init')
162
- .description('Generate a new Spring Boot skeleton with your package and project name')
163
- .requiredOption('-g, --group <group>', 'Java package group (e.g. com.rental.app)')
164
- .requiredOption('-n, --name <name>', 'Gradle project name (e.g. rental-app)')
165
- .option('-p, --path <dir>', 'Target directory (must be empty or not exist)', process.cwd())
166
- .option('--prefix <prefix>', 'Class prefix (defaults from project name, e.g. RentalApp)')
167
- .option('--skeleton-version <version>', 'Skeleton tag version (default: latest published stable)')
168
- .option('--dry-run', 'Show what would be created without writing')
169
- .action(async (opts) => {
170
- const ok = await runInit({
171
- path: opts.path,
172
- group: opts.group,
173
- name: opts.name,
174
- prefix: opts.prefix,
175
- version: opts.skeletonVersion,
176
- dryRun: opts.dryRun,
177
- });
178
- if (!ok)
179
- process.exitCode = 1;
180
- });
181
- scaffoldCmd
182
- .command('create')
183
- .description('Create a Spring Boot project and optionally apply recipes in one step')
184
- .argument('[recipes...]', 'Recipes to apply after init (name or name@version)')
185
- .requiredOption('-g, --group <group>', 'Java package group (e.g. com.rental.app)')
186
- .requiredOption('-n, --name <name>', 'Gradle project name (e.g. rental-app)')
187
- .option('-p, --path <dir>', 'Target directory (must be empty or not exist)', process.cwd())
188
- .option('--prefix <prefix>', 'Class prefix (defaults from project name, e.g. RentalApp)')
189
- .option('--skeleton-version <version>', 'Skeleton tag version (default: latest published stable)')
190
- .option('-r, --recipe <ref>', 'Recipe to apply (repeatable; same as positional recipes)', collectRecipe, [])
191
- .option('--dry-run', 'Show what would be created without writing')
192
- .action(async (recipes, opts) => {
193
- const merged = [...recipes, ...(opts.recipe ?? [])];
194
- // De-dupe while preserving order
195
- const seen = new Set();
196
- const unique = merged.filter((r) => {
197
- if (seen.has(r))
198
- return false;
199
- seen.add(r);
200
- return true;
201
- });
202
- await runCreate({
203
- path: opts.path,
204
- group: opts.group,
205
- name: opts.name,
206
- prefix: opts.prefix,
207
- version: opts.skeletonVersion,
208
- dryRun: opts.dryRun,
209
- recipes: unique,
210
- });
211
- });
212
- scaffoldCmd
213
- .command('list')
214
- .description('List the latest published stable recipes')
215
- .action(async () => {
216
- await printRecipes();
217
- });
218
- scaffoldCmd
219
- .command('cache [args...]', { hidden: true })
220
- .description('(Removed) Use `kodly scaffold list` instead')
14
+ program
15
+ .command('scaffold')
16
+ .description('Scaffold Spring Boot projects and apply recipes (no login). Run "kodly scaffold --help"')
17
+ .helpOption(false)
221
18
  .allowUnknownOption()
222
- .action(() => {
223
- console.error(chalk.yellow('Recipe cache commands were removed. Use `kodly scaffold list` to fetch the latest recipes from GitHub.'));
224
- process.exitCode = 1;
225
- });
226
- const applyCmd = registerApplyOptions(new Command('apply')
227
- .argument('<recipe>', 'Recipe ref in name@version format')
228
- .description('Apply a deterministic recipe to the current Spring Boot project'));
229
- applyCmd.action(async (recipe, opts) => {
230
- const ok = await runApply(recipe, opts);
231
- if (!ok)
232
- process.exitCode = 1;
19
+ .allowExcessArguments()
20
+ .argument('[args...]')
21
+ .action(async (args, _options, command) => {
22
+ const json = command.optsWithGlobals().json === true && !args.includes('--json') ? ['--json'] : [];
23
+ process.exitCode = await runScaffold([...args, ...json]);
233
24
  });
234
- scaffoldCmd.addCommand(applyCmd);
235
25
  };