@agentuity/cli 2.0.11 → 3.0.0-alpha.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/dist/cmd/ai/prompt/index.d.ts.map +1 -1
- package/dist/cmd/ai/prompt/index.js +2 -7
- package/dist/cmd/ai/prompt/index.js.map +1 -1
- package/dist/cmd/build/adapters/generic.d.ts +29 -0
- package/dist/cmd/build/adapters/generic.d.ts.map +1 -0
- package/dist/cmd/build/adapters/generic.js +190 -0
- package/dist/cmd/build/adapters/generic.js.map +1 -0
- package/dist/cmd/build/adapters/index.d.ts +15 -0
- package/dist/cmd/build/adapters/index.d.ts.map +1 -0
- package/dist/cmd/build/adapters/index.js +24 -0
- package/dist/cmd/build/adapters/index.js.map +1 -0
- package/dist/cmd/build/adapters/nextjs.d.ts +11 -0
- package/dist/cmd/build/adapters/nextjs.d.ts.map +1 -0
- package/dist/cmd/build/adapters/nextjs.js +118 -0
- package/dist/cmd/build/adapters/nextjs.js.map +1 -0
- package/dist/cmd/build/adapters/static-server.d.ts +23 -0
- package/dist/cmd/build/adapters/static-server.d.ts.map +1 -0
- package/dist/cmd/build/adapters/static-server.js +137 -0
- package/dist/cmd/build/adapters/static-server.js.map +1 -0
- package/dist/cmd/build/adapters/types.d.ts +71 -0
- package/dist/cmd/build/adapters/types.d.ts.map +1 -0
- package/dist/cmd/build/adapters/types.js +8 -0
- package/dist/cmd/build/adapters/types.js.map +1 -0
- package/dist/cmd/build/detect/engine.d.ts +24 -0
- package/dist/cmd/build/detect/engine.d.ts.map +1 -0
- package/dist/cmd/build/detect/engine.js +91 -0
- package/dist/cmd/build/detect/engine.js.map +1 -0
- package/dist/cmd/build/detect/frameworks.d.ts +66 -0
- package/dist/cmd/build/detect/frameworks.d.ts.map +1 -0
- package/dist/cmd/build/detect/frameworks.js +278 -0
- package/dist/cmd/build/detect/frameworks.js.map +1 -0
- package/dist/cmd/build/detect/generic.d.ts +13 -0
- package/dist/cmd/build/detect/generic.d.ts.map +1 -0
- package/dist/cmd/build/detect/generic.js +62 -0
- package/dist/cmd/build/detect/generic.js.map +1 -0
- package/dist/cmd/build/detect/index.d.ts +27 -0
- package/dist/cmd/build/detect/index.d.ts.map +1 -0
- package/dist/cmd/build/detect/index.js +76 -0
- package/dist/cmd/build/detect/index.js.map +1 -0
- package/dist/cmd/build/detect/types.d.ts +91 -0
- package/dist/cmd/build/detect/types.d.ts.map +1 -0
- package/dist/cmd/build/detect/types.js +9 -0
- package/dist/cmd/build/detect/types.js.map +1 -0
- package/dist/cmd/build/detect/util.d.ts +41 -0
- package/dist/cmd/build/detect/util.d.ts.map +1 -0
- package/dist/cmd/build/detect/util.js +101 -0
- package/dist/cmd/build/detect/util.js.map +1 -0
- package/dist/cmd/build/index.d.ts.map +1 -1
- package/dist/cmd/build/index.js +49 -22
- package/dist/cmd/build/index.js.map +1 -1
- package/dist/cmd/build/package/index.d.ts +30 -0
- package/dist/cmd/build/package/index.d.ts.map +1 -0
- package/dist/cmd/build/package/index.js +39 -0
- package/dist/cmd/build/package/index.js.map +1 -0
- package/dist/cmd/build/package/launch.d.ts +56 -0
- package/dist/cmd/build/package/launch.d.ts.map +1 -0
- package/dist/cmd/build/package/launch.js +56 -0
- package/dist/cmd/build/package/launch.js.map +1 -0
- package/dist/cmd/build/typecheck.d.ts.map +1 -1
- package/dist/cmd/build/typecheck.js +8 -0
- package/dist/cmd/build/typecheck.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +63 -13
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/coder/create.js +7 -7
- package/dist/cmd/coder/create.js.map +1 -1
- package/dist/cmd/coder/update.js +8 -8
- package/dist/cmd/coder/update.js.map +1 -1
- package/dist/cmd/coder/workspace/create.js +9 -9
- package/dist/cmd/coder/workspace/create.js.map +1 -1
- package/dist/cmd/dev/index.d.ts +9 -0
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/index.js +127 -923
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/project/auth/shared.d.ts.map +1 -1
- package/dist/cmd/project/auth/shared.js +14 -38
- package/dist/cmd/project/auth/shared.js.map +1 -1
- package/dist/cmd/project/create.d.ts.map +1 -1
- package/dist/cmd/project/create.js +12 -19
- package/dist/cmd/project/create.js.map +1 -1
- package/dist/cmd/project/frameworks-ai-examples.d.ts +15 -0
- package/dist/cmd/project/frameworks-ai-examples.d.ts.map +1 -0
- package/dist/cmd/project/frameworks-ai-examples.js +160 -0
- package/dist/cmd/project/frameworks-ai-examples.js.map +1 -0
- package/dist/cmd/project/frameworks-landing-pages.d.ts +17 -0
- package/dist/cmd/project/frameworks-landing-pages.d.ts.map +1 -0
- package/dist/cmd/project/frameworks-landing-pages.js +242 -0
- package/dist/cmd/project/frameworks-landing-pages.js.map +1 -0
- package/dist/cmd/project/frameworks.d.ts +58 -0
- package/dist/cmd/project/frameworks.d.ts.map +1 -0
- package/dist/cmd/project/frameworks.js +152 -0
- package/dist/cmd/project/frameworks.js.map +1 -0
- package/dist/cmd/project/reconcile.d.ts.map +1 -1
- package/dist/cmd/project/reconcile.js +10 -23
- package/dist/cmd/project/reconcile.js.map +1 -1
- package/dist/cmd/project/remote-import.js +1 -1
- package/dist/cmd/project/scaffold.d.ts +58 -0
- package/dist/cmd/project/scaffold.d.ts.map +1 -0
- package/dist/cmd/project/scaffold.js +223 -0
- package/dist/cmd/project/scaffold.js.map +1 -0
- package/dist/cmd/project/template-flow.d.ts +8 -4
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- package/dist/cmd/project/template-flow.js +93 -144
- package/dist/cmd/project/template-flow.js.map +1 -1
- package/dist/deploy-metadata.d.ts +49 -0
- package/dist/deploy-metadata.d.ts.map +1 -0
- package/dist/deploy-metadata.js +183 -0
- package/dist/deploy-metadata.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +24 -30
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +13 -8
- package/src/cmd/ai/prompt/index.ts +2 -7
- package/src/cmd/build/adapters/generic.ts +239 -0
- package/src/cmd/build/adapters/index.ts +30 -0
- package/src/cmd/build/adapters/nextjs.ts +146 -0
- package/src/cmd/build/adapters/static-server.ts +143 -0
- package/src/cmd/build/adapters/types.ts +93 -0
- package/src/cmd/build/detect/engine.ts +111 -0
- package/src/cmd/build/detect/frameworks.ts +335 -0
- package/src/cmd/build/detect/generic.ts +71 -0
- package/src/cmd/build/detect/index.ts +122 -0
- package/src/cmd/build/detect/types.ts +109 -0
- package/src/cmd/build/detect/util.ts +104 -0
- package/src/cmd/build/index.ts +64 -24
- package/src/cmd/build/package/index.ts +66 -0
- package/src/cmd/build/package/launch.ts +104 -0
- package/src/cmd/build/typecheck.ts +9 -0
- package/src/cmd/cloud/deploy.ts +86 -13
- package/src/cmd/coder/create.ts +8 -8
- package/src/cmd/coder/update.ts +7 -7
- package/src/cmd/coder/workspace/create.ts +10 -10
- package/src/cmd/dev/index.ts +155 -1059
- package/src/cmd/project/auth/shared.ts +14 -39
- package/src/cmd/project/create.ts +14 -19
- package/src/cmd/project/frameworks-ai-examples.ts +166 -0
- package/src/cmd/project/frameworks-landing-pages.ts +267 -0
- package/src/cmd/project/frameworks.ts +223 -0
- package/src/cmd/project/reconcile.ts +10 -22
- package/src/cmd/project/remote-import.ts +1 -1
- package/src/cmd/project/scaffold.ts +300 -0
- package/src/cmd/project/template-flow.ts +102 -156
- package/src/deploy-metadata.ts +253 -0
- package/src/index.ts +0 -2
- package/src/types.ts +0 -31
- package/dist/agents-docs.d.ts +0 -23
- package/dist/agents-docs.d.ts.map +0 -1
- package/dist/agents-docs.js +0 -56
- package/dist/agents-docs.js.map +0 -1
- package/dist/cmd/ai/prompt/agent.d.ts +0 -10
- package/dist/cmd/ai/prompt/agent.d.ts.map +0 -1
- package/dist/cmd/ai/prompt/agent.js +0 -28
- package/dist/cmd/ai/prompt/agent.js.map +0 -1
- package/dist/cmd/build/app-router-detector.d.ts +0 -39
- package/dist/cmd/build/app-router-detector.d.ts.map +0 -1
- package/dist/cmd/build/app-router-detector.js +0 -229
- package/dist/cmd/build/app-router-detector.js.map +0 -1
- package/dist/cmd/build/format-schema.d.ts +0 -6
- package/dist/cmd/build/format-schema.d.ts.map +0 -1
- package/dist/cmd/build/format-schema.js +0 -60
- package/dist/cmd/build/format-schema.js.map +0 -1
- package/dist/cmd/build/vite/agent-discovery.d.ts +0 -37
- package/dist/cmd/build/vite/agent-discovery.d.ts.map +0 -1
- package/dist/cmd/build/vite/agent-discovery.js +0 -263
- package/dist/cmd/build/vite/agent-discovery.js.map +0 -1
- package/dist/cmd/build/vite/beacon-plugin.d.ts +0 -19
- package/dist/cmd/build/vite/beacon-plugin.d.ts.map +0 -1
- package/dist/cmd/build/vite/beacon-plugin.js +0 -137
- package/dist/cmd/build/vite/beacon-plugin.js.map +0 -1
- package/dist/cmd/build/vite/browser-env-plugin.d.ts +0 -9
- package/dist/cmd/build/vite/browser-env-plugin.d.ts.map +0 -1
- package/dist/cmd/build/vite/browser-env-plugin.js +0 -28
- package/dist/cmd/build/vite/browser-env-plugin.js.map +0 -1
- package/dist/cmd/build/vite/bun-dev-server.d.ts +0 -67
- package/dist/cmd/build/vite/bun-dev-server.d.ts.map +0 -1
- package/dist/cmd/build/vite/bun-dev-server.js +0 -340
- package/dist/cmd/build/vite/bun-dev-server.js.map +0 -1
- package/dist/cmd/build/vite/bundle-files.d.ts +0 -12
- package/dist/cmd/build/vite/bundle-files.d.ts.map +0 -1
- package/dist/cmd/build/vite/bundle-files.js +0 -107
- package/dist/cmd/build/vite/bundle-files.js.map +0 -1
- package/dist/cmd/build/vite/config-loader.d.ts +0 -29
- package/dist/cmd/build/vite/config-loader.d.ts.map +0 -1
- package/dist/cmd/build/vite/config-loader.js +0 -57
- package/dist/cmd/build/vite/config-loader.js.map +0 -1
- package/dist/cmd/build/vite/db-rewrite.d.ts +0 -50
- package/dist/cmd/build/vite/db-rewrite.d.ts.map +0 -1
- package/dist/cmd/build/vite/db-rewrite.js +0 -169
- package/dist/cmd/build/vite/db-rewrite.js.map +0 -1
- package/dist/cmd/build/vite/docs-generator.d.ts +0 -13
- package/dist/cmd/build/vite/docs-generator.d.ts.map +0 -1
- package/dist/cmd/build/vite/docs-generator.js +0 -97
- package/dist/cmd/build/vite/docs-generator.js.map +0 -1
- package/dist/cmd/build/vite/env-types-generator.d.ts +0 -26
- package/dist/cmd/build/vite/env-types-generator.d.ts.map +0 -1
- package/dist/cmd/build/vite/env-types-generator.js +0 -110
- package/dist/cmd/build/vite/env-types-generator.js.map +0 -1
- package/dist/cmd/build/vite/index.d.ts +0 -3
- package/dist/cmd/build/vite/index.d.ts.map +0 -1
- package/dist/cmd/build/vite/index.js +0 -4
- package/dist/cmd/build/vite/index.js.map +0 -1
- package/dist/cmd/build/vite/lifecycle-generator.d.ts +0 -19
- package/dist/cmd/build/vite/lifecycle-generator.d.ts.map +0 -1
- package/dist/cmd/build/vite/lifecycle-generator.js +0 -328
- package/dist/cmd/build/vite/lifecycle-generator.js.map +0 -1
- package/dist/cmd/build/vite/metadata-generator.d.ts +0 -36
- package/dist/cmd/build/vite/metadata-generator.d.ts.map +0 -1
- package/dist/cmd/build/vite/metadata-generator.js +0 -575
- package/dist/cmd/build/vite/metadata-generator.js.map +0 -1
- package/dist/cmd/build/vite/prompt-generator.d.ts +0 -23
- package/dist/cmd/build/vite/prompt-generator.d.ts.map +0 -1
- package/dist/cmd/build/vite/prompt-generator.js +0 -123
- package/dist/cmd/build/vite/prompt-generator.js.map +0 -1
- package/dist/cmd/build/vite/public-asset-path-plugin.d.ts +0 -45
- package/dist/cmd/build/vite/public-asset-path-plugin.d.ts.map +0 -1
- package/dist/cmd/build/vite/public-asset-path-plugin.js +0 -166
- package/dist/cmd/build/vite/public-asset-path-plugin.js.map +0 -1
- package/dist/cmd/build/vite/route-discovery.d.ts +0 -64
- package/dist/cmd/build/vite/route-discovery.d.ts.map +0 -1
- package/dist/cmd/build/vite/route-discovery.js +0 -187
- package/dist/cmd/build/vite/route-discovery.js.map +0 -1
- package/dist/cmd/build/vite/server-bundler.d.ts +0 -20
- package/dist/cmd/build/vite/server-bundler.d.ts.map +0 -1
- package/dist/cmd/build/vite/server-bundler.js +0 -388
- package/dist/cmd/build/vite/server-bundler.js.map +0 -1
- package/dist/cmd/build/vite/static-renderer.d.ts +0 -26
- package/dist/cmd/build/vite/static-renderer.d.ts.map +0 -1
- package/dist/cmd/build/vite/static-renderer.js +0 -188
- package/dist/cmd/build/vite/static-renderer.js.map +0 -1
- package/dist/cmd/build/vite/tailwind-source-plugin.d.ts +0 -15
- package/dist/cmd/build/vite/tailwind-source-plugin.d.ts.map +0 -1
- package/dist/cmd/build/vite/tailwind-source-plugin.js +0 -61
- package/dist/cmd/build/vite/tailwind-source-plugin.js.map +0 -1
- package/dist/cmd/build/vite/vite-asset-server-config.d.ts +0 -24
- package/dist/cmd/build/vite/vite-asset-server-config.d.ts.map +0 -1
- package/dist/cmd/build/vite/vite-asset-server-config.js +0 -285
- package/dist/cmd/build/vite/vite-asset-server-config.js.map +0 -1
- package/dist/cmd/build/vite/vite-asset-server.d.ts +0 -30
- package/dist/cmd/build/vite/vite-asset-server.d.ts.map +0 -1
- package/dist/cmd/build/vite/vite-asset-server.js +0 -109
- package/dist/cmd/build/vite/vite-asset-server.js.map +0 -1
- package/dist/cmd/build/vite/vite-builder.d.ts +0 -59
- package/dist/cmd/build/vite/vite-builder.d.ts.map +0 -1
- package/dist/cmd/build/vite/vite-builder.js +0 -401
- package/dist/cmd/build/vite/vite-builder.js.map +0 -1
- package/dist/cmd/build/vite/workbench-generator.d.ts +0 -10
- package/dist/cmd/build/vite/workbench-generator.d.ts.map +0 -1
- package/dist/cmd/build/vite/workbench-generator.js +0 -135
- package/dist/cmd/build/vite/workbench-generator.js.map +0 -1
- package/dist/cmd/build/vite/ws-proxy.d.ts +0 -53
- package/dist/cmd/build/vite/ws-proxy.d.ts.map +0 -1
- package/dist/cmd/build/vite/ws-proxy.js +0 -95
- package/dist/cmd/build/vite/ws-proxy.js.map +0 -1
- package/dist/cmd/build/vite-bundler.d.ts +0 -29
- package/dist/cmd/build/vite-bundler.d.ts.map +0 -1
- package/dist/cmd/build/vite-bundler.js +0 -93
- package/dist/cmd/build/vite-bundler.js.map +0 -1
- package/dist/cmd/dev/agents.d.ts +0 -2
- package/dist/cmd/dev/agents.d.ts.map +0 -1
- package/dist/cmd/dev/agents.js +0 -123
- package/dist/cmd/dev/agents.js.map +0 -1
- package/dist/cmd/dev/api.d.ts +0 -20
- package/dist/cmd/dev/api.d.ts.map +0 -1
- package/dist/cmd/dev/api.js +0 -42
- package/dist/cmd/dev/api.js.map +0 -1
- package/dist/cmd/dev/dev-lock.d.ts +0 -62
- package/dist/cmd/dev/dev-lock.d.ts.map +0 -1
- package/dist/cmd/dev/dev-lock.js +0 -250
- package/dist/cmd/dev/dev-lock.js.map +0 -1
- package/dist/cmd/dev/download.d.ts +0 -11
- package/dist/cmd/dev/download.d.ts.map +0 -1
- package/dist/cmd/dev/download.js +0 -94
- package/dist/cmd/dev/download.js.map +0 -1
- package/dist/cmd/dev/file-watcher.d.ts +0 -24
- package/dist/cmd/dev/file-watcher.d.ts.map +0 -1
- package/dist/cmd/dev/file-watcher.js +0 -349
- package/dist/cmd/dev/file-watcher.js.map +0 -1
- package/dist/cmd/dev/process-manager.d.ts +0 -104
- package/dist/cmd/dev/process-manager.d.ts.map +0 -1
- package/dist/cmd/dev/process-manager.js +0 -204
- package/dist/cmd/dev/process-manager.js.map +0 -1
- package/dist/cmd/dev/sync.d.ts +0 -12
- package/dist/cmd/dev/sync.d.ts.map +0 -1
- package/dist/cmd/dev/sync.js +0 -227
- package/dist/cmd/dev/sync.js.map +0 -1
- package/dist/cmd/dev/templates.d.ts +0 -3
- package/dist/cmd/dev/templates.d.ts.map +0 -1
- package/dist/cmd/dev/templates.js +0 -58
- package/dist/cmd/dev/templates.js.map +0 -1
- package/dist/cmd/project/download.d.ts +0 -35
- package/dist/cmd/project/download.d.ts.map +0 -1
- package/dist/cmd/project/download.js +0 -403
- package/dist/cmd/project/download.js.map +0 -1
- package/dist/cmd/project/templates.d.ts +0 -9
- package/dist/cmd/project/templates.d.ts.map +0 -1
- package/dist/cmd/project/templates.js +0 -34
- package/dist/cmd/project/templates.js.map +0 -1
- package/src/agents-docs.ts +0 -86
- package/src/cmd/ai/prompt/agent.md +0 -305
- package/src/cmd/ai/prompt/agent.ts +0 -31
- package/src/cmd/build/app-router-detector.ts +0 -320
- package/src/cmd/build/format-schema.ts +0 -66
- package/src/cmd/build/vite/agent-discovery.ts +0 -380
- package/src/cmd/build/vite/beacon-plugin.ts +0 -164
- package/src/cmd/build/vite/browser-env-plugin.ts +0 -34
- package/src/cmd/build/vite/bun-dev-server.ts +0 -458
- package/src/cmd/build/vite/bundle-files.ts +0 -135
- package/src/cmd/build/vite/config-loader.ts +0 -76
- package/src/cmd/build/vite/db-rewrite.ts +0 -189
- package/src/cmd/build/vite/docs-generator.ts +0 -103
- package/src/cmd/build/vite/env-types-generator.ts +0 -145
- package/src/cmd/build/vite/index.ts +0 -3
- package/src/cmd/build/vite/lifecycle-generator.ts +0 -381
- package/src/cmd/build/vite/metadata-generator.ts +0 -713
- package/src/cmd/build/vite/prompt-generator.ts +0 -169
- package/src/cmd/build/vite/public-asset-path-plugin.ts +0 -209
- package/src/cmd/build/vite/route-discovery.ts +0 -271
- package/src/cmd/build/vite/server-bundler.ts +0 -481
- package/src/cmd/build/vite/static-renderer.ts +0 -239
- package/src/cmd/build/vite/tailwind-source-plugin.ts +0 -73
- package/src/cmd/build/vite/vite-asset-server-config.ts +0 -349
- package/src/cmd/build/vite/vite-asset-server.ts +0 -154
- package/src/cmd/build/vite/vite-builder.ts +0 -503
- package/src/cmd/build/vite/workbench-generator.ts +0 -152
- package/src/cmd/build/vite/ws-proxy.ts +0 -126
- package/src/cmd/build/vite-bundler.ts +0 -137
- package/src/cmd/dev/agents.ts +0 -140
- package/src/cmd/dev/api.ts +0 -65
- package/src/cmd/dev/dev-lock.ts +0 -332
- package/src/cmd/dev/download.ts +0 -117
- package/src/cmd/dev/file-watcher.ts +0 -423
- package/src/cmd/dev/process-manager.ts +0 -261
- package/src/cmd/dev/sync.ts +0 -411
- package/src/cmd/dev/templates.ts +0 -66
- package/src/cmd/project/download.ts +0 -505
- package/src/cmd/project/templates.ts +0 -56
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bun Dev Server
|
|
3
|
-
*
|
|
4
|
-
* Spawns Bun with --hot as a subprocess. Bun's --hot mode re-evaluates changed
|
|
5
|
-
* modules and hot-swaps the default export's `fetch` handler on the running
|
|
6
|
-
* server — no process restart, no port rebind, no dropped connections.
|
|
7
|
-
*
|
|
8
|
-
* The user's app.ts exports the result of createApp() which includes `fetch`
|
|
9
|
-
* and `port` properties that Bun uses to manage the server lifecycle.
|
|
10
|
-
*
|
|
11
|
-
* Key requirements for bun --hot:
|
|
12
|
-
* - app.ts MUST have `export default` with { fetch, port } properties
|
|
13
|
-
* - Without export default, Bun runs the code but never starts an HTTP server
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import type { Logger } from '../../../types';
|
|
17
|
-
import { getAgentEnv } from '../../../agent-detection';
|
|
18
|
-
import { createServer as createNetServer } from 'node:net';
|
|
19
|
-
|
|
20
|
-
export interface BunDevServerOptions {
|
|
21
|
-
rootDir: string;
|
|
22
|
-
port?: number;
|
|
23
|
-
logger: Logger;
|
|
24
|
-
vitePort: number;
|
|
25
|
-
inspect?: boolean;
|
|
26
|
-
inspectWait?: boolean;
|
|
27
|
-
inspectBrk?: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface BunDevServerResult {
|
|
31
|
-
bunServerPort: number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Check if a port is available for binding.
|
|
36
|
-
* Returns true if the port is free, false if in use.
|
|
37
|
-
*/
|
|
38
|
-
function isPortAvailable(port: number, host: string = '127.0.0.1'): Promise<boolean> {
|
|
39
|
-
return new Promise((resolve) => {
|
|
40
|
-
const server = createNetServer();
|
|
41
|
-
server.once('error', () => {
|
|
42
|
-
resolve(false);
|
|
43
|
-
});
|
|
44
|
-
server.listen(port, host, () => {
|
|
45
|
-
server.close(() => {
|
|
46
|
-
resolve(true);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Kill any process listening on the specified port.
|
|
54
|
-
* Uses lsof on Unix systems to find and kill the process.
|
|
55
|
-
*/
|
|
56
|
-
async function killProcessOnPort(
|
|
57
|
-
port: number,
|
|
58
|
-
logger: { debug: (msg: string, ...args: unknown[]) => void }
|
|
59
|
-
): Promise<boolean> {
|
|
60
|
-
if (process.platform === 'win32') {
|
|
61
|
-
// Windows: use netstat to find PID, then taskkill
|
|
62
|
-
// This is more complex and less reliable, skip for now
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
// Find PIDs listening on the port
|
|
68
|
-
const result = Bun.spawnSync(['lsof', '-t', '-i', `:${port}`], {
|
|
69
|
-
stdout: 'pipe',
|
|
70
|
-
stderr: 'ignore',
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
if (result.exitCode !== 0 || !result.stdout) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const pids = new TextDecoder()
|
|
78
|
-
.decode(result.stdout)
|
|
79
|
-
.trim()
|
|
80
|
-
.split('\n')
|
|
81
|
-
.filter((line) => line && /^\d+$/.test(line));
|
|
82
|
-
|
|
83
|
-
if (pids.length === 0) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Kill each process
|
|
88
|
-
for (const pid of pids) {
|
|
89
|
-
try {
|
|
90
|
-
// Use SIGKILL to ensure cleanup
|
|
91
|
-
const killResult = Bun.spawnSync(['kill', '-9', pid], {
|
|
92
|
-
stdout: 'ignore',
|
|
93
|
-
stderr: 'ignore',
|
|
94
|
-
});
|
|
95
|
-
if (killResult.exitCode === 0) {
|
|
96
|
-
logger.debug('Killed orphan process %s on port %d', pid, port);
|
|
97
|
-
}
|
|
98
|
-
} catch {
|
|
99
|
-
// Ignore kill errors
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Brief pause to let the port be released
|
|
104
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
105
|
-
return true;
|
|
106
|
-
} catch {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Ensure the port is available, cleaning up any orphan processes if needed.
|
|
113
|
-
*/
|
|
114
|
-
async function ensurePortAvailable(
|
|
115
|
-
port: number,
|
|
116
|
-
logger: { debug: (msg: string, ...args: unknown[]) => void }
|
|
117
|
-
): Promise<void> {
|
|
118
|
-
const available = await isPortAvailable(port);
|
|
119
|
-
if (available) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
logger.debug('Port %d is in use, attempting to clean up orphan process...', port);
|
|
124
|
-
|
|
125
|
-
const killed = await killProcessOnPort(port, logger);
|
|
126
|
-
if (killed) {
|
|
127
|
-
// Verify the port is now free
|
|
128
|
-
const nowAvailable = await isPortAvailable(port);
|
|
129
|
-
if (!nowAvailable) {
|
|
130
|
-
throw new Error(
|
|
131
|
-
`Port ${port} is still in use after cleanup. Another process may be holding it.\n` +
|
|
132
|
-
`Run 'lsof -i :${port}' to identify the process.`
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
logger.debug('Port %d is now available', port);
|
|
136
|
-
} else {
|
|
137
|
-
throw new Error(
|
|
138
|
-
`Port ${port} is already in use.\n` +
|
|
139
|
-
`Run 'lsof -i :${port}' to identify the process, or kill it manually.`
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Validation result for app.ts entry point.
|
|
146
|
-
*/
|
|
147
|
-
interface AppValidationResult {
|
|
148
|
-
/** Whether app.ts has a default export */
|
|
149
|
-
hasDefaultExport: boolean;
|
|
150
|
-
/** Whether app.ts calls createApp() */
|
|
151
|
-
hasCreateApp: boolean;
|
|
152
|
-
/** Whether it's the v1 pattern (destructuring without export) */
|
|
153
|
-
isV1Pattern: boolean;
|
|
154
|
-
/** Any validation hints to show */
|
|
155
|
-
hints: string[];
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Validate app.ts for common issues that prevent Bun --hot from starting.
|
|
160
|
-
*
|
|
161
|
-
* Bun --hot requires `export default { fetch, port }` to start a server.
|
|
162
|
-
* Common mistakes:
|
|
163
|
-
* - No `export default` (v1 pattern: destructuring result without exporting)
|
|
164
|
-
* - Calling createApp() but not exporting it
|
|
165
|
-
*
|
|
166
|
-
* @internal Exported for testing only
|
|
167
|
-
*/
|
|
168
|
-
export async function validateAppTs(appPath: string): Promise<AppValidationResult> {
|
|
169
|
-
const result: AppValidationResult = {
|
|
170
|
-
hasDefaultExport: false,
|
|
171
|
-
hasCreateApp: false,
|
|
172
|
-
isV1Pattern: false,
|
|
173
|
-
hints: [],
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const file = Bun.file(appPath);
|
|
177
|
-
if (!(await file.exists())) {
|
|
178
|
-
return result;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const content = await file.text();
|
|
182
|
-
|
|
183
|
-
// Strip comments to avoid false positives from commented-out code
|
|
184
|
-
// Simple approach: remove single-line and multi-line comments
|
|
185
|
-
const codeWithoutComments = content
|
|
186
|
-
.replace(/\/\/.*$/gm, '') // Single-line comments
|
|
187
|
-
.replace(/\/\*[\s\S]*?\*\//g, ''); // Multi-line comments
|
|
188
|
-
|
|
189
|
-
// Check for default export patterns (only in actual code, not comments)
|
|
190
|
-
// Matches: export default createApp(...), export default await createApp(...),
|
|
191
|
-
// export default { fetch, port }, const { ... } = await createApp(...) then export default result
|
|
192
|
-
result.hasDefaultExport = /\bexport\s+default\b/.test(codeWithoutComments);
|
|
193
|
-
|
|
194
|
-
// Check for createApp call
|
|
195
|
-
result.hasCreateApp = /\bcreateApp\s*\(/.test(content);
|
|
196
|
-
|
|
197
|
-
// Detect v1 pattern: destructuring createApp result without export default
|
|
198
|
-
// e.g., const { server, logger } = await createApp({...});
|
|
199
|
-
const hasDestructuring = /const\s*\{[^}]*\}\s*=\s*(?:await\s+)?createApp/.test(content);
|
|
200
|
-
if (hasDestructuring && !result.hasDefaultExport) {
|
|
201
|
-
result.isV1Pattern = true;
|
|
202
|
-
result.hints.push(
|
|
203
|
-
'app.ts calls createApp() but does not export it. Bun --hot requires `export default` to start a server.',
|
|
204
|
-
'',
|
|
205
|
-
'Fix: Change your app.ts to export the createApp() result:',
|
|
206
|
-
'',
|
|
207
|
-
' import { createApp } from "@agentuity/runtime";',
|
|
208
|
-
' import agents from "@agent/index";',
|
|
209
|
-
'',
|
|
210
|
-
' export default createApp({',
|
|
211
|
-
' agents,',
|
|
212
|
-
' router: { path: "/api", router: api },',
|
|
213
|
-
' });',
|
|
214
|
-
'',
|
|
215
|
-
'Or if you need the logger:',
|
|
216
|
-
'',
|
|
217
|
-
' const app = await createApp({ agents });',
|
|
218
|
-
' app.logger.debug("Running %s", app.server.url);',
|
|
219
|
-
' export default app;'
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Check for missing createApp entirely
|
|
224
|
-
if (!result.hasCreateApp && !content.includes('Bun.serve')) {
|
|
225
|
-
result.hints.push(
|
|
226
|
-
'app.ts does not call createApp(). This is required for Agentuity apps.',
|
|
227
|
-
'',
|
|
228
|
-
'Example:',
|
|
229
|
-
'',
|
|
230
|
-
' import { createApp } from "@agentuity/runtime";',
|
|
231
|
-
' export default createApp({ agents });'
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Build a detailed error message with validation hints and captured output.
|
|
240
|
-
*
|
|
241
|
-
* @internal Exported for testing only
|
|
242
|
-
*/
|
|
243
|
-
export function buildStartupErrorMessage(
|
|
244
|
-
port: number,
|
|
245
|
-
timeoutMs: number,
|
|
246
|
-
stderr: string,
|
|
247
|
-
validation: AppValidationResult,
|
|
248
|
-
stdout?: string
|
|
249
|
-
): string {
|
|
250
|
-
const lines: string[] = [];
|
|
251
|
-
|
|
252
|
-
lines.push(`Bun server failed to start on port ${port} after ${timeoutMs}ms`);
|
|
253
|
-
lines.push('');
|
|
254
|
-
|
|
255
|
-
// Show captured stderr if any
|
|
256
|
-
if (stderr.trim()) {
|
|
257
|
-
lines.push('Bun stderr:');
|
|
258
|
-
lines.push('');
|
|
259
|
-
// Indent stderr lines for readability
|
|
260
|
-
for (const line of stderr.trim().split('\n').slice(0, 20)) {
|
|
261
|
-
lines.push(` ${line}`);
|
|
262
|
-
}
|
|
263
|
-
if (stderr.split('\n').length > 20) {
|
|
264
|
-
lines.push(' ... (truncated)');
|
|
265
|
-
}
|
|
266
|
-
lines.push('');
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// Show captured stdout if any (runtime errors, uncaught exceptions, etc.)
|
|
270
|
-
if (stdout?.trim()) {
|
|
271
|
-
lines.push('Bun stdout:');
|
|
272
|
-
lines.push('');
|
|
273
|
-
for (const line of stdout.trim().split('\n').slice(0, 20)) {
|
|
274
|
-
lines.push(` ${line}`);
|
|
275
|
-
}
|
|
276
|
-
if (stdout.split('\n').length > 20) {
|
|
277
|
-
lines.push(' ... (truncated)');
|
|
278
|
-
}
|
|
279
|
-
lines.push('');
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// Show validation hints
|
|
283
|
-
if (validation.hints.length > 0) {
|
|
284
|
-
lines.push('Possible issue:');
|
|
285
|
-
lines.push('');
|
|
286
|
-
for (const hint of validation.hints) {
|
|
287
|
-
lines.push(` ${hint}`);
|
|
288
|
-
}
|
|
289
|
-
lines.push('');
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// Generic troubleshooting if no specific hints
|
|
293
|
-
if (validation.hints.length === 0) {
|
|
294
|
-
lines.push('Troubleshooting:');
|
|
295
|
-
lines.push('');
|
|
296
|
-
lines.push(' 1. Check app.ts exports `export default createApp({...})`');
|
|
297
|
-
lines.push(' 2. Check for TypeScript/syntax errors in your code');
|
|
298
|
-
lines.push(` 3. Check if port ${port} is already in use: lsof -i :${port}`);
|
|
299
|
-
lines.push(' 4. Try running manually: bun run --hot app.ts');
|
|
300
|
-
lines.push('');
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
return lines.join('\n');
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Start Bun dev server with --hot (Vite asset server must already be running).
|
|
308
|
-
*
|
|
309
|
-
* Uses `bun --hot` so Bun watches all imported files and hot-swaps the fetch
|
|
310
|
-
* handler on the running server. The server stays up — only the changed modules
|
|
311
|
-
* are re-evaluated.
|
|
312
|
-
*/
|
|
313
|
-
export async function startBunDevServer(options: BunDevServerOptions): Promise<BunDevServerResult> {
|
|
314
|
-
const { rootDir, port = 3500, logger, vitePort, inspect, inspectWait, inspectBrk } = options;
|
|
315
|
-
|
|
316
|
-
logger.debug('Starting Bun dev server (Vite already running on port %d)...', vitePort);
|
|
317
|
-
|
|
318
|
-
const appPath = `${rootDir}/app.ts`;
|
|
319
|
-
|
|
320
|
-
const appFile = Bun.file(appPath);
|
|
321
|
-
if (!(await appFile.exists())) {
|
|
322
|
-
throw new Error(`App entry not found at ${appPath}.`);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// Pre-validate app.ts for common issues
|
|
326
|
-
const validation = await validateAppTs(appPath);
|
|
327
|
-
if (validation.isV1Pattern) {
|
|
328
|
-
logger.warn('');
|
|
329
|
-
logger.warn('⚠️ app.ts may have a v1-style pattern that prevents Bun --hot from starting.');
|
|
330
|
-
for (const hint of validation.hints) {
|
|
331
|
-
logger.warn(' %s', hint);
|
|
332
|
-
}
|
|
333
|
-
logger.warn('');
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// Ensure the port is available, cleaning up any orphan processes
|
|
337
|
-
await ensurePortAvailable(port, logger);
|
|
338
|
-
|
|
339
|
-
process.env.PORT = String(port);
|
|
340
|
-
|
|
341
|
-
const args: string[] = ['bun'];
|
|
342
|
-
|
|
343
|
-
// --hot: in-process hot reload — re-evaluates changed modules and swaps
|
|
344
|
-
// the default export's fetch handler without restarting the process.
|
|
345
|
-
// --no-clear-screen: don't clear terminal on reload (CLI manages output)
|
|
346
|
-
args.push('--hot', '--no-clear-screen');
|
|
347
|
-
|
|
348
|
-
if (inspectBrk) {
|
|
349
|
-
args.push('--inspect-brk');
|
|
350
|
-
} else if (inspectWait) {
|
|
351
|
-
args.push('--inspect-wait');
|
|
352
|
-
} else if (inspect) {
|
|
353
|
-
args.push('--inspect');
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
args.push('run', appPath);
|
|
357
|
-
|
|
358
|
-
logger.debug('Spawning bun subprocess: %s', args.join(' '));
|
|
359
|
-
|
|
360
|
-
// Capture stderr for error reporting while still showing it in real-time
|
|
361
|
-
const stderrChunks: string[] = [];
|
|
362
|
-
const stdoutChunks: string[] = [];
|
|
363
|
-
|
|
364
|
-
// Helper to read a stream, capture output, and forward to parent
|
|
365
|
-
const captureStream = async (
|
|
366
|
-
stream: ReadableStream<Uint8Array>,
|
|
367
|
-
chunks: string[],
|
|
368
|
-
output: typeof process.stdout | typeof process.stderr
|
|
369
|
-
) => {
|
|
370
|
-
const reader = stream.getReader();
|
|
371
|
-
try {
|
|
372
|
-
while (true) {
|
|
373
|
-
const { done, value } = await reader.read();
|
|
374
|
-
if (done) break;
|
|
375
|
-
const str = new TextDecoder().decode(value);
|
|
376
|
-
chunks.push(str);
|
|
377
|
-
output.write(value); // Forward to parent for real-time visibility
|
|
378
|
-
}
|
|
379
|
-
} catch {
|
|
380
|
-
// Stream may be closed unexpectedly when process exits
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
const bunProcess = Bun.spawn(args, {
|
|
385
|
-
cwd: rootDir,
|
|
386
|
-
stdout: 'pipe',
|
|
387
|
-
stderr: 'pipe',
|
|
388
|
-
env: {
|
|
389
|
-
...process.env,
|
|
390
|
-
...getAgentEnv(),
|
|
391
|
-
PORT: String(port),
|
|
392
|
-
FORCE_COLOR: '1', // Enable colors even though stdout is piped
|
|
393
|
-
},
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
// Start capturing streams in the background (don't await, we need to check server readiness)
|
|
397
|
-
if (bunProcess.stdout) {
|
|
398
|
-
captureStream(bunProcess.stdout, stdoutChunks, process.stdout).catch(() => {});
|
|
399
|
-
}
|
|
400
|
-
if (bunProcess.stderr) {
|
|
401
|
-
captureStream(bunProcess.stderr, stderrChunks, process.stderr).catch(() => {});
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
405
|
-
(globalThis as any).__AGENTUITY_BUN_SUBPROCESS__ = bunProcess;
|
|
406
|
-
|
|
407
|
-
// Wait for server to start listening
|
|
408
|
-
const maxRetries = 50;
|
|
409
|
-
const retryDelay = 100;
|
|
410
|
-
const timeoutMs = maxRetries * retryDelay;
|
|
411
|
-
let serverReady = false;
|
|
412
|
-
|
|
413
|
-
for (let i = 0; i < maxRetries; i++) {
|
|
414
|
-
if (bunProcess.exitCode !== null) {
|
|
415
|
-
// Brief pause to let stream capture finish flushing
|
|
416
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
417
|
-
const stderr = stderrChunks.join('');
|
|
418
|
-
const stdout = stdoutChunks.join('');
|
|
419
|
-
const output = [stderr, stdout].filter(Boolean).join('\n');
|
|
420
|
-
throw new Error(
|
|
421
|
-
`Bun subprocess exited with code ${bunProcess.exitCode} during startup\n\n${output}`
|
|
422
|
-
);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
try {
|
|
426
|
-
await fetch(`http://127.0.0.1:${port}/`, {
|
|
427
|
-
method: 'HEAD',
|
|
428
|
-
signal: AbortSignal.timeout(1000),
|
|
429
|
-
});
|
|
430
|
-
serverReady = true;
|
|
431
|
-
break;
|
|
432
|
-
} catch {
|
|
433
|
-
// Not ready yet
|
|
434
|
-
}
|
|
435
|
-
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
if (!serverReady) {
|
|
439
|
-
try {
|
|
440
|
-
bunProcess.kill();
|
|
441
|
-
} catch (err) {
|
|
442
|
-
logger.debug('Error killing subprocess during startup failure: %s', err);
|
|
443
|
-
}
|
|
444
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
445
|
-
(globalThis as any).__AGENTUITY_BUN_SUBPROCESS__ = undefined;
|
|
446
|
-
|
|
447
|
-
// Brief pause to let stream capture finish flushing
|
|
448
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
449
|
-
const stderr = stderrChunks.join('');
|
|
450
|
-
const stdout = stdoutChunks.join('');
|
|
451
|
-
throw new Error(buildStartupErrorMessage(port, timeoutMs, stderr, validation, stdout));
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
logger.debug(`Bun dev server started on http://127.0.0.1:${port} (--hot mode)`);
|
|
455
|
-
logger.debug(`Proxied to Vite:${vitePort}`);
|
|
456
|
-
|
|
457
|
-
return { bunServerPort: port };
|
|
458
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { join, dirname } from 'node:path';
|
|
2
|
-
import { mkdirSync, cpSync } from 'node:fs';
|
|
3
|
-
import type { Logger } from '../../../types';
|
|
4
|
-
|
|
5
|
-
/** Paths that are always excluded regardless of .gitignore */
|
|
6
|
-
function isHardExcluded(match: string): boolean {
|
|
7
|
-
return (
|
|
8
|
-
match.startsWith('.agentuity/') ||
|
|
9
|
-
match.startsWith('.agentuity\\') ||
|
|
10
|
-
match.startsWith('node_modules/') ||
|
|
11
|
-
match.startsWith('node_modules\\') ||
|
|
12
|
-
match.startsWith('.git/') ||
|
|
13
|
-
match.startsWith('.git\\') ||
|
|
14
|
-
match === '.env' ||
|
|
15
|
-
match.startsWith('.env.')
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Use `git check-ignore --stdin` to filter out files that are ignored by .gitignore.
|
|
21
|
-
* Returns the subset of `files` that are NOT gitignored.
|
|
22
|
-
* Falls back to returning all files if not in a git repo or git is unavailable.
|
|
23
|
-
*/
|
|
24
|
-
async function filterGitIgnored(
|
|
25
|
-
rootDir: string,
|
|
26
|
-
files: string[],
|
|
27
|
-
logger: Logger
|
|
28
|
-
): Promise<string[]> {
|
|
29
|
-
if (files.length === 0) return files;
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
// Check if we're in a git repo
|
|
33
|
-
const gitCheck = Bun.spawnSync(['git', 'rev-parse', '--git-dir'], {
|
|
34
|
-
cwd: rootDir,
|
|
35
|
-
stderr: 'pipe',
|
|
36
|
-
});
|
|
37
|
-
if (gitCheck.exitCode !== 0) {
|
|
38
|
-
logger.debug('Not a git repository, skipping .gitignore filtering');
|
|
39
|
-
return files;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Use git check-ignore to find which files are ignored
|
|
43
|
-
const proc = Bun.spawn(['git', 'check-ignore', '--stdin'], {
|
|
44
|
-
cwd: rootDir,
|
|
45
|
-
stdin: 'pipe',
|
|
46
|
-
stdout: 'pipe',
|
|
47
|
-
stderr: 'pipe',
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// Write all file paths to stdin, one per line
|
|
51
|
-
proc.stdin.write(files.join('\n'));
|
|
52
|
-
proc.stdin.end();
|
|
53
|
-
|
|
54
|
-
const output = await new Response(proc.stdout).text();
|
|
55
|
-
await proc.exited;
|
|
56
|
-
|
|
57
|
-
// git check-ignore exits 0 if some files are ignored, 1 if none are ignored.
|
|
58
|
-
// Both are fine. Other exit codes mean an error.
|
|
59
|
-
|
|
60
|
-
const ignoredFiles = output
|
|
61
|
-
.split('\n')
|
|
62
|
-
.map((line) => line.trim())
|
|
63
|
-
.filter(Boolean);
|
|
64
|
-
const ignoredSet = new Set(ignoredFiles);
|
|
65
|
-
|
|
66
|
-
if (ignoredSet.size > 0) {
|
|
67
|
-
logger.debug(`Filtered ${ignoredSet.size} gitignored file(s) from bundle`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return files.filter((f) => !ignoredSet.has(f));
|
|
71
|
-
} catch {
|
|
72
|
-
logger.debug('git not available, skipping .gitignore filtering');
|
|
73
|
-
return files;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Copy files matching glob patterns into the build output directory.
|
|
79
|
-
* Files are copied preserving their relative directory structure from the project root.
|
|
80
|
-
* This runs BEFORE the build steps so that build output can overwrite any conflicts.
|
|
81
|
-
*
|
|
82
|
-
* Filtering layers:
|
|
83
|
-
* 1. Hard exclusions: .agentuity/, node_modules/, .git/, .env* (always skipped)
|
|
84
|
-
* 2. .gitignore: files ignored by git are skipped (falls back if not a git repo)
|
|
85
|
-
*/
|
|
86
|
-
export async function copyBundleFiles(
|
|
87
|
-
rootDir: string,
|
|
88
|
-
outDir: string,
|
|
89
|
-
patterns: string[],
|
|
90
|
-
logger: Logger
|
|
91
|
-
): Promise<number> {
|
|
92
|
-
let totalCopied = 0;
|
|
93
|
-
|
|
94
|
-
// Ensure output directory exists
|
|
95
|
-
mkdirSync(outDir, { recursive: true });
|
|
96
|
-
|
|
97
|
-
for (const pattern of patterns) {
|
|
98
|
-
const glob = new Bun.Glob(pattern);
|
|
99
|
-
const candidates: string[] = [];
|
|
100
|
-
|
|
101
|
-
// Phase 1: Glob match + hard exclusions
|
|
102
|
-
for await (const match of glob.scan({ cwd: rootDir, onlyFiles: true })) {
|
|
103
|
-
if (!isHardExcluded(match)) {
|
|
104
|
-
candidates.push(match);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Phase 2: Filter out gitignored files
|
|
109
|
-
const filesToCopy = await filterGitIgnored(rootDir, candidates, logger);
|
|
110
|
-
|
|
111
|
-
// Phase 3: Copy files
|
|
112
|
-
for (const match of filesToCopy) {
|
|
113
|
-
const src = join(rootDir, match);
|
|
114
|
-
const dest = join(outDir, match);
|
|
115
|
-
try {
|
|
116
|
-
mkdirSync(dirname(dest), { recursive: true });
|
|
117
|
-
cpSync(src, dest);
|
|
118
|
-
} catch (err) {
|
|
119
|
-
throw new Error(
|
|
120
|
-
`Failed to copy bundle file '${match}' (pattern '${pattern}'): ${(err as Error).message}`
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (filesToCopy.length === 0) {
|
|
126
|
-
logger.warn(`Bundle pattern '${pattern}' matched no files`);
|
|
127
|
-
} else {
|
|
128
|
-
logger.debug(`Bundle pattern '${pattern}': ${filesToCopy.length} file(s)`);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
totalCopied += filesToCopy.length;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return totalCopied;
|
|
135
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Config loader for v2
|
|
3
|
-
*
|
|
4
|
-
* In v2, all runtime config (analytics, workbench) goes in createApp().
|
|
5
|
-
* Vite-specific config (plugins, define, render, bundle) goes in vite.config.ts.
|
|
6
|
-
*
|
|
7
|
-
* Runtime config values are extracted from app.ts via app-config-extractor.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { Logger } from '../../../types';
|
|
11
|
-
import { extractAppConfig, type ExtractedAppConfig } from '../app-config-extractor';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Load runtime config from createApp() in app.ts (v2 approach).
|
|
15
|
-
*
|
|
16
|
-
* This is the only way to get analytics/workbench config in v2.
|
|
17
|
-
* The CLI reads these values directly from the user's createApp() call.
|
|
18
|
-
*/
|
|
19
|
-
export async function loadRuntimeConfig(
|
|
20
|
-
rootDir: string,
|
|
21
|
-
logger: Logger
|
|
22
|
-
): Promise<ExtractedAppConfig> {
|
|
23
|
-
return extractAppConfig(rootDir, logger);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Get workbench configuration with defaults.
|
|
28
|
-
*
|
|
29
|
-
* In v2, workbench config is extracted from createApp() in app.ts.
|
|
30
|
-
*/
|
|
31
|
-
export function getWorkbenchConfig(
|
|
32
|
-
dev: boolean,
|
|
33
|
-
runtimeConfig?: ExtractedAppConfig
|
|
34
|
-
): {
|
|
35
|
-
configured: boolean;
|
|
36
|
-
enabled: boolean;
|
|
37
|
-
route: string;
|
|
38
|
-
headers: Record<string, string>;
|
|
39
|
-
} {
|
|
40
|
-
const workbenchFromRuntime = runtimeConfig?.workbench;
|
|
41
|
-
|
|
42
|
-
// Workbench is enabled if:
|
|
43
|
-
// 1. In dev mode (never in production)
|
|
44
|
-
// 2. Workbench is configured in createApp()
|
|
45
|
-
const hasWorkbench = workbenchFromRuntime !== undefined;
|
|
46
|
-
const configured = hasWorkbench;
|
|
47
|
-
const enabled = dev && hasWorkbench;
|
|
48
|
-
|
|
49
|
-
// Extract values from createApp()
|
|
50
|
-
let route = '/workbench';
|
|
51
|
-
let headers: Record<string, string> = {};
|
|
52
|
-
|
|
53
|
-
if (workbenchFromRuntime !== undefined) {
|
|
54
|
-
if (typeof workbenchFromRuntime === 'string') {
|
|
55
|
-
route = workbenchFromRuntime;
|
|
56
|
-
} else if (typeof workbenchFromRuntime === 'object' && workbenchFromRuntime !== null) {
|
|
57
|
-
if ('route' in workbenchFromRuntime && typeof workbenchFromRuntime.route === 'string') {
|
|
58
|
-
route = workbenchFromRuntime.route;
|
|
59
|
-
}
|
|
60
|
-
if (
|
|
61
|
-
'headers' in workbenchFromRuntime &&
|
|
62
|
-
typeof workbenchFromRuntime.headers === 'object'
|
|
63
|
-
) {
|
|
64
|
-
headers = workbenchFromRuntime.headers as Record<string, string>;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
// boolean true uses defaults
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
configured,
|
|
72
|
-
enabled,
|
|
73
|
-
route,
|
|
74
|
-
headers,
|
|
75
|
-
};
|
|
76
|
-
}
|