Skip to content

refactor: remove routes.ts generation — derive types from Hono router#1168

Merged
Huijiro merged 7 commits intov2from
refactor/remove-routes-ts
Mar 12, 2026
Merged

refactor: remove routes.ts generation — derive types from Hono router#1168
Huijiro merged 7 commits intov2from
refactor/remove-routes-ts

Conversation

@Huijiro
Copy link
Copy Markdown
Member

@Huijiro Huijiro commented Mar 10, 2026

Summary

Eliminates routes.ts generation and the entire @agentuity/react API hook layer (useAPI, useWebsocket, useEventStream, createClient). All API communication now goes through Hono's native hc<AppRouter>() typed client, which already carries full type safety via the router's Schema type parameter.

213 files changed, +4,275 / -37,317 lines

What changed

Removed

  • routes.ts generation — no more RouteRegistry / RPCRouteRegistry module augmentation
  • @agentuity/react hooksuseAPI, useWebsocket, useEventStream, createClient, createAPIClient, setGlobalBaseUrl, setGlobalAuthHeader and all associated types
  • @agentuity/frontend client — route-registry-based client utilities
  • ast.ts (-3,120 lines) — full AST pipeline, acorn-loose + astring deps removed
  • File-based routingroute-discovery.ts and all file-convention code

Added / Changed

  • Hono hc() client everywhere — all test apps, templates, and docs now use hc<AppRouter>() for type-safe API calls, $ws() for WebSocket, native EventSource for SSE
  • Route-meta taggingwebsocket(), sse(), stream(), cron() handlers self-identify via Symbol.for('agentuity:route-meta') for handler type detection at build time
  • createRouter() simplified to thin new Hono<Env>() wrapper preserving Schema type inference
  • Agent discovery rewritten — uses import() + agent.metadata.* + toJSONSchema() instead of AST parsing
  • app-router-detector rewritten with TypeScript compiler API (no acorn)
  • Workbench schema display — derives TypeScript interface syntax from JSON Schema at runtime via jsonSchemaToTypeScript()
  • Templates updated_base and default templates use hc() client pattern, hono added as explicit dependency

CI fixes (latest commit)

  • Added missing hono dependency to tanstack-start, nextjs-app, vite-rsc-app, and _base template (needed for hono/client imports after migration)
  • Fixed 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)
  • Fixed rpc.pw.ts assertion to match renamed page title ("Hono Client Test" not "RPC Client Test")
  • Included build-regenerated files (generated app.ts, AGENTS.md prompts)

… 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)
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 10, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 848533fc-5362-45c4-acae-bed692e030d7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@agentuity-agent
Copy link
Copy Markdown

agentuity-agent bot commented Mar 10, 2026

The latest Agentuity deployment details. Learn more about Agentuity.

Project Deployment Preview Updated (UTC)
docs 🟡 Building - Mar 12, 2026 8:45 PM

Huijiro added 3 commits March 10, 2026 19:44
…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)
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 12, 2026

📦 Canary Packages Published

version: 1.0.39-6aa48f4

Packages
Package Version URL
@agentuity/cli 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-cli-1.0.39-6aa48f4.tgz
@agentuity/postgres 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-postgres-1.0.39-6aa48f4.tgz
@agentuity/react 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-react-1.0.39-6aa48f4.tgz
@agentuity/server 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-server-1.0.39-6aa48f4.tgz
@agentuity/frontend 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-frontend-1.0.39-6aa48f4.tgz
@agentuity/auth 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-auth-1.0.39-6aa48f4.tgz
@agentuity/opencode 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-opencode-1.0.39-6aa48f4.tgz
@agentuity/workbench 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-workbench-1.0.39-6aa48f4.tgz
@agentuity/schema 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-schema-1.0.39-6aa48f4.tgz
@agentuity/drizzle 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-drizzle-1.0.39-6aa48f4.tgz
@agentuity/coder 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-coder-1.0.39-6aa48f4.tgz
@agentuity/claude-code 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-claude-code-1.0.39-6aa48f4.tgz
@agentuity/evals 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-evals-1.0.39-6aa48f4.tgz
@agentuity/runtime 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-runtime-1.0.39-6aa48f4.tgz
@agentuity/core 1.0.39-6aa48f4 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.39-6aa48f4/agentuity-core-1.0.39-6aa48f4.tgz
Install

Add to your package.json:

{
  "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

@blacksmith-sh

This comment has been minimized.

Huijiro added 2 commits March 12, 2026 12:31
- 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)
@blacksmith-sh

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)
@Huijiro Huijiro merged commit f5a1206 into v2 Mar 12, 2026
16 of 18 checks passed
@Huijiro Huijiro deleted the refactor/remove-routes-ts branch March 12, 2026 21:02
This was referenced Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant