@agentuity/cli 1.0.1 → 1.0.3
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/AGENTS.md +40 -24
- package/bin/cli.ts +47 -22
- package/dist/agent-detection.d.ts +23 -38
- package/dist/agent-detection.d.ts.map +1 -1
- package/dist/agent-detection.js +412 -153
- package/dist/agent-detection.js.map +1 -1
- package/dist/ai-help.d.ts +23 -0
- package/dist/ai-help.d.ts.map +1 -0
- package/dist/ai-help.js +328 -0
- package/dist/ai-help.js.map +1 -0
- package/dist/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts +10 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +176 -16
- package/dist/auth.js.map +1 -1
- package/dist/banner.d.ts.map +1 -1
- package/dist/banner.js +5 -0
- package/dist/banner.js.map +1 -1
- package/dist/cache/agent-intro.d.ts +13 -0
- package/dist/cache/agent-intro.d.ts.map +1 -0
- package/dist/cache/agent-intro.js +54 -0
- package/dist/cache/agent-intro.js.map +1 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +1 -0
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/resource-region.d.ts +3 -2
- package/dist/cache/resource-region.d.ts.map +1 -1
- package/dist/cache/resource-region.js +13 -4
- package/dist/cache/resource-region.js.map +1 -1
- package/dist/catalyst.d.ts +7 -0
- package/dist/catalyst.d.ts.map +1 -0
- package/dist/catalyst.js +15 -0
- package/dist/catalyst.js.map +1 -0
- package/dist/cli.d.ts +12 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +290 -67
- package/dist/cli.js.map +1 -1
- package/dist/cmd/ai/detect.d.ts +3 -0
- package/dist/cmd/ai/detect.d.ts.map +1 -0
- package/dist/cmd/ai/detect.js +49 -0
- package/dist/cmd/ai/detect.js.map +1 -0
- package/dist/cmd/ai/index.d.ts.map +1 -1
- package/dist/cmd/ai/index.js +18 -1
- package/dist/cmd/ai/index.js.map +1 -1
- package/dist/cmd/ai/intro.d.ts +7 -0
- package/dist/cmd/ai/intro.d.ts.map +1 -0
- package/dist/cmd/ai/intro.js +141 -0
- package/dist/cmd/ai/intro.js.map +1 -0
- package/dist/cmd/ai/opencode/run.d.ts.map +1 -1
- package/dist/cmd/ai/opencode/run.js +5 -0
- package/dist/cmd/ai/opencode/run.js.map +1 -1
- package/dist/cmd/build/ast.d.ts.map +1 -1
- package/dist/cmd/build/ast.js +79 -0
- package/dist/cmd/build/ast.js.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.d.ts.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.js +2 -0
- package/dist/cmd/build/vite/bun-dev-server.js.map +1 -1
- package/dist/cmd/build/vite/docs-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/docs-generator.js +15 -1
- package/dist/cmd/build/vite/docs-generator.js.map +1 -1
- package/dist/cmd/build/vite/env-types-generator.d.ts +26 -0
- package/dist/cmd/build/vite/env-types-generator.d.ts.map +1 -0
- package/dist/cmd/build/vite/env-types-generator.js +110 -0
- package/dist/cmd/build/vite/env-types-generator.js.map +1 -0
- package/dist/cmd/build/vite/index.d.ts +2 -0
- package/dist/cmd/build/vite/index.d.ts.map +1 -1
- package/dist/cmd/build/vite/index.js +12 -1
- package/dist/cmd/build/vite/index.js.map +1 -1
- package/dist/cmd/build/vite/public-asset-path-plugin.d.ts.map +1 -1
- package/dist/cmd/build/vite/public-asset-path-plugin.js.map +1 -1
- package/dist/cmd/build/vite/vite-builder.d.ts +2 -0
- package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-builder.js +10 -1
- package/dist/cmd/build/vite/vite-builder.js.map +1 -1
- package/dist/cmd/cloud/db/create.js.map +1 -1
- package/dist/cmd/cloud/db/delete.js.map +1 -1
- package/dist/cmd/cloud/db/get.d.ts.map +1 -1
- package/dist/cmd/cloud/db/get.js +27 -12
- package/dist/cmd/cloud/db/get.js.map +1 -1
- package/dist/cmd/cloud/deploy-fork.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy-fork.js +2 -0
- package/dist/cmd/cloud/deploy-fork.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +17 -0
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/env/import.js.map +1 -1
- package/dist/cmd/cloud/env/list.js.map +1 -1
- package/dist/cmd/cloud/env/push.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/util.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/util.js +3 -3
- package/dist/cmd/cloud/keyvalue/util.js.map +1 -1
- package/dist/cmd/cloud/machine/list.js +3 -3
- package/dist/cmd/cloud/machine/list.js.map +1 -1
- package/dist/cmd/cloud/region/index.js.map +1 -1
- package/dist/cmd/cloud/region-lookup.d.ts +7 -4
- package/dist/cmd/cloud/region-lookup.d.ts.map +1 -1
- package/dist/cmd/cloud/region-lookup.js +59 -14
- package/dist/cmd/cloud/region-lookup.js.map +1 -1
- package/dist/cmd/cloud/sandbox/cp.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/cp.js +7 -5
- package/dist/cmd/cloud/sandbox/cp.js.map +1 -1
- package/dist/cmd/cloud/sandbox/create.js +2 -2
- 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 +8 -7
- package/dist/cmd/cloud/sandbox/delete.js.map +1 -1
- package/dist/cmd/cloud/sandbox/download.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/download.js +7 -5
- package/dist/cmd/cloud/sandbox/download.js.map +1 -1
- package/dist/cmd/cloud/sandbox/env.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/env.js +7 -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 +7 -5
- package/dist/cmd/cloud/sandbox/exec.js.map +1 -1
- package/dist/cmd/cloud/sandbox/get.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/get.js +12 -7
- package/dist/cmd/cloud/sandbox/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/list.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/list.js +40 -63
- package/dist/cmd/cloud/sandbox/list.js.map +1 -1
- package/dist/cmd/cloud/sandbox/ls.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/ls.js +7 -5
- package/dist/cmd/cloud/sandbox/ls.js.map +1 -1
- package/dist/cmd/cloud/sandbox/mkdir.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/mkdir.js +7 -5
- package/dist/cmd/cloud/sandbox/mkdir.js.map +1 -1
- package/dist/cmd/cloud/sandbox/rm.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/rm.js +7 -5
- package/dist/cmd/cloud/sandbox/rm.js.map +1 -1
- package/dist/cmd/cloud/sandbox/rmdir.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/rmdir.js +7 -5
- package/dist/cmd/cloud/sandbox/rmdir.js.map +1 -1
- package/dist/cmd/cloud/sandbox/run.js +1 -1
- package/dist/cmd/cloud/sandbox/run.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/build.js.map +1 -1
- package/dist/cmd/cloud/sandbox/snapshot/get.js.map +1 -1
- package/dist/cmd/cloud/sandbox/upload.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/upload.js +7 -5
- package/dist/cmd/cloud/sandbox/upload.js.map +1 -1
- package/dist/cmd/cloud/sandbox/util.d.ts +2 -2
- package/dist/cmd/cloud/sandbox/util.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/util.js +14 -13
- package/dist/cmd/cloud/sandbox/util.js.map +1 -1
- package/dist/cmd/cloud/ssh.d.ts.map +1 -1
- package/dist/cmd/cloud/ssh.js +3 -3
- package/dist/cmd/cloud/ssh.js.map +1 -1
- package/dist/cmd/cloud/storage/create.js.map +1 -1
- package/dist/cmd/cloud/storage/delete.js.map +1 -1
- package/dist/cmd/cloud/storage/get.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/get.js +5 -11
- package/dist/cmd/cloud/storage/get.js.map +1 -1
- package/dist/cmd/cloud/storage/list.d.ts.map +1 -1
- package/dist/cmd/cloud/storage/list.js +6 -6
- package/dist/cmd/cloud/storage/list.js.map +1 -1
- package/dist/cmd/cloud/stream/create.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/create.js +7 -4
- package/dist/cmd/cloud/stream/create.js.map +1 -1
- package/dist/cmd/cloud/stream/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/delete.js +25 -4
- package/dist/cmd/cloud/stream/delete.js.map +1 -1
- package/dist/cmd/cloud/stream/get.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/get.js +91 -62
- package/dist/cmd/cloud/stream/get.js.map +1 -1
- package/dist/cmd/cloud/stream/list.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/list.js +66 -38
- package/dist/cmd/cloud/stream/list.js.map +1 -1
- package/dist/cmd/cloud/stream/util.d.ts +20 -0
- package/dist/cmd/cloud/stream/util.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/util.js +27 -3
- package/dist/cmd/cloud/stream/util.js.map +1 -1
- package/dist/cmd/cloud/vector/util.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/util.js +3 -3
- package/dist/cmd/cloud/vector/util.js.map +1 -1
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/git/account/add.js.map +1 -1
- package/dist/cmd/git/list.js.map +1 -1
- package/dist/cmd/project/add/database.d.ts +2 -0
- package/dist/cmd/project/add/database.d.ts.map +1 -0
- package/dist/cmd/project/add/database.js +123 -0
- package/dist/cmd/project/add/database.js.map +1 -0
- package/dist/cmd/project/add/domain.d.ts +2 -0
- package/dist/cmd/project/add/domain.d.ts.map +1 -0
- package/dist/cmd/project/add/domain.js +152 -0
- package/dist/cmd/project/add/domain.js.map +1 -0
- package/dist/cmd/project/add/index.d.ts +2 -0
- package/dist/cmd/project/add/index.d.ts.map +1 -0
- package/dist/cmd/project/add/index.js +35 -0
- package/dist/cmd/project/add/index.js.map +1 -0
- package/dist/cmd/project/add/storage.d.ts +2 -0
- package/dist/cmd/project/add/storage.d.ts.map +1 -0
- package/dist/cmd/project/add/storage.js +123 -0
- package/dist/cmd/project/add/storage.js.map +1 -0
- package/dist/cmd/project/auth/init.js.map +1 -1
- package/dist/cmd/project/index.d.ts.map +1 -1
- package/dist/cmd/project/index.js +7 -0
- package/dist/cmd/project/index.js.map +1 -1
- package/dist/cmd/project/reconcile.d.ts.map +1 -1
- package/dist/cmd/project/reconcile.js +32 -0
- package/dist/cmd/project/reconcile.js.map +1 -1
- package/dist/cmd/support/report.js.map +1 -1
- package/dist/cmd/support/system.js +2 -2
- package/dist/cmd/support/system.js.map +1 -1
- package/dist/config.d.ts +6 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +31 -7
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +2 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/repl.js +2 -1
- package/dist/repl.js.map +1 -1
- package/dist/tui/box.d.ts +3 -1
- package/dist/tui/box.d.ts.map +1 -1
- package/dist/tui/box.js +22 -7
- package/dist/tui/box.js.map +1 -1
- package/dist/tui/colors.d.ts +0 -3
- package/dist/tui/colors.d.ts.map +1 -1
- package/dist/tui/colors.js +76 -23
- package/dist/tui/colors.js.map +1 -1
- package/dist/tui/prompt.d.ts +2 -0
- package/dist/tui/prompt.d.ts.map +1 -1
- package/dist/tui/prompt.js +44 -3
- package/dist/tui/prompt.js.map +1 -1
- package/dist/tui/symbols.d.ts +0 -4
- package/dist/tui/symbols.d.ts.map +1 -1
- package/dist/tui/symbols.js +5 -0
- package/dist/tui/symbols.js.map +1 -1
- package/dist/tui.d.ts +8 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +54 -9
- package/dist/tui.js.map +1 -1
- package/dist/types.d.ts +37 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/dist/version-check.d.ts.map +1 -1
- package/dist/version-check.js +5 -0
- package/dist/version-check.js.map +1 -1
- package/package.json +6 -6
- package/src/agent-detection.ts +457 -160
- package/src/ai-help.ts +393 -0
- package/src/api.ts +1 -1
- package/src/auth.ts +226 -17
- package/src/banner.ts +5 -0
- package/src/cache/agent-intro.ts +62 -0
- package/src/cache/index.ts +2 -0
- package/src/cache/resource-region.ts +28 -7
- package/src/catalyst.ts +16 -0
- package/src/cli.ts +375 -93
- package/src/cmd/ai/detect.ts +54 -0
- package/src/cmd/ai/index.ts +18 -1
- package/src/cmd/ai/intro.ts +154 -0
- package/src/cmd/ai/opencode/run.ts +5 -0
- package/src/cmd/build/ast.ts +97 -0
- package/src/cmd/build/vite/bun-dev-server.ts +2 -0
- package/src/cmd/build/vite/docs-generator.ts +15 -1
- package/src/cmd/build/vite/env-types-generator.ts +145 -0
- package/src/cmd/build/vite/index.ts +15 -0
- package/src/cmd/build/vite/public-asset-path-plugin.ts +8 -2
- package/src/cmd/build/vite/vite-builder.ts +31 -11
- package/src/cmd/cloud/db/create.ts +16 -16
- package/src/cmd/cloud/db/delete.ts +19 -19
- package/src/cmd/cloud/db/get.ts +32 -17
- package/src/cmd/cloud/deploy-fork.ts +2 -0
- package/src/cmd/cloud/deploy.ts +17 -0
- package/src/cmd/cloud/env/import.ts +6 -6
- package/src/cmd/cloud/env/list.ts +11 -11
- package/src/cmd/cloud/env/push.ts +6 -6
- package/src/cmd/cloud/keyvalue/util.ts +3 -3
- package/src/cmd/cloud/machine/list.ts +3 -3
- package/src/cmd/cloud/region/index.ts +3 -3
- package/src/cmd/cloud/region-lookup.ts +82 -22
- package/src/cmd/cloud/sandbox/cp.ts +9 -4
- package/src/cmd/cloud/sandbox/create.ts +2 -2
- package/src/cmd/cloud/sandbox/delete.ts +10 -7
- package/src/cmd/cloud/sandbox/download.ts +8 -5
- package/src/cmd/cloud/sandbox/env.ts +8 -5
- package/src/cmd/cloud/sandbox/exec.ts +10 -5
- package/src/cmd/cloud/sandbox/get.ts +13 -7
- package/src/cmd/cloud/sandbox/list.ts +47 -73
- package/src/cmd/cloud/sandbox/ls.ts +9 -5
- package/src/cmd/cloud/sandbox/mkdir.ts +9 -5
- package/src/cmd/cloud/sandbox/rm.ts +9 -5
- package/src/cmd/cloud/sandbox/rmdir.ts +9 -5
- package/src/cmd/cloud/sandbox/run.ts +1 -1
- package/src/cmd/cloud/sandbox/snapshot/build.ts +31 -31
- package/src/cmd/cloud/sandbox/snapshot/get.ts +17 -17
- package/src/cmd/cloud/sandbox/upload.ts +8 -5
- package/src/cmd/cloud/sandbox/util.ts +15 -14
- package/src/cmd/cloud/ssh.ts +2 -4
- package/src/cmd/cloud/storage/create.ts +16 -16
- package/src/cmd/cloud/storage/delete.ts +19 -19
- package/src/cmd/cloud/storage/get.ts +5 -16
- package/src/cmd/cloud/storage/list.ts +12 -6
- package/src/cmd/cloud/stream/create.ts +8 -4
- package/src/cmd/cloud/stream/delete.ts +28 -4
- package/src/cmd/cloud/stream/get.ts +102 -64
- package/src/cmd/cloud/stream/list.ts +76 -44
- package/src/cmd/cloud/stream/util.ts +39 -3
- package/src/cmd/cloud/vector/util.ts +3 -3
- package/src/cmd/dev/index.ts +4 -4
- package/src/cmd/git/account/add.ts +5 -5
- package/src/cmd/git/list.ts +7 -7
- package/src/cmd/project/add/database.ts +145 -0
- package/src/cmd/project/add/domain.ts +181 -0
- package/src/cmd/project/add/index.ts +35 -0
- package/src/cmd/project/add/storage.ts +147 -0
- package/src/cmd/project/auth/init.ts +6 -6
- package/src/cmd/project/index.ts +7 -0
- package/src/cmd/project/reconcile.ts +40 -0
- package/src/cmd/support/report.ts +5 -5
- package/src/cmd/support/system.ts +2 -2
- package/src/config.ts +40 -12
- package/src/errors.ts +7 -0
- package/src/index.ts +11 -0
- package/src/repl.ts +4 -1
- package/src/tui/box.ts +24 -9
- package/src/tui/colors.ts +83 -26
- package/src/tui/prompt.ts +55 -3
- package/src/tui/symbols.ts +6 -0
- package/src/tui.ts +55 -9
- package/src/types.ts +46 -2
- package/src/version-check.ts +6 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createSubcommand } from '../../types';
|
|
2
|
+
import { getExecutingAgent, getAgentDisplayName, KNOWN_AGENTS } from '../../agent-detection';
|
|
3
|
+
import { getCommand } from '../../command-prefix';
|
|
4
|
+
import * as tui from '../../tui';
|
|
5
|
+
|
|
6
|
+
export const detectSubcommand = createSubcommand({
|
|
7
|
+
name: 'detect',
|
|
8
|
+
description: 'Detect if the CLI is being run from a known AI coding agent',
|
|
9
|
+
tags: ['read-only', 'fast'],
|
|
10
|
+
idempotent: true,
|
|
11
|
+
examples: [
|
|
12
|
+
{ command: getCommand('ai detect'), description: 'Detect the executing agent' },
|
|
13
|
+
{ command: getCommand('ai detect --json'), description: 'Output detection result as JSON' },
|
|
14
|
+
],
|
|
15
|
+
handler(ctx) {
|
|
16
|
+
const agentId = getExecutingAgent();
|
|
17
|
+
const agentName = agentId ? getAgentDisplayName(agentId) : null;
|
|
18
|
+
|
|
19
|
+
if (ctx.options.json) {
|
|
20
|
+
tui.json({
|
|
21
|
+
id: agentId ?? null,
|
|
22
|
+
name: agentName,
|
|
23
|
+
});
|
|
24
|
+
// Exit with code 1 when no agent detected (consistent with non-JSON mode)
|
|
25
|
+
if (!agentId) {
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (agentId) {
|
|
32
|
+
tui.success(`Detected agent: ${agentName} (${agentId})`);
|
|
33
|
+
} else {
|
|
34
|
+
tui.newline();
|
|
35
|
+
tui.info('No AI coding agent detected.');
|
|
36
|
+
tui.newline();
|
|
37
|
+
console.log(` This CLI can detect when it's being run by an AI coding agent.`);
|
|
38
|
+
console.log(` Currently supported agents:\n`);
|
|
39
|
+
for (const [, id] of KNOWN_AGENTS) {
|
|
40
|
+
console.log(` - ${getAgentDisplayName(id)} (${id})`);
|
|
41
|
+
}
|
|
42
|
+
tui.newline();
|
|
43
|
+
console.log(
|
|
44
|
+
` You can also set the ${tui.colorPrimary('AGENTUITY_AGENT_MODE')} environment variable`
|
|
45
|
+
);
|
|
46
|
+
console.log(` to manually specify the agent.\n`);
|
|
47
|
+
|
|
48
|
+
// Exit with code 1 when no agent detected (non-JSON mode)
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export default detectSubcommand;
|
package/src/cmd/ai/index.ts
CHANGED
|
@@ -3,6 +3,8 @@ import capabilitiesCommand from './capabilities';
|
|
|
3
3
|
import promptCommand from './prompt';
|
|
4
4
|
import schemaCommand from './schema';
|
|
5
5
|
import opencodeCommand from './opencode';
|
|
6
|
+
import introSubcommand from './intro';
|
|
7
|
+
import detectSubcommand from './detect';
|
|
6
8
|
import { getCommand } from '../../command-prefix';
|
|
7
9
|
|
|
8
10
|
export const command = createCommand({
|
|
@@ -11,6 +13,14 @@ export const command = createCommand({
|
|
|
11
13
|
skipUpgradeCheck: true,
|
|
12
14
|
tags: ['fast'],
|
|
13
15
|
examples: [
|
|
16
|
+
{
|
|
17
|
+
command: getCommand('ai detect'),
|
|
18
|
+
description: 'Detect if running from an AI coding agent',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
command: getCommand('ai intro'),
|
|
22
|
+
description: 'Introduce the Agentuity CLI to your AI agent',
|
|
23
|
+
},
|
|
14
24
|
{
|
|
15
25
|
command: getCommand('ai opencode install'),
|
|
16
26
|
description: 'Install Agentuity Open Code plugin',
|
|
@@ -24,5 +34,12 @@ export const command = createCommand({
|
|
|
24
34
|
description: 'Output CLI schema for AI consumption',
|
|
25
35
|
},
|
|
26
36
|
],
|
|
27
|
-
subcommands: [
|
|
37
|
+
subcommands: [
|
|
38
|
+
detectSubcommand,
|
|
39
|
+
introSubcommand,
|
|
40
|
+
opencodeCommand,
|
|
41
|
+
capabilitiesCommand,
|
|
42
|
+
promptCommand,
|
|
43
|
+
schemaCommand,
|
|
44
|
+
],
|
|
28
45
|
});
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { createSubcommand } from '../../types';
|
|
2
|
+
import type { CommandContext } from '../../types';
|
|
3
|
+
import { getCommand } from '../../command-prefix';
|
|
4
|
+
import { getExecutingAgent, getAgentDisplayName, KNOWN_AGENTS } from '../../agent-detection';
|
|
5
|
+
import { getVersion } from '../../version';
|
|
6
|
+
import * as tui from '../../tui';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Generate the introduction prompt for AI agents
|
|
10
|
+
*/
|
|
11
|
+
export function generateIntroPrompt(agent: string | undefined): string {
|
|
12
|
+
const agentGreeting = agent ? `Hello ${getAgentDisplayName(agent)}! ` : 'Hello! ';
|
|
13
|
+
|
|
14
|
+
const detectedAgents = KNOWN_AGENTS.map(([, name]) => getAgentDisplayName(name)).join(', ');
|
|
15
|
+
|
|
16
|
+
return `${agentGreeting}Welcome to the Agentuity CLI (v${getVersion()}).
|
|
17
|
+
|
|
18
|
+
## What is Agentuity?
|
|
19
|
+
|
|
20
|
+
Agentuity is a cloud platform for building, deploying, and running AI agents with production-grade infrastructure. It provides:
|
|
21
|
+
|
|
22
|
+
- **Serverless Agent Runtime**: Deploy agents that scale automatically with zero cold starts
|
|
23
|
+
- **Built-in Services**: Key-value storage, vector databases, object storage, and PostgreSQL - all accessible via simple APIs
|
|
24
|
+
- **Agent-to-Agent Communication**: Agents can discover and communicate with each other seamlessly
|
|
25
|
+
- **Observability**: Full tracing, logging, and monitoring out of the box
|
|
26
|
+
- **Developer Experience**: Local development server, hot reload, and TypeScript-first SDK
|
|
27
|
+
|
|
28
|
+
## How to Use This CLI
|
|
29
|
+
|
|
30
|
+
The Agentuity CLI is designed to be agent-friendly. Here are the key commands:
|
|
31
|
+
|
|
32
|
+
### Discovery & Introspection
|
|
33
|
+
\`\`\`bash
|
|
34
|
+
${getCommand('--help=json')} # Get complete CLI schema as JSON
|
|
35
|
+
${getCommand('ai capabilities show')} # List all capabilities and workflows
|
|
36
|
+
${getCommand('ai schema show')} # Detailed command metadata
|
|
37
|
+
\`\`\`
|
|
38
|
+
|
|
39
|
+
### Project Management
|
|
40
|
+
\`\`\`bash
|
|
41
|
+
${getCommand('project create')} # Create a new Agentuity project
|
|
42
|
+
${getCommand('project list')} # List all projects
|
|
43
|
+
${getCommand('dev')} # Start local development server
|
|
44
|
+
\`\`\`
|
|
45
|
+
|
|
46
|
+
### Deployment
|
|
47
|
+
\`\`\`bash
|
|
48
|
+
${getCommand('cloud deploy')} # Deploy to production
|
|
49
|
+
${getCommand('cloud deployment list')} # List deployments
|
|
50
|
+
${getCommand('cloud deployment logs')} # View deployment logs
|
|
51
|
+
\`\`\`
|
|
52
|
+
|
|
53
|
+
### Cloud Services
|
|
54
|
+
\`\`\`bash
|
|
55
|
+
${getCommand('cloud kv')} # Key-value storage operations
|
|
56
|
+
${getCommand('cloud vector')} # Vector database operations
|
|
57
|
+
${getCommand('cloud storage')} # Object storage operations
|
|
58
|
+
${getCommand('env set KEY value')} # Set environment variables
|
|
59
|
+
${getCommand('env set KEY value --secret')} # Set secrets (encrypted)
|
|
60
|
+
\`\`\`
|
|
61
|
+
|
|
62
|
+
## Best Practices for AI Agents
|
|
63
|
+
|
|
64
|
+
1. **Always use \`--json\` for machine-readable output**
|
|
65
|
+
\`\`\`bash
|
|
66
|
+
${getCommand('--json project list')}
|
|
67
|
+
\`\`\`
|
|
68
|
+
|
|
69
|
+
2. **Use \`--explain\` before destructive operations**
|
|
70
|
+
\`\`\`bash
|
|
71
|
+
${getCommand('--explain cloud deployment delete <id>')}
|
|
72
|
+
\`\`\`
|
|
73
|
+
|
|
74
|
+
3. **Use \`--dry-run\` to test commands safely**
|
|
75
|
+
\`\`\`bash
|
|
76
|
+
${getCommand('--dry-run cloud deploy')}
|
|
77
|
+
\`\`\`
|
|
78
|
+
|
|
79
|
+
4. **Check requirements before running commands**
|
|
80
|
+
- Many commands require authentication (\`${getCommand('auth login')}\`)
|
|
81
|
+
- Project commands require an \`agentuity.json\` file in the current directory
|
|
82
|
+
|
|
83
|
+
## Error Handling
|
|
84
|
+
|
|
85
|
+
Errors are returned as structured JSON when using \`--json\`:
|
|
86
|
+
\`\`\`json
|
|
87
|
+
{
|
|
88
|
+
"error": {
|
|
89
|
+
"code": "AUTH_REQUIRED",
|
|
90
|
+
"message": "Authentication required",
|
|
91
|
+
"suggestions": ["Run '${getCommand('auth login')}' to authenticate"]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
\`\`\`
|
|
95
|
+
|
|
96
|
+
## Getting Started Workflow
|
|
97
|
+
|
|
98
|
+
1. \`${getCommand('auth login')}\` - Authenticate with Agentuity
|
|
99
|
+
2. \`${getCommand('project create')}\` - Create a new project (or work in existing one)
|
|
100
|
+
3. \`${getCommand('dev')}\` - Start local development
|
|
101
|
+
4. \`${getCommand('cloud deploy')}\` - Deploy to production
|
|
102
|
+
|
|
103
|
+
## Agent Detection
|
|
104
|
+
|
|
105
|
+
This CLI can detect when it's being run by an AI coding agent. Currently supported agents: ${detectedAgents}.
|
|
106
|
+
|
|
107
|
+
${agent ? `You were detected as: **${getAgentDisplayName(agent)}**` : 'No agent was detected for this session.'}
|
|
108
|
+
|
|
109
|
+
## More Information
|
|
110
|
+
|
|
111
|
+
- Documentation: https://agentuity.dev/docs
|
|
112
|
+
- API Reference: https://agentuity.dev/api
|
|
113
|
+
- Examples: https://github.com/agentuity/examples
|
|
114
|
+
|
|
115
|
+
For detailed command help, use \`${getCommand('<command> --help')}\` or \`${getCommand('--help=json')}\` for the full schema.
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const introSubcommand = createSubcommand({
|
|
120
|
+
name: 'intro',
|
|
121
|
+
description: 'Introduction to Agentuity CLI for AI coding agents',
|
|
122
|
+
tags: ['read-only', 'fast'],
|
|
123
|
+
idempotent: true,
|
|
124
|
+
examples: [{ command: getCommand('ai intro'), description: 'Show introduction for AI agents' }],
|
|
125
|
+
handler(_ctx: CommandContext) {
|
|
126
|
+
const agent = getExecutingAgent();
|
|
127
|
+
|
|
128
|
+
if (!agent) {
|
|
129
|
+
// Human is running this command directly
|
|
130
|
+
tui.newline();
|
|
131
|
+
tui.info(tui.bold('This command is designed for AI coding agents'));
|
|
132
|
+
tui.newline();
|
|
133
|
+
console.log(
|
|
134
|
+
` This command outputs an introduction to the Agentuity CLI that helps AI\n` +
|
|
135
|
+
` coding agents understand how to use the platform effectively.\n`
|
|
136
|
+
);
|
|
137
|
+
console.log(` ${tui.bold('To use this command:')}\n`);
|
|
138
|
+
console.log(
|
|
139
|
+
` Ask your AI coding agent to run ${tui.colorPrimary(`"${getCommand('ai intro')}"`)} to introduce\n` +
|
|
140
|
+
` itself to the Agentuity platform and learn how to help you build and deploy agents.\n`
|
|
141
|
+
);
|
|
142
|
+
console.log(
|
|
143
|
+
` ${tui.muted('Supported agents:')} ${KNOWN_AGENTS.map(([, name]) => getAgentDisplayName(name)).join(', ')}\n`
|
|
144
|
+
);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Agent is running this command - output the full prompt
|
|
149
|
+
const prompt = generateIntroPrompt(agent);
|
|
150
|
+
console.log(prompt);
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
export default introSubcommand;
|
|
@@ -82,6 +82,11 @@ export const runSubcommand = createSubcommand({
|
|
|
82
82
|
env: {
|
|
83
83
|
...process.env,
|
|
84
84
|
AGENTUITY_CODER_MODE: 'non-interactive',
|
|
85
|
+
AGENTUITY_AGENT_MODE: 'opencode',
|
|
86
|
+
// Pass through profile if set
|
|
87
|
+
...(process.env.AGENTUITY_PROFILE
|
|
88
|
+
? { AGENTUITY_PROFILE: process.env.AGENTUITY_PROFILE }
|
|
89
|
+
: {}),
|
|
85
90
|
},
|
|
86
91
|
});
|
|
87
92
|
|
package/src/cmd/build/ast.ts
CHANGED
|
@@ -1246,6 +1246,60 @@ function extractZValidatorSchema(callExpr: ASTCallExpression): {
|
|
|
1246
1246
|
return result;
|
|
1247
1247
|
}
|
|
1248
1248
|
|
|
1249
|
+
/**
|
|
1250
|
+
* Extract output schema from SSE options object.
|
|
1251
|
+
* Example: sse({ output: MySchema }, handler)
|
|
1252
|
+
*
|
|
1253
|
+
* @param callExpr - The SSE CallExpression AST node
|
|
1254
|
+
* @returns Object with outputSchemaVariable if found
|
|
1255
|
+
*/
|
|
1256
|
+
function extractSSEOutputSchema(callExpr: ASTCallExpression): {
|
|
1257
|
+
outputSchemaVariable?: string;
|
|
1258
|
+
} {
|
|
1259
|
+
const result: { outputSchemaVariable?: string } = {};
|
|
1260
|
+
|
|
1261
|
+
// sse() can be called as:
|
|
1262
|
+
// 1. sse(handler) - no schema
|
|
1263
|
+
// 2. sse({ output: schema }, handler) - with schema
|
|
1264
|
+
if (!callExpr.arguments || callExpr.arguments.length === 0) {
|
|
1265
|
+
return result;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
// Check if first argument is an options object with 'output' property
|
|
1269
|
+
const firstArg = callExpr.arguments[0] as ASTNode;
|
|
1270
|
+
if (firstArg.type !== 'ObjectExpression') {
|
|
1271
|
+
// First argument is handler function, no options
|
|
1272
|
+
return result;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
const objExpr = firstArg as ASTObjectExpression;
|
|
1276
|
+
for (const prop of objExpr.properties) {
|
|
1277
|
+
// Skip SpreadElement entries (e.g., { ...obj }) which don't have key/value
|
|
1278
|
+
if ((prop as ASTNode).type !== 'Property') {
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
// Extract key name - could be Identifier or Literal
|
|
1283
|
+
let keyName: string | undefined;
|
|
1284
|
+
const propKey = prop.key as { type: string; name?: string; value?: unknown };
|
|
1285
|
+
if (propKey.type === 'Identifier') {
|
|
1286
|
+
keyName = propKey.name;
|
|
1287
|
+
} else if (propKey.type === 'Literal') {
|
|
1288
|
+
keyName = String(propKey.value);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
if (!keyName) continue;
|
|
1292
|
+
|
|
1293
|
+
// Look for the 'output' property
|
|
1294
|
+
if (keyName === 'output' && prop.value.type === 'Identifier') {
|
|
1295
|
+
result.outputSchemaVariable = (prop.value as ASTNodeIdentifier).name;
|
|
1296
|
+
break;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
return result;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1249
1303
|
/**
|
|
1250
1304
|
* Extract schema from Hono validator('json', callback) pattern
|
|
1251
1305
|
* Example: validator('json', (value, c) => { const result = mySchema['~standard'].validate(value); ... })
|
|
@@ -1543,6 +1597,8 @@ export async function parseRoute(
|
|
|
1543
1597
|
const action = statement.expression.arguments[0];
|
|
1544
1598
|
let suffix = '';
|
|
1545
1599
|
let config: Record<string, unknown> | undefined;
|
|
1600
|
+
// Capture SSE call expression for output schema extraction
|
|
1601
|
+
let sseCallExpr: ASTCallExpression | undefined;
|
|
1546
1602
|
// Supported HTTP methods that can be represented in BuildMetadata
|
|
1547
1603
|
const SUPPORTED_HTTP_METHODS = ['get', 'post', 'put', 'delete', 'patch'] as const;
|
|
1548
1604
|
type SupportedHttpMethod = (typeof SUPPORTED_HTTP_METHODS)[number];
|
|
@@ -1804,6 +1860,10 @@ export async function parseRoute(
|
|
|
1804
1860
|
calleeName === 'stream'
|
|
1805
1861
|
) {
|
|
1806
1862
|
type = calleeName;
|
|
1863
|
+
// Capture SSE call expression for output schema extraction
|
|
1864
|
+
if (calleeName === 'sse') {
|
|
1865
|
+
sseCallExpr = callExpr;
|
|
1866
|
+
}
|
|
1807
1867
|
break;
|
|
1808
1868
|
}
|
|
1809
1869
|
if (calleeName === 'cron') {
|
|
@@ -1959,6 +2019,43 @@ export async function parseRoute(
|
|
|
1959
2019
|
}
|
|
1960
2020
|
}
|
|
1961
2021
|
|
|
2022
|
+
// Extract output schema from SSE options: sse({ output: schema }, handler)
|
|
2023
|
+
// For SSE routes, the sse({ output }) pattern takes precedence over any
|
|
2024
|
+
// validator-provided schema. Imported schemas need not be exported, but
|
|
2025
|
+
// locally-defined schemas must be exported and are validated below.
|
|
2026
|
+
if (sseCallExpr) {
|
|
2027
|
+
const sseSchemaInfo = extractSSEOutputSchema(sseCallExpr);
|
|
2028
|
+
if (sseSchemaInfo.outputSchemaVariable) {
|
|
2029
|
+
// Track where the schema is imported from (if imported)
|
|
2030
|
+
const outputImportInfo = importInfoMap.get(
|
|
2031
|
+
sseSchemaInfo.outputSchemaVariable
|
|
2032
|
+
);
|
|
2033
|
+
// Validate that locally-defined schemas are exported
|
|
2034
|
+
// (skip validation if schema is imported from another module)
|
|
2035
|
+
if (!outputImportInfo) {
|
|
2036
|
+
validateSchemaExports(
|
|
2037
|
+
sseSchemaInfo.outputSchemaVariable,
|
|
2038
|
+
'output',
|
|
2039
|
+
importedNames,
|
|
2040
|
+
exportedNames,
|
|
2041
|
+
rel,
|
|
2042
|
+
method,
|
|
2043
|
+
thepath
|
|
2044
|
+
);
|
|
2045
|
+
}
|
|
2046
|
+
// Override any validator-provided schema with SSE-specific schema
|
|
2047
|
+
routeConfig.outputSchemaVariable = sseSchemaInfo.outputSchemaVariable;
|
|
2048
|
+
if (outputImportInfo) {
|
|
2049
|
+
routeConfig.outputSchemaImportPath = outputImportInfo.modulePath;
|
|
2050
|
+
routeConfig.outputSchemaImportedName = outputImportInfo.importedName;
|
|
2051
|
+
} else {
|
|
2052
|
+
// Clear any validator-provided import info since we're using local schema
|
|
2053
|
+
delete routeConfig.outputSchemaImportPath;
|
|
2054
|
+
delete routeConfig.outputSchemaImportedName;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
|
|
1962
2059
|
// Fall back to exported schemas when validator doesn't provide them
|
|
1963
2060
|
// This works for all route types (API, WebSocket, SSE, stream)
|
|
1964
2061
|
// For API routes, this enables `export const outputSchema` pattern
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { Logger } from '../../../types';
|
|
9
|
+
import { getAgentEnv } from '../../../agent-detection';
|
|
9
10
|
|
|
10
11
|
export interface BunDevServerOptions {
|
|
11
12
|
rootDir: string;
|
|
@@ -80,6 +81,7 @@ export async function startBunDevServer(options: BunDevServerOptions): Promise<B
|
|
|
80
81
|
stderr: 'inherit',
|
|
81
82
|
env: {
|
|
82
83
|
...process.env,
|
|
84
|
+
...getAgentEnv(),
|
|
83
85
|
PORT: String(port),
|
|
84
86
|
},
|
|
85
87
|
});
|
|
@@ -22,15 +22,28 @@ This directory contains auto-generated TypeScript files created by the Agentuity
|
|
|
22
22
|
- \`app.ts\` - Application entry point
|
|
23
23
|
- \`analytics-config.ts\` - Web analytics configuration from \`agentuity.json\`
|
|
24
24
|
- \`webanalytics.ts\` - Web analytics injection and route registration
|
|
25
|
+
- \`env.d.ts\` - TypeScript types for environment variables from \`.env\` files
|
|
25
26
|
- \`state.ts\` - App state type (only generated when \`setup()\` returns state in \`app.ts\`)
|
|
26
27
|
- \`router.ts\` - Runtime wrapper with type augmentation (only generated when \`setup()\` returns state in \`app.ts\`)
|
|
27
28
|
|
|
29
|
+
## Environment Variable Types
|
|
30
|
+
|
|
31
|
+
The \`env.d.ts\` file provides TypeScript intellisense for your environment variables:
|
|
32
|
+
|
|
33
|
+
- **ProcessEnv**: All variables from your \`.env\` files are typed as \`string\`
|
|
34
|
+
- **ImportMetaEnv**: Only \`VITE_*\`, \`AGENTUITY_PUBLIC_*\`, and \`PUBLIC_*\` prefixed variables (for client-side use)
|
|
35
|
+
|
|
36
|
+
Files are merged based on build mode:
|
|
37
|
+
- **Development**: \`.env.{profile}\` → \`.env.development\` → \`.env\` (later files override)
|
|
38
|
+
- **Production**: \`.env.{profile}\` → \`.env\` → \`.env.production\` (later files override)
|
|
39
|
+
|
|
28
40
|
## For Developers
|
|
29
41
|
|
|
30
42
|
Do not modify these files. Instead:
|
|
31
43
|
- Add/modify agents in \`src/agent/\`
|
|
32
44
|
- Add/modify routes in \`src/api/\`
|
|
33
45
|
- Configure app in \`app.ts\`
|
|
46
|
+
- Add environment variables to \`.env\` files
|
|
34
47
|
|
|
35
48
|
These files ARE version controlled to enable better tooling and type checking.
|
|
36
49
|
`;
|
|
@@ -45,7 +58,7 @@ const AGENTS_MD_CONTENT = `# AI Agent Instructions
|
|
|
45
58
|
2. ❌ NEVER include \`src/generated/\` files in context when analyzing code
|
|
46
59
|
3. ❌ NEVER suggest changes to generated files
|
|
47
60
|
4. ✅ Ignore this directory when searching for user code
|
|
48
|
-
5. ✅ Direct users to modify source files in \`src/agent/\`, \`src/api/\`,
|
|
61
|
+
5. ✅ Direct users to modify source files in \`src/agent/\`, \`src/api/\`, \`app.ts\`, or \`.env\` files
|
|
49
62
|
|
|
50
63
|
## What Gets Generated
|
|
51
64
|
|
|
@@ -54,6 +67,7 @@ const AGENTS_MD_CONTENT = `# AI Agent Instructions
|
|
|
54
67
|
- \`app.ts\` - Entry point assembled from project configuration
|
|
55
68
|
- \`analytics-config.ts\` - Web analytics configuration from \`agentuity.json\`
|
|
56
69
|
- \`webanalytics.ts\` - Web analytics injection and route registration
|
|
70
|
+
- \`env.d.ts\` - TypeScript types for environment variables from \`.env\` files
|
|
57
71
|
- \`state.ts\` - App state type (only generated when \`setup()\` returns state in \`app.ts\`)
|
|
58
72
|
- \`router.ts\` - Runtime wrapper with type augmentation (only generated when \`setup()\` returns state)
|
|
59
73
|
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Types Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates src/generated/env.d.ts by analyzing local .env files
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { existsSync, mkdirSync } from 'node:fs';
|
|
9
|
+
import { getEnvFilePaths, readEnvFile, isPublicVarKey } from '../../../env-util';
|
|
10
|
+
import type { Logger } from '../../../types';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generate TypeScript declarations for environment variables
|
|
14
|
+
*/
|
|
15
|
+
function generateEnvTypesContent(keys: string[]): string {
|
|
16
|
+
const sortedKeys = [...keys].sort();
|
|
17
|
+
const publicKeys = sortedKeys.filter(isPublicVarKey);
|
|
18
|
+
|
|
19
|
+
// Build ProcessEnv interface entries
|
|
20
|
+
const processEnvEntries =
|
|
21
|
+
sortedKeys.length > 0
|
|
22
|
+
? sortedKeys.map((key) => `\t\treadonly ${key}: string;`).join('\n')
|
|
23
|
+
: '\t\t\t// No environment variables found';
|
|
24
|
+
|
|
25
|
+
// Build ImportMetaEnv interface entries (only public keys: VITE_*, AGENTUITY_PUBLIC_*, PUBLIC_*)
|
|
26
|
+
const importMetaEnvEntries =
|
|
27
|
+
publicKeys.length > 0
|
|
28
|
+
? publicKeys.map((key) => `\treadonly ${key}: string;`).join('\n')
|
|
29
|
+
: '\t// No VITE_*, AGENTUITY_PUBLIC_*, or PUBLIC_* prefixed variables found';
|
|
30
|
+
|
|
31
|
+
return `// @generated
|
|
32
|
+
// AUTO-GENERATED from local .env files
|
|
33
|
+
// This file is auto-generated by the build tool - do not edit manually
|
|
34
|
+
|
|
35
|
+
declare global {
|
|
36
|
+
namespace NodeJS {
|
|
37
|
+
interface ProcessEnv {
|
|
38
|
+
${processEnvEntries}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Vite-compatible environment types
|
|
44
|
+
// Only includes variables with VITE_, AGENTUITY_PUBLIC_, or PUBLIC_ prefix
|
|
45
|
+
interface ImportMetaEnv {
|
|
46
|
+
${importMetaEnvEntries}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface ImportMeta {
|
|
50
|
+
readonly env: ImportMetaEnv;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {};
|
|
54
|
+
|
|
55
|
+
// FOUND AN ERROR IN THIS FILE?
|
|
56
|
+
// Please file an issue at https://github.com/agentuity/sdk/issues
|
|
57
|
+
// or if you know the fix please submit a PR!
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface GenerateEnvTypesOptions {
|
|
62
|
+
/** Root directory of the project */
|
|
63
|
+
rootDir: string;
|
|
64
|
+
/** Source directory (typically rootDir/src) */
|
|
65
|
+
srcDir: string;
|
|
66
|
+
/** Logger instance */
|
|
67
|
+
logger: Logger;
|
|
68
|
+
/** Whether building for production (affects .env file precedence) */
|
|
69
|
+
isProduction: boolean;
|
|
70
|
+
/** Optional config profile name (e.g., 'staging', 'test') for .env.{profile} files */
|
|
71
|
+
profile?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Generate environment type definitions from local .env files
|
|
76
|
+
*
|
|
77
|
+
* @param options - Generation options
|
|
78
|
+
* @returns true if types were generated, false if no env files found
|
|
79
|
+
*/
|
|
80
|
+
export async function generateEnvTypes(options: GenerateEnvTypesOptions): Promise<boolean> {
|
|
81
|
+
const { rootDir, srcDir, logger, isProduction, profile } = options;
|
|
82
|
+
|
|
83
|
+
logger.debug('[env-types] Starting env types generation...');
|
|
84
|
+
logger.debug(`[env-types] rootDir: ${rootDir}`);
|
|
85
|
+
logger.debug(`[env-types] srcDir: ${srcDir}`);
|
|
86
|
+
logger.debug(`[env-types] isProduction: ${isProduction}`);
|
|
87
|
+
logger.debug(`[env-types] profile: ${profile ?? '(none)'}`);
|
|
88
|
+
|
|
89
|
+
// Get env file paths based on build mode and profile
|
|
90
|
+
// Dev: ['.env.{profile}', '.env.development', '.env'] - later files override earlier
|
|
91
|
+
// Prod: ['.env.{profile}', '.env', '.env.production'] - later files override earlier
|
|
92
|
+
const envFilePaths = getEnvFilePaths(rootDir, { isProduction, configName: profile });
|
|
93
|
+
logger.debug(`[env-types] Env file paths to check: ${envFilePaths.join(', ')}`);
|
|
94
|
+
|
|
95
|
+
// Read and merge env files (later files override earlier)
|
|
96
|
+
const mergedEnv: Record<string, string> = {};
|
|
97
|
+
let foundAnyFile = false;
|
|
98
|
+
|
|
99
|
+
for (const filePath of envFilePaths) {
|
|
100
|
+
const envVars = await readEnvFile(filePath);
|
|
101
|
+
const keyCount = Object.keys(envVars).length;
|
|
102
|
+
|
|
103
|
+
if (keyCount > 0) {
|
|
104
|
+
foundAnyFile = true;
|
|
105
|
+
logger.debug(`[env-types] Read ${keyCount} vars from ${filePath}`);
|
|
106
|
+
|
|
107
|
+
// Merge - later values override earlier
|
|
108
|
+
for (const [key, value] of Object.entries(envVars)) {
|
|
109
|
+
mergedEnv[key] = value;
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
logger.debug(`[env-types] No vars found in ${filePath} (file may not exist)`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!foundAnyFile) {
|
|
117
|
+
logger.debug('[env-types] No .env files found, skipping env types generation');
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Extract just the keys (we don't include values in types)
|
|
122
|
+
const keys = Object.keys(mergedEnv);
|
|
123
|
+
logger.debug(`[env-types] Total unique keys: ${keys.length}`);
|
|
124
|
+
|
|
125
|
+
// Determine output path
|
|
126
|
+
const outDir = join(srcDir, 'generated');
|
|
127
|
+
const outputPath = join(outDir, 'env.d.ts');
|
|
128
|
+
|
|
129
|
+
// Ensure output directory exists
|
|
130
|
+
if (!existsSync(outDir)) {
|
|
131
|
+
mkdirSync(outDir, { recursive: true });
|
|
132
|
+
logger.debug(`[env-types] Created output directory: ${outDir}`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Generate and write types
|
|
136
|
+
const typesContent = generateEnvTypesContent(keys);
|
|
137
|
+
await Bun.write(outputPath, typesContent);
|
|
138
|
+
|
|
139
|
+
const publicKeyCount = keys.filter(isPublicVarKey).length;
|
|
140
|
+
logger.debug(
|
|
141
|
+
`[env-types] Generated env types with ${keys.length} keys (${publicKeyCount} public) at ${outputPath}`
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
@@ -6,6 +6,7 @@ import { discoverAgents, type AgentMetadata } from './agent-discovery';
|
|
|
6
6
|
import { discoverRoutes, type RouteMetadata, type RouteInfo } from './route-discovery';
|
|
7
7
|
import { generateAgentRegistry, generateRouteRegistry } from './registry-generator';
|
|
8
8
|
import { generateLifecycleTypes } from './lifecycle-generator';
|
|
9
|
+
import { generateEnvTypes } from './env-types-generator';
|
|
9
10
|
import { generateMetadata, writeMetadataFile, generateRouteMapping } from './metadata-generator';
|
|
10
11
|
import { generateEntryFile } from '../entry-generator';
|
|
11
12
|
import { loadAgentuityConfig, getWorkbenchConfig } from './config-loader';
|
|
@@ -22,6 +23,8 @@ export interface AgentuityPluginOptions {
|
|
|
22
23
|
deploymentId?: string;
|
|
23
24
|
logLevel?: LogLevel;
|
|
24
25
|
deploymentOptions?: DeployOptions;
|
|
26
|
+
/** Optional config profile name (e.g., 'staging', 'test') for .env.{profile} files */
|
|
27
|
+
profile?: string;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/**
|
|
@@ -45,6 +48,7 @@ export function agentuityPlugin(options: AgentuityPluginOptions): Plugin {
|
|
|
45
48
|
deploymentId = '',
|
|
46
49
|
logLevel = 'info',
|
|
47
50
|
deploymentOptions,
|
|
51
|
+
profile,
|
|
48
52
|
} = options;
|
|
49
53
|
const logger = createLogger(logLevel);
|
|
50
54
|
const srcDir = join(rootDir, 'src');
|
|
@@ -97,6 +101,17 @@ export function agentuityPlugin(options: AgentuityPluginOptions): Plugin {
|
|
|
97
101
|
const lifecycleResult = await generateLifecycleTypes(rootDir, srcDir, logger);
|
|
98
102
|
logger.debug(`[vite-plugin] generateLifecycleTypes returned: ${lifecycleResult}`);
|
|
99
103
|
|
|
104
|
+
// Generate environment types from local .env files
|
|
105
|
+
logger.debug('[vite-plugin] About to call generateEnvTypes');
|
|
106
|
+
const envTypesResult = await generateEnvTypes({
|
|
107
|
+
rootDir,
|
|
108
|
+
srcDir,
|
|
109
|
+
logger,
|
|
110
|
+
isProduction: !dev,
|
|
111
|
+
profile,
|
|
112
|
+
});
|
|
113
|
+
logger.debug(`[vite-plugin] generateEnvTypes returned: ${envTypesResult}`);
|
|
114
|
+
|
|
100
115
|
// Generate entry file (pass workbench and analytics config)
|
|
101
116
|
await generateEntryFile({
|
|
102
117
|
rootDir,
|
|
@@ -162,7 +162,10 @@ export function publicAssetPathPlugin(options: PublicAssetPathPluginOptions = {}
|
|
|
162
162
|
const patterns = createIncorrectPatterns();
|
|
163
163
|
for (const { regex, replacement } of patterns) {
|
|
164
164
|
const replaceRegex = new RegExp(regex.source, regex.flags);
|
|
165
|
-
transformed = transformed.replace(
|
|
165
|
+
transformed = transformed.replace(
|
|
166
|
+
replaceRegex,
|
|
167
|
+
replacement.replace('{base}', targetBase)
|
|
168
|
+
);
|
|
166
169
|
}
|
|
167
170
|
}
|
|
168
171
|
|
|
@@ -171,7 +174,10 @@ export function publicAssetPathPlugin(options: PublicAssetPathPluginOptions = {}
|
|
|
171
174
|
const publicPatterns = createPublicPatterns();
|
|
172
175
|
for (const { regex, replacement } of publicPatterns) {
|
|
173
176
|
const replaceRegex = new RegExp(regex.source, regex.flags);
|
|
174
|
-
transformed = transformed.replace(
|
|
177
|
+
transformed = transformed.replace(
|
|
178
|
+
replaceRegex,
|
|
179
|
+
replacement.replace('{base}', targetBase)
|
|
180
|
+
);
|
|
175
181
|
}
|
|
176
182
|
}
|
|
177
183
|
|