@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
@@ -1,105 +1,48 @@
1
1
  import chalk from 'chalk';
2
- import ora from 'ora';
3
- import { fetchMemberships, getMembershipSlug, getMembershipName, isDefaultMembership, findMembership, formatActiveOrg, resetToDefaultOrg, ensureDefaultOrg, resolveActiveOrg, } from '../utils/org.js';
4
- import { setOrgSlug } from '../utils/config.js';
5
- import { requireAuth } from '../utils/session.js';
6
- export const orgCommands = (program) => {
7
- const orgCmd = program.command('org').description('Manage organizations');
8
- orgCmd
2
+ import { settings } from '../core/config.js';
3
+ import { buildContext } from '../core/context.js';
4
+ import { CliError, ExitCode } from '../core/errors.js';
5
+ import { fetchMemberships } from '../core/memberships.js';
6
+ import { emit, run } from '../core/output.js';
7
+ export const orgCommands = (program, cliVersion) => {
8
+ const org = program.command('org').description('Organisations you belong to');
9
+ org
9
10
  .command('list')
10
- .description('List organizations you belong to')
11
- .action(async () => {
12
- if (!(await requireAuth()))
13
- return;
14
- const spinner = ora('Fetching organizations...').start();
15
- try {
16
- const memberships = await fetchMemberships(true);
17
- const activeOrg = await resolveActiveOrg();
18
- const activeSlug = activeOrg?.slug;
19
- if (memberships.length === 0) {
20
- spinner.fail(chalk.yellow('No organizations found.'));
21
- return;
11
+ .description('List your organisations')
12
+ .action(run(async (_options, command) => {
13
+ const ctx = buildContext(command, cliVersion);
14
+ ctx.requireLogin();
15
+ const memberships = await fetchMemberships(ctx.api);
16
+ const active = ctx.api.session.orgSlug;
17
+ emit(ctx.json, memberships.map((m) => ({ ...m, active: m.orgSlug === active })), () => {
18
+ if (memberships.length === 0)
19
+ console.log('You belong to no organisation.');
20
+ for (const m of memberships) {
21
+ const marker = m.orgSlug === active ? chalk.green(' *') : '';
22
+ console.log(`${chalk.cyan(m.orgSlug)} ${m.orgName ?? ''}${chalk.dim(m.roleName ? ` (${m.roleName})` : '')}${marker}`);
22
23
  }
23
- spinner.stop();
24
- console.log(chalk.bold('\nYour Organizations:\n'));
25
- memberships.forEach((membership) => {
26
- const slug = getMembershipSlug(membership);
27
- const name = getMembershipName(membership);
28
- const role = membership.role ? chalk.dim(` (${membership.role})`) : '';
29
- const isActive = slug === activeSlug;
30
- const defaultLabel = isDefaultMembership(membership) ? chalk.dim(' [default]') : '';
31
- const currentLabel = isActive ? chalk.green(' *') : '';
32
- console.log(` ${chalk.cyan(slug)} - ${name}${role}${defaultLabel}${currentLabel}`);
33
- });
34
- console.log('');
35
- if (activeOrg) {
36
- console.log(chalk.dim(`Active organization: ${formatActiveOrg(activeOrg)}`));
37
- }
38
- console.log('');
39
- }
40
- catch (error) {
41
- spinner.fail(chalk.red('Failed to list organizations: ' + (error.message || 'Unknown error')));
42
- }
43
- });
44
- orgCmd
24
+ });
25
+ }));
26
+ org
27
+ .command('switch')
28
+ .argument('<slug>', 'the organisation slug')
29
+ .description('Use this organisation for the next commands')
30
+ .action(run(async (slug, _options, command) => {
31
+ const ctx = buildContext(command, cliVersion);
32
+ ctx.requireLogin();
33
+ const memberships = await fetchMemberships(ctx.api);
34
+ if (!memberships.some((m) => m.orgSlug === slug)) {
35
+ throw new CliError(`You are not a member of "${slug}". Run "kodly org list".`, ExitCode.USAGE);
36
+ }
37
+ settings().set('orgSlug', slug);
38
+ emit(ctx.json, { org: slug }, () => console.log(`Organisation: ${chalk.cyan(slug)}`));
39
+ }));
40
+ org
45
41
  .command('current')
46
- .description('Show the currently active organization')
47
- .action(async () => {
48
- if (!(await requireAuth()))
49
- return;
50
- const spinner = ora('Fetching organization...').start();
51
- try {
52
- const org = await ensureDefaultOrg();
53
- spinner.stop();
54
- if (org) {
55
- console.log(chalk.green(`Active organization: ${formatActiveOrg(org)}`));
56
- }
57
- else {
58
- console.log(chalk.yellow('No active organization found.'));
59
- }
60
- }
61
- catch (error) {
62
- spinner.fail(chalk.red('Failed to fetch organization: ' + (error.message || 'Unknown error')));
63
- }
64
- });
65
- orgCmd
66
- .command('switch <slug>')
67
- .description('Switch to a different organization')
68
- .action(async (slug) => {
69
- if (!(await requireAuth()))
70
- return;
71
- const spinner = ora('Verifying organization...').start();
72
- try {
73
- const memberships = await fetchMemberships(true);
74
- const membership = findMembership(memberships, slug);
75
- if (!membership) {
76
- spinner.fail(chalk.red(`Organization "${slug}" not found. Run "kodly org list" to see available organizations.`));
77
- return;
78
- }
79
- setOrgSlug(slug);
80
- spinner.succeed(chalk.green(`Switched to organization: ${getMembershipName(membership)} (${slug})`));
81
- }
82
- catch (error) {
83
- spinner.fail(chalk.red('Failed to switch organization: ' + (error.message || 'Unknown error')));
84
- }
85
- });
86
- orgCmd
87
- .command('unset')
88
- .description('Reset to your default organization')
89
- .action(async () => {
90
- if (!(await requireAuth()))
91
- return;
92
- const spinner = ora('Resetting to default organization...').start();
93
- try {
94
- const org = await resetToDefaultOrg();
95
- if (!org) {
96
- spinner.fail(chalk.yellow('No default organization found.'));
97
- return;
98
- }
99
- spinner.succeed(chalk.green(`Using default organization: ${formatActiveOrg(org)}`));
100
- }
101
- catch (error) {
102
- spinner.fail(chalk.red('Failed to reset organization: ' + (error.message || 'Unknown error')));
103
- }
104
- });
42
+ .description('Show the active organisation')
43
+ .action(run(async (_options, command) => {
44
+ const ctx = buildContext(command, cliVersion);
45
+ const slug = ctx.api.session.orgSlug ?? null;
46
+ emit(ctx.json, { org: slug }, () => console.log(slug ?? 'No organisation. Run "kodly org switch <slug>".'));
47
+ }));
105
48
  };
@@ -0,0 +1,157 @@
1
+ import chalk from 'chalk';
2
+ import { buildContext } from '../core/context.js';
3
+ import { CliError, ExitCode } from '../core/errors.js';
4
+ import { ago, storyPath } from '../core/format.js';
5
+ import { emit, run } from '../core/output.js';
6
+ import fs from 'node:fs';
7
+ import { checkoutOf } from '../core/checkout.js';
8
+ import { findStory, requestId } from '../core/story.js';
9
+ import { checkoutStory } from './code.js';
10
+ const printPlan = (view, kind) => {
11
+ const plan = view.plan;
12
+ if (!plan) {
13
+ console.log(`The story has no ${kind} yet.`);
14
+ return;
15
+ }
16
+ const approval = view.approval ? chalk.green(`approved by ${view.approval.approvedByEmail ?? view.approval.approvedBy ?? '?'}`) : chalk.yellow('not approved');
17
+ console.log(`${chalk.bold(`${kind} v${plan.version}`)} ${approval}${view.outdated ? chalk.yellow(', outdated: the story changed') : ''}`);
18
+ console.log(chalk.dim(`by ${plan.createdBy ?? '?'} ${ago(plan.createdAt)}`));
19
+ const doc = plan.document ?? {};
20
+ if (doc.summary)
21
+ console.log(`\n${doc.summary}`);
22
+ for (const codebase of doc.codebases ?? []) {
23
+ console.log(chalk.bold(`\n${codebase.name ?? codebase.codebaseSlug ?? ''}`) + chalk.dim(codebase.responsibility ? ` ${codebase.responsibility}` : ''));
24
+ (codebase.steps ?? []).forEach((step, i) => console.log(` ${i + 1}. ${step.title ?? ''}`));
25
+ }
26
+ if (doc.decisions?.length) {
27
+ console.log(chalk.bold('\nDecisions'));
28
+ for (const d of doc.decisions)
29
+ console.log(` ${d.title ?? d.id}: ${d.decision ?? ''}`);
30
+ }
31
+ if (doc.tests?.length) {
32
+ console.log(chalk.bold('\nTests'));
33
+ for (const t of doc.tests)
34
+ console.log(` ${t.id} ${t.title ?? ''}${chalk.dim(t.level ? ` (${t.level.toLowerCase()})` : '')}`);
35
+ }
36
+ if (doc.exclusions?.length) {
37
+ console.log(chalk.bold('\nNot tested'));
38
+ for (const e of doc.exclusions)
39
+ console.log(` ${e.title ?? ''}${chalk.dim(e.reason ? `: ${e.reason}` : '')}`);
40
+ }
41
+ if (doc.assumptions?.length) {
42
+ console.log(chalk.bold('\nAssumptions'));
43
+ for (const a of doc.assumptions)
44
+ console.log(` - ${a}`);
45
+ }
46
+ };
47
+ /** `plan` and `test-plan` share their commands. Only the route, the name and the MCP prompt differ. */
48
+ const planCommands = (program, cliVersion, name, route, kind, prompt) => {
49
+ const group = program.command(name).description(`The ${kind} of a story`);
50
+ const load = async (ctx, id) => {
51
+ const project = ctx.project();
52
+ const item = await findStory(ctx.api, project, id);
53
+ const path = storyPath(project, item.slug, route);
54
+ return { item, path, view: await ctx.api.request(path) };
55
+ };
56
+ group
57
+ .command('show')
58
+ .argument('<story>', 'the story identifier or slug')
59
+ .description(`Show the ${kind}`)
60
+ .action(run(async (id, _options, command) => {
61
+ const ctx = buildContext(command, cliVersion);
62
+ const { view } = await load(ctx, id);
63
+ emit(ctx.json, view, () => printPlan(view, kind));
64
+ }));
65
+ group
66
+ .command('approve')
67
+ .argument('<story>', 'the story identifier or slug')
68
+ .description(`Approve the current ${kind} (needs your approval in the browser)`)
69
+ .action(run(async (id, _options, command) => {
70
+ const ctx = buildContext(command, cliVersion);
71
+ const { item, path, view } = await load(ctx, id);
72
+ if (!view.plan)
73
+ throw new CliError(`The story has no ${kind} to approve.`, ExitCode.CONFLICT);
74
+ if (view.outdated)
75
+ throw new CliError(`The ${kind} is outdated, because the story changed. Ask for a new ${kind} first.`, ExitCode.CONFLICT);
76
+ const approved = await ctx.api.request(`${path}/approve`, { method: 'POST', body: { version: view.plan.version } });
77
+ emit(ctx.json, approved, () => console.log(chalk.green(`Approved ${kind} v${view.plan?.version} of ${item.identifier ?? item.slug}.`)));
78
+ }));
79
+ group
80
+ .command('draft')
81
+ .argument('<story>', 'the story identifier or slug')
82
+ .option('--dir <path>', 'the folder for the checkout')
83
+ .description(`Prepare a ${kind} with your local agent: check out the code, then tell the agent to draft the ${kind}`)
84
+ .action(run(async (id, options, command) => {
85
+ const ctx = buildContext(command, cliVersion);
86
+ let root;
87
+ let identifier;
88
+ const existing = checkoutOf(id, options.dir);
89
+ if (existing) {
90
+ root = existing.root;
91
+ identifier = existing.context.identifier ?? existing.context.story;
92
+ }
93
+ else {
94
+ const created = await checkoutStory(ctx, id, options.dir);
95
+ root = created.root;
96
+ identifier = created.item.identifier ?? created.item.slug;
97
+ }
98
+ emit(ctx.json, { root, prompt: `/mcp__kodly__${prompt} ${identifier}` }, () => {
99
+ console.log(`The code of ${identifier} is in ${root}. Your agent reads it and saves a ${kind} draft.`);
100
+ console.log('Next:');
101
+ console.log(` cd ${root}`);
102
+ console.log(` claude "/mcp__kodly__${prompt} ${identifier}"`);
103
+ console.log(`Then approve the ${kind} in the browser: kodly ${name} approve ${identifier}`);
104
+ });
105
+ }));
106
+ group
107
+ .command('submit')
108
+ .argument('<story>', 'the story identifier or slug')
109
+ .requiredOption('--file <path>', 'a JSON file with {"plan": {...}} or {"edits": [...]}, and an optional "reason"')
110
+ .option('--harness <name>', 'the local agent tool, for example claude-code')
111
+ .description(`Save a ${kind} draft from a file. A person approves it in the browser.`)
112
+ .action(run(async (id, options, command) => {
113
+ const ctx = buildContext(command, cliVersion);
114
+ const { item, path, view } = await load(ctx, id);
115
+ let input;
116
+ try {
117
+ input = JSON.parse(fs.readFileSync(options.file, 'utf8'));
118
+ }
119
+ catch (e) {
120
+ throw new CliError(`${options.file} is not a JSON file that kodly can read: ${e.message}`, ExitCode.USAGE);
121
+ }
122
+ if (!input.plan === !input.edits)
123
+ throw new CliError(`${options.file} must hold "plan" or "edits", not both.`, ExitCode.USAGE);
124
+ const saved = await saveDraft(ctx.api, path, view, { plan: input.plan, edits: input.edits, reason: input.reason, harness: options.harness });
125
+ emit(ctx.json, saved, () => console.log(chalk.green(`Saved ${kind} v${saved.version} of ${item.identifier ?? item.slug}. Approve it: kodly ${name} approve ${item.identifier ?? item.slug}`)));
126
+ }));
127
+ };
128
+ /** Saves a plan or test-plan draft with the version and the story fingerprint of `view`. A retry of the call gives the same revision. */
129
+ export const saveDraft = (api, path, view, draft) => api.request(`${path}/drafts`, {
130
+ method: 'POST',
131
+ body: {
132
+ requestId: requestId(), expectedVersion: view.plan?.version ?? 0, storyFingerprint: view.storyFingerprint,
133
+ plan: draft.plan, edits: draft.edits, reason: draft.reason, harness: draft.harness, model: draft.model,
134
+ },
135
+ });
136
+ export const planningCommands = (program, cliVersion) => {
137
+ planCommands(program, cliVersion, 'plan', '/planning', 'plan', 'plan');
138
+ planCommands(program, cliVersion, 'test-plan', '/test-planning', 'test plan', 'test_plan');
139
+ program
140
+ .command('scope')
141
+ .description('The scope of a story')
142
+ .command('approve')
143
+ .argument('<story>', 'the story identifier or slug')
144
+ .description('Approve the current version of the story text (needs your approval in the browser)')
145
+ .action(run(async (id, _options, command) => {
146
+ const ctx = buildContext(command, cliVersion);
147
+ const project = ctx.project();
148
+ const item = await findStory(ctx.api, project, id);
149
+ const history = await ctx.api.request(storyPath(project, item.slug, '/history'), { query: { output: 'STORY' } });
150
+ if (!history?.currentStoryVersion)
151
+ throw new CliError('The story has no version to approve.', ExitCode.CONFLICT);
152
+ const result = await ctx.api.request(storyPath(project, item.slug, '/history/approve-scope'), {
153
+ method: 'POST', body: { version: history.currentStoryVersion },
154
+ });
155
+ emit(ctx.json, result, () => console.log(chalk.green(`Approved the scope of ${item.identifier ?? item.slug} (v${history.currentStoryVersion}).`)));
156
+ }));
157
+ };
@@ -1,93 +1,95 @@
1
1
  import chalk from 'chalk';
2
- import ora from 'ora';
3
- import path from 'path';
4
- import { Api } from '../api/client.js';
5
- import { requireAuthAndOrg } from '../utils/session.js';
6
- import { printActiveOrg } from '../utils/org.js';
7
- export const projectCommands = (program) => {
8
- const projectCmd = program.command('project').description('Manage projects');
9
- projectCmd
2
+ import { settings } from '../core/config.js';
3
+ import { buildContext } from '../core/context.js';
4
+ import { CliError, ExitCode } from '../core/errors.js';
5
+ import { projectPath, table } from '../core/format.js';
6
+ import { emit, run } from '../core/output.js';
7
+ /** A project in the web app is a workspace in the API. */
8
+ export const projectCommands = (program, cliVersion) => {
9
+ const project = program.command('project').description('The projects of your organisation');
10
+ project
10
11
  .command('list')
11
- .description('List all projects')
12
- .action(async () => {
13
- const org = await requireAuthAndOrg();
14
- if (!org)
15
- return;
16
- const spinner = ora('Fetching projects...').start();
17
- try {
18
- const res = await Api.projects.list();
19
- const projects = res.data.data;
20
- if (!projects || projects.length === 0) {
21
- spinner.stop();
22
- printActiveOrg(org);
23
- console.log(chalk.yellow('No projects found.'));
24
- return;
25
- }
26
- spinner.stop();
27
- printActiveOrg(org);
28
- console.log(chalk.bold('\nYour Projects:\n'));
29
- projects.forEach((p) => {
30
- console.log(` ${chalk.cyan(p.slug)} - ${p.name}`);
31
- });
32
- console.log('');
33
- }
34
- catch (error) {
35
- spinner.fail(chalk.red('Failed to list projects: ' + (error.message || 'Unknown error')));
12
+ .description('List the projects that you can see')
13
+ .action(run(async (_options, command) => {
14
+ const ctx = buildContext(command, cliVersion);
15
+ ctx.requireLogin();
16
+ const projects = (await ctx.api.request('/my-workspace')) ?? [];
17
+ const active = command.optsWithGlobals().project || process.env.KODLY_PROJECT || settings().get('projectSlug');
18
+ emit(ctx.json, projects, () => {
19
+ if (projects.length === 0)
20
+ console.log('You see no projects in this organisation.');
21
+ table(projects.map((p) => [chalk.cyan(p.slug) + (p.slug === active ? chalk.green(' *') : ''), p.name ?? '',
22
+ `${p.codebaseCount ?? 0} codebases, ${p.memberCount ?? 0} members`]), ['PROJECT', 'NAME', '']);
23
+ });
24
+ }));
25
+ project
26
+ .command('use')
27
+ .argument('<slug>', 'the project slug')
28
+ .description('Use this project for the next commands')
29
+ .action(run(async (slug, _options, command) => {
30
+ const ctx = buildContext(command, cliVersion);
31
+ ctx.requireLogin();
32
+ const projects = (await ctx.api.request('/my-workspace')) ?? [];
33
+ if (!projects.some((p) => p.slug === slug)) {
34
+ throw new CliError(`You cannot see a project "${slug}". Run "kodly project list".`, ExitCode.USAGE);
36
35
  }
37
- });
38
- projectCmd
39
- .command('checkout [slug] [path]')
40
- .description('Checkout a project to local environment')
41
- .action(async (slugArg, pathArg) => {
42
- const org = await requireAuthAndOrg();
43
- if (!org)
36
+ settings().set('projectSlug', slug);
37
+ emit(ctx.json, { project: slug }, () => console.log(`Project: ${chalk.cyan(slug)}`));
38
+ }));
39
+ project
40
+ .command('current')
41
+ .description('Show the active project')
42
+ .action(run(async (_options, command) => {
43
+ const ctx = buildContext(command, cliVersion);
44
+ const slug = ctx.project();
45
+ emit(ctx.json, { project: slug }, () => console.log(slug));
46
+ }));
47
+ project
48
+ .command('local')
49
+ .argument('[mode]', 'on or off; leave it out to show the setting')
50
+ .description('Show or change local work for the active project: no automatic hosted plan, test plan or build runs (a change needs your approval in the browser)')
51
+ .action(run(async (mode, _options, command) => {
52
+ const ctx = buildContext(command, cliVersion);
53
+ const path = projectPath(ctx.project(), '/local-work');
54
+ const current = await ctx.api.request(path);
55
+ if (mode === undefined) {
56
+ emit(ctx.json, current, () => console.log(`Local work: ${current.setting.enabled ? chalk.green('on') : 'off'}${current.canManage ? '' : chalk.dim(' (only a project admin can change it)')}`));
44
57
  return;
45
- let slug = slugArg;
46
- if (!slug) {
47
- const cwd = process.cwd();
48
- const { getProjectData } = await import('../utils/project.js');
49
- const projectData = getProjectData(cwd);
50
- slug = projectData?.projectSlug || '';
51
- if (!slug) {
52
- console.log(chalk.red('Error: projectSlug is required. Provide it as an argument or run inside a directory with .kodly/project.info.json'));
53
- return;
54
- }
55
58
  }
56
- const spinner = ora(`Checking out project ${slug}...`).start();
57
- try {
58
- printActiveOrg(org);
59
- let projectDir = pathArg ? path.resolve(process.cwd(), pathArg) : null;
60
- // If path not provided, try to fetch default from project settings
61
- if (!projectDir) {
62
- try {
63
- const projectRes = await Api.projects.get(slug);
64
- const project = projectRes.data.data;
65
- if (project && project.userSettings && project.userSettings.codeSyncBasePath) {
66
- let targetPath = project.userSettings.codeSyncBasePath;
67
- projectDir = targetPath; // Assign to projectDir
68
- }
69
- }
70
- catch (e) {
71
- // Ignore errors fetching settings
72
- }
73
- }
74
- // Default to current directory + slug if still not set
75
- if (!projectDir) {
76
- projectDir = path.resolve(process.cwd(), slug);
77
- }
78
- spinner.text = `Checking out project files...`;
79
- // Get Files
80
- const checkoutRes = await Api.projects.checkout(slug);
81
- const files = checkoutRes.data.data; // Array of SyncCodeResultDto
82
- const { syncCheckoutFiles } = await import('../utils/checkout.js');
83
- const success = await syncCheckoutFiles(projectDir, files, 'project', spinner);
84
- if (success) {
85
- spinner.succeed(chalk.green(`Project checked out to ${projectDir}`));
86
- console.log(`Files synchronized: ${files.length}`);
87
- }
88
- }
89
- catch (error) {
90
- spinner.fail(chalk.red(`Checkout failed: ${error.message || 'Unknown error'}`));
59
+ if (mode !== 'on' && mode !== 'off')
60
+ throw new CliError('Choose on or off.', ExitCode.USAGE);
61
+ const saved = await ctx.api.request(path, { method: 'PUT', body: { revision: current.setting.revision, enabled: mode === 'on' } });
62
+ emit(ctx.json, saved, () => console.log(`Local work: ${saved.enabled ? chalk.green('on') : 'off'}. ${saved.enabled
63
+ ? 'Kodly starts no automatic hosted plan, test plan or build runs for the stories of this project.'
64
+ : 'Kodly starts the automatic hosted runs again.'}`));
65
+ }));
66
+ project
67
+ .command('local-qa')
68
+ .argument('[mode]', 'on or off; leave it out to show the setting')
69
+ .description('Show or change local QA for the active project: QA results of a local agent count after a person accepts them'
70
+ + ' (a change needs your approval in the browser)')
71
+ .action(run(async (mode, _options, command) => {
72
+ const ctx = buildContext(command, cliVersion);
73
+ const path = projectPath(ctx.project(), '/local-qa');
74
+ const current = await ctx.api.request(path);
75
+ if (mode === undefined) {
76
+ emit(ctx.json, current, () => console.log(`Local QA: ${current.setting.enabled ? chalk.green('on') : 'off'}${current.canManage ? '' : chalk.dim(' (only a project admin can change it)')}`));
77
+ return;
91
78
  }
92
- });
79
+ if (mode !== 'on' && mode !== 'off')
80
+ throw new CliError('Choose on or off.', ExitCode.USAGE);
81
+ const saved = await ctx.api.request(path, { method: 'PUT', body: { revision: current.setting.revision, enabled: mode === 'on' } });
82
+ emit(ctx.json, saved, () => console.log(`Local QA: ${saved.enabled ? chalk.green('on') : 'off'}. ${saved.enabled
83
+ ? 'A person can accept the QA results of a local agent with kodly qa accept. Another member then approves the code.'
84
+ : 'QA runs only in the Kodly sandbox.'}`));
85
+ }));
86
+ program
87
+ .command('members')
88
+ .description('List the members of the active project')
89
+ .action(run(async (_options, command) => {
90
+ const ctx = buildContext(command, cliVersion);
91
+ const team = await ctx.api.request(projectPath(ctx.project(), '/members'));
92
+ const members = team?.members ?? [];
93
+ emit(ctx.json, members, () => table(members.map((m) => [m.name ?? '', m.email ?? '', (m.access ?? '').toLowerCase() + (m.owner ? ', owner' : '')]), ['NAME', 'EMAIL', 'ACCESS']));
94
+ }));
93
95
  };