Skip to content

Commit 153d432

Browse files
baozhoutaoclaude
andauthored
docs(plugin-ai): compile the README's snippets against the shipped surface (#8180)
Burns down the `packages/plugin-ai/README.md` entry in this gate's `UNGATED_DOCS` ledger (objectui#5174, batch 27). The entry is deleted rather than rewritten because the page now reads zero. The page taught an API the components do not have. All three exported components take a single `schema` prop plus callbacks (`AIFormAssistProps`, `AIRecommendationsProps`, `NLQueryInputProps`), while every example passed flat props -- `formId=`, `objectName=`, `fields=`, `maxResults=`, `layout=`. The README was wrong against components that are right, so the README is what moves: one typed binding per example, annotated with the schema type `@object-ui/types` exports, passed as `schema={...}`, with `declare const` stand-ins for the two ambient names the page never defined. Three of the four `tsx` fences were bare JSX with no import line, so the undefined component name short-circuited the prop check on the same element: the ledger's `TS2322x3` was the visible half of six. The three latent ones surface only once the names resolve, and this diff pays down all six. No `packages/plugin-ai/src/**` or `packages/types/src/**` edit, no widened type, no fragment marker, no loosened gate. The gate file's strictness region is byte-identical. Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr Co-authored-by: Claude <noreply@anthropic.com>
1 parent a915064 commit 153d432

2 files changed

Lines changed: 103 additions & 50 deletions

File tree

‎packages/plugin-ai/README.md‎

Lines changed: 103 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,92 +22,147 @@ npm install @object-ui/plugin-ai
2222

2323
## Quick Start
2424

25+
Every component in this package takes exactly one schema object plus optional
26+
callbacks — `schema` carries the configuration, the callbacks carry the
27+
behaviour. The schema types ship from `@object-ui/types`.
28+
2529
```tsx
2630
import { AIFormAssist, AIRecommendations, NLQueryInput } from '@object-ui/plugin-ai';
31+
import type {
32+
AIFormAssistSchema,
33+
AIRecommendationItem,
34+
AIRecommendationsSchema,
35+
NLQuerySchema,
36+
} from '@object-ui/types';
37+
38+
declare const recommendationsData: AIRecommendationItem[];
39+
40+
const contactAssist: AIFormAssistSchema = {
41+
type: 'ai-form-assist',
42+
formId: 'new-contact',
43+
objectName: 'Contact',
44+
fields: ['name', 'email', 'company'],
45+
showConfidence: true,
46+
};
2747

2848
function SmartForm() {
2949
return (
3050
<div>
31-
<AIFormAssist
32-
formId="new-contact"
33-
objectName="Contact"
34-
fields={['name', 'email', 'company']}
35-
showConfidence
36-
/>
51+
<AIFormAssist schema={contactAssist} />
3752
</div>
3853
);
3954
}
4055

56+
const productPicks: AIRecommendationsSchema = {
57+
type: 'ai-recommendations',
58+
objectName: 'Product',
59+
maxResults: 5,
60+
layout: 'grid',
61+
recommendations: recommendationsData,
62+
};
63+
4164
function RecommendationsPanel() {
42-
return (
43-
<AIRecommendations
44-
objectName="Product"
45-
maxResults={5}
46-
layout="grid"
47-
recommendations={recommendationsData}
48-
/>
49-
);
65+
return <AIRecommendations schema={productPicks} />;
5066
}
5167

68+
const orderSearch: NLQuerySchema = {
69+
type: 'nl-query',
70+
objectName: 'Order',
71+
placeholder: 'Ask a question about your orders...',
72+
suggestions: ['Show orders from last week', 'Top customers by revenue'],
73+
};
74+
5275
function SearchBar() {
53-
return (
54-
<NLQueryInput
55-
objectName="Order"
56-
placeholder="Ask a question about your orders..."
57-
suggestions={['Show orders from last week', 'Top customers by revenue']}
58-
/>
59-
);
76+
return <NLQueryInput schema={orderSearch} />;
6077
}
6178
```
6279

6380
## API
6481

6582
### AIFormAssist
6683

67-
AI-powered form field suggestions and auto-fill:
84+
AI-powered form field suggestions and auto-fill. Props: `schema`, plus the
85+
optional `onApply` and `onRefresh` callbacks.
6886

6987
```tsx
70-
<AIFormAssist
71-
formId="new-lead"
72-
objectName="Lead"
73-
fields={['name', 'email', 'phone']}
74-
autoFill={false}
75-
showConfidence
76-
showReasoning={false}
77-
/>
88+
import { AIFormAssist } from '@object-ui/plugin-ai';
89+
import type { AIFormAssistSchema } from '@object-ui/types';
90+
91+
const leadAssist: AIFormAssistSchema = {
92+
type: 'ai-form-assist',
93+
formId: 'new-lead',
94+
objectName: 'Lead',
95+
fields: ['name', 'email', 'phone'],
96+
autoFill: false,
97+
showConfidence: true,
98+
showReasoning: false,
99+
};
100+
101+
const assistPanel = (
102+
<AIFormAssist
103+
schema={leadAssist}
104+
onApply={(suggestion) => console.log(suggestion.fieldName, suggestion.value)}
105+
/>
106+
);
78107
```
79108

80109
### AIRecommendations
81110

82-
Display AI-generated recommendations:
111+
Display AI-generated recommendations. Props: `schema`, plus the optional
112+
`onSelect` and `onDismiss` callbacks.
83113

84114
```tsx
85-
<AIRecommendations
86-
objectName="Product"
87-
recommendations={data}
88-
maxResults={10}
89-
layout="list" // 'list' | 'grid' | 'carousel'
90-
showScores={false}
91-
emptyMessage="No recommendations available"
92-
/>
115+
import { AIRecommendations } from '@object-ui/plugin-ai';
116+
import type { AIRecommendationItem, AIRecommendationsSchema } from '@object-ui/types';
117+
118+
declare const data: AIRecommendationItem[];
119+
120+
const productPicks: AIRecommendationsSchema = {
121+
type: 'ai-recommendations',
122+
objectName: 'Product',
123+
recommendations: data,
124+
maxResults: 10,
125+
layout: 'list', // 'list' | 'grid' | 'carousel'
126+
showScores: false,
127+
emptyMessage: 'No recommendations available',
128+
};
129+
130+
const panel = (
131+
<AIRecommendations schema={productPicks} onSelect={(item) => console.log(item.id)} />
132+
);
93133
```
94134

95135
### NLQueryInput
96136

97-
Natural language query input for data exploration:
137+
Natural language query input for data exploration. Props: `schema`, plus the
138+
optional `onSubmit` callback.
98139

99140
```tsx
100-
<NLQueryInput
101-
objectName="Order"
102-
placeholder="Ask anything..."
103-
suggestions={['Recent orders', 'Revenue by month']}
104-
showHistory={false}
105-
/>
141+
import { NLQueryInput } from '@object-ui/plugin-ai';
142+
import type { NLQuerySchema } from '@object-ui/types';
143+
144+
const orderSearch: NLQuerySchema = {
145+
type: 'nl-query',
146+
objectName: 'Order',
147+
placeholder: 'Ask anything...',
148+
suggestions: ['Recent orders', 'Revenue by month'],
149+
showHistory: false,
150+
};
151+
152+
const searchBar = <NLQueryInput schema={orderSearch} onSubmit={(query) => console.log(query)} />;
106153
```
107154

108-
### Schema-Driven Usage
155+
## Schema-Driven Usage
156+
157+
Components auto-register with `ComponentRegistry` on import. The registry key is
158+
the schema's `type`, and it is **not** always the component name — `NLQueryInput`
159+
registers as `nl-query`:
109160

110-
Components auto-register with `ComponentRegistry`:
161+
| Component | Registry `type` | Schema type |
162+
|---|---|---|
163+
| `AIFormAssist` | `ai-form-assist` | `AIFormAssistSchema` |
164+
| `AIRecommendations` | `ai-recommendations` | `AIRecommendationsSchema` |
165+
| `NLQueryInput` | `nl-query` | `NLQuerySchema` |
111166

112167
```json
113168
{

‎scripts/check-doc-snippet-types.mjs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,6 @@ const UNGATED_DOCS = {
779779
'1 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies; 15 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; plus TS2741x1 — candidate real defects, un-triaged',
780780
'packages/fields/README.md':
781781
'2 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; 1 unresolved-module diagnostic(s)',
782-
'packages/plugin-ai/README.md':
783-
'5 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; plus TS2322x3 — candidate real defects, un-triaged',
784782
'packages/plugin-charts/README.md':
785783
'6 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies',
786784
'packages/plugin-chatbot/README.md':

0 commit comments

Comments
 (0)