Skip to content

Commit d1ce546

Browse files
Claudehotlong
andauthored
Refactor objectstack-data and objectstack-kernel skills with rules/ structure
Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/7c9dbfcd-1ebf-450b-8756-2cd8cc41f5f6 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 1b646d5 commit d1ce546

File tree

11 files changed

+3744
-224
lines changed

11 files changed

+3744
-224
lines changed

skills/objectstack-data/SKILL.md

Lines changed: 148 additions & 224 deletions
Large diffs are not rendered by default.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Evaluation Tests (evals/)
2+
3+
This directory is reserved for future skill evaluation tests.
4+
5+
## Purpose
6+
7+
Evaluation tests (evals) validate that AI assistants correctly understand and apply the rules defined in this skill when generating code or providing guidance.
8+
9+
## Structure
10+
11+
When implemented, evals will follow this structure:
12+
13+
```
14+
evals/
15+
├── naming/
16+
│ ├── test-object-names.md
17+
│ ├── test-field-keys.md
18+
│ └── test-option-values.md
19+
├── relationships/
20+
│ ├── test-lookup-vs-master-detail.md
21+
│ └── test-junction-patterns.md
22+
├── validation/
23+
│ ├── test-script-inversion.md
24+
│ └── test-state-machine.md
25+
└── ...
26+
```
27+
28+
## Format
29+
30+
Each eval file will contain:
31+
1. **Scenario** — Description of the task
32+
2. **Expected Output** — Correct implementation
33+
3. **Common Mistakes** — Incorrect patterns to avoid
34+
4. **Validation Criteria** — How to score the output
35+
36+
## Status
37+
38+
⚠️ **Not yet implemented** — This is a placeholder for future development.
39+
40+
## Contributing
41+
42+
When adding evals:
43+
1. Each eval should test a single, specific rule or pattern
44+
2. Include both positive (correct) and negative (incorrect) examples
45+
3. Reference the corresponding rule file in `rules/`
46+
4. Use realistic scenarios from actual ObjectStack projects
Lines changed: 348 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,348 @@
1+
# Field Types Reference
2+
3+
Quick reference for choosing the right field type from 48 available options.
4+
5+
## Text & Content
6+
7+
| Type | When to Use | Config |
8+
|:-----|:------------|:-------|
9+
| `text` | Single-line strings (names, codes, titles) | `maxLength`, `minLength`, `defaultValue` |
10+
| `textarea` | Multi-line plain text (notes, descriptions) | `maxLength`, `rows` |
11+
| `email` | Email addresses — built-in format validation | `required`, `unique` |
12+
| `url` | Web URLs — built-in format validation | `required` |
13+
| `phone` | Phone numbers | `format` (custom regex) |
14+
| `password` | Masked / hashed input | `minLength`, `hashAlgorithm` |
15+
| `markdown` | Markdown-formatted content | `maxLength` |
16+
| `html` | Raw HTML content | `maxLength`, `sanitize` |
17+
| `richtext` | WYSIWYG rich text editor | `maxLength` |
18+
19+
## Numbers
20+
21+
| Type | When to Use | Config |
22+
|:-----|:------------|:-------|
23+
| `number` | Generic numeric value | `min`, `max`, `precision`, `step` |
24+
| `currency` | Monetary amounts | `currencyConfig` (precision, currencyMode, defaultCurrency) |
25+
| `percent` | Percentage values (0-100) | `min`, `max`, `precision` |
26+
27+
## Date & Time
28+
29+
| Type | When to Use | Config |
30+
|:-----|:------------|:-------|
31+
| `date` | Date only (no time component) | `defaultValue`, `min`, `max` |
32+
| `datetime` | Full date + time | `defaultValue`, `timezone` |
33+
| `time` | Time only (no date component) | `defaultValue`, `format` |
34+
35+
## Logic
36+
37+
| Type | When to Use | Config |
38+
|:-----|:------------|:-------|
39+
| `boolean` | Standard checkbox | `defaultValue` |
40+
| `toggle` | Toggle switch (distinct UI from checkbox) | `defaultValue` |
41+
42+
## Selection
43+
44+
| Type | When to Use | Config |
45+
|:-----|:------------|:-------|
46+
| `select` | Single-choice dropdown | `options` (value, label, color, default) |
47+
| `multiselect` | Tag-style multi-choice | `options`, `max` |
48+
| `radio` | Radio button group (fewer choices, always visible) | `options` |
49+
| `checkboxes` | Checkbox group | `options` |
50+
51+
**Critical:** Every option must have lowercase `value` and human-readable `label`.
52+
53+
```typescript
54+
options: [
55+
{ label: 'In Progress', value: 'in_progress', color: '#3498db' },
56+
{ label: 'Done', value: 'done', default: true },
57+
]
58+
```
59+
60+
## Relational
61+
62+
| Type | When to Use | Key Config |
63+
|:-----|:------------|:-----------|
64+
| `lookup` | Reference another object (independent) | `reference`, `referenceFilters`, `multiple` |
65+
| `master_detail` | Parent–child with lifecycle control | `reference`, `deleteBehavior` (cascade/restrict/set_null) |
66+
| `tree` | Hierarchical self-reference | `reference` |
67+
68+
Set `multiple: true` on lookup for many-to-many via junction.
69+
70+
## Media
71+
72+
| Type | When to Use | Config |
73+
|:-----|:------------|:-------|
74+
| `image` | Image files (PNG, JPG, GIF, WebP) | `fileAttachmentConfig` (maxSize, allowedTypes, storage) |
75+
| `file` | Generic file attachments | `fileAttachmentConfig`, `allowedExtensions` |
76+
| `avatar` | User/profile picture | `fileAttachmentConfig`, `cropAspectRatio` |
77+
| `video` | Video files | `fileAttachmentConfig`, `maxDuration` |
78+
| `audio` | Audio files | `fileAttachmentConfig`, `maxDuration` |
79+
80+
All use `fileAttachmentConfig` for size limits, allowed types, virus scanning, and storage provider.
81+
82+
## Calculated
83+
84+
| Type | When to Use | Config |
85+
|:-----|:------------|:-------|
86+
| `formula` | Computed from an expression referencing other fields | `expression`, `resultType` |
87+
| `summary` | Roll-up aggregation from child records | `summaryType` (count/sum/min/max/avg), `summaryField`, `reference` |
88+
| `autonumber` | Auto-incrementing display format | `format` (e.g., `"CASE-{0000}"`) |
89+
90+
## Enhanced Types
91+
92+
| Type | When to Use | Config |
93+
|:-----|:------------|:-------|
94+
| `location` | Geographic coordinates (lat/lng) | `defaultZoom`, `enableSearch` |
95+
| `address` | Structured address (street, city, country) | `countryFilter`, `autocomplete` |
96+
| `code` | Syntax-highlighted code editor | `language`, `theme` |
97+
| `json` | JSON data | `schema` (JSON Schema for validation) |
98+
| `color` | Color picker | `format` (hex/rgb/hsl), `alpha` |
99+
| `rating` | Star/heart rating | `max` (default 5), `icon` |
100+
| `slider` | Numeric slider | `min`, `max`, `step` |
101+
| `signature` | Digital signature pad | `signatureConfig` |
102+
| `qrcode` | QR code generator | `qrConfig` |
103+
| `progress` | Progress bar | `min`, `max`, `showPercentage` |
104+
| `tags` | Free-form tag input | `max`, `delimiter`, `caseSensitive` |
105+
| `vector` | AI/ML embeddings (semantic search, RAG) | `vectorConfig` (dimensions, distanceMetric, indexType) |
106+
107+
## Field Type Decision Tree
108+
109+
```
110+
What kind of data?
111+
112+
├── Text?
113+
│ ├── Single line → text
114+
│ ├── Multiple lines → textarea
115+
│ ├── Formatted → richtext / markdown / html
116+
│ ├── Email → email
117+
│ ├── URL → url
118+
│ ├── Phone → phone
119+
│ └── Code → code
120+
121+
├── Number?
122+
│ ├── Money → currency
123+
│ ├── Percentage → percent
124+
│ └── Generic → number
125+
126+
├── Date/Time?
127+
│ ├── Date only → date
128+
│ ├── Time only → time
129+
│ └── Date + Time → datetime
130+
131+
├── True/False?
132+
│ ├── Checkbox → boolean
133+
│ └── Switch → toggle
134+
135+
├── Choose from list?
136+
│ ├── Single choice, dropdown → select
137+
│ ├── Single choice, always visible → radio
138+
│ ├── Multiple choice, tags → multiselect
139+
│ └── Multiple choice, checkboxes → checkboxes
140+
141+
├── Reference another object?
142+
│ ├── Independent → lookup
143+
│ ├── Owned child → master_detail
144+
│ └── Hierarchy → tree
145+
146+
├── File/Media?
147+
│ ├── Image → image
148+
│ ├── Video → video
149+
│ ├── Audio → audio
150+
│ ├── User photo → avatar
151+
│ └── Generic file → file
152+
153+
├── Calculated?
154+
│ ├── Formula → formula
155+
│ ├── Roll-up → summary
156+
│ └── Auto-number → autonumber
157+
158+
└── Special?
159+
├── Location → location
160+
├── Address → address
161+
├── Color → color
162+
├── Rating → rating
163+
├── Signature → signature
164+
├── QR code → qrcode
165+
├── Progress → progress
166+
├── Tags → tags
167+
├── JSON data → json
168+
└── AI embeddings → vector
169+
```
170+
171+
## Common Field Configurations
172+
173+
### Text with Max Length
174+
175+
```typescript
176+
{
177+
type: 'text',
178+
maxLength: 255,
179+
required: true,
180+
}
181+
```
182+
183+
### Email with Uniqueness
184+
185+
```typescript
186+
{
187+
type: 'email',
188+
required: true,
189+
unique: true,
190+
}
191+
```
192+
193+
### Currency with Precision
194+
195+
```typescript
196+
{
197+
type: 'currency',
198+
currencyConfig: {
199+
precision: 2,
200+
currencyMode: 'multi', // or 'single'
201+
defaultCurrency: 'USD',
202+
},
203+
}
204+
```
205+
206+
### Select with Default
207+
208+
```typescript
209+
{
210+
type: 'select',
211+
required: true,
212+
options: [
213+
{ label: 'Low', value: 'low' },
214+
{ label: 'Medium', value: 'medium', default: true },
215+
{ label: 'High', value: 'high', color: '#e74c3c' },
216+
],
217+
}
218+
```
219+
220+
### Lookup (One-to-Many)
221+
222+
```typescript
223+
{
224+
type: 'lookup',
225+
reference: 'account',
226+
required: true,
227+
referenceFilters: {
228+
status: 'active',
229+
},
230+
}
231+
```
232+
233+
### Lookup (Many-to-Many)
234+
235+
```typescript
236+
{
237+
type: 'lookup',
238+
reference: 'tag',
239+
multiple: true,
240+
max: 10,
241+
}
242+
```
243+
244+
### Master-Detail with Cascade
245+
246+
```typescript
247+
{
248+
type: 'master_detail',
249+
reference: 'invoice',
250+
deleteBehavior: 'cascade',
251+
required: true,
252+
}
253+
```
254+
255+
### Formula
256+
257+
```typescript
258+
{
259+
type: 'formula',
260+
expression: 'amount * tax_rate',
261+
resultType: 'currency',
262+
}
263+
```
264+
265+
### Summary (Roll-up)
266+
267+
```typescript
268+
{
269+
type: 'summary',
270+
reference: 'invoice_line_item',
271+
summaryType: 'sum',
272+
summaryField: 'amount',
273+
}
274+
```
275+
276+
### Autonumber
277+
278+
```typescript
279+
{
280+
type: 'autonumber',
281+
format: 'CASE-{0000}',
282+
}
283+
```
284+
285+
### Vector (AI Embeddings)
286+
287+
```typescript
288+
{
289+
type: 'vector',
290+
vectorConfig: {
291+
dimensions: 1536, // OpenAI ada-002
292+
distanceMetric: 'cosine',
293+
indexType: 'hnsw',
294+
},
295+
}
296+
```
297+
298+
## Incorrect vs Correct
299+
300+
### ❌ Incorrect — Wrong Type for Email
301+
302+
```typescript
303+
{
304+
type: 'text', // ❌ No built-in email validation
305+
maxLength: 255,
306+
}
307+
```
308+
309+
### ✅ Correct — Use email Type
310+
311+
```typescript
312+
{
313+
type: 'email', // ✅ Built-in validation + UI affordances
314+
}
315+
```
316+
317+
### ❌ Incorrect — Uppercase Option Value
318+
319+
```typescript
320+
options: [
321+
{ label: 'Done', value: 'Done' }, // ❌ Uppercase
322+
]
323+
```
324+
325+
### ✅ Correct — Lowercase Option Value
326+
327+
```typescript
328+
options: [
329+
{ label: 'Done', value: 'done' }, // ✅ Lowercase
330+
]
331+
```
332+
333+
### ❌ Incorrect — Missing Reference
334+
335+
```typescript
336+
{
337+
type: 'lookup', // ❌ No reference specified
338+
}
339+
```
340+
341+
### ✅ Correct — Specify Reference
342+
343+
```typescript
344+
{
345+
type: 'lookup',
346+
reference: 'account', // ✅ Target object specified
347+
}
348+
```

0 commit comments

Comments
 (0)