@agentlang/cli 0.7.9 → 0.8.1
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/out/uigen/cli.js +88 -0
- package/out/uigen/cli.js.map +1 -0
- package/out/uigen/index.js +175 -0
- package/out/uigen/index.js.map +1 -0
- package/out/uigen/utils.js +44 -0
- package/out/uigen/utils.js.map +1 -0
- package/package.json +2 -2
package/out/uigen/cli.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
// CLI setup
|
|
5
|
+
const program = new Command();
|
|
6
|
+
program
|
|
7
|
+
.name('agentlang-build-ui')
|
|
8
|
+
.description('CLI tool to build deployable React apps from AgentLang schemas')
|
|
9
|
+
.version('1.0.0');
|
|
10
|
+
program.on('--help', () => {
|
|
11
|
+
console.log(chalk.blue.bold('🚀 Agentlang UI Builder'));
|
|
12
|
+
});
|
|
13
|
+
program
|
|
14
|
+
.command('build')
|
|
15
|
+
.description('Build a complete React application from AgentLang schema')
|
|
16
|
+
.requiredOption('-r, --repo <repo>', 'GitHub repository (format: owner/repo)')
|
|
17
|
+
.option('-b, --branch <branch>', 'Git branch to use', 'main')
|
|
18
|
+
.requiredOption('-o, --output <path>', 'Output directory for built files')
|
|
19
|
+
.requiredOption('--org <org>', 'GitHub organization')
|
|
20
|
+
.requiredOption('--username <username>', 'GitHub username')
|
|
21
|
+
.requiredOption('--token <token>', 'GitHub personal access token')
|
|
22
|
+
.requiredOption('--api-url <url>', 'API URL for the deployed application');
|
|
23
|
+
// .action(async options => {
|
|
24
|
+
// const builder = new AgentLangBuilder();
|
|
25
|
+
// // await builder.build(options);
|
|
26
|
+
// });
|
|
27
|
+
program
|
|
28
|
+
.command('generate-schema')
|
|
29
|
+
.description('Generate only the AgentLang schema (without building the app)')
|
|
30
|
+
.requiredOption('-r, --repo <repo>', 'GitHub repository (format: owner/repo)')
|
|
31
|
+
.option('-b, --branch <branch>', 'Git branch to use', 'main')
|
|
32
|
+
.requiredOption('--org <org>', 'GitHub organization')
|
|
33
|
+
.requiredOption('--username <username>', 'GitHub username')
|
|
34
|
+
.requiredOption('--token <token>', 'GitHub personal access token')
|
|
35
|
+
.action(async (options) => {
|
|
36
|
+
// Set environment variables
|
|
37
|
+
const envVars = {
|
|
38
|
+
GITHUB_REPO: options.repo,
|
|
39
|
+
GITHUB_BRANCH: options.branch || 'main',
|
|
40
|
+
GITHUB_ORG: options.org || options.repo.split('/')[0],
|
|
41
|
+
GITHUB_USERNAME: options.username || options.repo.split('/')[0],
|
|
42
|
+
GITHUB_TOKEN: options.token || process.env.GITHUB_TOKEN,
|
|
43
|
+
};
|
|
44
|
+
Object.entries(envVars).forEach(([key, value]) => {
|
|
45
|
+
if (value) {
|
|
46
|
+
process.env[key] = value;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (!process.env.GITHUB_TOKEN) {
|
|
50
|
+
console.error(chalk.red('GitHub token is required. Set GITHUB_TOKEN environment variable or use --token option.'));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
// generateSchema is private, so we cannot call it here.
|
|
54
|
+
// Instead, print an error message.
|
|
55
|
+
console.error(chalk.red('Error: generate-schema command is not available. This functionality is not exposed by AgentLangBuilder.'));
|
|
56
|
+
process.exit(1);
|
|
57
|
+
});
|
|
58
|
+
program
|
|
59
|
+
.command('build-app')
|
|
60
|
+
.description('Build only the React application (requires ui-schema.ts to exist)')
|
|
61
|
+
.action(async () => {
|
|
62
|
+
// buildReactApp is private, so we cannot call it here.
|
|
63
|
+
// Instead, print an error message.
|
|
64
|
+
console.error(chalk.red('Error: build-app command is not available. This functionality is not exposed by AgentLangBuilder.'));
|
|
65
|
+
process.exit(1);
|
|
66
|
+
});
|
|
67
|
+
// Handle errors
|
|
68
|
+
program.exitOverride();
|
|
69
|
+
try {
|
|
70
|
+
program.parse();
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
// Handle help and version commands gracefully
|
|
74
|
+
if (err && typeof err === 'object' && 'code' in err) {
|
|
75
|
+
const code = err.code;
|
|
76
|
+
if (code === 'commander.help' ||
|
|
77
|
+
code === 'commander.version' ||
|
|
78
|
+
code === '(outputHelp)' ||
|
|
79
|
+
code === 'commander.helpDisplayed') {
|
|
80
|
+
process.exit(0);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Handle other errors
|
|
84
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
85
|
+
console.error(chalk.red('Error:'), errorMessage);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/uigen/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,YAAY;AACZ,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,oBAAoB,CAAC;KAC1B,WAAW,CAAC,gEAAgE,CAAC;KAC7E,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC,CAAC;AAEH,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,0DAA0D,CAAC;KACvE,cAAc,CAAC,mBAAmB,EAAE,wCAAwC,CAAC;KAC7E,MAAM,CAAC,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,CAAC;KAC5D,cAAc,CAAC,qBAAqB,EAAE,kCAAkC,CAAC;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,YAAY,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// Export utility functions
|
|
2
|
+
export const version = '1.0.0';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { execSync } from 'child_process';
|
|
8
|
+
import { simpleGit } from 'simple-git';
|
|
9
|
+
import { flushAllAndLoad } from 'agentlang/src/runtime/loader';
|
|
10
|
+
import { fetchModule, getUserModuleNames } from 'agentlang/src/runtime/module';
|
|
11
|
+
import { buildGraph } from 'agentlang/src/runtime/relgraph';
|
|
12
|
+
import { loadUISchema } from '@agentlang/utils';
|
|
13
|
+
import os from 'os';
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = path.dirname(__filename);
|
|
16
|
+
export class AgentLangBuilder {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.spinner = ora();
|
|
19
|
+
}
|
|
20
|
+
validateOptions(options) {
|
|
21
|
+
if (!options.repo) {
|
|
22
|
+
throw new Error('Repository is required. Use --repo <owner/repo>');
|
|
23
|
+
}
|
|
24
|
+
if (!options.output) {
|
|
25
|
+
throw new Error('Output directory is required. Use --output <path>');
|
|
26
|
+
}
|
|
27
|
+
if (!options.org) {
|
|
28
|
+
throw new Error('GitHub organization is required. Use --org <org>');
|
|
29
|
+
}
|
|
30
|
+
if (!options.username) {
|
|
31
|
+
throw new Error('GitHub username is required. Use --username <username>');
|
|
32
|
+
}
|
|
33
|
+
if (!options.token) {
|
|
34
|
+
throw new Error('GitHub token is required. Use --token <token>');
|
|
35
|
+
}
|
|
36
|
+
if (!options.apiUrl) {
|
|
37
|
+
throw new Error('API URL is required. Use --api-url <url>');
|
|
38
|
+
}
|
|
39
|
+
// Check if output directory exists and is empty
|
|
40
|
+
if (fs.existsSync(options.output)) {
|
|
41
|
+
const contents = fs.readdirSync(options.output);
|
|
42
|
+
if (contents.length > 0) {
|
|
43
|
+
throw new Error(`Output directory ${options.output} is not empty. Please use an empty directory.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Create output directory if it doesn't exist
|
|
47
|
+
fs.ensureDirSync(options.output);
|
|
48
|
+
}
|
|
49
|
+
async generateSchema(options) {
|
|
50
|
+
this.spinner.start('Generating AgentLang schema...');
|
|
51
|
+
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'agentlang-build-'));
|
|
52
|
+
try {
|
|
53
|
+
this.spinner.start('Cloning repository...');
|
|
54
|
+
const git = simpleGit();
|
|
55
|
+
let repoPath = options.repo;
|
|
56
|
+
if (!repoPath.includes('/')) {
|
|
57
|
+
if (!options.org) {
|
|
58
|
+
throw new Error('When repo name is not in `owner/repo` format, --org is required.');
|
|
59
|
+
}
|
|
60
|
+
repoPath = `${options.org}/${options.repo}`;
|
|
61
|
+
}
|
|
62
|
+
const repoUrl = `https://${options.username}:${options.token}@github.com/${repoPath}.git`;
|
|
63
|
+
await git.clone(repoUrl, tempDir, [`--branch=${options.branch || 'main'}`, '--depth=1', '--single-branch']);
|
|
64
|
+
this.spinner.succeed('Repository cloned successfully');
|
|
65
|
+
const packageJsonPath = path.join(tempDir, 'package.json');
|
|
66
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
67
|
+
this.spinner.start('Installing repository dependencies...');
|
|
68
|
+
try {
|
|
69
|
+
execSync('npm install', {
|
|
70
|
+
cwd: tempDir,
|
|
71
|
+
stdio: 'pipe',
|
|
72
|
+
});
|
|
73
|
+
this.spinner.succeed('Dependencies installed successfully');
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
this.spinner.fail('Failed to install dependencies');
|
|
77
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
78
|
+
throw new Error(`Failed to install repository dependencies: ${errorMessage}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
this.spinner.start('Initializing AgentLang and loading project...');
|
|
82
|
+
await flushAllAndLoad(tempDir);
|
|
83
|
+
this.spinner.succeed('Project loaded successfully');
|
|
84
|
+
this.spinner.start('Generating UI schema...');
|
|
85
|
+
const modules = getUserModuleNames();
|
|
86
|
+
const entities = modules.flatMap((module) => fetchModule(module)
|
|
87
|
+
.getEntityNames()
|
|
88
|
+
.map((entity) => `${module}/${entity}`));
|
|
89
|
+
const rootEntities = modules.flatMap((module) => {
|
|
90
|
+
const graph = buildGraph(module);
|
|
91
|
+
return graph
|
|
92
|
+
.getRoots()
|
|
93
|
+
.map((root) => `${root.entity.getModuleName()}/${root.entity.getEntryName()}`);
|
|
94
|
+
});
|
|
95
|
+
const publicAgents = modules.flatMap(moduleName => {
|
|
96
|
+
const module = fetchModule(moduleName);
|
|
97
|
+
if (!module) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
return module
|
|
101
|
+
.getAgentNames()
|
|
102
|
+
.filter(agentName => {
|
|
103
|
+
var _a;
|
|
104
|
+
const agent = module.getAgent(agentName);
|
|
105
|
+
return (_a = agent === null || agent === void 0 ? void 0 : agent.isPublic()) !== null && _a !== void 0 ? _a : false;
|
|
106
|
+
})
|
|
107
|
+
.map(agentName => `${moduleName}/${agentName}`);
|
|
108
|
+
});
|
|
109
|
+
const appName = options.repo;
|
|
110
|
+
const packageJson = await fs.readFile(path.join(tempDir, 'package.json'), 'utf8');
|
|
111
|
+
const packageJsonObject = JSON.parse(packageJson);
|
|
112
|
+
const team = {
|
|
113
|
+
Name: options.repo,
|
|
114
|
+
Description: packageJsonObject.description || 'An application generated from ' + options.repo,
|
|
115
|
+
};
|
|
116
|
+
const schema = await loadUISchema(appName, tempDir, entities, rootEntities, publicAgents, team);
|
|
117
|
+
schema.appInfo.apiUrl = options.apiUrl;
|
|
118
|
+
const uiSchemaPath = path.join(__dirname, '../ui-schema.ts');
|
|
119
|
+
const schemaContent = `export default ${JSON.stringify(schema, null, 4)};`;
|
|
120
|
+
await fs.writeFile(uiSchemaPath, schemaContent);
|
|
121
|
+
this.spinner.succeed('Schema generated successfully');
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
this.spinner.fail('Schema generation failed');
|
|
125
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
126
|
+
throw new Error(`Failed to generate schema: ${errorMessage}`);
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
await fs.remove(tempDir);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
buildReactApp() {
|
|
133
|
+
this.spinner.start('Building React application...');
|
|
134
|
+
try {
|
|
135
|
+
// Check if ui-schema.ts was generated
|
|
136
|
+
const uiSchemaPath = path.join(__dirname, '../ui-schema.ts');
|
|
137
|
+
if (!fs.existsSync(uiSchemaPath)) {
|
|
138
|
+
throw new Error('UI schema file not found. Schema generation may have failed.');
|
|
139
|
+
}
|
|
140
|
+
// Run Vite build
|
|
141
|
+
execSync('npm run build-app', {
|
|
142
|
+
cwd: path.dirname(__dirname),
|
|
143
|
+
stdio: 'pipe',
|
|
144
|
+
});
|
|
145
|
+
this.spinner.succeed('React app built successfully');
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
this.spinner.fail('React app build failed');
|
|
149
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
150
|
+
throw new Error(`Failed to build React app: ${errorMessage}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async copyBuildFiles(options) {
|
|
154
|
+
this.spinner.start('Copying build files to output directory...');
|
|
155
|
+
try {
|
|
156
|
+
const distPath = path.join(__dirname, '../dist');
|
|
157
|
+
if (!fs.existsSync(distPath)) {
|
|
158
|
+
throw new Error('Build directory not found. React app build may have failed.');
|
|
159
|
+
}
|
|
160
|
+
// Copy all files from dist to output
|
|
161
|
+
await fs.copy(distPath, options.output);
|
|
162
|
+
this.spinner.succeed('Build files copied successfully');
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
this.spinner.fail('Failed to copy build files');
|
|
166
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
167
|
+
throw new Error(`Failed to copy build files: ${errorMessage}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
export default {
|
|
172
|
+
version,
|
|
173
|
+
AgentLangBuilder,
|
|
174
|
+
};
|
|
175
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/uigen/index.ts"],"names":[],"mappings":"AAYA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,OAAO,GAAY,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MA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|
+
import http from 'isomorphic-git/http/web';
|
|
2
|
+
import { createFS } from '@agentlang/fs-git-interop/fs';
|
|
3
|
+
import { createGit } from '@agentlang/fs-git-interop/git';
|
|
4
|
+
import { Buffer } from 'buffer';
|
|
5
|
+
// Ensure Buffer is available globally
|
|
6
|
+
if (typeof window !== 'undefined') {
|
|
7
|
+
window.Buffer = Buffer;
|
|
8
|
+
}
|
|
9
|
+
export const createGitUtils = async (options = {}) => {
|
|
10
|
+
const fsName = options.fsName || 'studio';
|
|
11
|
+
const fs = await createFS({ name: fsName });
|
|
12
|
+
const git = createGit(fs);
|
|
13
|
+
return { fs, git };
|
|
14
|
+
};
|
|
15
|
+
export const cloneRepository = async (url, dir, branch = 'main') => {
|
|
16
|
+
const { git } = await createGitUtils();
|
|
17
|
+
await git.clone(url, dir, {
|
|
18
|
+
http,
|
|
19
|
+
branch: branch,
|
|
20
|
+
singleBranch: true,
|
|
21
|
+
depth: 1,
|
|
22
|
+
corsProxy: 'https://cors-proxy-1.fractl.io',
|
|
23
|
+
});
|
|
24
|
+
return dir;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Read a file from a Git repository
|
|
28
|
+
* @param repoPath - Path to the repository
|
|
29
|
+
* @param filePath - Path to the file within the repository
|
|
30
|
+
* @returns Promise resolving to the file content as string
|
|
31
|
+
*/
|
|
32
|
+
export const readRepoFile = async (repoPath, filePath) => {
|
|
33
|
+
const { fs } = await createGitUtils();
|
|
34
|
+
const fullPath = `${repoPath}/${filePath}`;
|
|
35
|
+
const content = await fs.readFile(fullPath);
|
|
36
|
+
return content.toString();
|
|
37
|
+
};
|
|
38
|
+
export function generateGitHubUrl(org, repo, githubUsername, githubToken) {
|
|
39
|
+
if (githubUsername && githubToken) {
|
|
40
|
+
return `https://${githubUsername}:${githubToken}@github.com/${org}/${repo}.git`;
|
|
41
|
+
}
|
|
42
|
+
return `https://github.com/${org}/${repo}.git`;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=utils.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QAAgB,EAAmB,EAAE;IACxF,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,cAAc,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5C,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,GAAW,EAAE,IAAY,EAAE,cAAuB,EAAE,WAAoB;IACxG,IAAI,cAAc,IAAI,WAAW,EAAE,CAAC;QAClC,OAAO,WAAW,cAAc,IAAI,WAAW,eAAe,GAAG,IAAI,IAAI,MAAM,CAAC;IAClF,CAAC;IACD,OAAO,sBAAsB,GAAG,IAAI,IAAI,MAAM,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentlang/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "A command-line interface tool for Agentlang",
|
|
5
5
|
"main": "out/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@anthropic-ai/sdk": "^0.65.0",
|
|
56
56
|
"@asteasolutions/zod-to-openapi": "7.3.4",
|
|
57
57
|
"@redocly/cli": "^2.0.2",
|
|
58
|
-
"agentlang": "^0.7.
|
|
58
|
+
"agentlang": "^0.7.6",
|
|
59
59
|
"better-sqlite3": "^12.4.1",
|
|
60
60
|
"chalk": "^5.4.1",
|
|
61
61
|
"chokidar": "^4.0.3",
|