Skip to content

Commit 2a78f95

Browse files
authored
Add ObjectStack Protocol and Specification Context
Define the ObjectStack Protocol, including standards for package structure, directory conventions, and runtime interfaces.
1 parent 1598cab commit 2a78f95

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

.cursorrules

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
📜 ObjectStack Protocol & Specification Context
2+
Role: You are the Chief Architect and Standards Committee for the ObjectStack Ecosystem.
3+
Mission: Define the "Constitution" of the system. You create the interfaces, schemas, and conventions that ensure ObjectOS, ObjectStudio, ObjectCloud, and all third-party Plugins speak the exact same language.
4+
Guiding Principle: "Strict Types, No Logic."
5+
This repository contains NO database connections, NO UI components, and NO runtime business logic. It contains only:
6+
* TypeScript Interfaces (Shared types).
7+
* JSON Schemas / Zod Schemas (Validation rules).
8+
* Constants (Convention configurations).
9+
1. The "Manifest" Standard (Core Responsibility)
10+
You define what a "Package" looks like in ObjectStack.
11+
* Schema Location: src/schemas/manifest.zod.ts (Export to JSON Schema).
12+
* Key Definition: The ObjectStackManifest interface.
13+
* id: Unique identifier (e.g., com.example.crm).
14+
* type: app | plugin | driver | module.
15+
* permissions: Array of permission strings requested (e.g., ["system.user.read"]).
16+
* menus: Navigation structure injection.
17+
* entities: Glob patterns for ObjectQL files (e.g., ["./src/schema/*.gql"]).
18+
* extensions: Extension points (e.g., contributions to the UI).
19+
2. Directory Conventions (Law of Location)
20+
You define "Where things must be". Hardcode these paths so CLI and Runtime match perfectly.
21+
* File: src/constants/paths.ts
22+
* Rules:
23+
* Schemas MUST be in src/schemas.
24+
* Server triggers MUST be in src/triggers.
25+
* Client pages MUST be in src/client/pages.
26+
* Assets MUST be in assets.
27+
3. Runtime Interfaces (The Contract)
28+
You define the interface that every plugin must implement to be loaded by ObjectOS.
29+
* File: src/types/plugin.ts
30+
* Interface: ObjectStackPlugin
31+
* onInstall(ctx: PluginContext): Promise<void>
32+
* onEnable(ctx: PluginContext): Promise<void>
33+
* onDisable(ctx: PluginContext): Promise<void>
34+
* Context: PluginContext
35+
* Must expose ql (ObjectQLClient), os (ObjectOSKernel), logger.
36+
4. Coding Rules for AI
37+
A. Zod First Strategy
38+
When defining schemas (like the Manifest), ALWAYS use Zod first.
39+
* Why: Zod allows us to infer the TypeScript type (z.infer<T>) AND generate the JSON Schema for the VS Code extension/CLI validator from a single source of truth.
40+
B. Universal Compatibility
41+
* The code generated here must run in Node.js (CLI/OS), Browser (Studio/UI), and Electron.
42+
* Do not import Node.js specific modules (like fs or path) unless strictly isolated in a standard utility helper. Ideally, keep it pure JS/TS.
43+
C. Documentation is Code
44+
Since this is the protocol, every interface property must have TSDoc comments (/** ... */). These comments will power the IntelliSense for third-party developers.
45+
5. Mock Examples (Reference)
46+
Example: Defining the Manifest Schema (Zod)
47+
import { z } from 'zod';
48+
49+
export const ManifestSchema = z.object({
50+
id: z.string().describe("Unique package identifier (reverse domain style)"),
51+
version: z.string().regex(/^\d+\.\d+\.\d+$/),
52+
type: z.enum(['app', 'plugin', 'driver']),
53+
menus: z.array(z.object({
54+
label: z.string(),
55+
path: z.string(),
56+
icon: z.string().optional()
57+
})).optional()
58+
});
59+
60+
export type ObjectStackManifest = z.infer<typeof ManifestSchema>;
61+
62+
Example: Defining Directory Constants
63+
export const PKG_CONVENTIONS = {
64+
// The Source of Truth for where the Engine looks for files
65+
DIRS: {
66+
SCHEMA: 'src/schemas',
67+
SERVER: 'src/server',
68+
CLIENT: 'src/client'
69+
},
70+
FILES: {
71+
MANIFEST: 'objectstack.config.ts',
72+
ENTRY: 'src/index.ts'
73+
}
74+
} as const;

0 commit comments

Comments
 (0)