@agentuity/cli 0.0.28 → 0.0.30

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,iBA4EnE"}
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,iBA6HnE"}
@@ -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,SAwJvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
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,mCAuVlB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmd/dev/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,OAAO,mCAiXlB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"template-flow.d.ts","sourceRoot":"","sources":["../../../src/cmd/project/template-flow.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAO3C,UAAU,iBAAiB;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+J7E"}
1
+ {"version":3,"file":"template-flow.d.ts","sourceRoot":"","sources":["../../../src/cmd/project/template-flow.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAO3C,UAAU,iBAAiB;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyJ7E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentuity/cli",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
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.11",
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 entrypoints: string[] = [];
20
+ const appEntrypoints: string[] = [];
21
21
 
22
- for (const folder of ['apis', 'agents', 'web']) {
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,18 @@ 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]sx?$/.test(filename)) {
33
- entrypoints.push(filename);
32
+ if (/\.[jt]s?$/.test(filename)) {
33
+ appEntrypoints.push(filename);
34
34
  }
35
35
  }
36
36
  }
37
+ appEntrypoints.push(appFile);
37
38
 
38
- entrypoints.push(appFile);
39
+ const webDir = join(srcDir, 'web');
40
+
41
+ const webEntrypoints = [...new Bun.Glob('**.html').scanSync(webDir)].map((a) =>
42
+ resolve(webDir, a)
43
+ );
39
44
 
40
45
  if (existsSync(outDir)) {
41
46
  rmSync(outDir, { recursive: true, force: true });
@@ -51,38 +56,82 @@ export async function bundle({ dev = false, rootDir }: BundleOptions) {
51
56
  'process.env.NODE_ENV': JSON.stringify(isProd ? 'production' : 'development'),
52
57
  };
53
58
 
54
- const config: Bun.BuildConfig = {
55
- entrypoints,
56
- root: rootDir,
57
- outdir: outDir,
58
- define,
59
- sourcemap: dev ? 'inline' : 'external',
60
- env: 'AGENTUITY_CLOUD_*',
61
- plugins: [AgentuityBundler],
62
- target: 'bun',
63
- format: 'esm',
64
- banner: `// Generated file. DO NOT EDIT`,
65
- minify: isProd,
66
- drop: isProd ? ['debugger'] : undefined,
67
- naming: isProd
68
- ? {
69
- entry: '[dir]/[name].js',
70
- chunk: 'chunks/[name]-[hash].js',
71
- asset: 'assets/[name]-[hash].[ext]',
59
+ await (async () => {
60
+ const config: Bun.BuildConfig = {
61
+ entrypoints: appEntrypoints,
62
+ root: rootDir,
63
+ outdir: outDir,
64
+ define,
65
+ sourcemap: dev ? 'inline' : 'external',
66
+ env: 'AGENTUITY_CLOUD_*',
67
+ plugins: [AgentuityBundler],
68
+ target: 'bun',
69
+ format: 'esm',
70
+ banner: `// Generated file. DO NOT EDIT`,
71
+ minify: isProd,
72
+ drop: isProd ? ['debugger'] : undefined,
73
+ conditions: [isProd ? 'production' : 'development', 'bun'],
74
+ };
75
+ try {
76
+ await Bun.build(config);
77
+ } catch (ex) {
78
+ console.error(ex);
79
+ process.exit(1);
80
+ }
81
+ })();
82
+
83
+ await (async () => {
84
+ // Find monorepo root by looking for package.json with workspaces
85
+ let workspaceRoot = rootDir;
86
+ let currentDir = rootDir;
87
+ while (currentDir !== '/') {
88
+ const pkgPath = join(currentDir, 'package.json');
89
+ if (existsSync(pkgPath)) {
90
+ const pkg = JSON.parse(await Bun.file(pkgPath).text());
91
+ if (pkg.workspaces) {
92
+ workspaceRoot = currentDir;
93
+ break;
72
94
  }
73
- : undefined,
74
- conditions: [isProd ? 'production' : 'development', 'bun'],
75
- };
95
+ }
96
+ currentDir = resolve(currentDir, '..');
97
+ }
98
+
99
+ const config: Bun.BuildConfig = {
100
+ entrypoints: webEntrypoints,
101
+ root: workspaceRoot,
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
+ };
119
+ try {
120
+ await Bun.build(config);
121
+ } catch (ex) {
122
+ console.error(ex);
123
+ process.exit(1);
124
+ }
125
+ })();
126
+
127
+ const webPublicDir = join(webDir, 'public');
128
+ if (existsSync(webPublicDir)) {
129
+ const webOutPublicDir = join(outDir, 'web', 'public');
130
+ cpSync(webPublicDir, webOutPublicDir, { recursive: true });
131
+ }
76
132
 
77
133
  await Bun.write(
78
134
  `${outDir}/package.json`,
79
135
  JSON.stringify({ name: pkgContents.name, version: pkgContents.version }, null, 2)
80
136
  );
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
137
  }
@@ -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', 'app.tsx');
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
- const routehtml = renderToString(require("./src/web/app").default);
223
- app.get("/", (c) => c.html(\`<html><body><div id="root">\${routehtml}</div><script src="/web/${uniqid}/client.js" type="module"></script></body></html>\`));
224
- app.get("/web/${uniqid}/client.js", (c) => new Response(Bun.file('./src/web/client.generated.js'), { type: 'text/javascript', headers: { 'Cache-Control': 'public, max-age=31536000, immutable' } }));
225
- app.get('/public/*', serveStatic({ root: './src/web' }));
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
 
@@ -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) {
@@ -113,12 +113,6 @@ export async function runCreateFlow(options: CreateFlowOptions): Promise<void> {
113
113
  }
114
114
  }
115
115
 
116
- // Show directory and name confirmation
117
- if (!skipPrompts) {
118
- tui.info(`📁 Project: ${tui.bold(projectName)}`);
119
- tui.info(`📂 Directory: ${tui.bold(dest)}\n`);
120
- }
121
-
122
116
  // Step 5: Select template
123
117
  let selectedTemplate: TemplateInfo;
124
118
  if (initialTemplate) {