@agentuity/cli 2.0.10 → 2.0.12
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/cache/resource-region.d.ts.map +1 -1
- package/dist/cache/resource-region.js +48 -25
- package/dist/cache/resource-region.js.map +1 -1
- package/dist/cmd/build/vite/agent-discovery.js +4 -4
- package/dist/cmd/build/vite/agent-discovery.js.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.d.ts +20 -0
- package/dist/cmd/build/vite/bun-dev-server.d.ts.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.js +62 -4
- package/dist/cmd/build/vite/bun-dev-server.js.map +1 -1
- package/dist/cmd/build/vite/index.d.ts +0 -1
- package/dist/cmd/build/vite/index.d.ts.map +1 -1
- package/dist/cmd/build/vite/index.js +0 -1
- package/dist/cmd/build/vite/index.js.map +1 -1
- package/dist/cmd/build/vite/static-renderer.d.ts +17 -0
- package/dist/cmd/build/vite/static-renderer.d.ts.map +1 -1
- package/dist/cmd/build/vite/static-renderer.js +18 -6
- package/dist/cmd/build/vite/static-renderer.js.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server-config.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server-config.js +34 -27
- package/dist/cmd/build/vite/vite-asset-server-config.js.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server.d.ts +9 -0
- package/dist/cmd/build/vite/vite-asset-server.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server.js +5 -1
- package/dist/cmd/build/vite/vite-asset-server.js.map +1 -1
- package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-builder.js +12 -1
- package/dist/cmd/build/vite/vite-builder.js.map +1 -1
- package/dist/cmd/build/vite/ws-proxy.d.ts +15 -1
- package/dist/cmd/build/vite/ws-proxy.d.ts.map +1 -1
- package/dist/cmd/build/vite/ws-proxy.js +33 -0
- package/dist/cmd/build/vite/ws-proxy.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +98 -39
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/sandbox/checkpoint/create.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/checkpoint/create.js +3 -4
- package/dist/cmd/cloud/sandbox/checkpoint/create.js.map +1 -1
- package/dist/cmd/cloud/sandbox/checkpoint/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/checkpoint/delete.js +3 -4
- package/dist/cmd/cloud/sandbox/checkpoint/delete.js.map +1 -1
- package/dist/cmd/cloud/sandbox/checkpoint/list.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/checkpoint/list.js +3 -4
- package/dist/cmd/cloud/sandbox/checkpoint/list.js.map +1 -1
- package/dist/cmd/cloud/sandbox/checkpoint/restore.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/checkpoint/restore.js +3 -4
- package/dist/cmd/cloud/sandbox/checkpoint/restore.js.map +1 -1
- package/dist/cmd/cloud/sandbox/create.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/create.js +13 -4
- package/dist/cmd/cloud/sandbox/create.js.map +1 -1
- package/dist/cmd/cloud/sandbox/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/delete.js +3 -4
- package/dist/cmd/cloud/sandbox/delete.js.map +1 -1
- package/dist/cmd/cloud/sandbox/env.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/env.js +3 -5
- package/dist/cmd/cloud/sandbox/env.js.map +1 -1
- package/dist/cmd/cloud/sandbox/exec.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/exec.js +114 -41
- package/dist/cmd/cloud/sandbox/exec.js.map +1 -1
- package/dist/cmd/cloud/sandbox/execution/list.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/execution/list.js +3 -5
- package/dist/cmd/cloud/sandbox/execution/list.js.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/cp.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/cp.js +61 -113
- package/dist/cmd/cloud/sandbox/fs/cp.js.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/download.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/download.js +11 -22
- package/dist/cmd/cloud/sandbox/fs/download.js.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/ls.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/ls.js +3 -5
- package/dist/cmd/cloud/sandbox/fs/ls.js.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/mkdir.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/mkdir.js +3 -5
- package/dist/cmd/cloud/sandbox/fs/mkdir.js.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/rm.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/rm.js +3 -5
- package/dist/cmd/cloud/sandbox/fs/rm.js.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/rmdir.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/rmdir.js +3 -5
- package/dist/cmd/cloud/sandbox/fs/rmdir.js.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/upload.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/fs/upload.js +7 -8
- package/dist/cmd/cloud/sandbox/fs/upload.js.map +1 -1
- package/dist/cmd/cloud/sandbox/get.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/get.js +21 -7
- package/dist/cmd/cloud/sandbox/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/job/create.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/job/create.js +3 -4
- package/dist/cmd/cloud/sandbox/job/create.js.map +1 -1
- package/dist/cmd/cloud/sandbox/job/destroy.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/job/destroy.js +3 -4
- package/dist/cmd/cloud/sandbox/job/destroy.js.map +1 -1
- package/dist/cmd/cloud/sandbox/job/get.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/job/get.js +3 -4
- package/dist/cmd/cloud/sandbox/job/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/job/list.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/job/list.js +3 -4
- package/dist/cmd/cloud/sandbox/job/list.js.map +1 -1
- package/dist/cmd/cloud/sandbox/job/logs.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/job/logs.js +4 -4
- package/dist/cmd/cloud/sandbox/job/logs.js.map +1 -1
- package/dist/cmd/cloud/sandbox/pause.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/pause.js +21 -5
- package/dist/cmd/cloud/sandbox/pause.js.map +1 -1
- package/dist/cmd/cloud/sandbox/resume.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/resume.js +3 -4
- package/dist/cmd/cloud/sandbox/resume.js.map +1 -1
- package/dist/cmd/cloud/sandbox/run.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/run.js +36 -7
- package/dist/cmd/cloud/sandbox/run.js.map +1 -1
- package/dist/cmd/cloud/sandbox/util.d.ts +19 -0
- package/dist/cmd/cloud/sandbox/util.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/util.js +40 -2
- package/dist/cmd/cloud/sandbox/util.js.map +1 -1
- package/dist/cmd/coder/create.d.ts.map +1 -1
- package/dist/cmd/coder/create.js +18 -0
- package/dist/cmd/coder/create.js.map +1 -1
- package/dist/cmd/coder/index.d.ts.map +1 -1
- package/dist/cmd/coder/index.js +4 -0
- package/dist/cmd/coder/index.js.map +1 -1
- package/dist/cmd/coder/start.d.ts.map +1 -1
- package/dist/cmd/coder/start.js +52 -1
- package/dist/cmd/coder/start.js.map +1 -1
- package/dist/cmd/coder/tui-init.js +1 -1
- package/dist/cmd/coder/tui-init.js.map +1 -1
- package/dist/cmd/coder/update.d.ts.map +1 -1
- package/dist/cmd/coder/update.js +21 -1
- package/dist/cmd/coder/update.js.map +1 -1
- package/dist/cmd/coder/workspace/create.d.ts.map +1 -1
- package/dist/cmd/coder/workspace/create.js +57 -13
- package/dist/cmd/coder/workspace/create.js.map +1 -1
- package/dist/cmd/coder/workspace/index.d.ts.map +1 -1
- package/dist/cmd/coder/workspace/index.js +1 -1
- package/dist/cmd/coder/workspace/index.js.map +1 -1
- package/dist/cmd/coder/workspace/list.js +2 -2
- package/dist/cmd/coder/workspace/list.js.map +1 -1
- package/dist/cmd/dev/dev-lock.d.ts.map +1 -1
- package/dist/cmd/dev/dev-lock.js +43 -17
- package/dist/cmd/dev/dev-lock.js.map +1 -1
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/index.js +211 -125
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/dev/process-manager.d.ts +41 -1
- package/dist/cmd/dev/process-manager.d.ts.map +1 -1
- package/dist/cmd/dev/process-manager.js +160 -31
- package/dist/cmd/dev/process-manager.js.map +1 -1
- package/dist/cmd/project/create.d.ts.map +1 -1
- package/dist/cmd/project/create.js +0 -2
- package/dist/cmd/project/create.js.map +1 -1
- package/dist/cmd/project/index.d.ts.map +1 -1
- package/dist/cmd/project/index.js +0 -3
- package/dist/cmd/project/index.js.map +1 -1
- package/dist/cmd/project/template-flow.d.ts +0 -1
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- package/dist/cmd/project/template-flow.js +1 -124
- package/dist/cmd/project/template-flow.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +7 -7
- package/src/cache/resource-region.ts +68 -44
- package/src/cmd/ai/prompt/web.md +43 -17
- package/src/cmd/build/vite/agent-discovery.ts +4 -4
- package/src/cmd/build/vite/bun-dev-server.ts +92 -6
- package/src/cmd/build/vite/index.ts +0 -1
- package/src/cmd/build/vite/static-renderer.ts +18 -7
- package/src/cmd/build/vite/vite-asset-server-config.ts +37 -27
- package/src/cmd/build/vite/vite-asset-server.ts +5 -1
- package/src/cmd/build/vite/vite-builder.ts +12 -1
- package/src/cmd/build/vite/ws-proxy.ts +52 -3
- package/src/cmd/cloud/deploy.ts +117 -49
- package/src/cmd/cloud/sandbox/checkpoint/create.ts +10 -4
- package/src/cmd/cloud/sandbox/checkpoint/delete.ts +10 -4
- package/src/cmd/cloud/sandbox/checkpoint/list.ts +10 -4
- package/src/cmd/cloud/sandbox/checkpoint/restore.ts +10 -4
- package/src/cmd/cloud/sandbox/create.ts +14 -4
- package/src/cmd/cloud/sandbox/delete.ts +10 -4
- package/src/cmd/cloud/sandbox/env.ts +10 -5
- package/src/cmd/cloud/sandbox/exec.ts +157 -42
- package/src/cmd/cloud/sandbox/execution/list.ts +10 -5
- package/src/cmd/cloud/sandbox/fs/cp.ts +94 -126
- package/src/cmd/cloud/sandbox/fs/download.ts +18 -25
- package/src/cmd/cloud/sandbox/fs/ls.ts +10 -5
- package/src/cmd/cloud/sandbox/fs/mkdir.ts +10 -5
- package/src/cmd/cloud/sandbox/fs/rm.ts +10 -5
- package/src/cmd/cloud/sandbox/fs/rmdir.ts +10 -5
- package/src/cmd/cloud/sandbox/fs/upload.ts +14 -8
- package/src/cmd/cloud/sandbox/get.ts +28 -7
- package/src/cmd/cloud/sandbox/job/create.ts +10 -4
- package/src/cmd/cloud/sandbox/job/destroy.ts +10 -4
- package/src/cmd/cloud/sandbox/job/get.ts +10 -4
- package/src/cmd/cloud/sandbox/job/list.ts +10 -4
- package/src/cmd/cloud/sandbox/job/logs.ts +11 -4
- package/src/cmd/cloud/sandbox/pause.ts +31 -5
- package/src/cmd/cloud/sandbox/resume.ts +10 -4
- package/src/cmd/cloud/sandbox/run.ts +49 -11
- package/src/cmd/cloud/sandbox/util.ts +63 -2
- package/src/cmd/coder/create.ts +24 -1
- package/src/cmd/coder/index.ts +4 -0
- package/src/cmd/coder/start.ts +63 -1
- package/src/cmd/coder/tui-init.ts +1 -1
- package/src/cmd/coder/update.ts +18 -1
- package/src/cmd/coder/workspace/create.ts +84 -15
- package/src/cmd/coder/workspace/index.ts +3 -1
- package/src/cmd/coder/workspace/list.ts +2 -2
- package/src/cmd/dev/dev-lock.ts +50 -16
- package/src/cmd/dev/index.ts +249 -134
- package/src/cmd/dev/process-manager.ts +173 -33
- package/src/cmd/project/create.ts +0 -2
- package/src/cmd/project/index.ts +0 -3
- package/src/cmd/project/template-flow.ts +0 -147
- 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/project/auth/generate.d.ts +0 -5
- package/dist/cmd/project/auth/generate.d.ts.map +0 -1
- package/dist/cmd/project/auth/generate.js +0 -102
- package/dist/cmd/project/auth/generate.js.map +0 -1
- package/dist/cmd/project/auth/index.d.ts +0 -2
- package/dist/cmd/project/auth/index.d.ts.map +0 -1
- package/dist/cmd/project/auth/index.js +0 -21
- package/dist/cmd/project/auth/index.js.map +0 -1
- package/dist/cmd/project/auth/init.d.ts +0 -2
- package/dist/cmd/project/auth/init.d.ts.map +0 -1
- package/dist/cmd/project/auth/init.js +0 -213
- package/dist/cmd/project/auth/init.js.map +0 -1
- package/dist/cmd/project/auth/shared.d.ts +0 -93
- package/dist/cmd/project/auth/shared.d.ts.map +0 -1
- package/dist/cmd/project/auth/shared.js +0 -475
- package/dist/cmd/project/auth/shared.js.map +0 -1
- package/src/cmd/build/vite/public-asset-path-plugin.ts +0 -209
- package/src/cmd/project/auth/generate.ts +0 -116
- package/src/cmd/project/auth/index.ts +0 -21
- package/src/cmd/project/auth/init.ts +0 -256
- package/src/cmd/project/auth/shared.ts +0 -591
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vite plugin to fix incorrect public asset paths
|
|
3
|
-
*
|
|
4
|
-
* Developers should use /public/ paths for static assets from src/web/public/.
|
|
5
|
-
* In production, these paths are transformed to CDN URLs.
|
|
6
|
-
*
|
|
7
|
-
* This plugin:
|
|
8
|
-
* 1. During build: Rewrites /public/* paths to CDN URLs
|
|
9
|
-
* 2. During dev: Warns only about incorrect source paths (src/web/public/)
|
|
10
|
-
*
|
|
11
|
-
* Supported patterns (work in dev, rewritten to CDN in production):
|
|
12
|
-
* - '/public/foo.svg' → CDN URL (recommended)
|
|
13
|
-
* - './public/foo.svg' → CDN URL
|
|
14
|
-
* - 'url(/public/foo.svg)' → CDN URL (CSS unquoted)
|
|
15
|
-
* - 'url(./public/foo.svg)' → CDN URL (CSS unquoted)
|
|
16
|
-
*
|
|
17
|
-
* Incorrect patterns (warned in dev, rewritten in production):
|
|
18
|
-
* - '/src/web/public/foo.svg' → CDN URL
|
|
19
|
-
* - './src/web/public/foo.svg' → CDN URL
|
|
20
|
-
* - 'src/web/public/foo.svg' → CDN URL
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import type { Plugin } from 'vite';
|
|
24
|
-
|
|
25
|
-
export interface PublicAssetPathPluginOptions {
|
|
26
|
-
/** Whether to show warnings in dev mode (default: true) */
|
|
27
|
-
warnInDev?: boolean;
|
|
28
|
-
/** CDN base URL for production builds (e.g., 'https://cdn.agentuity.com/{deploymentId}/client/') */
|
|
29
|
-
cdnBaseUrl?: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface PathPattern {
|
|
33
|
-
regex: RegExp;
|
|
34
|
-
description: string;
|
|
35
|
-
/** Replacement template - use {base} for the target base URL */
|
|
36
|
-
replacement: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Patterns that are incorrect - reference source paths directly
|
|
41
|
-
*/
|
|
42
|
-
function createIncorrectPatterns(): PathPattern[] {
|
|
43
|
-
return [
|
|
44
|
-
// '/src/web/public/...' or './src/web/public/...' or 'src/web/public/...'
|
|
45
|
-
{
|
|
46
|
-
regex: /(['"`])(?:\.?\/)?src\/web\/public\//g,
|
|
47
|
-
description: 'src/web/public/',
|
|
48
|
-
replacement: '$1{base}',
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Patterns that need rewriting for production CDN
|
|
55
|
-
* Both patterns simply replace the prefix while preserving the rest of the path naturally.
|
|
56
|
-
*/
|
|
57
|
-
function createPublicPatterns(): PathPattern[] {
|
|
58
|
-
return [
|
|
59
|
-
// './public/...' (relative public path) - replace prefix, keep rest
|
|
60
|
-
{
|
|
61
|
-
regex: /(['"`])\.\/public\//g,
|
|
62
|
-
description: './public/',
|
|
63
|
-
replacement: '$1{base}',
|
|
64
|
-
},
|
|
65
|
-
// '/public/...' (absolute public path) - replace prefix, keep rest
|
|
66
|
-
{
|
|
67
|
-
regex: /(['"`])\/public\//g,
|
|
68
|
-
description: '/public/',
|
|
69
|
-
replacement: '$1{base}',
|
|
70
|
-
},
|
|
71
|
-
// CSS url(/public/...) — unquoted path inside url()
|
|
72
|
-
{
|
|
73
|
-
regex: /url\(\/public\//g,
|
|
74
|
-
description: 'url(/public/)',
|
|
75
|
-
replacement: 'url({base}',
|
|
76
|
-
},
|
|
77
|
-
// CSS url(./public/...) — unquoted relative path inside url()
|
|
78
|
-
{
|
|
79
|
-
regex: /url\(\.\/public\//g,
|
|
80
|
-
description: 'url(./public/)',
|
|
81
|
-
replacement: 'url({base}',
|
|
82
|
-
},
|
|
83
|
-
];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Vite plugin that fixes public asset paths and rewrites to CDN URLs
|
|
88
|
-
*
|
|
89
|
-
* Rewrites all public asset paths to CDN URLs in production.
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* // In vite config:
|
|
93
|
-
* plugins: [publicAssetPathPlugin({ cdnBaseUrl: 'https://cdn.example.com/deploy/client/' })]
|
|
94
|
-
*
|
|
95
|
-
* // In code, use /public/ paths:
|
|
96
|
-
* <img src="/public/logo.svg" />
|
|
97
|
-
*
|
|
98
|
-
* // Transforms in production:
|
|
99
|
-
* // '/public/logo.svg' → 'https://cdn.example.com/deploy/client/logo.svg'
|
|
100
|
-
*/
|
|
101
|
-
export function publicAssetPathPlugin(options: PublicAssetPathPluginOptions = {}): Plugin {
|
|
102
|
-
const { warnInDev = true, cdnBaseUrl } = options;
|
|
103
|
-
|
|
104
|
-
let isDev = false;
|
|
105
|
-
const warnedFiles = new Map<string, Set<string>>(); // file -> set of patterns warned
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
name: 'agentuity:public-asset-path',
|
|
109
|
-
|
|
110
|
-
configResolved(config) {
|
|
111
|
-
isDev = config.command === 'serve';
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
transform(code, id) {
|
|
115
|
-
// Only transform files in src/web (browser code)
|
|
116
|
-
if (!id.includes('/src/web/') && !id.includes('\\src\\web\\')) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Quick check: does the code contain any patterns we care about?
|
|
121
|
-
const hasIncorrectSourcePaths = code.includes('src/web/public/');
|
|
122
|
-
const hasPublicPaths = code.includes('/public/') || code.includes('./public/');
|
|
123
|
-
|
|
124
|
-
if (!hasIncorrectSourcePaths && !hasPublicPaths) {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// In dev mode, only warn about incorrect source paths (src/web/public/)
|
|
129
|
-
// /public/ and ./public/ paths work correctly in dev mode
|
|
130
|
-
if (isDev) {
|
|
131
|
-
if (warnInDev && hasIncorrectSourcePaths) {
|
|
132
|
-
const patterns = createIncorrectPatterns();
|
|
133
|
-
const foundPatterns: string[] = [];
|
|
134
|
-
|
|
135
|
-
for (const { regex, description } of patterns) {
|
|
136
|
-
if (regex.test(code)) {
|
|
137
|
-
foundPatterns.push(description);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (foundPatterns.length > 0) {
|
|
142
|
-
const fileWarnings = warnedFiles.get(id) || new Set();
|
|
143
|
-
const newWarnings = foundPatterns.filter((p) => !fileWarnings.has(p));
|
|
144
|
-
|
|
145
|
-
if (newWarnings.length > 0) {
|
|
146
|
-
for (const p of newWarnings) {
|
|
147
|
-
fileWarnings.add(p);
|
|
148
|
-
}
|
|
149
|
-
warnedFiles.set(id, fileWarnings);
|
|
150
|
-
|
|
151
|
-
this.warn(
|
|
152
|
-
`Found incorrect asset path(s) in ${id}:\n` +
|
|
153
|
-
newWarnings.map((p) => ` - '${p}' should be '/public/'`).join('\n') +
|
|
154
|
-
`\nUse '/public/...' paths for static assets.`
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
// In dev mode, never transform - Vite serves from source paths
|
|
160
|
-
// and the Bun server proxies /public/* to Vite
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Build mode: transform paths to CDN URLs
|
|
165
|
-
let transformed = code;
|
|
166
|
-
|
|
167
|
-
// Determine target URL: CDN base if provided, otherwise /public/
|
|
168
|
-
const targetBase = cdnBaseUrl
|
|
169
|
-
? cdnBaseUrl.endsWith('/')
|
|
170
|
-
? cdnBaseUrl
|
|
171
|
-
: `${cdnBaseUrl}/`
|
|
172
|
-
: '/public/';
|
|
173
|
-
|
|
174
|
-
// Transform incorrect source paths (src/web/public/) → CDN
|
|
175
|
-
if (hasIncorrectSourcePaths) {
|
|
176
|
-
const patterns = createIncorrectPatterns();
|
|
177
|
-
for (const { regex, replacement } of patterns) {
|
|
178
|
-
const replaceRegex = new RegExp(regex.source, regex.flags);
|
|
179
|
-
transformed = transformed.replace(
|
|
180
|
-
replaceRegex,
|
|
181
|
-
replacement.replace('{base}', targetBase)
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Transform public paths → CDN
|
|
187
|
-
if (hasPublicPaths) {
|
|
188
|
-
const publicPatterns = createPublicPatterns();
|
|
189
|
-
for (const { regex, replacement } of publicPatterns) {
|
|
190
|
-
const replaceRegex = new RegExp(regex.source, regex.flags);
|
|
191
|
-
transformed = transformed.replace(
|
|
192
|
-
replaceRegex,
|
|
193
|
-
replacement.replace('{base}', targetBase)
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Return transformed code if changed
|
|
199
|
-
if (transformed !== code) {
|
|
200
|
-
return {
|
|
201
|
-
code: transformed,
|
|
202
|
-
map: null,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return null;
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate auth schema SQL using drizzle-kit export
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import * as fs from 'node:fs';
|
|
7
|
-
import * as path from 'node:path';
|
|
8
|
-
import { createSubcommand } from '../../../types';
|
|
9
|
-
import * as tui from '../../../tui';
|
|
10
|
-
import { getCommand } from '../../../command-prefix';
|
|
11
|
-
import { generateAuthSchemaSql, getGeneratedSqlDir } from './shared';
|
|
12
|
-
|
|
13
|
-
export const generateSubcommand = createSubcommand({
|
|
14
|
-
name: 'generate',
|
|
15
|
-
description: 'Generate SQL schema for Agentuity Auth tables',
|
|
16
|
-
tags: ['slow'],
|
|
17
|
-
requires: { project: true },
|
|
18
|
-
examples: [
|
|
19
|
-
{
|
|
20
|
-
command: getCommand('project auth generate'),
|
|
21
|
-
description: 'Generate SQL schema and save to agentuity-auth-schema.sql',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
command: getCommand('project auth generate --output ./migrations/auth.sql'),
|
|
25
|
-
description: 'Generate schema to a custom path',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
command: getCommand('project auth generate --output -'),
|
|
29
|
-
description: 'Output SQL to stdout',
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
schema: {
|
|
33
|
-
options: z.object({
|
|
34
|
-
output: z
|
|
35
|
-
.string()
|
|
36
|
-
.optional()
|
|
37
|
-
.describe(
|
|
38
|
-
'Output path for generated SQL (default: ./agentuity-auth-schema.sql). Use "-" for stdout.'
|
|
39
|
-
),
|
|
40
|
-
}),
|
|
41
|
-
response: z.object({
|
|
42
|
-
success: z.boolean().describe('Whether generation succeeded'),
|
|
43
|
-
outputPath: z.string().optional().describe('Path where SQL was written'),
|
|
44
|
-
}),
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
async handler(ctx) {
|
|
48
|
-
const { logger, opts, projectDir, options } = ctx;
|
|
49
|
-
const explicitOutput = opts?.output as string | undefined;
|
|
50
|
-
const toStdout = explicitOutput === '-';
|
|
51
|
-
const isJson = options?.json === true;
|
|
52
|
-
|
|
53
|
-
if (!toStdout && !isJson) {
|
|
54
|
-
tui.newline();
|
|
55
|
-
tui.info(tui.bold('Agentuity Auth Schema Generation'));
|
|
56
|
-
tui.newline();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
const sql = isJson
|
|
61
|
-
? await generateAuthSchemaSql(logger, projectDir)
|
|
62
|
-
: await tui.spinner({
|
|
63
|
-
message: 'Generating auth schema SQL from Drizzle schema',
|
|
64
|
-
clearOnSuccess: true,
|
|
65
|
-
callback: () => generateAuthSchemaSql(logger, projectDir),
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
if (toStdout) {
|
|
69
|
-
console.log(sql);
|
|
70
|
-
return { success: true };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
let outputPath: string;
|
|
74
|
-
let displayPath: string;
|
|
75
|
-
|
|
76
|
-
if (explicitOutput) {
|
|
77
|
-
outputPath = path.resolve(projectDir, explicitOutput);
|
|
78
|
-
displayPath = explicitOutput;
|
|
79
|
-
} else {
|
|
80
|
-
const sqlOutputDir = await getGeneratedSqlDir(projectDir);
|
|
81
|
-
const sqlFileName = 'agentuity-auth-schema.sql';
|
|
82
|
-
outputPath = path.join(sqlOutputDir, sqlFileName);
|
|
83
|
-
displayPath =
|
|
84
|
-
sqlOutputDir === projectDir ? sqlFileName : path.relative(projectDir, outputPath);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
fs.writeFileSync(outputPath, sql);
|
|
88
|
-
|
|
89
|
-
if (!isJson) {
|
|
90
|
-
tui.success(`Auth schema SQL saved to ${tui.bold(displayPath)}`);
|
|
91
|
-
tui.newline();
|
|
92
|
-
tui.info('Next steps:');
|
|
93
|
-
console.log(' 1. Review the generated SQL file');
|
|
94
|
-
console.log(' 2. Run the SQL against your database');
|
|
95
|
-
console.log(` ${tui.muted('Or use: agentuity project auth init')}`);
|
|
96
|
-
tui.newline();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return { success: true, outputPath };
|
|
100
|
-
} catch (error) {
|
|
101
|
-
logger.error('Schema generation failed', { error });
|
|
102
|
-
|
|
103
|
-
if (!isJson) {
|
|
104
|
-
tui.error(
|
|
105
|
-
`Schema generation failed: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
106
|
-
);
|
|
107
|
-
tui.newline();
|
|
108
|
-
tui.info('Make sure you have:');
|
|
109
|
-
console.log(' 1. @agentuity/auth installed as a dependency');
|
|
110
|
-
console.log(' 2. drizzle-kit available (installed with @agentuity/auth)');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return { success: false };
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createCommand } from '../../../types';
|
|
2
|
-
import { initSubcommand } from './init';
|
|
3
|
-
import { generateSubcommand } from './generate';
|
|
4
|
-
import { getCommand } from '../../../command-prefix';
|
|
5
|
-
|
|
6
|
-
export const authCommand = createCommand({
|
|
7
|
-
name: 'auth',
|
|
8
|
-
description: 'Manage project authentication (Agentuity Auth)',
|
|
9
|
-
tags: ['slow', 'requires-auth'],
|
|
10
|
-
examples: [
|
|
11
|
-
{
|
|
12
|
-
command: getCommand('project auth init'),
|
|
13
|
-
description: 'Set up Agentuity Auth for an existing project',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
command: getCommand('project auth generate'),
|
|
17
|
-
description: 'Generate SQL schema for auth tables',
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
subcommands: [initSubcommand, generateSubcommand],
|
|
21
|
-
});
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import enquirer from 'enquirer';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
import { getCommand } from '../../../command-prefix';
|
|
6
|
-
import { readEnvFile, writeEnvFile } from '../../../env-util';
|
|
7
|
-
import * as tui from '../../../tui';
|
|
8
|
-
import { createSubcommand } from '../../../types';
|
|
9
|
-
import {
|
|
10
|
-
detectOrmSetup,
|
|
11
|
-
ensureAuthDependencies,
|
|
12
|
-
generateAuthFileContent,
|
|
13
|
-
generateAuthSchemaSql,
|
|
14
|
-
getGeneratedSqlDir,
|
|
15
|
-
printIntegrationExamples,
|
|
16
|
-
runAuthMigrations,
|
|
17
|
-
selectOrCreateDatabase,
|
|
18
|
-
} from './shared';
|
|
19
|
-
|
|
20
|
-
export const initSubcommand = createSubcommand({
|
|
21
|
-
name: 'init',
|
|
22
|
-
description: 'Set up Agentuity Auth for your project',
|
|
23
|
-
tags: ['mutating', 'slow', 'requires-auth'],
|
|
24
|
-
requires: { auth: true, org: true },
|
|
25
|
-
idempotent: false,
|
|
26
|
-
examples: [
|
|
27
|
-
{
|
|
28
|
-
command: getCommand('project auth init'),
|
|
29
|
-
description: 'Set up Agentuity Auth with database selection',
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
schema: {
|
|
33
|
-
options: z.object({
|
|
34
|
-
skipMigrations: z
|
|
35
|
-
.boolean()
|
|
36
|
-
.optional()
|
|
37
|
-
.describe(
|
|
38
|
-
'Skip running database migrations (run `agentuity project auth generate` later)'
|
|
39
|
-
),
|
|
40
|
-
}),
|
|
41
|
-
response: z.object({
|
|
42
|
-
success: z.boolean().describe('Whether setup succeeded'),
|
|
43
|
-
database: z.string().optional().describe('Database name used'),
|
|
44
|
-
authFileCreated: z.boolean().describe('Whether auth.ts was created'),
|
|
45
|
-
migrationsRun: z.boolean().describe('Whether migrations were run'),
|
|
46
|
-
}),
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
async handler(ctx) {
|
|
50
|
-
const { logger, opts, auth, orgId, config } = ctx;
|
|
51
|
-
|
|
52
|
-
tui.newline();
|
|
53
|
-
tui.info(tui.bold('Agentuity Auth Setup'));
|
|
54
|
-
tui.newline();
|
|
55
|
-
tui.info('This will:');
|
|
56
|
-
console.log(' • Ensure you have a Postgres database configured');
|
|
57
|
-
console.log(' • Install @agentuity/auth');
|
|
58
|
-
console.log(' • Run database migrations to create auth tables');
|
|
59
|
-
console.log(' • Show you how to wire auth into your API and UI');
|
|
60
|
-
tui.newline();
|
|
61
|
-
|
|
62
|
-
const projectDir = process.cwd();
|
|
63
|
-
|
|
64
|
-
// Check for package.json
|
|
65
|
-
const packageJsonPath = path.join(projectDir, 'package.json');
|
|
66
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
67
|
-
tui.fatal('No package.json found. Run this command from your project root.');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Step 1: Check for DATABASE_URL or select/create database
|
|
71
|
-
let databaseUrl = process.env.DATABASE_URL;
|
|
72
|
-
|
|
73
|
-
if (!databaseUrl) {
|
|
74
|
-
// Check .env file
|
|
75
|
-
const envPath = path.join(projectDir, '.env');
|
|
76
|
-
if (fs.existsSync(envPath)) {
|
|
77
|
-
const envContent = fs.readFileSync(envPath, 'utf-8');
|
|
78
|
-
const match = envContent.match(/^DATABASE_URL=(.+)$/m);
|
|
79
|
-
if (match?.[1]) {
|
|
80
|
-
databaseUrl = match[1].trim().replace(/^["']|["']$/g, '');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Show database picker (with existing as first option if configured)
|
|
86
|
-
const dbInfo = await selectOrCreateDatabase({
|
|
87
|
-
logger,
|
|
88
|
-
auth,
|
|
89
|
-
orgId,
|
|
90
|
-
config,
|
|
91
|
-
existingUrl: databaseUrl,
|
|
92
|
-
projectDir,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// Get the region from the selected database
|
|
96
|
-
const region = dbInfo.region;
|
|
97
|
-
|
|
98
|
-
const databaseName = dbInfo.name;
|
|
99
|
-
|
|
100
|
-
// Update .env with database URL using proper parsing
|
|
101
|
-
const envPath = path.join(projectDir, '.env');
|
|
102
|
-
const existingEnv = await readEnvFile(envPath);
|
|
103
|
-
|
|
104
|
-
// Check if DATABASE_URL already exists
|
|
105
|
-
const hasDatabaseUrl = 'DATABASE_URL' in existingEnv;
|
|
106
|
-
|
|
107
|
-
if (dbInfo.url !== databaseUrl || !hasDatabaseUrl) {
|
|
108
|
-
if (hasDatabaseUrl) {
|
|
109
|
-
// DATABASE_URL exists, use AUTH_DATABASE_URL instead
|
|
110
|
-
await writeEnvFile(envPath, { AUTH_DATABASE_URL: dbInfo.url });
|
|
111
|
-
tui.success('AUTH_DATABASE_URL added to .env');
|
|
112
|
-
tui.warning(
|
|
113
|
-
`DATABASE_URL already exists. Update your ${tui.bold('src/auth.ts')} to use AUTH_DATABASE_URL.`
|
|
114
|
-
);
|
|
115
|
-
} else {
|
|
116
|
-
await writeEnvFile(envPath, { DATABASE_URL: dbInfo.url });
|
|
117
|
-
tui.success('DATABASE_URL added to .env');
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
tui.success(`Using database: ${databaseName}`);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Add AGENTUITY_AUTH_SECRET if not present
|
|
124
|
-
// Re-read env to get latest state
|
|
125
|
-
const currentEnv = await readEnvFile(envPath);
|
|
126
|
-
|
|
127
|
-
const hasAuthSecret =
|
|
128
|
-
'AGENTUITY_AUTH_SECRET' in currentEnv || 'BETTER_AUTH_SECRET' in currentEnv;
|
|
129
|
-
if (!hasAuthSecret) {
|
|
130
|
-
const devSecret = `dev-${crypto.randomUUID()}-CHANGE-ME`;
|
|
131
|
-
await writeEnvFile(envPath, { AGENTUITY_AUTH_SECRET: devSecret });
|
|
132
|
-
tui.success('AGENTUITY_AUTH_SECRET added to .env (development default)');
|
|
133
|
-
tui.warning(
|
|
134
|
-
`Replace ${tui.bold('AGENTUITY_AUTH_SECRET')} with a secure value before deploying.`
|
|
135
|
-
);
|
|
136
|
-
tui.info(`Generate one with: ${tui.muted('openssl rand -hex 32')}`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Step 2: Install dependencies
|
|
140
|
-
tui.newline();
|
|
141
|
-
await ensureAuthDependencies({ projectDir, logger });
|
|
142
|
-
|
|
143
|
-
// Step 3: Generate auth.ts if it doesn't exist
|
|
144
|
-
const authFilePath = path.join(projectDir, 'src', 'auth.ts');
|
|
145
|
-
let authFileCreated = false;
|
|
146
|
-
|
|
147
|
-
if (fs.existsSync(authFilePath)) {
|
|
148
|
-
tui.info('src/auth.ts already exists, skipping generation');
|
|
149
|
-
} else {
|
|
150
|
-
const { createFile } = await enquirer.prompt<{ createFile: boolean }>({
|
|
151
|
-
type: 'confirm',
|
|
152
|
-
name: 'createFile',
|
|
153
|
-
message: 'Create src/auth.ts with default configuration?',
|
|
154
|
-
initial: true,
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
if (createFile) {
|
|
158
|
-
// Ensure src directory exists
|
|
159
|
-
const srcDir = path.join(projectDir, 'src');
|
|
160
|
-
if (!fs.existsSync(srcDir)) {
|
|
161
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
fs.writeFileSync(authFilePath, generateAuthFileContent());
|
|
165
|
-
tui.success('Created src/auth.ts');
|
|
166
|
-
authFileCreated = true;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Step 4: Run migrations (ORM-aware)
|
|
171
|
-
let migrationsRun = false;
|
|
172
|
-
|
|
173
|
-
if (opts.skipMigrations) {
|
|
174
|
-
tui.info('Skipping migrations (run `agentuity project auth generate` later)');
|
|
175
|
-
} else if (databaseName) {
|
|
176
|
-
tui.newline();
|
|
177
|
-
|
|
178
|
-
const ormSetup = await detectOrmSetup(projectDir);
|
|
179
|
-
|
|
180
|
-
if (ormSetup === 'drizzle') {
|
|
181
|
-
tui.info(tui.bold('Drizzle detected in your project.'));
|
|
182
|
-
tui.newline();
|
|
183
|
-
console.log(
|
|
184
|
-
' Since you manage your own Drizzle schema, add authSchema to your schema:'
|
|
185
|
-
);
|
|
186
|
-
tui.newline();
|
|
187
|
-
console.log(tui.muted(" import * as authSchema from '@agentuity/auth/schema';"));
|
|
188
|
-
console.log(tui.muted(' export const schema = { ...authSchema, ...yourSchema };'));
|
|
189
|
-
tui.newline();
|
|
190
|
-
console.log(' Then run migrations:');
|
|
191
|
-
console.log(tui.muted(' bunx drizzle-kit push'));
|
|
192
|
-
tui.newline();
|
|
193
|
-
} else if (ormSetup === 'prisma') {
|
|
194
|
-
tui.info(tui.bold('Prisma detected in your project.'));
|
|
195
|
-
tui.newline();
|
|
196
|
-
|
|
197
|
-
const sql = await tui.spinner({
|
|
198
|
-
message: 'Preparing auth database schema...',
|
|
199
|
-
clearOnSuccess: true,
|
|
200
|
-
callback: () => generateAuthSchemaSql(logger, projectDir),
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
const sqlOutputDir = await getGeneratedSqlDir(projectDir);
|
|
204
|
-
const sqlFileName = 'agentuity-auth-schema.sql';
|
|
205
|
-
const sqlFilePath = path.join(sqlOutputDir, sqlFileName);
|
|
206
|
-
const relativePath =
|
|
207
|
-
sqlOutputDir === projectDir ? sqlFileName : path.relative(projectDir, sqlFilePath);
|
|
208
|
-
fs.writeFileSync(sqlFilePath, sql);
|
|
209
|
-
tui.success(`Auth schema SQL saved to ${tui.bold(relativePath)}`);
|
|
210
|
-
tui.newline();
|
|
211
|
-
console.log(' Run this SQL against your database to create auth tables.');
|
|
212
|
-
tui.newline();
|
|
213
|
-
} else {
|
|
214
|
-
const { runMigrations } = await enquirer.prompt<{ runMigrations: boolean }>({
|
|
215
|
-
type: 'confirm',
|
|
216
|
-
name: 'runMigrations',
|
|
217
|
-
message: 'Run database migrations now? (idempotent, safe to re-run)',
|
|
218
|
-
initial: true,
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
if (runMigrations) {
|
|
222
|
-
const sql = await tui.spinner({
|
|
223
|
-
message: 'Preparing auth database schema...',
|
|
224
|
-
clearOnSuccess: true,
|
|
225
|
-
callback: () => generateAuthSchemaSql(logger, projectDir),
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
await runAuthMigrations({
|
|
229
|
-
logger,
|
|
230
|
-
auth,
|
|
231
|
-
orgId,
|
|
232
|
-
region,
|
|
233
|
-
databaseName,
|
|
234
|
-
sql,
|
|
235
|
-
config,
|
|
236
|
-
});
|
|
237
|
-
migrationsRun = true;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
} else {
|
|
241
|
-
tui.warning(
|
|
242
|
-
'Could not determine database name. Run `agentuity project auth generate` manually.'
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Step 5: Print integration examples
|
|
247
|
-
printIntegrationExamples();
|
|
248
|
-
|
|
249
|
-
return {
|
|
250
|
-
success: true,
|
|
251
|
-
database: databaseName,
|
|
252
|
-
authFileCreated,
|
|
253
|
-
migrationsRun,
|
|
254
|
-
};
|
|
255
|
-
},
|
|
256
|
-
});
|