Agent-native UI system

给聊天、CLI 和编码代理用的同一份契约

用同一份 registry 源码和 @timui/agent SDK 支撑聊天式需求拆解、CLI 命令编排、Agent 自动检索、代码生成与落地校验。React、Vue、HTML、WeApp 的选择规则保持一致。

Chat builder
live contract
我需要一个移动端 SaaS 首页,带数据概览、任务列表和底部导航。
选择 registry:page 模板,补充 dashboard block,并拉取 React 源码。
CLI path
npx timkit add mobile-agent-console --yes --framework react
Agent JSON
{ type: "registry:page", frameworks: ["react", "vue"] }

Discover

registry-index.json

Plan

@timui/agent SDK

Install

timkit agent CLI

Compose

pages + blocks + ui

Agent build workflow

1

Parse intent

识别页面、区块、原子组件和目标框架

2

Read contract

先读 /agent/{name}.json,只用里面列出的 props 和示例

3

Install code

npx timkit add <name> --yes --framework <target>

4

Verify

npx timkit agent validate <file> --component <name>,再跑目标项目的 typecheck

Plan、Inspect、Validate

Plan

从一句话选出组件和安装命令。

npx timkit agent plan "我要一个按钮" --framework react

Inspect

先看契约里的 props,再写组件。

npx timkit agent inspect button

Validate

对照契约检查源码。

npx timkit agent validate ./button.tsx --framework react --component button

Install

按 plan 给出的命令安装。

npx timkit add button --yes --framework react
Programmable Agent SDK

One API for chat sessions, CLI plans, and code agents

@timui/agent exposes registry search, component metadata, install planning, starter code generation, validation hints, and multi-turn chat state. Agents can stop scraping prose pages and operate on stable typed contracts.

import { TimkitAgent } from '@timui/agent'

const agent = new TimkitAgent({ registryItems })
const plan = agent.plan({
  prompt: 'Build a mobile AI workspace with chat, tool calls, and preview',
  framework: 'react',
  mode: 'agent',
  mobile: true,
})

if (plan.confidence === 'none') {
  throw new Error(plan.clarification)
}

const code = agent.generateComponent({
  name: plan.selected[0].name,
  framework: plan.framework,
})
const check = agent.validateComponent(code.files[0].content, {
  framework: plan.framework,
  component: plan.selected[0].name,
})
Machine-readable endpoints

Stable URLs for model context

Agent 不需要抓取页面。它可以先读取目录,再按 item URL 拉取源码,最后根据框架和 viewport metadata 做选择。

Acceptance gates

Preview protocol

React and Vue both use LOAD_PREVIEW runtime messages.

Framework parity

Demo source resolution is canonical across frameworks.

Performance budget

Registry size and preview lazy loading are checked by goal scripts.

pnpm goal:acceptance && pnpm goal:test:preview:protocol