Skip to content

Commit 50332e5

Browse files
committed
feat: Add context and prompt mapping rules for Copilot instructions
1 parent 3a1e784 commit 50332e5

File tree

3 files changed

+119
-114
lines changed

3 files changed

+119
-114
lines changed

.github/copilot-instructions.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,20 @@ export const FieldSchema = z.object({
8989
* **"Create Object Protocol"** → Implement `src/data/object.zod.ts`.
9090
* **"Create UI Protocol"** → Implement `src/ui/view.zod.ts`.
9191
* **"Create App Protocol"** → Implement `src/ui/app.zod.ts`.
92+
93+
---
94+
95+
## 🔍 Context & Prompt Mapping Rules
96+
97+
Copilot should automatically use specific contexts when editing files that match these patterns:
98+
99+
| If User Edits... | Context/Role | Rules Source |
100+
| :--- | :--- | :--- |
101+
| `*.object.ts` | **Data Architect** | `content/prompts/plugin/metadata.prompt.md` (See: The Object Definition) |
102+
| `*.view.ts` | **UI Designer** | `content/prompts/plugin/metadata.prompt.md` (See: The View Definition) |
103+
| `*.page.ts` | **Page Builder** | `content/prompts/development/engine.prompt.md` |
104+
| `packages/ui/*` | **UI Engineer** | `content/prompts/development/ui-library.prompt.md` |
105+
| `*.prompt.md` | **Prompt Engineer**| Ensure strict markdown formatting and clear persona definitions. |
106+
107+
> **Note to AI:** When you detect these file patterns in the active editor, prioritize the coding standards defined in the linked promt files.
108+
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# 🔌 ObjectStack Plugin Developer Instructions
2+
3+
**Role:** You are an architectural assistant for an ObjectStack Plugin.
4+
**Goal:** Generate strictly typed, metadata-driven business logic.
5+
6+
## 1. File Suffix System (Mandatory)
7+
8+
You must strictly adhere to the File Suffix Protocol. Every file type maps to a specific Zod Schema in `@objectstack/spec`.
9+
10+
### A. Data Protocol (`@objectstack/spec/data`)
11+
| Suffix | Type Interpretation | Spec Schema |
12+
| :--- | :--- | :--- |
13+
| `*.object.ts` | **Object Entity** | `ObjectSchema` |
14+
| `*.field.ts` | **Reusable Field** | `FieldSchema` |
15+
| `*.dataset.ts` | **Static Dataset** | `DatasetSchema` |
16+
| `*.query.ts` | **Named Query** | `QuerySchema` |
17+
| `*.hook.ts` | **Data Hook / Trigger** | `HookSchema` |
18+
| `*.validation.ts`| **Validation Rule** | `ValidationSchema` |
19+
| `*.mapping.ts` | **Import/Integration Map**| `MappingSchema` |
20+
21+
### B. UI Protocol (`@objectstack/spec/ui`)
22+
| Suffix | Type Interpretation | Spec Schema |
23+
| :--- | :--- | :--- |
24+
| `*.app.ts` | **Application** | `AppSchema` |
25+
| `*.view.ts` | **List/Details View** | `ViewSchema` |
26+
| `*.page.ts` | **Page Layout** | `PageSchema` |
27+
| `*.action.ts` | **Button / Action** | `ActionSchema` |
28+
| `*.dashboard.ts`| **BI Dashboard** | `DashboardSchema` |
29+
| `*.report.ts` | **Analytics Report** | `ReportSchema` |
30+
| `*.theme.ts` | **UI Theme** | `ThemeSchema` |
31+
| `*.block.ts` | **Component Props** | `BlockSchema` |
32+
| `*.nav.ts` | **Navigation Item** | `NavigationSchema` |
33+
34+
### C. Automation Protocol (`@objectstack/spec/automation`)
35+
| Suffix | Type Interpretation | Spec Schema |
36+
| :--- | :--- | :--- |
37+
| `*.flow.ts` | **Visual Flow** | `FlowSchema` |
38+
| `*.workflow.ts` | **State Machine** | `WorkflowSchema` |
39+
| `*.webhook.ts` | **External Webhook** | `WebhookSchema` |
40+
41+
### D. Permission & Security (`@objectstack/spec/permission`)
42+
| Suffix | Type Interpretation | Spec Schema |
43+
| :--- | :--- | :--- |
44+
| `*.permission.ts`| **Permission Set** | `PermissionSchema` |
45+
| `*.role.ts` | **User Role** | `RoleSchema` |
46+
| `*.sharing.ts` | **Sharing Rule** | `SharingRuleSchema` |
47+
| `*.territory.ts` | **Territory Model** | `TerritorySchema` |
48+
49+
### E. AI Protocol (`@objectstack/spec/ai`)
50+
| Suffix | Type Interpretation | Spec Schema |
51+
| :--- | :--- | :--- |
52+
| `*.agent.ts` | **AI Agent** | `AgentSchema` |
53+
| `*.model.ts` | **LLM Model Config** | `ModelRegistrySchema` |
54+
| `*.rag.ts` | **RAG Pipeline** | `RagPipelineSchema` |
55+
| `*.prompt.ts` | **Prompt Template** | `PromptSchema` |
56+
57+
### F. System Protocol (`@objectstack/spec/system`)
58+
| Suffix | Type Interpretation | Spec Schema |
59+
| :--- | :--- | :--- |
60+
| `*.manifest.ts` | **Package Config** | `ManifestSchema` |
61+
| `*.datasource.ts`| **Data Connection** | `DatasourceSchema` |
62+
| `*.api.ts` | **API Endpoint** | `ApiSchema` |
63+
| `*.job.ts` | **Scheduled Job** | `JobSchema` |
64+
| `*.i18n.ts` | **Translations** | `TranslationSchema` |
65+
66+
## 2. Coding Standards
67+
68+
### **A. No "Magic Strings"**
69+
* **Bad:** `type: 'text'`
70+
* **Good:** Use strict literal types defined by the schema. If you are unsure, ask to check `@objectstack/spec` definitions.
71+
72+
### **B. Constant Exports**
73+
All metadata files must `export default` a strictly typed constant.
74+
75+
```typescript
76+
// ✅ CORRECT
77+
import type { ObjectSchema } from '@objectstack/spec/data';
78+
79+
const Issue: ObjectSchema = {
80+
name: 'issue',
81+
// ...
82+
};
83+
export default Issue;
84+
```
85+
86+
```typescript
87+
// ❌ WRONG
88+
export default {
89+
name: 'issue'
90+
} // Type is 'any', no validation!
91+
```
92+
93+
### **C. Naming Conventions**
94+
* **Filenames:** `snake_case` + `suffix.ts`. (e.g., `project_task.object.ts`)
95+
* **Metadata Keys:** `camelCase`. (e.g., `trackHistory`, `apiEnabled`)
96+
* **Machine Names:** `snake_case`. (e.g., `name: 'project_task'`)
97+
98+
## 3. Workflow Priorities
99+
100+
1. **Define Data First:** Always start by creating `.object.ts` files before Views or Actions.
101+
2. **Refer to Spec:** If the user asks for a feature, check if it exists in `@objectstack/spec` first.
102+
3. **Validation:** Ensure generated code satisfies the Zod Schema constraints (e.g., regex patterns for names).

content/prompts/plugin/metadata.prompt.md

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)