-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.clinerules
166 lines (124 loc) · 3.51 KB
/
.clinerules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Project Architecture
## Structure
```
packages/
├── mcp-server/ # Server implementation
├── obsidian-plugin/ # Obsidian plugin
└── shared/ # Shared utilities and types
```
## Features
- Self-contained modules in src/features/ with structure:
```
feature/
├── components/ # Svelte UI components
├── services/ # Core business logic
├── constants/ # Feature-specific constants
├── types.ts # Types and interfaces
├── utils.ts # Helper functions
└── index.ts # Public API & setup
```
- feature/index.ts exports a setup function:
- `function setup(plugin: McpToolsPlugin): { success: true } | { success: false, error: string }`
- Handle dependencies and state:
- Check dependencies on setup
- Use Svelte stores for UI state
- Persist settings via Obsidian API
- Clean up on unload/errors
- Extend plugin settings:
```typescript
// features/some-feature/types.ts
declare module "obsidian" {
interface McpToolsPluginSettings {
featureName?: {
setting1?: string;
setting2?: boolean;
};
}
}
```
- Export UI components:
```typescript
// index.ts
export { default as FeatureSettings } from "./components/SettingsTab.svelte";
export * from "./constants";
export * from "./types";
```
## Error Handling
- Return descriptive error messages
- Log errors with full context
- Clean up resources on failure
- Use Obsidian Notice for user feedback
- Catch and handle async errors
- Format errors for client responses
## Type Safety
- Use ArkType for runtime validation
- Define types with inference:
```typescript
const schema = type({
name: "string",
required: "boolean?",
config: {
maxSize: "number",
mode: "'strict'|'loose'",
},
});
type Config = typeof schema.infer;
```
- Validate external data:
```typescript
const result = schema(untrustedData);
if (result instanceof type.errors) {
throw new Error(result.summary);
}
```
- Pipe transformations:
```typescript
const transformed = type("string.json.parse")
.pipe(searchSchema)
.to(parametersSchema);
```
- Add descriptions for better errors:
```typescript
type({
query: type("string>0").describe("Search text cannot be empty"),
limit: type("number>0").describe("Result limit must be positive"),
});
```
## Development
- Write in TypeScript strict mode
- Use Bun for building/testing
- Test features in isolation
## Core Integrations
- Obsidian API for vault access
- Obsidian plugins
- Local REST API for communication
- Smart Connections for search
- Templater for templates
## Coding Style
- Prefer functional over OOP
- Use pure functions when possible
- Keep files focused on single responsibility
- Use descriptive, action-oriented names
- Place shared code in shared package
- Keep components small and focused
# Project Guidelines
## Documentation Requirements
- Update relevant documentation in /docs when modifying features
- Keep README.md in sync with new capabilities
- Maintain changelog entries in CHANGELOG.md
## Task Summary Records
When starting a task:
- Create a new Markdown file in /cline_docs
- Record the initial objective
- Create a checklist of subtasks
Maintain the task file:
- Update the checklist after completing subtasks
- Record what worked and didn't work
When completing a task:
- Summarize the task outcome
- Verify the initial objective was completed
- Record final insights
## Testing Standards
- Unit tests required for business logic
- Integration tests for API endpoints
- E2E tests for critical user flows