You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .cursor/rules/sdk/example.mdc
+16-2Lines changed: 16 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,10 +5,24 @@ alwaysApply: false
5
5
---
6
6
- All example files should have consistent error handling using try-catch blocks with process.exit(0) on success and process.exit(1) on error
7
7
- Use top-level await with try-catch instead of async function wrappers
8
-
- Error messages should use: `console.error("❌ Error:", error)`
9
8
- Examples can use plain `Error` objects (they're user-facing demos, not SDK code)
10
9
- All example files which load models should have an unloadModel call to unload the model when done
10
+
- Logging convention (uniform across all examples):
11
+
- Normal messages (status, steps, metrics, progress) use `console.log` prefixed with `▸ ` (e.g. `console.log("▸ Loading model")`)
12
+
- Caught errors use `console.error` prefixed with `✖ ` (e.g. `console.error("✖", error)`). Reserve `console.error` for errors only — some runtimes render it in red, which looks alarming for ordinary output
13
+
- Genuine results stay unprefixed so they read apart from the `▸` commentary: stream tokens via `process.stdout.write(token)`, final results via plain `console.log`
14
+
- Do not use other decorative emojis; only `▸` (info) and `✖` (error)
15
+
- No shared logging helper — each example stays standalone and copy-pasteable
16
+
- Download progress renders as one in-place line on stderr, not a raw progress-object dump:
17
+
```ts
18
+
onProgress: (p) => {
19
+
const mb = (n: number) => (n / 1e6).toFixed(1);
20
+
const line = `▸ Downloading ${p.percentage.toFixed(0)}% (${mb(p.downloaded)}/${mb(p.total)} MB)`;
0 commit comments