refactor: remove routes.ts generation — derive types from Hono router#1168
Merged
refactor: remove routes.ts generation — derive types from Hono router#1168
Conversation
… routes.ts
- Create _route-meta.ts with Symbol.for('agentuity:route-meta') tagging
- Tag websocket(), sse(), stream(), cron() handlers with route type metadata
- Build-time route discovery now detects handler types from router.routes
- Add 'export {}' module marker to routes.ts when no imports present
(prevents declare module from replacing instead of augmenting)
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 Coding Plan
Comment |
…y types Remove the entire route registry type system and associated React hooks. Users should use Hono's native hc() client for type-safe API calls. Deleted from @agentuity/react: - useAPI, useWebsocket, useEventStream hooks - createClient, createAPIClient functions - RouteRegistry, RPCRouteRegistry type re-exports Deleted from @agentuity/frontend: - client/ directory (framework-agnostic client) - RouteRegistry, WebSocketRouteRegistry, SSERouteRegistry, RPCRouteRegistry interfaces Deleted from CLI: - generateRouteRegistry() and all route registry template code (~920 lines) - RouteInfo interface (no longer needed) - routes.ts virtual module Net: -13,579 lines deleted, +34 added
- Update web.md AI prompt: replace useAPI/useWebsocket examples with hc() client - Update api.md, agent.md: remove routes.ts from generated files list - Update react AGENTS.md and README.md for new hook surface - Update frontend AGENTS.md: remove client/ and types.ts references - Update claude-code skill files: replace hook examples with hc() - Update docs-generator.ts: remove routes.ts from generated files docs - Clean up stale comments in context.tsx - Remove unused useEffect import from context.tsx
- Replace all useAPI, createAPIClient, createClient imports with hc() - Rewrite routes to use chained Hono methods for schema type propagation - Use new Hono<Env>() directly instead of createRouter() in route files - Export AppRouter type from router.ts for typed client usage - Fix websocket() return type to preserve outputFormat: 'ws' for hc()$ws - Update StreamsPage to use native WebSocket/EventSource via hc() client - Update PathParamsPage to use hc() path param syntax (client[':param']) - Update RpcTestPage to use hc().$post/$ws + native EventSource for SSE - All typechecks pass (0 errors), all tests pass (665 runtime, 755 CLI)
📦 Canary Packages Publishedversion: PackagesInstallAdd to your {
"dependencies": {
"@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-cli-1.0.39-6aa48f4.tgz",
"@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-postgres-1.0.39-6aa48f4.tgz",
"@agentuity/react": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-react-1.0.39-6aa48f4.tgz",
"@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-server-1.0.39-6aa48f4.tgz",
"@agentuity/frontend": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-frontend-1.0.39-6aa48f4.tgz",
"@agentuity/auth": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-auth-1.0.39-6aa48f4.tgz",
"@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-opencode-1.0.39-6aa48f4.tgz",
"@agentuity/workbench": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-workbench-1.0.39-6aa48f4.tgz",
"@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-schema-1.0.39-6aa48f4.tgz",
"@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-drizzle-1.0.39-6aa48f4.tgz",
"@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-coder-1.0.39-6aa48f4.tgz",
"@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-claude-code-1.0.39-6aa48f4.tgz",
"@agentuity/evals": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-evals-1.0.39-6aa48f4.tgz",
"@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-runtime-1.0.39-6aa48f4.tgz",
"@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-core-1.0.39-6aa48f4.tgz"
}
}Or install directly: bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-cli-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-postgres-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-react-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-server-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-frontend-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-auth-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-opencode-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-workbench-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-schema-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-drizzle-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-coder-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-claude-code-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-evals-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-runtime-1.0.39-6aa48f4.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-core-1.0.39-6aa48f4.tgz |
This comment has been minimized.
This comment has been minimized.
- Delete 3 orphaned react test files (useAPI-dynamic-params, type-safety-issue-468, route-registry-types) - Migrate templates/_base and templates/default to chained Hono + hc() client - Migrate tanstack-start, nextjs-app, vite-rsc-app test apps to hc() client - Migrate auth-package-app to fetch-based helpers (no hc() - testing auth features) - Migrate docs app ChatDemo + HelloDemo to fetch-based calls - Update opencode agent prompts to reference hc() instead of useAPI/useWebsocket - Update docs nav-data descriptions - Fix sse.ts JSDoc to reference EventSource/EventStreamManager instead of useEventStream - All format/lint clean, all builds pass
…outer imports - Rewrite apps/docs/src/api/index.ts to import and .route() all 20 sub-routers - Remove unused createRouter imports from 5 route files - Convert route files from createRouter() imperative to new Hono<Env>() chained - Delete stale apps/docs/src/generated/routes.ts (1,983 lines)
This comment has been minimized.
This comment has been minimized.
…e2e test assertions
- Add hono to dependencies in tanstack-start, nextjs-app, vite-rsc-app,
and the _base template (needed for hono/client imports)
- Use `${window.location.origin}/api` instead of "/api" for hc() in
e2e-web pages — Hono's $ws() needs an absolute URL to construct
ws:// protocol (relative URLs cause 'Invalid URL' in new URL())
- Fix rpc.pw.ts assertion: page title is 'Hono Client Test' not
'RPC Client Test'
- Include build-regenerated files (generated app.ts, AGENTS.md prompts)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Eliminates
routes.tsgeneration and the entire@agentuity/reactAPI hook layer (useAPI,useWebsocket,useEventStream,createClient). All API communication now goes through Hono's nativehc<AppRouter>()typed client, which already carries full type safety via the router'sSchematype parameter.213 files changed, +4,275 / -37,317 lines
What changed
Removed
routes.tsgeneration — no moreRouteRegistry/RPCRouteRegistrymodule augmentation@agentuity/reacthooks —useAPI,useWebsocket,useEventStream,createClient,createAPIClient,setGlobalBaseUrl,setGlobalAuthHeaderand all associated types@agentuity/frontendclient — route-registry-based client utilitiesast.ts(-3,120 lines) — full AST pipeline,acorn-loose+astringdeps removedroute-discovery.tsand all file-convention codeAdded / Changed
hc()client everywhere — all test apps, templates, and docs now usehc<AppRouter>()for type-safe API calls,$ws()for WebSocket, nativeEventSourcefor SSEwebsocket(),sse(),stream(),cron()handlers self-identify viaSymbol.for('agentuity:route-meta')for handler type detection at build timecreateRouter()simplified to thinnew Hono<Env>()wrapper preserving Schema type inferenceimport()+agent.metadata.*+toJSONSchema()instead of AST parsingapp-router-detectorrewritten with TypeScript compiler API (no acorn)jsonSchemaToTypeScript()_baseanddefaulttemplates usehc()client pattern,honoadded as explicit dependencyCI fixes (latest commit)
honodependency totanstack-start,nextjs-app,vite-rsc-app, and_basetemplate (needed forhono/clientimports after migration)hc()base URL in e2e-web pages — changed from relative'/api'to\${window.location.origin}/api`(Hono's$ws()needs absolute URLs to constructws://` protocol)rpc.pw.tsassertion to match renamed page title ("Hono Client Test"not"RPC Client Test")app.ts, AGENTS.md prompts)