@agentuity/cli 0.0.29 → 0.0.31
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../src/cmd/bundle/bundler.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;CACd;AAED,wBAAsB,MAAM,CAAC,EAAE,GAAW,EAAE,OAAO,EAAE,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../src/cmd/bundle/bundler.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;CACd;AAED,wBAAsB,MAAM,CAAC,EAAE,GAAW,EAAE,OAAO,EAAE,EAAE,aAAa,iBA8HnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/cmd/bundle/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAwGrC,QAAA,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/cmd/bundle/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAwGrC,QAAA,MAAM,gBAAgB,EAAE,SAgJvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmd/dev/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmd/dev/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,OAAO,mCAiXlB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentuity/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"prepublishOnly": "bun run clean && bun run build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@agentuity/core": "0.0.
|
|
31
|
+
"@agentuity/core": "0.0.29",
|
|
32
32
|
"acorn-loose": "^8.5.2",
|
|
33
33
|
"astring": "^1.9.0",
|
|
34
34
|
"commander": "^14.0.2",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { existsSync, rmSync } from 'node:fs';
|
|
1
|
+
import { join, resolve } from 'node:path';
|
|
2
|
+
import { cpSync, existsSync, rmSync } from 'node:fs';
|
|
3
3
|
import AgentuityBundler from './plugin';
|
|
4
4
|
import { getFilesRecursively } from './file';
|
|
5
5
|
import { getVersion } from '../../version';
|
|
@@ -17,9 +17,9 @@ export async function bundle({ dev = false, rootDir }: BundleOptions) {
|
|
|
17
17
|
const outDir = join(rootDir, '.agentuity');
|
|
18
18
|
const srcDir = join(rootDir, 'src');
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const appEntrypoints: string[] = [];
|
|
21
21
|
|
|
22
|
-
for (const folder of ['apis', 'agents'
|
|
22
|
+
for (const folder of ['apis', 'agents']) {
|
|
23
23
|
const dir = join(srcDir, folder);
|
|
24
24
|
if (!existsSync(dir)) {
|
|
25
25
|
if (folder === 'agents') {
|
|
@@ -29,13 +29,14 @@ export async function bundle({ dev = false, rootDir }: BundleOptions) {
|
|
|
29
29
|
}
|
|
30
30
|
const files = await getFilesRecursively(dir);
|
|
31
31
|
for (const filename of files) {
|
|
32
|
-
if (/\.[jt]
|
|
33
|
-
|
|
32
|
+
if (/\.[jt]s?$/.test(filename)) {
|
|
33
|
+
appEntrypoints.push(filename);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
appEntrypoints.push(appFile);
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
const webDir = join(srcDir, 'web');
|
|
39
40
|
|
|
40
41
|
if (existsSync(outDir)) {
|
|
41
42
|
rmSync(outDir, { recursive: true, force: true });
|
|
@@ -43,7 +44,6 @@ export async function bundle({ dev = false, rootDir }: BundleOptions) {
|
|
|
43
44
|
|
|
44
45
|
const pkgFile = Bun.file('./package.json');
|
|
45
46
|
const pkgContents = JSON.parse(await pkgFile.text());
|
|
46
|
-
|
|
47
47
|
const isProd = !dev;
|
|
48
48
|
|
|
49
49
|
const define = {
|
|
@@ -51,38 +51,88 @@ export async function bundle({ dev = false, rootDir }: BundleOptions) {
|
|
|
51
51
|
'process.env.NODE_ENV': JSON.stringify(isProd ? 'production' : 'development'),
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
?
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
await (async () => {
|
|
55
|
+
const config: Bun.BuildConfig = {
|
|
56
|
+
entrypoints: appEntrypoints,
|
|
57
|
+
root: rootDir,
|
|
58
|
+
outdir: outDir,
|
|
59
|
+
define,
|
|
60
|
+
sourcemap: dev ? 'inline' : 'external',
|
|
61
|
+
env: 'AGENTUITY_CLOUD_*',
|
|
62
|
+
plugins: [AgentuityBundler],
|
|
63
|
+
target: 'bun',
|
|
64
|
+
format: 'esm',
|
|
65
|
+
banner: `// Generated file. DO NOT EDIT`,
|
|
66
|
+
minify: isProd,
|
|
67
|
+
drop: isProd ? ['debugger'] : undefined,
|
|
68
|
+
conditions: [isProd ? 'production' : 'development', 'bun'],
|
|
69
|
+
};
|
|
70
|
+
try {
|
|
71
|
+
await Bun.build(config);
|
|
72
|
+
} catch (ex) {
|
|
73
|
+
console.error(ex);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
})();
|
|
77
|
+
|
|
78
|
+
await (async () => {
|
|
79
|
+
// Find workspace root for monorepo support
|
|
80
|
+
let workspaceRoot = rootDir;
|
|
81
|
+
let currentDir = rootDir;
|
|
82
|
+
while (currentDir !== '/') {
|
|
83
|
+
const pkgPath = join(currentDir, 'package.json');
|
|
84
|
+
if (existsSync(pkgPath)) {
|
|
85
|
+
const pkg = JSON.parse(await Bun.file(pkgPath).text());
|
|
86
|
+
if (pkg.workspaces) {
|
|
87
|
+
workspaceRoot = currentDir;
|
|
88
|
+
break;
|
|
72
89
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
90
|
+
}
|
|
91
|
+
currentDir = resolve(currentDir, '..');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Make webEntrypoints - just the HTML files themselves
|
|
95
|
+
const webEntrypoints = [...new Bun.Glob('**.html').scanSync(webDir)].map((htmlFile) =>
|
|
96
|
+
resolve(webDir, htmlFile)
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const config: Bun.BuildConfig = {
|
|
100
|
+
entrypoints: webEntrypoints,
|
|
101
|
+
root: webDir,
|
|
102
|
+
outdir: join(outDir, 'web'),
|
|
103
|
+
define,
|
|
104
|
+
sourcemap: dev ? 'inline' : 'linked',
|
|
105
|
+
env: 'AGENTUITY_CLOUD_*',
|
|
106
|
+
plugins: [AgentuityBundler],
|
|
107
|
+
target: 'browser',
|
|
108
|
+
format: 'cjs',
|
|
109
|
+
banner: `// Generated file. DO NOT EDIT`,
|
|
110
|
+
minify: isProd,
|
|
111
|
+
drop: isProd ? ['debugger'] : undefined,
|
|
112
|
+
naming: {
|
|
113
|
+
entry: '[name].js',
|
|
114
|
+
chunk: 'chunk/[name]-[hash].js',
|
|
115
|
+
asset: 'asset/[name]-[hash].[ext]',
|
|
116
|
+
},
|
|
117
|
+
packages: 'bundle',
|
|
118
|
+
external: workspaceRoot !== rootDir ? [] : undefined,
|
|
119
|
+
};
|
|
120
|
+
try {
|
|
121
|
+
await Bun.build(config);
|
|
122
|
+
} catch (ex) {
|
|
123
|
+
console.error(ex);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
})();
|
|
127
|
+
|
|
128
|
+
const webPublicDir = join(webDir, 'public');
|
|
129
|
+
if (existsSync(webPublicDir)) {
|
|
130
|
+
const webOutPublicDir = join(outDir, 'web', 'public');
|
|
131
|
+
cpSync(webPublicDir, webOutPublicDir, { recursive: true });
|
|
132
|
+
}
|
|
76
133
|
|
|
77
134
|
await Bun.write(
|
|
78
135
|
`${outDir}/package.json`,
|
|
79
136
|
JSON.stringify({ name: pkgContents.name, version: pkgContents.version }, null, 2)
|
|
80
137
|
);
|
|
81
|
-
|
|
82
|
-
const agentuityYAML = Bun.file('./agentuity.yaml');
|
|
83
|
-
if (await agentuityYAML.exists()) {
|
|
84
|
-
await Bun.write(`${outDir}/agentuity.yaml`, agentuityYAML);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
await Bun.build(config);
|
|
88
138
|
}
|
package/src/cmd/bundle/plugin.ts
CHANGED
|
@@ -146,6 +146,9 @@ const AgentuityBundler: BunPlugin = {
|
|
|
146
146
|
namespace: 'file',
|
|
147
147
|
},
|
|
148
148
|
async (args) => {
|
|
149
|
+
if (build.config.target !== 'bun') {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
149
152
|
await args.defer();
|
|
150
153
|
|
|
151
154
|
const inserts: string[] = [];
|
|
@@ -199,30 +202,19 @@ const AgentuityBundler: BunPlugin = {
|
|
|
199
202
|
inserts.push(buffer);
|
|
200
203
|
}
|
|
201
204
|
|
|
202
|
-
const indexFile = join(srcDir, 'web', '
|
|
205
|
+
const indexFile = join(srcDir, 'web', 'index.html');
|
|
203
206
|
|
|
204
207
|
if (existsSync(indexFile)) {
|
|
205
|
-
const uniqid = Math.random().toString(36);
|
|
206
|
-
const clientjscode = `
|
|
207
|
-
import React from "react";
|
|
208
|
-
import { createRoot } from "react-dom/client";
|
|
209
|
-
import { App } from "./app";
|
|
210
|
-
|
|
211
|
-
const root = createRoot(document.getElementById("root"));
|
|
212
|
-
root.render(<App />);
|
|
213
|
-
`;
|
|
214
|
-
const clientFile = join(srcDir, 'web', 'client.generated.js');
|
|
215
|
-
writeFileSync(clientFile, clientjscode);
|
|
216
|
-
|
|
217
208
|
inserts.unshift(`await (async () => {
|
|
218
|
-
const { renderToString } = require('react-dom/server');
|
|
219
209
|
const { serveStatic } = require('hono/bun');
|
|
220
210
|
const { getApp } = await import('@agentuity/runtime');
|
|
221
211
|
const app = getApp()!;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
app.get('/
|
|
212
|
+
const index = await Bun.file(import.meta.dir + '/web/index.js').text();
|
|
213
|
+
const webstatic = serveStatic({ root: import.meta.dir + '/web' });
|
|
214
|
+
app.get('/', (c) => c.html(index));
|
|
215
|
+
app.get('/chunk/*', webstatic);
|
|
216
|
+
app.get('/asset/*', webstatic);
|
|
217
|
+
app.get('/public/*', webstatic);
|
|
226
218
|
})();`);
|
|
227
219
|
}
|
|
228
220
|
|
package/src/cmd/dev/index.ts
CHANGED
|
@@ -53,6 +53,7 @@ export const command = createCommand({
|
|
|
53
53
|
let restarting = false;
|
|
54
54
|
let shuttingDownForRestart = false;
|
|
55
55
|
let pendingRestart = false;
|
|
56
|
+
let building = false;
|
|
56
57
|
|
|
57
58
|
// Track restart timestamps to detect restart loops
|
|
58
59
|
const restartTimestamps: number[] = [];
|
|
@@ -177,11 +178,14 @@ export const command = createCommand({
|
|
|
177
178
|
}),
|
|
178
179
|
tui.spinner('Building project', async () => {
|
|
179
180
|
try {
|
|
181
|
+
building = true;
|
|
180
182
|
await bundle({
|
|
181
183
|
rootDir,
|
|
182
184
|
dev: true,
|
|
183
185
|
});
|
|
186
|
+
building = false;
|
|
184
187
|
} catch {
|
|
188
|
+
building = false;
|
|
185
189
|
failure('Build failed');
|
|
186
190
|
}
|
|
187
191
|
}),
|
|
@@ -292,6 +296,17 @@ export const command = createCommand({
|
|
|
292
296
|
const watcher = watch(watchDir, { recursive: true }, (eventType, changedFile) => {
|
|
293
297
|
const absPath = changedFile ? join(watchDir, changedFile) : watchDir;
|
|
294
298
|
|
|
299
|
+
// Ignore file changes during active build to prevent loops
|
|
300
|
+
if (building) {
|
|
301
|
+
logger.trace(
|
|
302
|
+
'File change ignored (build in progress): %s (event: %s, file: %s)',
|
|
303
|
+
watchDir,
|
|
304
|
+
eventType,
|
|
305
|
+
changedFile
|
|
306
|
+
);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
295
310
|
// Ignore node_modules folder
|
|
296
311
|
if (absPath.includes('node_modules')) {
|
|
297
312
|
logger.trace(
|
|
@@ -314,6 +329,17 @@ export const command = createCommand({
|
|
|
314
329
|
return;
|
|
315
330
|
}
|
|
316
331
|
|
|
332
|
+
// Ignore changes to src/web/public directory (static assets, not code)
|
|
333
|
+
if (changedFile && changedFile === 'src/web/public') {
|
|
334
|
+
logger.trace(
|
|
335
|
+
'File change ignored (static assets dir): %s (event: %s, file: %s)',
|
|
336
|
+
watchDir,
|
|
337
|
+
eventType,
|
|
338
|
+
changedFile
|
|
339
|
+
);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
|
|
317
343
|
// Ignore generated files to prevent restart loops
|
|
318
344
|
if (changedFile) {
|
|
319
345
|
for (const pattern of ignorePatterns) {
|