@objectstack/spec 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -4
- package/dist/stack.zod.d.ts +4768 -2542
- package/dist/stack.zod.d.ts.map +1 -1
- package/dist/stack.zod.js +20 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,20 +54,74 @@ The specification is organized into five namespaces mapping to the three-layer a
|
|
|
54
54
|
|
|
55
55
|
## 📚 Usage
|
|
56
56
|
|
|
57
|
+
### 🤖 AI Quick Reference
|
|
58
|
+
|
|
59
|
+
**For AI Agents and LLMs:** This package is the single source of truth for ObjectStack protocol definitions. When working with ObjectStack:
|
|
60
|
+
|
|
61
|
+
1. **Import Patterns**: Always use namespace imports (`Data.Field`, `UI.View`) or direct subpath imports
|
|
62
|
+
2. **Validation**: Use Zod schemas for runtime validation (e.g., `ObjectSchema.parse(config)`)
|
|
63
|
+
3. **Type Inference**: Derive TypeScript types from Zod (`type Field = z.infer<typeof FieldSchema>`)
|
|
64
|
+
4. **Naming Convention**:
|
|
65
|
+
- Configuration keys (TypeScript properties): `camelCase` (e.g., `maxLength`, `defaultValue`)
|
|
66
|
+
- Machine names (data values): `snake_case` (e.g., `name: 'todo_task'`, `field: 'due_date'`)
|
|
67
|
+
5. **Context Files**: Load prompts from `prompts/` directory for architectural understanding
|
|
68
|
+
|
|
69
|
+
**Common Tasks:**
|
|
70
|
+
```typescript
|
|
71
|
+
// Define an Object
|
|
72
|
+
import { Data } from '@objectstack/spec';
|
|
73
|
+
const task: Data.Object = {
|
|
74
|
+
name: 'todo_task',
|
|
75
|
+
fields: {
|
|
76
|
+
subject: { type: 'text', label: 'Subject', required: true },
|
|
77
|
+
priority: { type: 'number', min: 1, max: 5 }
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Validate at runtime
|
|
82
|
+
import { ObjectSchema } from '@objectstack/spec/data';
|
|
83
|
+
const result = ObjectSchema.safeParse(task);
|
|
84
|
+
|
|
85
|
+
// Define an App
|
|
86
|
+
import { UI } from '@objectstack/spec';
|
|
87
|
+
const app: UI.App = {
|
|
88
|
+
id: 'crm',
|
|
89
|
+
name: 'CRM',
|
|
90
|
+
navigation: { /* ... */ }
|
|
91
|
+
};
|
|
92
|
+
```
|
|
93
|
+
|
|
57
94
|
### Import Styles
|
|
58
95
|
|
|
59
96
|
**Important:** This package does NOT export types at the root level to prevent naming conflicts. You must use one of the following import styles:
|
|
60
97
|
|
|
61
98
|
### 🤖 AI-Ready Context
|
|
62
99
|
|
|
63
|
-
This package includes a `prompts/` directory containing system instructions and architectural context
|
|
100
|
+
This package includes a `prompts/` directory in the package root containing system instructions and architectural context:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
node_modules/@objectstack/spec/prompts/
|
|
104
|
+
├── architecture.md # System architecture overview
|
|
105
|
+
├── plugin/ # Plugin development guides
|
|
106
|
+
└── development/ # Development workflows
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
These prompts are useful for:
|
|
64
110
|
1. **AI Agents**: Creating agents that understand ObjectStack.
|
|
65
111
|
2. **IDE Context**: Adding `node_modules/@objectstack/spec/prompts/*.md` to your Cursor/Copilot context.
|
|
66
|
-
3. **LLM Auto-Discovery**: The `llms.txt` file in the root provides a knowledge base for autonomous agents.
|
|
112
|
+
3. **LLM Auto-Discovery**: The `llms.txt` file in the repository root provides a knowledge base for autonomous agents.
|
|
67
113
|
|
|
68
114
|
```typescript
|
|
69
|
-
|
|
70
|
-
|
|
115
|
+
// If using Vite/bundler with raw import support
|
|
116
|
+
import context from '@objectstack/spec/prompts/architecture.md?raw';
|
|
117
|
+
|
|
118
|
+
// Or read from disk in Node.js
|
|
119
|
+
import fs from 'fs';
|
|
120
|
+
import path from 'path';
|
|
121
|
+
const context = fs.readFileSync(
|
|
122
|
+
path.join(process.cwd(), 'node_modules/@objectstack/spec/prompts/architecture.md'),
|
|
123
|
+
'utf-8'
|
|
124
|
+
);
|
|
71
125
|
```
|
|
72
126
|
|
|
73
127
|
#### 1. Namespace Imports from Root
|