@kodly.dev/kodly-cli 1.0.16
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/dist/api/client.js +96 -0
- package/dist/bin/kodly.js +35 -0
- package/dist/commands/auth.js +89 -0
- package/dist/commands/completion.js +90 -0
- package/dist/commands/docs.js +152 -0
- package/dist/commands/man.js +96 -0
- package/dist/commands/org.js +105 -0
- package/dist/commands/project.js +93 -0
- package/dist/commands/push.js +51 -0
- package/dist/commands/scaffold.js +236 -0
- package/dist/commands/status.js +52 -0
- package/dist/commands/task.js +155 -0
- package/dist/utils/changes.js +90 -0
- package/dist/utils/checkout.js +168 -0
- package/dist/utils/config.js +22 -0
- package/dist/utils/org.js +138 -0
- package/dist/utils/project.js +21 -0
- package/dist/utils/session.js +28 -0
- package/dist/utils/task.js +25 -0
- package/llm.txt +90 -0
- package/package.json +46 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import crypto from 'crypto';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import ignore from 'ignore';
|
|
7
|
+
export async function syncCheckoutFiles(targetDir, incomingFiles, entityName, spinner) {
|
|
8
|
+
// Ensure target dir exists
|
|
9
|
+
if (!fs.existsSync(targetDir)) {
|
|
10
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
const kodlyDir = path.join(targetDir, '.kodly');
|
|
13
|
+
if (!fs.existsSync(kodlyDir)) {
|
|
14
|
+
fs.mkdirSync(kodlyDir, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
// 1. Prepare ignore rules
|
|
17
|
+
let ig = ignore();
|
|
18
|
+
const gitignorePath = path.join(targetDir, '.gitignore');
|
|
19
|
+
if (fs.existsSync(gitignorePath)) {
|
|
20
|
+
ig.add(fs.readFileSync(gitignorePath, 'utf8'));
|
|
21
|
+
}
|
|
22
|
+
// Always ignore .kodly, .git, and common build dirs
|
|
23
|
+
ig.add(['.kodly', '.git', 'node_modules', 'dist', 'build', '.kodly-docs.json', '.kodlyspec', 'package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock', 'pnpm-lock.yaml']);
|
|
24
|
+
// 2. Process incoming files and compute hashes
|
|
25
|
+
const incomingMap = {};
|
|
26
|
+
incomingFiles.forEach((file) => {
|
|
27
|
+
const relativePath = file.basePath ? file.basePath.replace(/^\//, '') : '';
|
|
28
|
+
const fileNameFull = file.fileName;
|
|
29
|
+
const key = relativePath ? path.posix.join(relativePath, fileNameFull) : fileNameFull;
|
|
30
|
+
let fileBuffer;
|
|
31
|
+
if (file.isBase64Encoded) {
|
|
32
|
+
fileBuffer = Buffer.from(file.content || '', 'base64');
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
fileBuffer = Buffer.from(file.content || '');
|
|
36
|
+
}
|
|
37
|
+
const hash = crypto.createHash('md5').update(fileBuffer).digest('hex');
|
|
38
|
+
incomingMap[key] = {
|
|
39
|
+
content: fileBuffer,
|
|
40
|
+
hash,
|
|
41
|
+
isBase64: file.isBase64Encoded
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
// 3. Scan local files
|
|
45
|
+
const localFiles = scanDirectory(targetDir, '', ig);
|
|
46
|
+
const localMap = {}; // filepath -> hash
|
|
47
|
+
localFiles.forEach(subPath => {
|
|
48
|
+
const fullPath = path.join(targetDir, subPath);
|
|
49
|
+
const contentBuffer = fs.readFileSync(fullPath);
|
|
50
|
+
const hash = crypto.createHash('md5').update(contentBuffer).digest('hex');
|
|
51
|
+
localMap[subPath] = hash;
|
|
52
|
+
});
|
|
53
|
+
// 4. Compute Changeset
|
|
54
|
+
const changes = [];
|
|
55
|
+
const newChecksums = {};
|
|
56
|
+
// Check incoming files (NEW, MODIFIED, UNCHANGED)
|
|
57
|
+
Object.keys(incomingMap).forEach(incomingKey => {
|
|
58
|
+
newChecksums[incomingKey] = incomingMap[incomingKey].hash;
|
|
59
|
+
if (!localMap[incomingKey]) {
|
|
60
|
+
changes.push({ filepath: incomingKey, status: 'NEW' });
|
|
61
|
+
}
|
|
62
|
+
else if (localMap[incomingKey] !== incomingMap[incomingKey].hash) {
|
|
63
|
+
changes.push({ filepath: incomingKey, status: 'MODIFIED' });
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
changes.push({ filepath: incomingKey, status: 'UNCHANGED' });
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
// Check local files (TO_BE_DELETED)
|
|
70
|
+
Object.keys(localMap).forEach(localKey => {
|
|
71
|
+
if (!incomingMap[localKey]) {
|
|
72
|
+
changes.push({ filepath: localKey, status: 'TO_BE_DELETED' });
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
// 5. Present changeset
|
|
76
|
+
const actionableChanges = changes.filter(c => c.status !== 'UNCHANGED');
|
|
77
|
+
if (actionableChanges.length === 0) {
|
|
78
|
+
// No changes needed, just write checksums
|
|
79
|
+
fs.writeFileSync(path.join(kodlyDir, 'checksums.json'), JSON.stringify(newChecksums, null, 2));
|
|
80
|
+
return true; // No prompts needed, proceed as success
|
|
81
|
+
}
|
|
82
|
+
const isFreshCheckout = Object.keys(localMap).length === 0;
|
|
83
|
+
if (!isFreshCheckout) {
|
|
84
|
+
spinner.stop(); // Stop spinner to prompt user
|
|
85
|
+
console.log(chalk.bold(`\nChangeset for ${entityName}:`));
|
|
86
|
+
actionableChanges.sort((a, b) => a.filepath.localeCompare(b.filepath)).forEach(file => {
|
|
87
|
+
let color = chalk.yellow;
|
|
88
|
+
if (file.status === 'NEW')
|
|
89
|
+
color = chalk.green;
|
|
90
|
+
if (file.status === 'TO_BE_DELETED')
|
|
91
|
+
color = chalk.red;
|
|
92
|
+
let prefix = '';
|
|
93
|
+
if (file.status === 'NEW')
|
|
94
|
+
prefix = '+';
|
|
95
|
+
else if (file.status === 'MODIFIED')
|
|
96
|
+
prefix = 'M';
|
|
97
|
+
else if (file.status === 'TO_BE_DELETED')
|
|
98
|
+
prefix = '-';
|
|
99
|
+
console.log(` ${color(prefix)} ${file.filepath}`);
|
|
100
|
+
});
|
|
101
|
+
console.log('');
|
|
102
|
+
// 6. Prompt user
|
|
103
|
+
const { confirm } = await inquirer.prompt([{
|
|
104
|
+
type: 'confirm',
|
|
105
|
+
name: 'confirm',
|
|
106
|
+
message: 'Do you want to apply these changes?',
|
|
107
|
+
default: true
|
|
108
|
+
}]);
|
|
109
|
+
if (!confirm) {
|
|
110
|
+
console.log(chalk.yellow('Checkout aborted by user.'));
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
spinner.start('Applying changes...');
|
|
114
|
+
}
|
|
115
|
+
// 7. Apply Changes
|
|
116
|
+
// Write NEW and MODIFIED files
|
|
117
|
+
const incomingToApply = changes.filter(c => c.status === 'NEW' || c.status === 'MODIFIED' || c.status === 'UNCHANGED');
|
|
118
|
+
incomingToApply.forEach(c => {
|
|
119
|
+
const fullPath = path.join(targetDir, c.filepath);
|
|
120
|
+
const dirName = path.dirname(fullPath);
|
|
121
|
+
if (!fs.existsSync(dirName)) {
|
|
122
|
+
fs.mkdirSync(dirName, { recursive: true });
|
|
123
|
+
}
|
|
124
|
+
fs.writeFileSync(fullPath, incomingMap[c.filepath].content);
|
|
125
|
+
});
|
|
126
|
+
// Delete TO_BE_DELETED files
|
|
127
|
+
const toDelete = changes.filter(c => c.status === 'TO_BE_DELETED');
|
|
128
|
+
toDelete.forEach(c => {
|
|
129
|
+
const fullPath = path.join(targetDir, c.filepath);
|
|
130
|
+
if (fs.existsSync(fullPath)) {
|
|
131
|
+
fs.unlinkSync(fullPath);
|
|
132
|
+
// Optionally, try to remove empty directory
|
|
133
|
+
const dirName = path.dirname(fullPath);
|
|
134
|
+
removeEmptyDirs(dirName, targetDir);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
// Write Checksums
|
|
138
|
+
fs.writeFileSync(path.join(kodlyDir, 'checksums.json'), JSON.stringify(newChecksums, null, 2));
|
|
139
|
+
return true; // Applied successfully
|
|
140
|
+
}
|
|
141
|
+
function scanDirectory(dir, base, ig) {
|
|
142
|
+
const list = fs.readdirSync(dir);
|
|
143
|
+
const results = [];
|
|
144
|
+
list.forEach(file => {
|
|
145
|
+
const fullPath = path.join(dir, file);
|
|
146
|
+
const rawRelativePath = path.join(base, file);
|
|
147
|
+
const relativePath = rawRelativePath.replace(/\\/g, '/'); // forward slashes
|
|
148
|
+
if (ig.ignores(relativePath))
|
|
149
|
+
return;
|
|
150
|
+
const stat = fs.statSync(fullPath);
|
|
151
|
+
if (stat.isDirectory()) {
|
|
152
|
+
results.push(...scanDirectory(fullPath, relativePath, ig));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
results.push(relativePath);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
return results;
|
|
159
|
+
}
|
|
160
|
+
function removeEmptyDirs(dir, stopAt) {
|
|
161
|
+
if (dir === stopAt || !fs.existsSync(dir))
|
|
162
|
+
return;
|
|
163
|
+
const files = fs.readdirSync(dir);
|
|
164
|
+
if (files.length === 0) {
|
|
165
|
+
fs.rmdirSync(dir);
|
|
166
|
+
removeEmptyDirs(path.dirname(dir), stopAt);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Conf from 'conf';
|
|
2
|
+
const config = new Conf({
|
|
3
|
+
projectName: 'nokode-cli',
|
|
4
|
+
});
|
|
5
|
+
export const getAuthToken = () => {
|
|
6
|
+
return config.get('authToken');
|
|
7
|
+
};
|
|
8
|
+
export const setAuthToken = (token) => {
|
|
9
|
+
config.set('authToken', token);
|
|
10
|
+
};
|
|
11
|
+
export const clearAuthToken = () => {
|
|
12
|
+
config.delete('authToken');
|
|
13
|
+
};
|
|
14
|
+
export const getOrgSlug = () => {
|
|
15
|
+
return config.get('orgSlug');
|
|
16
|
+
};
|
|
17
|
+
export const setOrgSlug = (slug) => {
|
|
18
|
+
config.set('orgSlug', slug);
|
|
19
|
+
};
|
|
20
|
+
export const clearOrgSlug = () => {
|
|
21
|
+
config.delete('orgSlug');
|
|
22
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { getAuthToken, getOrgSlug, setOrgSlug } from './config.js';
|
|
4
|
+
import { getLocalOrgSlug } from './project.js';
|
|
5
|
+
const BASE_URL = 'https://api.app.kodly.dev/api/v1';
|
|
6
|
+
let membershipsCache = null;
|
|
7
|
+
const MEMBERSHIPS_CACHE_TTL_MS = 60000;
|
|
8
|
+
export function parseMemberships(responseData) {
|
|
9
|
+
if (Array.isArray(responseData)) {
|
|
10
|
+
return responseData;
|
|
11
|
+
}
|
|
12
|
+
if (responseData && typeof responseData === 'object' && Array.isArray(responseData.data)) {
|
|
13
|
+
return responseData.data;
|
|
14
|
+
}
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
export function getMembershipSlug(membership) {
|
|
18
|
+
return (membership.organisationSlug ??
|
|
19
|
+
membership.orgSlug ??
|
|
20
|
+
membership.slug ??
|
|
21
|
+
membership.organisation?.slug ??
|
|
22
|
+
membership.org?.slug);
|
|
23
|
+
}
|
|
24
|
+
export function getMembershipName(membership) {
|
|
25
|
+
return (membership.organisationName ??
|
|
26
|
+
membership.orgName ??
|
|
27
|
+
membership.name ??
|
|
28
|
+
membership.organisation?.name ??
|
|
29
|
+
membership.org?.name ??
|
|
30
|
+
getMembershipSlug(membership) ??
|
|
31
|
+
'Unknown');
|
|
32
|
+
}
|
|
33
|
+
export function isDefaultMembership(membership) {
|
|
34
|
+
return membership.isDefault ?? membership.default ?? membership.is_default ?? false;
|
|
35
|
+
}
|
|
36
|
+
export function getActiveMembershipSlug(memberships, configuredSlug) {
|
|
37
|
+
if (configuredSlug) {
|
|
38
|
+
return configuredSlug;
|
|
39
|
+
}
|
|
40
|
+
return getMembershipSlug(memberships.find(isDefaultMembership) ?? memberships[0] ?? {});
|
|
41
|
+
}
|
|
42
|
+
export function findMembership(memberships, slug) {
|
|
43
|
+
return memberships.find((membership) => getMembershipSlug(membership) === slug);
|
|
44
|
+
}
|
|
45
|
+
export function clearMembershipsCache() {
|
|
46
|
+
membershipsCache = null;
|
|
47
|
+
}
|
|
48
|
+
export async function fetchMemberships(force = false) {
|
|
49
|
+
const token = getAuthToken();
|
|
50
|
+
if (!token) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
if (!force &&
|
|
54
|
+
membershipsCache &&
|
|
55
|
+
Date.now() - membershipsCache.fetchedAt < MEMBERSHIPS_CACHE_TTL_MS) {
|
|
56
|
+
return membershipsCache.data;
|
|
57
|
+
}
|
|
58
|
+
const response = await axios.get(`${BASE_URL}/me/memberships`, {
|
|
59
|
+
headers: { 'X-AUTH-TOKEN': token },
|
|
60
|
+
});
|
|
61
|
+
const memberships = parseMemberships(response.data.data);
|
|
62
|
+
membershipsCache = { data: memberships, fetchedAt: Date.now() };
|
|
63
|
+
return memberships;
|
|
64
|
+
}
|
|
65
|
+
export async function resolveOrgSlug(cwd = process.cwd()) {
|
|
66
|
+
const localOrgSlug = getLocalOrgSlug(cwd);
|
|
67
|
+
if (localOrgSlug) {
|
|
68
|
+
return localOrgSlug;
|
|
69
|
+
}
|
|
70
|
+
const configuredSlug = getOrgSlug();
|
|
71
|
+
if (configuredSlug) {
|
|
72
|
+
return configuredSlug;
|
|
73
|
+
}
|
|
74
|
+
const memberships = await fetchMemberships();
|
|
75
|
+
const slug = getActiveMembershipSlug(memberships);
|
|
76
|
+
if (slug) {
|
|
77
|
+
setOrgSlug(slug);
|
|
78
|
+
}
|
|
79
|
+
return slug;
|
|
80
|
+
}
|
|
81
|
+
function buildActiveOrg(slug, memberships, source) {
|
|
82
|
+
const membership = findMembership(memberships, slug);
|
|
83
|
+
return {
|
|
84
|
+
slug,
|
|
85
|
+
name: membership ? getMembershipName(membership) : slug,
|
|
86
|
+
isExplicit: source === 'config',
|
|
87
|
+
source,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export async function resolveActiveOrg(cwd = process.cwd()) {
|
|
91
|
+
const localOrgSlug = getLocalOrgSlug(cwd);
|
|
92
|
+
if (localOrgSlug) {
|
|
93
|
+
const memberships = await fetchMemberships();
|
|
94
|
+
return buildActiveOrg(localOrgSlug, memberships, 'project');
|
|
95
|
+
}
|
|
96
|
+
const configuredSlug = getOrgSlug();
|
|
97
|
+
const memberships = await fetchMemberships();
|
|
98
|
+
const slug = getActiveMembershipSlug(memberships, configuredSlug);
|
|
99
|
+
if (!slug) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return buildActiveOrg(slug, memberships, configuredSlug ? 'config' : 'default');
|
|
103
|
+
}
|
|
104
|
+
export async function ensureDefaultOrg(cwd = process.cwd()) {
|
|
105
|
+
const org = await resolveActiveOrg(cwd);
|
|
106
|
+
if (!org) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
if (!getLocalOrgSlug(cwd) && !getOrgSlug()) {
|
|
110
|
+
setOrgSlug(org.slug);
|
|
111
|
+
return { ...org, isExplicit: false, source: 'default' };
|
|
112
|
+
}
|
|
113
|
+
return org;
|
|
114
|
+
}
|
|
115
|
+
export async function resetToDefaultOrg() {
|
|
116
|
+
clearMembershipsCache();
|
|
117
|
+
const memberships = await fetchMemberships(true);
|
|
118
|
+
const slug = getActiveMembershipSlug(memberships);
|
|
119
|
+
if (!slug) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
setOrgSlug(slug);
|
|
123
|
+
return buildActiveOrg(slug, memberships, 'default');
|
|
124
|
+
}
|
|
125
|
+
export function formatActiveOrg(org) {
|
|
126
|
+
const suffix = org.source === 'project' ? ' (project)' : org.source === 'default' ? ' (default)' : '';
|
|
127
|
+
return `${org.name} (${org.slug})${suffix}`;
|
|
128
|
+
}
|
|
129
|
+
export function printActiveOrg(org) {
|
|
130
|
+
console.log(chalk.dim(`Organization: ${formatActiveOrg(org)}`));
|
|
131
|
+
}
|
|
132
|
+
export function shouldSkipOrgHeader(url) {
|
|
133
|
+
if (!url) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return (url.includes('/auth/') ||
|
|
137
|
+
url.includes('/me/memberships'));
|
|
138
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export function getLocalOrgSlug(cwd = process.cwd()) {
|
|
4
|
+
const projectData = getProjectData(cwd);
|
|
5
|
+
return projectData?.orgSlug;
|
|
6
|
+
}
|
|
7
|
+
export function getProjectData(cwd) {
|
|
8
|
+
const infoPath = path.join(cwd, '.kodly', 'project.info.json');
|
|
9
|
+
if (fs.existsSync(infoPath)) {
|
|
10
|
+
try {
|
|
11
|
+
const data = JSON.parse(fs.readFileSync(infoPath, 'utf8'));
|
|
12
|
+
if (data.projectSlug) {
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
// Ignore parse error
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { getAuthToken } from './config.js';
|
|
3
|
+
import { ensureDefaultOrg, printActiveOrg } from './org.js';
|
|
4
|
+
export async function requireAuth() {
|
|
5
|
+
if (!getAuthToken()) {
|
|
6
|
+
console.log(chalk.red('You must be logged in. Run "kodly login" first.'));
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
export async function requireAuthAndOrg() {
|
|
12
|
+
if (!(await requireAuth())) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const org = await ensureDefaultOrg();
|
|
16
|
+
if (!org) {
|
|
17
|
+
console.log(chalk.red('No organization found. Run "kodly org list" to see available organizations.'));
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return org;
|
|
21
|
+
}
|
|
22
|
+
export async function showActiveOrg() {
|
|
23
|
+
const org = await ensureDefaultOrg();
|
|
24
|
+
if (org) {
|
|
25
|
+
printActiveOrg(org);
|
|
26
|
+
}
|
|
27
|
+
return org;
|
|
28
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export function getTaskData(cwd) {
|
|
4
|
+
const kodlyDir = path.join(cwd, '.kodly');
|
|
5
|
+
if (!fs.existsSync(kodlyDir)) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const files = fs.readdirSync(kodlyDir);
|
|
9
|
+
const taskFile = files.find(f => f.startsWith('task.spec') && f.endsWith('.json'));
|
|
10
|
+
if (!taskFile) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const parsedData = JSON.parse(fs.readFileSync(path.join(kodlyDir, taskFile), 'utf8'));
|
|
15
|
+
const slug = parsedData.taskId || '';
|
|
16
|
+
const title = parsedData.title || '';
|
|
17
|
+
if (slug) {
|
|
18
|
+
return { slug, title };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
// Ignore parse error
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
package/llm.txt
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Kodly CLI
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
Kodly CLI is the official command-line interface and agent for the Kodly Platform. It allows developers and AI agents to seamlessly interact with Kodly projects, tasks, and documentation directly from the terminal.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
To install the Kodly CLI globally, run the following command:
|
|
8
|
+
\`\`\`bash
|
|
9
|
+
npm install -g @kodly.dev/kodly-cli
|
|
10
|
+
\`\`\`
|
|
11
|
+
|
|
12
|
+
## Core Concepts & Workflow
|
|
13
|
+
The typical developer/agent workflow involves:
|
|
14
|
+
1. **Authentication**: Authenticate with the Kodly platform.
|
|
15
|
+
2. **Checkout**: Download a specific task, project, or documentation to the local environment. This creates a `.kodly/` directory containing context data (such as `task-spec.json` and `project.info.json`) and file checksums tracking state.
|
|
16
|
+
3. **Development**: Modify the necessary codebase files locally. Never manually modify internal files inside the `.kodly/` directory.
|
|
17
|
+
4. **Status & Sync**: Check which files have been altered using `status` and push the changes back to Kodly using `push`. The CLI automatically diffs and pushes only modified files based on checksums.
|
|
18
|
+
|
|
19
|
+
## Command Reference
|
|
20
|
+
|
|
21
|
+
### Authentication
|
|
22
|
+
- `kodly login` : Login to Kodly (Interactive).
|
|
23
|
+
- `kodly whoami` : Check current logged-in user.
|
|
24
|
+
- `kodly logout` : Logout from Kodly.
|
|
25
|
+
|
|
26
|
+
### Organization Management
|
|
27
|
+
- `kodly org list` : List all organizations you belong to.
|
|
28
|
+
- `kodly org current` : Show the currently active organization.
|
|
29
|
+
- `kodly org switch <org-slug>` : Switch to a different organization.
|
|
30
|
+
- `kodly org unset` : Clear the org override and use your default organization.
|
|
31
|
+
|
|
32
|
+
### Task Management
|
|
33
|
+
- `kodly task list` : List all tasks assigned to the current user.
|
|
34
|
+
- `kodly task checkout <slug> [path]` : Checkout a task to the local environment.
|
|
35
|
+
- `kodly task create <projectSlug> <title...>` : Create a new task for a project.
|
|
36
|
+
|
|
37
|
+
### Project Management
|
|
38
|
+
- `kodly project list` : List all projects you have access to.
|
|
39
|
+
- `kodly project checkout [slug] [path]` : Checkout a full project codebase to the local environment.
|
|
40
|
+
|
|
41
|
+
### Knowledge Management (Docs)
|
|
42
|
+
- `kodly docs checkout <project-slug> [path]` : Checkout project documentation to the local environment.
|
|
43
|
+
- `kodly docs status` : Show the working tree status of documentation.
|
|
44
|
+
- `kodly docs push` : Push local documentation changes to the Kodly platform.
|
|
45
|
+
|
|
46
|
+
### Syncing Code
|
|
47
|
+
- `kodly status` : Show the working tree status (identifies which local files differ from the remote task/project state).
|
|
48
|
+
- `kodly push` : Push local source code changes to Kodly.
|
|
49
|
+
|
|
50
|
+
### Scaffolding (Spring Boot Recipes)
|
|
51
|
+
Recipes repo: https://github.com/kodly-dev/kodly-scaffold-recipies-java (override with `KODLY_RECIPES_REPO_URL`). See `packages/scaffolder/RECIPES.md` for authoring recipes.
|
|
52
|
+
|
|
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
|
+
- `kodly scaffold init --group <group> --name <name>` : Generate a new Spring Boot skeleton with your package and project name. No login required.
|
|
55
|
+
- `kodly scaffold <recipe>@<version>` : Apply a deterministic recipe to a local Spring Boot skeleton project. No login required.
|
|
56
|
+
- `kodly scaffold list` : List locally cached recipes.
|
|
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).
|
|
59
|
+
|
|
60
|
+
Options for create/apply: `--path <dir>`, `--group <group>`, `--prefix <prefix>`, `--skeleton-version <ver>` (create/init), `--dry-run`, `-r/--recipe <ref>` (create, repeatable).
|
|
61
|
+
|
|
62
|
+
### Utilities
|
|
63
|
+
- `kodly man` : Show the comprehensive user manual.
|
|
64
|
+
- `kodly completion [shell]` : Generate shell autocompletion scripts (zsh, bash, fish).
|
|
65
|
+
|
|
66
|
+
## Important Notes for AI Agents
|
|
67
|
+
- **State Machine**: The CLI relies on the `.kodly/` folder to maintain sync state and store entity details (e.g. `task.spec.json` or `project.info.json`).
|
|
68
|
+
- **Do Not Modify `.kodly/`**: Checksums for change detection are stored here. Manually editing files in this directory will corrupt the CLI's synchronization state.
|
|
69
|
+
- **Push Behavior**: Executing push operations only uploads files that are actually modified compared to the remote state.
|
|
70
|
+
- **Ignored Files**: The CLI respects standard ignore conventions (like `.gitignore`) during file comparisons for both `status` and `push`.
|
|
71
|
+
|
|
72
|
+
## Typical AI Agent Workflows
|
|
73
|
+
|
|
74
|
+
### 1. Working on an Existing Task
|
|
75
|
+
1. **Find the task**: Run `kodly task list` to locate the task assigned to you and note its `<task-slug>`.
|
|
76
|
+
2. **Checkout**:
|
|
77
|
+
- *If outside a project*: Run `kodly task checkout <task-slug>` and navigate into it (`cd <task-slug>`).
|
|
78
|
+
- *If already inside a project directory (contains `.kodly/`)*: Run `kodly task checkout <task-slug> .` to sync the task directly into the current directory.
|
|
79
|
+
3. **Develop**: Implement the requested changes in the codebase.
|
|
80
|
+
4. **Verify**: Run `kodly status` to ensure modified files are correctly detected.
|
|
81
|
+
5. **Push**: Run `kodly push` to sync your local changes up to the Kodly platform.
|
|
82
|
+
|
|
83
|
+
### 2. Working on a New Task
|
|
84
|
+
1. **Find the project**: Run `kodly project list` to identify the `<project-slug>` you want to create the task under.
|
|
85
|
+
2. **Create the task**: Run `kodly task create <project-slug> "<Task Title>"`. The CLI will output the newly created task's slug.
|
|
86
|
+
3. **Checkout**:
|
|
87
|
+
- *If outside a project*: Run `kodly task checkout <new-task-slug>` and navigate into it (`cd <new-task-slug>`).
|
|
88
|
+
- *If already inside a project directory (contains `.kodly/`)*: Run `kodly task checkout <new-task-slug> .` to sync the task directly into the current workspace.
|
|
89
|
+
4. **Develop**: Implement the new features or files.
|
|
90
|
+
5. **Push**: Run `kodly push` to submit your new work.
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kodly.dev/kodly-cli",
|
|
3
|
+
"version": "1.0.16",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"kodly": "./dist/bin/kodly.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"predev": "npm run build",
|
|
11
|
+
"dev": "node dist/bin/kodly.js",
|
|
12
|
+
"prestart": "npm run build",
|
|
13
|
+
"start": "node dist/bin/kodly.js",
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"kodly",
|
|
18
|
+
"cli",
|
|
19
|
+
"agent"
|
|
20
|
+
],
|
|
21
|
+
"author": "Kodly",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"description": "CLI Agent for Kodly Platform",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"llm.txt"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@kodly.dev/scaffolder": "1.0.0",
|
|
33
|
+
"@types/inquirer": "^9.0.9",
|
|
34
|
+
"@types/node": "^25.0.5",
|
|
35
|
+
"axios": "^1.13.2",
|
|
36
|
+
"chalk": "^5.6.2",
|
|
37
|
+
"commander": "^14.0.2",
|
|
38
|
+
"conf": "^15.0.2",
|
|
39
|
+
"ignore": "^7.0.5",
|
|
40
|
+
"inquirer": "^13.1.0",
|
|
41
|
+
"ora": "^9.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"typescript": "^5.9.3"
|
|
45
|
+
}
|
|
46
|
+
}
|