Skip to content

Commit d3b0ab4

Browse files
committed
feat: 添加llms.txt文件,提供AI代理的上下文和架构概述
1 parent 9ce43d2 commit d3b0ab4

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

packages/spec/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ The specification is organized into five namespaces mapping to the three-layer a
6363
This package includes a `prompts/` directory containing system instructions and architectural context. This is useful for:
6464
1. **AI Agents**: Creating agents that understand ObjectStack.
6565
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.
6667

6768
```typescript
6869
import context from '@objectstack/spec/prompts/architecture.md?raw'; // If using Vite/bundler

packages/spec/llms.txt

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# @objectstack/spec Context for AI Agents
2+
3+
> **SYSTEM NOTE**: This file provides a high-level summary of the ObjectStack Protocol to help LLMs understand the codebase structure and intent.
4+
5+
## 1. Architecture Overview (The "Three-Layer Model")
6+
7+
ObjectStack is a metadata-driven "Post-SaaS Operating System".
8+
It is divided into three layers, reflected in the import paths:
9+
10+
### Layer 1: ObjectQL (`@objectstack/spec/data`)
11+
**The Business Kernel**. Defines "What Data Exists".
12+
- **`ObjectSchema`**: Defines database tables (postgres/mongo agnostic).
13+
- **`FieldSchema`**: Defines columns with types (`text`, `number`, `lookup`, `formula`).
14+
- **`QuerySchema`**: A JSON-based AST for querying data (replaces SQL).
15+
- **`DriverInterface`**: The contract for database adapters.
16+
17+
### Layer 2: ObjectOS (`@objectstack/spec/system` & `@objectstack/spec/api`)
18+
**The Runtime Kernel**. Defines "How System Operates".
19+
- **`ManifestSchema`**: `objectstack.config.ts` configuration.
20+
- **`IdentitySchema`**: Users, Roles, and Authentication.
21+
- **`EventSchema`**: System bus and Webhooks.
22+
- **`EndpointSchema`**: API Gateway configuration.
23+
24+
### Layer 3: ObjectUI (`@objectstack/spec/ui`)
25+
**The Presentation Layer**. Defines "How Users Interact".
26+
- **`AppSchema`**: Navigation menus and branding.
27+
- **`ViewSchema`**: Layouts for data (Grid, Kanban, Calendar).
28+
- **`ActionSchema`**: Buttons and triggers.
29+
30+
---
31+
32+
## 2. Coding Patterns (Zod First)
33+
34+
All definitions are virtually **Zod Schemas**.
35+
- **Configuration Keys**: `camelCase` (e.g., `maxLength`, `referenceFilters`).
36+
- **Data Values**: `snake_case` (e.g., `object: 'project_task'`, `type: 'lookup'`).
37+
38+
### Example: Defining an Object
39+
```typescript
40+
import { ObjectSchema } from '@objectstack/spec/data';
41+
42+
// Describes a "Task" object
43+
const taskObject = {
44+
name: 'project_task', // snake_case table name
45+
label: 'Project Task',
46+
fields: {
47+
status: { type: 'select', options: ['todo', 'done'] },
48+
priority: { type: 'number', defaultValue: 0 }
49+
}
50+
};
51+
```
52+
53+
### Example: Building a Query
54+
```typescript
55+
import { QuerySchema } from '@objectstack/spec/data';
56+
57+
// JSON-based SQL alternative
58+
const query = {
59+
object: 'project_task',
60+
filters: [
61+
['status', '=', 'todo'],
62+
'and',
63+
['priority', '>', 1]
64+
],
65+
sort: [{ field: 'created_at', order: 'desc' }],
66+
top: 10
67+
};
68+
```
69+
70+
---
71+
72+
## 3. Key exports by Namespace
73+
74+
### `import * as Data from '@objectstack/spec/data'`
75+
- `ObjectSchema`, `FieldSchema`: Logic & Storage definition.
76+
- `QuerySchema`, `FilterSchema`: Data retrieval AST.
77+
- `DriverInterface`, `DatasourceSchema`: Database connectivity.
78+
- `WorkflowSchema`, `FlowSchema`: Automation logic.
79+
80+
### `import * as UI from '@objectstack/spec/ui'`
81+
- `ViewSchema`: `type: 'grid' | 'kanban' | 'calendar'`.
82+
- `FormSchema`: `layout: 'simple' | 'tabbed'`.
83+
- `DashboardSchema`: Widget composition.
84+
85+
### `import * as System from '@objectstack/spec/system'`
86+
- `PluginSchema`: Module lifecycle.
87+
- `EventSchema`: Pub/Sub definitions.
88+
- `PolicySchema`: Security rules.

packages/spec/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"dist",
3535
"json-schema",
3636
"prompts",
37+
"llms.txt",
3738
"README.md"
3839
],
3940
"scripts": {

0 commit comments

Comments
 (0)