@agentuity/cli 0.0.100 → 0.0.102
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 +19 -188
- package/bin/cli.ts +13 -6
- package/dist/api.d.ts +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +41 -12
- package/dist/cli.js.map +1 -1
- package/dist/cmd/ai/index.d.ts.map +1 -1
- package/dist/cmd/ai/index.js +6 -1
- package/dist/cmd/ai/index.js.map +1 -1
- package/dist/cmd/ai/prompt/agent.d.ts +7 -0
- package/dist/cmd/ai/prompt/agent.d.ts.map +1 -1
- package/dist/cmd/ai/prompt/agent.js +12 -323
- package/dist/cmd/ai/prompt/agent.js.map +1 -1
- package/dist/cmd/ai/prompt/api.d.ts +7 -0
- package/dist/cmd/ai/prompt/api.d.ts.map +1 -1
- package/dist/cmd/ai/prompt/api.js +12 -260
- package/dist/cmd/ai/prompt/api.js.map +1 -1
- package/dist/cmd/ai/prompt/version.d.ts +35 -0
- package/dist/cmd/ai/prompt/version.d.ts.map +1 -0
- package/dist/cmd/ai/prompt/version.js +55 -0
- package/dist/cmd/ai/prompt/version.js.map +1 -0
- package/dist/cmd/ai/prompt/web.d.ts +7 -0
- package/dist/cmd/ai/prompt/web.d.ts.map +1 -1
- package/dist/cmd/ai/prompt/web.js +12 -283
- package/dist/cmd/ai/prompt/web.js.map +1 -1
- package/dist/cmd/ai/skills/generate.d.ts +3 -0
- package/dist/cmd/ai/skills/generate.d.ts.map +1 -0
- package/dist/cmd/ai/skills/generate.js +65 -0
- package/dist/cmd/ai/skills/generate.js.map +1 -0
- package/dist/cmd/ai/skills/generator.d.ts +4 -0
- package/dist/cmd/ai/skills/generator.d.ts.map +1 -0
- package/dist/cmd/ai/skills/generator.js +402 -0
- package/dist/cmd/ai/skills/generator.js.map +1 -0
- package/dist/cmd/ai/skills/index.d.ts +4 -0
- package/dist/cmd/ai/skills/index.d.ts.map +1 -0
- package/dist/cmd/ai/skills/index.js +21 -0
- package/dist/cmd/ai/skills/index.js.map +1 -0
- package/dist/cmd/auth/signup.d.ts.map +1 -1
- package/dist/cmd/auth/signup.js +1 -0
- package/dist/cmd/auth/signup.js.map +1 -1
- package/dist/cmd/build/ast.d.ts +2 -1
- package/dist/cmd/build/ast.d.ts.map +1 -1
- package/dist/cmd/build/ast.js +135 -47
- package/dist/cmd/build/ast.js.map +1 -1
- package/dist/cmd/build/entry-generator.d.ts.map +1 -1
- package/dist/cmd/build/entry-generator.js +255 -188
- package/dist/cmd/build/entry-generator.js.map +1 -1
- package/dist/cmd/build/vite/agent-discovery.d.ts.map +1 -1
- package/dist/cmd/build/vite/agent-discovery.js +103 -45
- package/dist/cmd/build/vite/agent-discovery.js.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.d.ts +7 -1
- package/dist/cmd/build/vite/bun-dev-server.d.ts.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.js +52 -26
- package/dist/cmd/build/vite/bun-dev-server.js.map +1 -1
- package/dist/cmd/build/vite/docs-generator.d.ts +13 -0
- package/dist/cmd/build/vite/docs-generator.d.ts.map +1 -0
- package/dist/cmd/build/vite/docs-generator.js +81 -0
- package/dist/cmd/build/vite/docs-generator.js.map +1 -0
- package/dist/cmd/build/vite/index.d.ts +3 -3
- package/dist/cmd/build/vite/index.d.ts.map +1 -1
- package/dist/cmd/build/vite/index.js +9 -7
- package/dist/cmd/build/vite/index.js.map +1 -1
- package/dist/cmd/build/vite/lifecycle-generator.d.ts +1 -1
- package/dist/cmd/build/vite/lifecycle-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/lifecycle-generator.js +19 -5
- package/dist/cmd/build/vite/lifecycle-generator.js.map +1 -1
- package/dist/cmd/build/vite/metadata-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/metadata-generator.js +203 -7
- package/dist/cmd/build/vite/metadata-generator.js.map +1 -1
- package/dist/cmd/build/vite/prompt-generator.d.ts +23 -0
- package/dist/cmd/build/vite/prompt-generator.d.ts.map +1 -0
- package/dist/cmd/build/vite/prompt-generator.js +123 -0
- package/dist/cmd/build/vite/prompt-generator.js.map +1 -0
- package/dist/cmd/build/vite/registry-generator.d.ts +3 -3
- package/dist/cmd/build/vite/registry-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/registry-generator.js +644 -103
- package/dist/cmd/build/vite/registry-generator.js.map +1 -1
- package/dist/cmd/build/vite/route-discovery.d.ts +4 -0
- package/dist/cmd/build/vite/route-discovery.d.ts.map +1 -1
- package/dist/cmd/build/vite/route-discovery.js.map +1 -1
- package/dist/cmd/build/vite/server-bundler.d.ts +4 -0
- package/dist/cmd/build/vite/server-bundler.d.ts.map +1 -1
- package/dist/cmd/build/vite/server-bundler.js +63 -17
- package/dist/cmd/build/vite/server-bundler.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 +4 -0
- package/dist/cmd/build/vite/vite-asset-server-config.js.map +1 -1
- package/dist/cmd/build/vite/vite-builder.d.ts +1 -1
- package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-builder.js +118 -96
- package/dist/cmd/build/vite/vite-builder.js.map +1 -1
- package/dist/cmd/build/vite-bundler.js +6 -6
- package/dist/cmd/build/vite-bundler.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +89 -32
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/create-namespace.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/create-namespace.js +3 -1
- package/dist/cmd/cloud/keyvalue/create-namespace.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete-namespace.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete-namespace.js +3 -1
- package/dist/cmd/cloud/keyvalue/delete-namespace.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete.js +3 -1
- package/dist/cmd/cloud/keyvalue/delete.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/set.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/set.js +4 -2
- package/dist/cmd/cloud/keyvalue/set.js.map +1 -1
- package/dist/cmd/cloud/stream/get.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/get.js +2 -13
- package/dist/cmd/cloud/stream/get.js.map +1 -1
- package/dist/cmd/cloud/vector/delete-namespace.d.ts +3 -0
- package/dist/cmd/cloud/vector/delete-namespace.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/delete-namespace.js +77 -0
- package/dist/cmd/cloud/vector/delete-namespace.js.map +1 -0
- package/dist/cmd/cloud/vector/index.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/index.js +21 -4
- package/dist/cmd/cloud/vector/index.js.map +1 -1
- package/dist/cmd/cloud/vector/list-namespaces.d.ts +3 -0
- package/dist/cmd/cloud/vector/list-namespaces.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/list-namespaces.js +42 -0
- package/dist/cmd/cloud/vector/list-namespaces.js.map +1 -0
- package/dist/cmd/cloud/vector/stats.d.ts +3 -0
- package/dist/cmd/cloud/vector/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/stats.js +142 -0
- package/dist/cmd/cloud/vector/stats.js.map +1 -0
- package/dist/cmd/cloud/vector/upsert.d.ts +3 -0
- package/dist/cmd/cloud/vector/upsert.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/upsert.js +192 -0
- package/dist/cmd/cloud/vector/upsert.js.map +1 -0
- package/dist/cmd/dev/file-watcher.d.ts.map +1 -1
- package/dist/cmd/dev/file-watcher.js +94 -33
- package/dist/cmd/dev/file-watcher.js.map +1 -1
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/index.js +298 -61
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/dev/skills.d.ts +10 -0
- package/dist/cmd/dev/skills.d.ts.map +1 -0
- package/dist/cmd/dev/skills.js +57 -0
- package/dist/cmd/dev/skills.js.map +1 -0
- package/dist/cmd/dev/sync.d.ts.map +1 -1
- package/dist/cmd/dev/sync.js +19 -3
- package/dist/cmd/dev/sync.js.map +1 -1
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/index.js +1 -0
- package/dist/cmd/index.js.map +1 -1
- package/dist/cmd/project/create.d.ts.map +1 -1
- package/dist/cmd/project/create.js +3 -0
- package/dist/cmd/project/create.js.map +1 -1
- package/dist/cmd/project/template-flow.d.ts +1 -0
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- package/dist/cmd/project/template-flow.js +30 -5
- package/dist/cmd/project/template-flow.js.map +1 -1
- package/dist/cmd/setup/index.d.ts.map +1 -1
- package/dist/cmd/setup/index.js +1 -0
- package/dist/cmd/setup/index.js.map +1 -1
- package/dist/cmd/upgrade/index.d.ts +15 -0
- package/dist/cmd/upgrade/index.d.ts.map +1 -1
- package/dist/cmd/upgrade/index.js +59 -4
- package/dist/cmd/upgrade/index.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/domain.d.ts +45 -0
- package/dist/domain.d.ts.map +1 -0
- package/dist/domain.js +200 -0
- package/dist/domain.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/schema-generator.d.ts +2 -0
- package/dist/schema-generator.d.ts.map +1 -1
- package/dist/schema-generator.js +18 -0
- package/dist/schema-generator.js.map +1 -1
- package/dist/steps.d.ts +1 -1
- package/dist/steps.d.ts.map +1 -1
- package/dist/steps.js +16 -5
- package/dist/steps.js.map +1 -1
- package/dist/tui/prompt.d.ts +1 -2
- package/dist/tui/prompt.d.ts.map +1 -1
- package/dist/tui/prompt.js +8 -4
- package/dist/tui/prompt.js.map +1 -1
- package/dist/tui.d.ts +16 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +23 -2
- package/dist/tui.js.map +1 -1
- package/dist/types.d.ts +9 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -3
- package/dist/types.js.map +1 -1
- package/package.json +5 -8
- package/src/api.ts +1 -1
- package/src/cli.ts +47 -12
- package/src/cmd/ai/index.ts +6 -1
- package/src/cmd/ai/prompt/agent.md +306 -0
- package/src/cmd/ai/prompt/agent.ts +12 -322
- package/src/cmd/ai/prompt/api.md +360 -0
- package/src/cmd/ai/prompt/api.ts +13 -260
- package/src/cmd/ai/prompt/version.ts +61 -0
- package/src/cmd/ai/prompt/web.md +509 -0
- package/src/cmd/ai/prompt/web.ts +12 -282
- package/src/cmd/ai/skills/generate.ts +75 -0
- package/src/cmd/ai/skills/generator.ts +519 -0
- package/src/cmd/ai/skills/index.ts +23 -0
- package/src/cmd/auth/signup.ts +1 -0
- package/src/cmd/build/ast.ts +161 -48
- package/src/cmd/build/entry-generator.ts +258 -187
- package/src/cmd/build/vite/agent-discovery.ts +151 -58
- package/src/cmd/build/vite/bun-dev-server.ts +57 -27
- package/src/cmd/build/vite/docs-generator.ts +87 -0
- package/src/cmd/build/vite/index.ts +9 -7
- package/src/cmd/build/vite/lifecycle-generator.ts +19 -5
- package/src/cmd/build/vite/metadata-generator.ts +251 -7
- package/src/cmd/build/vite/prompt-generator.ts +169 -0
- package/src/cmd/build/vite/registry-generator.ts +750 -108
- package/src/cmd/build/vite/route-discovery.ts +4 -0
- package/src/cmd/build/vite/server-bundler.ts +73 -23
- package/src/cmd/build/vite/vite-asset-server-config.ts +5 -0
- package/src/cmd/build/vite/vite-builder.ts +134 -100
- package/src/cmd/build/vite-bundler.ts +6 -6
- package/src/cmd/cloud/deploy.ts +114 -36
- package/src/cmd/cloud/keyvalue/create-namespace.ts +3 -1
- package/src/cmd/cloud/keyvalue/delete-namespace.ts +3 -1
- package/src/cmd/cloud/keyvalue/delete.ts +3 -1
- package/src/cmd/cloud/keyvalue/set.ts +4 -2
- package/src/cmd/cloud/stream/get.ts +2 -9
- package/src/cmd/cloud/vector/delete-namespace.ts +89 -0
- package/src/cmd/cloud/vector/index.ts +21 -4
- package/src/cmd/cloud/vector/list-namespaces.ts +46 -0
- package/src/cmd/cloud/vector/stats.ts +160 -0
- package/src/cmd/cloud/vector/upsert.ts +216 -0
- package/src/cmd/dev/file-watcher.ts +109 -34
- package/src/cmd/dev/index.ts +364 -60
- package/src/cmd/dev/skills.ts +82 -0
- package/src/cmd/dev/sync.ts +41 -6
- package/src/cmd/index.ts +1 -0
- package/src/cmd/project/create.ts +3 -0
- package/src/cmd/project/template-flow.ts +37 -5
- package/src/cmd/setup/index.ts +1 -0
- package/src/cmd/upgrade/index.ts +68 -4
- package/src/config.ts +9 -0
- package/src/domain.ts +273 -0
- package/src/index.ts +0 -5
- package/src/runtime-bootstrap.md +1 -1
- package/src/schema-generator.ts +23 -0
- package/src/steps.ts +16 -5
- package/src/tui/prompt.ts +11 -5
- package/src/tui.ts +21 -2
- package/src/types/md.d.ts +8 -0
- package/src/types.ts +12 -3
- package/dist/cmd/cloud/domain.d.ts +0 -17
- package/dist/cmd/cloud/domain.d.ts.map +0 -1
- package/dist/cmd/cloud/domain.js +0 -79
- package/dist/cmd/cloud/domain.js.map +0 -1
- package/dist/runtime-bootstrap.d.ts +0 -56
- package/dist/runtime-bootstrap.d.ts.map +0 -1
- package/dist/runtime-bootstrap.js +0 -95
- package/dist/runtime-bootstrap.js.map +0 -1
- package/src/cmd/cloud/domain.ts +0 -100
- package/src/runtime-bootstrap.ts +0 -131
package/src/cmd/build/ast.ts
CHANGED
|
@@ -1173,6 +1173,37 @@ export async function parseRoute(
|
|
|
1173
1173
|
}
|
|
1174
1174
|
}
|
|
1175
1175
|
}
|
|
1176
|
+
|
|
1177
|
+
// Scan for exported schemas (for WebSocket/SSE routes)
|
|
1178
|
+
let exportedInputSchemaName: string | undefined;
|
|
1179
|
+
let exportedOutputSchemaName: string | undefined;
|
|
1180
|
+
for (const body of ast.body) {
|
|
1181
|
+
if (body.type === 'ExportNamedDeclaration') {
|
|
1182
|
+
const exportDecl = body as {
|
|
1183
|
+
declaration?: {
|
|
1184
|
+
type: string;
|
|
1185
|
+
declarations?: Array<ASTVariableDeclarator>;
|
|
1186
|
+
};
|
|
1187
|
+
};
|
|
1188
|
+
|
|
1189
|
+
if (exportDecl.declaration?.type === 'VariableDeclaration') {
|
|
1190
|
+
const varDecl = exportDecl.declaration as {
|
|
1191
|
+
declarations: Array<ASTVariableDeclarator>;
|
|
1192
|
+
};
|
|
1193
|
+
for (const d of varDecl.declarations) {
|
|
1194
|
+
if (d.id.type === 'Identifier') {
|
|
1195
|
+
const name = (d.id as ASTNodeIdentifier).name;
|
|
1196
|
+
if (name === 'inputSchema') {
|
|
1197
|
+
exportedInputSchemaName = name;
|
|
1198
|
+
} else if (name === 'outputSchema') {
|
|
1199
|
+
exportedOutputSchemaName = name;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1176
1207
|
for (const body of ast.body) {
|
|
1177
1208
|
if (body.type === 'ExportDefaultDeclaration') {
|
|
1178
1209
|
const identifier = body.declaration as ASTNodeIdentifier;
|
|
@@ -1406,6 +1437,16 @@ export async function parseRoute(
|
|
|
1406
1437
|
}
|
|
1407
1438
|
}
|
|
1408
1439
|
|
|
1440
|
+
// For WebSocket/SSE routes that don't use validator(), fall back to exported schemas
|
|
1441
|
+
if (!routeConfig.hasValidator && (type === 'websocket' || type === 'sse')) {
|
|
1442
|
+
if (!routeConfig.inputSchemaVariable && exportedInputSchemaName) {
|
|
1443
|
+
routeConfig.inputSchemaVariable = exportedInputSchemaName;
|
|
1444
|
+
}
|
|
1445
|
+
if (!routeConfig.outputSchemaVariable && exportedOutputSchemaName) {
|
|
1446
|
+
routeConfig.outputSchemaVariable = exportedOutputSchemaName;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1409
1450
|
routes.push({
|
|
1410
1451
|
id,
|
|
1411
1452
|
method: method as 'get' | 'post' | 'put' | 'delete' | 'patch',
|
|
@@ -1528,10 +1569,17 @@ export function checkRouteConflicts(content: string, workbenchEndpoint: string):
|
|
|
1528
1569
|
*/
|
|
1529
1570
|
export function extractAppStateType(content: string): string | null {
|
|
1530
1571
|
try {
|
|
1531
|
-
const sourceFile = ts.createSourceFile(
|
|
1572
|
+
const sourceFile = ts.createSourceFile(
|
|
1573
|
+
'app.ts',
|
|
1574
|
+
content,
|
|
1575
|
+
ts.ScriptTarget.Latest,
|
|
1576
|
+
true,
|
|
1577
|
+
ts.ScriptKind.TS
|
|
1578
|
+
);
|
|
1532
1579
|
let appStateType: string | null = null;
|
|
1533
1580
|
let foundCreateApp = false;
|
|
1534
1581
|
let foundSetup = false;
|
|
1582
|
+
let exportedSetupFunc: ts.FunctionDeclaration | undefined;
|
|
1535
1583
|
|
|
1536
1584
|
function visitNode(node: ts.Node): void {
|
|
1537
1585
|
// Look for createApp call expression (can be on await expression)
|
|
@@ -1584,14 +1632,49 @@ export function extractAppStateType(content: string): string | null {
|
|
|
1584
1632
|
}
|
|
1585
1633
|
}
|
|
1586
1634
|
|
|
1635
|
+
// Also record exported setup function
|
|
1636
|
+
if (
|
|
1637
|
+
ts.isFunctionDeclaration(node) &&
|
|
1638
|
+
node.name &&
|
|
1639
|
+
node.name.text === 'setup' &&
|
|
1640
|
+
node.modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)
|
|
1641
|
+
) {
|
|
1642
|
+
exportedSetupFunc = node;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1587
1645
|
ts.forEachChild(node, visitNode);
|
|
1588
1646
|
}
|
|
1589
1647
|
|
|
1590
1648
|
function findReturnObject(
|
|
1591
|
-
func: ts.FunctionExpression | ts.ArrowFunction
|
|
1649
|
+
func: ts.FunctionExpression | ts.ArrowFunction | ts.FunctionDeclaration
|
|
1592
1650
|
): ts.ObjectLiteralExpression | null {
|
|
1593
1651
|
let returnObject: ts.ObjectLiteralExpression | null = null;
|
|
1594
1652
|
|
|
1653
|
+
// Handle arrow function with expression body: () => ({ ... })
|
|
1654
|
+
if (ts.isArrowFunction(func) && !ts.isBlock(func.body)) {
|
|
1655
|
+
const bodyExpr = func.body;
|
|
1656
|
+
// Handle parenthesized expression: () => ({ ... })
|
|
1657
|
+
const expr = ts.isParenthesizedExpression(bodyExpr) ? bodyExpr.expression : bodyExpr;
|
|
1658
|
+
|
|
1659
|
+
if (ts.isObjectLiteralExpression(expr)) {
|
|
1660
|
+
return expr;
|
|
1661
|
+
}
|
|
1662
|
+
if (ts.isIdentifier(expr)) {
|
|
1663
|
+
// Support: const state = {...}; const setup = () => state;
|
|
1664
|
+
// Walk up to find the enclosing source file or statement list
|
|
1665
|
+
let scope: ts.Node = func;
|
|
1666
|
+
while (scope && !ts.isSourceFile(scope) && !ts.isBlock(scope)) {
|
|
1667
|
+
scope = scope.parent;
|
|
1668
|
+
}
|
|
1669
|
+
if (scope) {
|
|
1670
|
+
findVariableDeclaration(scope, expr.text);
|
|
1671
|
+
}
|
|
1672
|
+
return returnObject;
|
|
1673
|
+
}
|
|
1674
|
+
// For other expressions, can't extract type
|
|
1675
|
+
return null;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1595
1678
|
function visitFuncNode(node: ts.Node): void {
|
|
1596
1679
|
if (ts.isReturnStatement(node) && node.expression) {
|
|
1597
1680
|
// Handle direct object literal
|
|
@@ -1603,7 +1686,9 @@ export function extractAppStateType(content: string): string | null {
|
|
|
1603
1686
|
// Try to find the variable declaration
|
|
1604
1687
|
const varName = node.expression.text;
|
|
1605
1688
|
// Walk back through the function to find the declaration
|
|
1606
|
-
|
|
1689
|
+
if (func.body && ts.isBlock(func.body)) {
|
|
1690
|
+
findVariableDeclaration(func.body, varName);
|
|
1691
|
+
}
|
|
1607
1692
|
}
|
|
1608
1693
|
}
|
|
1609
1694
|
ts.forEachChild(node, visitFuncNode);
|
|
@@ -1625,7 +1710,7 @@ export function extractAppStateType(content: string): string | null {
|
|
|
1625
1710
|
visitForVar(body);
|
|
1626
1711
|
}
|
|
1627
1712
|
|
|
1628
|
-
if (func.body) {
|
|
1713
|
+
if (func.body && ts.isBlock(func.body)) {
|
|
1629
1714
|
visitFuncNode(func.body);
|
|
1630
1715
|
}
|
|
1631
1716
|
|
|
@@ -1682,6 +1767,17 @@ export function extractAppStateType(content: string): string | null {
|
|
|
1682
1767
|
|
|
1683
1768
|
visitNode(sourceFile);
|
|
1684
1769
|
|
|
1770
|
+
// If no inline setup found but we have an exported setup function, use that
|
|
1771
|
+
if (foundCreateApp && !foundSetup && exportedSetupFunc) {
|
|
1772
|
+
foundSetup = true;
|
|
1773
|
+
const returnObj = findReturnObject(exportedSetupFunc);
|
|
1774
|
+
if (returnObj) {
|
|
1775
|
+
appStateType = objectLiteralToTypeDefinition(returnObj, sourceFile);
|
|
1776
|
+
} else {
|
|
1777
|
+
logger.debug('Exported setup function found but no return object');
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1685
1781
|
if (!foundCreateApp) {
|
|
1686
1782
|
logger.debug('Did not find createApp call in app.ts');
|
|
1687
1783
|
} else if (!foundSetup) {
|
|
@@ -1728,17 +1824,7 @@ async function updateTsconfigPathMapping(rootDir: string, shouldAdd: boolean): P
|
|
|
1728
1824
|
|
|
1729
1825
|
if (shouldAdd) {
|
|
1730
1826
|
// Add or update the path mapping
|
|
1731
|
-
tsconfig.compilerOptions.paths['@agentuity/runtime'] = [
|
|
1732
|
-
'./.agentuity/.agentuity_runtime.ts',
|
|
1733
|
-
];
|
|
1734
|
-
|
|
1735
|
-
// Ensure .agentuity_types.ts is included so module augmentation works
|
|
1736
|
-
if (!tsconfig.include) {
|
|
1737
|
-
tsconfig.include = [];
|
|
1738
|
-
}
|
|
1739
|
-
if (!tsconfig.include.includes('.agentuity/.agentuity_types.ts')) {
|
|
1740
|
-
tsconfig.include.push('.agentuity/.agentuity_types.ts');
|
|
1741
|
-
}
|
|
1827
|
+
tsconfig.compilerOptions.paths['@agentuity/runtime'] = ['./src/generated/router.ts'];
|
|
1742
1828
|
|
|
1743
1829
|
logger.debug('Added @agentuity/runtime path mapping to tsconfig.json');
|
|
1744
1830
|
} else {
|
|
@@ -1769,9 +1855,10 @@ async function updateTsconfigPathMapping(rootDir: string, shouldAdd: boolean): P
|
|
|
1769
1855
|
const RuntimePackageNotFound = StructuredError('RuntimePackageNotFound');
|
|
1770
1856
|
|
|
1771
1857
|
/**
|
|
1772
|
-
* Generate lifecycle type files (
|
|
1858
|
+
* Generate lifecycle type files (src/generated/state.ts and src/generated/router.ts)
|
|
1773
1859
|
*
|
|
1774
1860
|
* @param rootDir - Root directory of the project
|
|
1861
|
+
* @param outDir - Output directory (typically src/generated/)
|
|
1775
1862
|
* @param appFilePath - Path to app.ts file
|
|
1776
1863
|
* @returns true if files were generated, false if no setup found
|
|
1777
1864
|
*/
|
|
@@ -1794,44 +1881,60 @@ export async function generateLifecycleTypes(
|
|
|
1794
1881
|
return false;
|
|
1795
1882
|
}
|
|
1796
1883
|
|
|
1797
|
-
|
|
1884
|
+
// Ensure output directory exists (now src/generated instead of .agentuity)
|
|
1885
|
+
if (!existsSync(outDir)) {
|
|
1886
|
+
mkdirSync(outDir, { recursive: true });
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
// Find @agentuity/runtime by walking up directory tree
|
|
1890
|
+
// This works in any project structure - monorepos, nested projects, etc.
|
|
1891
|
+
let runtimePkgPath: string | null = null;
|
|
1892
|
+
let currentDir = rootDir;
|
|
1893
|
+
const searchedPaths: string[] = [];
|
|
1894
|
+
|
|
1895
|
+
while (currentDir && currentDir !== '/' && currentDir !== '.') {
|
|
1896
|
+
const candidatePath = join(currentDir, 'node_modules', '@agentuity', 'runtime');
|
|
1897
|
+
searchedPaths.push(candidatePath);
|
|
1898
|
+
|
|
1899
|
+
if (existsSync(candidatePath)) {
|
|
1900
|
+
runtimePkgPath = candidatePath;
|
|
1901
|
+
logger.debug(`Found runtime package at: ${candidatePath}`);
|
|
1902
|
+
break;
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
// Try packages/ for monorepo source layout
|
|
1906
|
+
const packagesPath = join(currentDir, 'packages', 'runtime');
|
|
1907
|
+
searchedPaths.push(packagesPath);
|
|
1908
|
+
|
|
1909
|
+
if (existsSync(packagesPath)) {
|
|
1910
|
+
runtimePkgPath = packagesPath;
|
|
1911
|
+
logger.debug(`Found runtime package (source) at: ${packagesPath}`);
|
|
1912
|
+
break;
|
|
1913
|
+
}
|
|
1798
1914
|
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1915
|
+
// Move up one directory
|
|
1916
|
+
const parent = dirname(currentDir);
|
|
1917
|
+
if (parent === currentDir) break; // Reached root
|
|
1918
|
+
currentDir = parent;
|
|
1802
1919
|
}
|
|
1803
1920
|
|
|
1804
|
-
|
|
1805
|
-
// Try multiple locations: app-level node_modules, then monorepo root
|
|
1806
|
-
const appLevelPath = join(rootDir, 'node_modules', '@agentuity', 'runtime');
|
|
1807
|
-
// From apps/testing/auth-app to monorepo root is 3 levels up (../../..)
|
|
1808
|
-
const rootLevelPath = join(rootDir, '..', '..', '..', 'node_modules', '@agentuity', 'runtime');
|
|
1809
|
-
|
|
1810
|
-
let runtimePkgPath: string;
|
|
1811
|
-
if (existsSync(appLevelPath)) {
|
|
1812
|
-
runtimePkgPath = appLevelPath;
|
|
1813
|
-
logger.debug(`Found runtime package at app level: ${appLevelPath}`);
|
|
1814
|
-
} else if (existsSync(rootLevelPath)) {
|
|
1815
|
-
runtimePkgPath = rootLevelPath;
|
|
1816
|
-
logger.debug(`Found runtime package at root level: ${rootLevelPath}`);
|
|
1817
|
-
} else {
|
|
1921
|
+
if (!runtimePkgPath) {
|
|
1818
1922
|
throw new RuntimePackageNotFound({
|
|
1819
1923
|
message:
|
|
1820
|
-
`@agentuity/runtime package not found
|
|
1821
|
-
` - ${
|
|
1822
|
-
` - ${rootLevelPath}\n` +
|
|
1924
|
+
`@agentuity/runtime package not found.\n` +
|
|
1925
|
+
`Searched paths:\n${searchedPaths.map((p) => ` - ${p}`).join('\n')}\n` +
|
|
1823
1926
|
`Make sure dependencies are installed by running 'bun install' or 'npm install'`,
|
|
1824
1927
|
});
|
|
1825
1928
|
}
|
|
1826
1929
|
|
|
1827
1930
|
let runtimeImportPath: string | null = null;
|
|
1828
1931
|
|
|
1829
|
-
// Calculate relative path from
|
|
1932
|
+
// Calculate relative path from src/generated/ to the package location
|
|
1830
1933
|
// Don't resolve symlinks - we want to use the symlink path so it works in both
|
|
1831
1934
|
// local dev (symlinked to packages/) and CI (actual node_modules)
|
|
1832
1935
|
if (existsSync(runtimePkgPath)) {
|
|
1833
|
-
// Calculate relative path from
|
|
1834
|
-
const relPath = relative(
|
|
1936
|
+
// Calculate relative path from src/generated/ to node_modules package
|
|
1937
|
+
const relPath = relative(outDir, runtimePkgPath);
|
|
1835
1938
|
runtimeImportPath = relPath;
|
|
1836
1939
|
logger.debug(`Using relative path to runtime package: ${relPath}`);
|
|
1837
1940
|
} else {
|
|
@@ -1848,10 +1951,11 @@ export async function generateLifecycleTypes(
|
|
|
1848
1951
|
});
|
|
1849
1952
|
}
|
|
1850
1953
|
|
|
1851
|
-
// Now generate .
|
|
1954
|
+
// Now generate state.ts with AppState type
|
|
1852
1955
|
// NOTE: We can ONLY augment the package name, not relative paths
|
|
1853
1956
|
// TypeScript resolves @agentuity/runtime through path mapping -> wrapper -> actual package
|
|
1854
|
-
const typesContent = `//
|
|
1957
|
+
const typesContent = `// @generated
|
|
1958
|
+
// AUTO-GENERATED from app.ts setup() return type
|
|
1855
1959
|
// This file is auto-generated by the build tool - do not edit manually
|
|
1856
1960
|
|
|
1857
1961
|
/**
|
|
@@ -1877,17 +1981,22 @@ export type GeneratedAppState = ${appStateType};
|
|
|
1877
1981
|
declare module '@agentuity/runtime' {
|
|
1878
1982
|
interface AppState extends GeneratedAppState {}
|
|
1879
1983
|
}
|
|
1984
|
+
|
|
1985
|
+
// FOUND AN ERROR IN THIS FILE?
|
|
1986
|
+
// Please file an issue at https://github.com/agentuity/sdk/issues
|
|
1987
|
+
// or if you know the fix please submit a PR!
|
|
1880
1988
|
`;
|
|
1881
|
-
const typesPath = join(outDir, '.
|
|
1989
|
+
const typesPath = join(outDir, 'state.ts');
|
|
1882
1990
|
await Bun.write(typesPath, typesContent);
|
|
1883
1991
|
logger.debug(`Generated lifecycle types: ${typesPath}`);
|
|
1884
1992
|
|
|
1885
|
-
const wrapperContent = `//
|
|
1993
|
+
const wrapperContent = `// @generated
|
|
1994
|
+
// AUTO-GENERATED runtime wrapper
|
|
1886
1995
|
// This file is auto-generated by the build tool - do not edit manually
|
|
1887
1996
|
|
|
1888
1997
|
// Import augmentations file (NOT type-only) to trigger module augmentation
|
|
1889
|
-
import type { GeneratedAppState } from '
|
|
1890
|
-
import '
|
|
1998
|
+
import type { GeneratedAppState } from './state';
|
|
1999
|
+
import './state';
|
|
1891
2000
|
|
|
1892
2001
|
// Import from actual package location
|
|
1893
2002
|
import { createRouter as baseCreateRouter, type Env } from '${runtimeImportPath}/src/index';
|
|
@@ -1929,13 +2038,17 @@ type AppRouter = Hono<AppEnv>;
|
|
|
1929
2038
|
* \`\`\`
|
|
1930
2039
|
*/
|
|
1931
2040
|
export function createRouter(): AppRouter {
|
|
1932
|
-
return baseCreateRouter() as
|
|
2041
|
+
return baseCreateRouter() as unknown as AppRouter;
|
|
1933
2042
|
}
|
|
1934
2043
|
|
|
1935
2044
|
// Re-export everything else
|
|
1936
2045
|
export * from '${runtimeImportPath}/src/index';
|
|
2046
|
+
|
|
2047
|
+
// FOUND AN ERROR IN THIS FILE?
|
|
2048
|
+
// Please file an issue at https://github.com/agentuity/sdk/issues
|
|
2049
|
+
// or if you know the fix please submit a PR!
|
|
1937
2050
|
`;
|
|
1938
|
-
const wrapperPath = join(outDir, '.
|
|
2051
|
+
const wrapperPath = join(outDir, 'router.ts');
|
|
1939
2052
|
await Bun.write(wrapperPath, wrapperContent);
|
|
1940
2053
|
logger.debug(`Generated lifecycle wrapper: ${wrapperPath}`);
|
|
1941
2054
|
|