@kodly.dev/kodly-cli 1.0.16 → 1.0.17
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 +80 -0
- package/dist/bin/kodly.js +5 -1
- package/dist/commands/completion.js +2 -8
- package/dist/commands/man.js +2 -5
- package/dist/commands/scaffold.js +28 -38
- package/dist/utils/config.js +12 -0
- package/dist/utils/update-check.js +91 -0
- package/llm.txt +1 -3
- package/package.json +4 -3
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# @kodly.dev/kodly-cli
|
|
2
|
+
|
|
3
|
+
Official CLI for the [Kodly](https://kodly.dev) platform: authenticate, check out tasks/projects/docs, sync changes, and scaffold Spring Boot apps from recipes.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @kodly.dev/kodly-cli
|
|
9
|
+
kodly --version
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Authenticate
|
|
16
|
+
kodly login
|
|
17
|
+
kodly whoami
|
|
18
|
+
|
|
19
|
+
# Work on a task
|
|
20
|
+
kodly task list
|
|
21
|
+
kodly task checkout <task-slug>
|
|
22
|
+
cd <task-slug>
|
|
23
|
+
# …edit code…
|
|
24
|
+
kodly status
|
|
25
|
+
kodly push
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Scaffolding (no login required)
|
|
29
|
+
|
|
30
|
+
Recipes come from [kodly-scaffold-recipies-java](https://github.com/kodly-dev/kodly-scaffold-recipies-java). Override with `KODLY_RECIPES_REPO_URL`.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# List available recipes (live catalog from the recipes repo)
|
|
34
|
+
kodly scaffold list
|
|
35
|
+
|
|
36
|
+
# Create a project and apply recipes in one step
|
|
37
|
+
kodly scaffold create \
|
|
38
|
+
-g com.acme.orders \
|
|
39
|
+
-n orders-app \
|
|
40
|
+
-p ./orders-app \
|
|
41
|
+
sql@1.0.0 redis-cache@1.0.1
|
|
42
|
+
|
|
43
|
+
# Or step by step
|
|
44
|
+
kodly scaffold init -g com.acme.orders -n orders-app -p ./orders-app
|
|
45
|
+
cd ./orders-app
|
|
46
|
+
kodly scaffold sql@1.0.0
|
|
47
|
+
kodly scaffold redis-cache@1.0.1
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Common commands
|
|
51
|
+
|
|
52
|
+
| Area | Commands |
|
|
53
|
+
|------|----------|
|
|
54
|
+
| Auth | `kodly login`, `kodly whoami`, `kodly logout` |
|
|
55
|
+
| Org | `kodly org list`, `kodly org switch <slug>` |
|
|
56
|
+
| Tasks | `kodly task list`, `kodly task checkout <slug>`, `kodly task create …` |
|
|
57
|
+
| Projects | `kodly project list`, `kodly project checkout [slug]` |
|
|
58
|
+
| Docs | `kodly docs checkout <project-slug>`, `kodly docs status`, `kodly docs push` |
|
|
59
|
+
| Sync | `kodly status`, `kodly push` |
|
|
60
|
+
| Scaffold | `kodly scaffold list`, `kodly scaffold create …`, `kodly scaffold <recipe>@<version>` |
|
|
61
|
+
| Help | `kodly man`, `kodly completion [zsh\|bash\|fish]` |
|
|
62
|
+
|
|
63
|
+
## Notes
|
|
64
|
+
|
|
65
|
+
- Do **not** edit files under `.kodly/` — they hold sync checksums and context.
|
|
66
|
+
- The CLI warns when a newer version is published on npm. Update with:
|
|
67
|
+
```bash
|
|
68
|
+
npm install -g @kodly.dev/kodly-cli@latest
|
|
69
|
+
```
|
|
70
|
+
Disable with `KODLY_DISABLE_UPDATE_CHECK=1`.
|
|
71
|
+
|
|
72
|
+
## Programmatic scaffolding
|
|
73
|
+
|
|
74
|
+
The Spring Boot recipe engine is also available as [`@kodly.dev/scaffolder`](https://www.npmjs.com/package/@kodly.dev/scaffolder).
|
|
75
|
+
|
|
76
|
+
## More
|
|
77
|
+
|
|
78
|
+
- Full manual: `kodly man`
|
|
79
|
+
- Agent reference (shipped with the package): `llm.txt`
|
|
80
|
+
- Website: [kodly.dev](https://kodly.dev)
|
package/dist/bin/kodly.js
CHANGED
|
@@ -16,6 +16,7 @@ import { projectCommands } from '../commands/project.js';
|
|
|
16
16
|
import { docsCommands } from '../commands/docs.js';
|
|
17
17
|
import { orgCommands } from '../commands/org.js';
|
|
18
18
|
import { scaffoldCommands, normalizeScaffoldArgv } from '../commands/scaffold.js';
|
|
19
|
+
import { warnIfCliOutdated } from '../utils/update-check.js';
|
|
19
20
|
const program = new Command();
|
|
20
21
|
program
|
|
21
22
|
.name('kodly')
|
|
@@ -32,4 +33,7 @@ projectCommands(program);
|
|
|
32
33
|
docsCommands(program);
|
|
33
34
|
orgCommands(program);
|
|
34
35
|
scaffoldCommands(program);
|
|
35
|
-
program.
|
|
36
|
+
program.hook('preAction', async () => {
|
|
37
|
+
await warnIfCliOutdated(packageJson.version);
|
|
38
|
+
});
|
|
39
|
+
await program.parseAsync(normalizeScaffoldArgv(process.argv));
|
|
@@ -14,8 +14,7 @@ export const completionCommands = (program) => {
|
|
|
14
14
|
#
|
|
15
15
|
|
|
16
16
|
complete -c kodly -f -n '__fish_use_subcommand' -a 'login logout whoami task push status man help completion project docs org scaffold'
|
|
17
|
-
complete -c kodly -f -n '__fish_seen_subcommand_from scaffold' -a 'init create list
|
|
18
|
-
complete -c kodly -f -n '__fish_seen_subcommand_from cache' -a 'list clear'
|
|
17
|
+
complete -c kodly -f -n '__fish_seen_subcommand_from scaffold' -a 'init create list'
|
|
19
18
|
complete -c kodly -f -n '__fish_seen_subcommand_from task' -a 'list checkout create'
|
|
20
19
|
complete -c kodly -f -n '__fish_seen_subcommand_from project' -a 'checkout list'
|
|
21
20
|
complete -c kodly -f -n '__fish_seen_subcommand_from docs' -a 'checkout push status'
|
|
@@ -67,15 +66,10 @@ _kodly_completion() {
|
|
|
67
66
|
return 0
|
|
68
67
|
;;
|
|
69
68
|
scaffold)
|
|
70
|
-
local scaffold_opts="init create list
|
|
69
|
+
local scaffold_opts="init create list"
|
|
71
70
|
COMPREPLY=( $(compgen -W "\${scaffold_opts}" -- \${cur}) )
|
|
72
71
|
return 0
|
|
73
72
|
;;
|
|
74
|
-
cache)
|
|
75
|
-
local cache_opts="list clear"
|
|
76
|
-
COMPREPLY=( $(compgen -W "\${cache_opts}" -- \${cur}) )
|
|
77
|
-
return 0
|
|
78
|
-
;;
|
|
79
73
|
*)
|
|
80
74
|
;;
|
|
81
75
|
esac
|
package/dist/commands/man.js
CHANGED
|
@@ -59,7 +59,7 @@ export const manCommands = (program) => {
|
|
|
59
59
|
console.log(' Show the working tree status of documentation.');
|
|
60
60
|
console.log(chalk.bold('\n9. Scaffolding Recipes'));
|
|
61
61
|
console.log(' Generate Spring Boot projects and apply deterministic recipes.');
|
|
62
|
-
console.log(' Does not require login —
|
|
62
|
+
console.log(' Does not require login — fetches recipes from GitHub and writes local files.');
|
|
63
63
|
console.log(chalk.cyan(' $ kodly scaffold create -g <group> -n <name> -p <dir> [recipes...]'));
|
|
64
64
|
console.log(' Example: ' +
|
|
65
65
|
chalk.cyan('kodly scaffold create -g com.acme.orders -n orders-app -p ./orders-app sql@1.0.0 redis-cache@1.0.0'));
|
|
@@ -77,11 +77,8 @@ export const manCommands = (program) => {
|
|
|
77
77
|
chalk.yellow('--dry-run') +
|
|
78
78
|
', ' +
|
|
79
79
|
chalk.yellow('--recipe'));
|
|
80
|
-
console.log(' List
|
|
80
|
+
console.log(' List available recipes (live catalog from the recipes repo default branch):');
|
|
81
81
|
console.log(chalk.cyan(' $ kodly scaffold list'));
|
|
82
|
-
console.log(' Manage recipe cache:');
|
|
83
|
-
console.log(chalk.cyan(' $ kodly scaffold cache list'));
|
|
84
|
-
console.log(chalk.cyan(' $ kodly scaffold cache clear [recipe@version]'));
|
|
85
82
|
console.log(chalk.bold('\n10. Shell Autocompletion'));
|
|
86
83
|
console.log(' Enable tab completion for kodly commands.');
|
|
87
84
|
console.log(' ' + chalk.bold('Bash / Zsh:'));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import ora from 'ora';
|
|
4
|
-
import { scaffold, scaffoldInit,
|
|
4
|
+
import { scaffold, scaffoldInit, listRecipes, ScaffoldError, } from '@kodly.dev/scaffolder';
|
|
5
5
|
function errorMessage(error) {
|
|
6
6
|
if (error instanceof ScaffoldError)
|
|
7
7
|
return error.message;
|
|
@@ -102,17 +102,25 @@ async function runCreate(opts) {
|
|
|
102
102
|
}
|
|
103
103
|
console.log(chalk.green(`\nDone. Project ready at ${opts.path}`));
|
|
104
104
|
}
|
|
105
|
-
function
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
async function printRecipes() {
|
|
106
|
+
const spinner = ora('Fetching recipes...').start();
|
|
107
|
+
try {
|
|
108
|
+
const recipes = await listRecipes();
|
|
109
|
+
spinner.stop();
|
|
110
|
+
if (recipes.length === 0) {
|
|
111
|
+
console.log(chalk.yellow('No recipes found.'));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
console.log(chalk.bold('\nAvailable Recipes\n'));
|
|
115
|
+
for (const item of recipes) {
|
|
116
|
+
console.log(` ${chalk.cyan(item.name)}@${item.version}`);
|
|
117
|
+
}
|
|
118
|
+
console.log('');
|
|
110
119
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
catch (error) {
|
|
121
|
+
spinner.fail(chalk.red(errorMessage(error)));
|
|
122
|
+
process.exitCode = 1;
|
|
114
123
|
}
|
|
115
|
-
console.log('');
|
|
116
124
|
}
|
|
117
125
|
function registerApplyOptions(cmd) {
|
|
118
126
|
return cmd
|
|
@@ -124,7 +132,7 @@ function registerApplyOptions(cmd) {
|
|
|
124
132
|
function collectRecipe(value, previous) {
|
|
125
133
|
return [...previous, value];
|
|
126
134
|
}
|
|
127
|
-
const SCAFFOLD_SUBCOMMANDS = new Set(['init', 'create', 'list', '
|
|
135
|
+
const SCAFFOLD_SUBCOMMANDS = new Set(['init', 'create', 'list', 'apply', 'cache']);
|
|
128
136
|
/** Rewrite `scaffold <recipe>` to `scaffold apply <recipe>` for shorthand. */
|
|
129
137
|
export function normalizeScaffoldArgv(argv) {
|
|
130
138
|
const scaffoldIdx = argv.indexOf('scaffold');
|
|
@@ -194,35 +202,17 @@ export const scaffoldCommands = (program) => {
|
|
|
194
202
|
});
|
|
195
203
|
scaffoldCmd
|
|
196
204
|
.command('list')
|
|
197
|
-
.description('List
|
|
198
|
-
.action(() => {
|
|
199
|
-
|
|
205
|
+
.description('List available recipes from the recipes repository default branch')
|
|
206
|
+
.action(async () => {
|
|
207
|
+
await printRecipes();
|
|
200
208
|
});
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
.
|
|
204
|
-
.
|
|
209
|
+
scaffoldCmd
|
|
210
|
+
.command('cache [args...]', { hidden: true })
|
|
211
|
+
.description('(Removed) Use `kodly scaffold list` instead')
|
|
212
|
+
.allowUnknownOption()
|
|
205
213
|
.action(() => {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
cacheCmd
|
|
209
|
-
.command('clear [target]')
|
|
210
|
-
.description('Clear recipe cache (all, recipe name, or recipe@version)')
|
|
211
|
-
.action((target) => {
|
|
212
|
-
try {
|
|
213
|
-
clearRecipeCache(target);
|
|
214
|
-
if (!target) {
|
|
215
|
-
console.log(chalk.green('Cleared all cached recipes.'));
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
console.log(chalk.green(`Cleared cache for ${target}.`));
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
catch (error) {
|
|
222
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
223
|
-
console.error(chalk.red(`Failed to clear cache: ${message}`));
|
|
224
|
-
process.exitCode = 1;
|
|
225
|
-
}
|
|
214
|
+
console.error(chalk.yellow('Recipe cache commands were removed. Use `kodly scaffold list` to fetch the latest recipes from GitHub.'));
|
|
215
|
+
process.exitCode = 1;
|
|
226
216
|
});
|
|
227
217
|
const applyCmd = registerApplyOptions(new Command('apply')
|
|
228
218
|
.argument('<recipe>', 'Recipe ref in name@version format')
|
package/dist/utils/config.js
CHANGED
|
@@ -20,3 +20,15 @@ export const setOrgSlug = (slug) => {
|
|
|
20
20
|
export const clearOrgSlug = () => {
|
|
21
21
|
config.delete('orgSlug');
|
|
22
22
|
};
|
|
23
|
+
export const getUpdateCheckCache = () => {
|
|
24
|
+
const lastCheckedAt = config.get('updateCheck.lastCheckedAt');
|
|
25
|
+
const latestVersion = config.get('updateCheck.latestVersion');
|
|
26
|
+
if (typeof lastCheckedAt !== 'number' || typeof latestVersion !== 'string') {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return { lastCheckedAt, latestVersion };
|
|
30
|
+
};
|
|
31
|
+
export const setUpdateCheckCache = (cache) => {
|
|
32
|
+
config.set('updateCheck.lastCheckedAt', cache.lastCheckedAt);
|
|
33
|
+
config.set('updateCheck.latestVersion', cache.latestVersion);
|
|
34
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { getUpdateCheckCache, setUpdateCheckCache } from './config.js';
|
|
4
|
+
export const KODLY_CLI_PACKAGE_NAME = '@kodly.dev/kodly-cli';
|
|
5
|
+
const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
6
|
+
const FETCH_TIMEOUT_MS = 1500;
|
|
7
|
+
function parseVersionParts(version) {
|
|
8
|
+
const core = version.trim().replace(/^v/i, '').split('-')[0]?.split('+')[0];
|
|
9
|
+
if (!core)
|
|
10
|
+
return null;
|
|
11
|
+
const parts = core.split('.').map((part) => Number.parseInt(part, 10));
|
|
12
|
+
if (parts.length < 3 || parts.slice(0, 3).some((n) => Number.isNaN(n))) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return [parts[0], parts[1], parts[2]];
|
|
16
|
+
}
|
|
17
|
+
/** True when `latest` is a newer semver than `current` (major.minor.patch only). */
|
|
18
|
+
export function isNewerVersion(latest, current) {
|
|
19
|
+
const a = parseVersionParts(latest);
|
|
20
|
+
const b = parseVersionParts(current);
|
|
21
|
+
if (!a || !b)
|
|
22
|
+
return false;
|
|
23
|
+
for (let i = 0; i < 3; i++) {
|
|
24
|
+
if (a[i] > b[i])
|
|
25
|
+
return true;
|
|
26
|
+
if (a[i] < b[i])
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
function shouldSkipUpdateCheck(argv) {
|
|
32
|
+
if (process.env.KODLY_DISABLE_UPDATE_CHECK === '1')
|
|
33
|
+
return true;
|
|
34
|
+
if (process.env.NO_UPDATE_NOTIFIER === '1')
|
|
35
|
+
return true;
|
|
36
|
+
if (process.env.CI === 'true' || process.env.CI === '1')
|
|
37
|
+
return true;
|
|
38
|
+
// Avoid polluting shell completion / version-only output
|
|
39
|
+
if (argv.includes('completion'))
|
|
40
|
+
return true;
|
|
41
|
+
if (argv.includes('--version') || argv.includes('-V'))
|
|
42
|
+
return true;
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
async function fetchLatestVersion() {
|
|
46
|
+
const url = `https://registry.npmjs.org/${encodeURIComponent(KODLY_CLI_PACKAGE_NAME)}/latest`;
|
|
47
|
+
const response = await axios.get(url, {
|
|
48
|
+
timeout: FETCH_TIMEOUT_MS,
|
|
49
|
+
headers: { Accept: 'application/json' },
|
|
50
|
+
validateStatus: (status) => status >= 200 && status < 300,
|
|
51
|
+
});
|
|
52
|
+
const version = response.data?.version;
|
|
53
|
+
return typeof version === 'string' && version.trim() ? version.trim() : undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Warn on stderr when the installed CLI is behind the latest npm release.
|
|
57
|
+
* Failures are silent. Results are cached for 24h.
|
|
58
|
+
*/
|
|
59
|
+
export async function warnIfCliOutdated(currentVersion, argv = process.argv) {
|
|
60
|
+
if (shouldSkipUpdateCheck(argv))
|
|
61
|
+
return;
|
|
62
|
+
let latestVersion;
|
|
63
|
+
const cached = getUpdateCheckCache();
|
|
64
|
+
const now = Date.now();
|
|
65
|
+
const cacheFresh = cached != null && now - cached.lastCheckedAt < CACHE_TTL_MS;
|
|
66
|
+
if (cacheFresh) {
|
|
67
|
+
latestVersion = cached.latestVersion;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
try {
|
|
71
|
+
latestVersion = await fetchLatestVersion();
|
|
72
|
+
if (latestVersion) {
|
|
73
|
+
try {
|
|
74
|
+
setUpdateCheckCache({ lastCheckedAt: now, latestVersion });
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// Cache write failures (permissions, etc.) must not break the CLI
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Network / registry errors must never break the CLI
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!latestVersion || !isNewerVersion(latestVersion, currentVersion)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
console.error(chalk.yellow(`\nUpdate available: ${chalk.bold(currentVersion)} → ${chalk.bold(latestVersion)}\n` +
|
|
90
|
+
` Run: ${chalk.cyan(`npm install -g ${KODLY_CLI_PACKAGE_NAME}@latest`)}\n`));
|
|
91
|
+
}
|
package/llm.txt
CHANGED
|
@@ -53,9 +53,7 @@ Recipes repo: https://github.com/kodly-dev/kodly-scaffold-recipies-java (overrid
|
|
|
53
53
|
- `kodly scaffold create -g <group> -n <name> -p <dir> [recipes...]` : Create a Spring Boot project and apply recipes in one step (shared package/name/prefix). No login required.
|
|
54
54
|
- `kodly scaffold init --group <group> --name <name>` : Generate a new Spring Boot skeleton with your package and project name. No login required.
|
|
55
55
|
- `kodly scaffold <recipe>@<version>` : Apply a deterministic recipe to a local Spring Boot skeleton project. No login required.
|
|
56
|
-
- `kodly scaffold list` : List
|
|
57
|
-
- `kodly scaffold cache list` : List locally cached recipes.
|
|
58
|
-
- `kodly scaffold cache clear [recipe@version]` : Clear recipe cache (all, one recipe, or one version).
|
|
56
|
+
- `kodly scaffold list` : List available recipes from the recipes repo default branch (`recipes/*/manifest.json`). No login required.
|
|
59
57
|
|
|
60
58
|
Options for create/apply: `--path <dir>`, `--group <group>`, `--prefix <prefix>`, `--skeleton-version <ver>` (create/init), `--dry-run`, `-r/--recipe <ref>` (create, repeatable).
|
|
61
59
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kodly.dev/kodly-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"kodly": "./dist/bin/kodly.js"
|
|
@@ -23,13 +23,14 @@
|
|
|
23
23
|
"description": "CLI Agent for Kodly Platform",
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
|
-
"llm.txt"
|
|
26
|
+
"llm.txt",
|
|
27
|
+
"README.md"
|
|
27
28
|
],
|
|
28
29
|
"publishConfig": {
|
|
29
30
|
"access": "public"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@kodly.dev/scaffolder": "1.0.
|
|
33
|
+
"@kodly.dev/scaffolder": "1.0.1",
|
|
33
34
|
"@types/inquirer": "^9.0.9",
|
|
34
35
|
"@types/node": "^25.0.5",
|
|
35
36
|
"axios": "^1.13.2",
|