Skip to content

Commit 01a7814

Browse files
committed
docs: record where the M/O annotation goes, and lowercase hex
The annotation moves above the key, which is both what it means and what survives Prettier. Prettier also lowercases hex digits, so the id examples follow.
1 parent cf2f782 commit 01a7814

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

‎AGENTS.md‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ const COMMANDS = {
172172
// --- Client to Server Commands ---
173173

174174
// Description from spec.
175-
commandName: { // Mandatory
175+
// Mandatory
176+
commandName: {
176177
id: 0x0000,
177178
args: {
178179
argName: ZCLDataTypes.uint8,
@@ -186,7 +187,8 @@ const COMMANDS = {
186187
// --- Server to Client Commands ---
187188

188189
// Description from spec.
189-
notificationName: { // Optional
190+
// Optional
191+
notificationName: {
190192
id: 0x0020, // 32
191193
direction: Cluster.DIRECTION_SERVER_TO_CLIENT,
192194
args: {
@@ -224,11 +226,13 @@ module.exports = ExampleCluster;
224226
1. **Description placement**: ABOVE the attribute/command
225227
2. **M/O marker placement**:
226228
- Single-line: at END of line (`attrName: { ... }, // Mandatory`)
227-
- Multi-line: on OPENING brace (`attrName: { // Mandatory`)
229+
- Multi-line: on its own line ABOVE the key (`// Mandatory` then `attrName: {`),
230+
below the description if there is one. Not on the opening brace: Prettier pulls a
231+
comment there inside the braces, where it reads as if it belongs to `id`.
228232
- NEVER on closing brace
229233
3. **Copy exactly**: Text from spec, 1-on-1
230234
4. **Skip if >5 sentences**: Skip and only refer to section in spec
231-
5. **Line wrap**: Respect 100 char limit (ESLint)
235+
5. **Line wrap**: Respect 100 char limit (Prettier `printWidth`); run `npm run format:write`
232236
6. **M/O source for attrs**: Server-side column in spec table
233237
7. **M/O source for cmds**:
234238
- Server "receives" → server-side M/O
@@ -252,15 +256,15 @@ pirUnoccupiedToOccupiedDelay: { id: 0x0011, type: ZCLDataTypes.uint16 }, // 17,
252256

253257
| Field | Format | Notes |
254258
|-------|--------|-------|
255-
| `id` | Hex (`0x0000`) | Always 4-digit format (0x0000); add decimal comment if > 9 |
259+
| `id` | Hex (`0x0000`) | Always 4-digit format (0x0000), lowercase digits; add decimal comment if > 9 |
256260
| `type` | `ZCLDataTypes.*` | See type reference below |
257261
| M/O | Inline comment | `// Mandatory`, `// Optional`, or `// Conditional` |
258262

259263
#### Hex with Decimal Comments
260264

261265
For hex values > 9 (where hex differs from decimal), add decimal in comment:
262266
```javascript
263-
id: 0x000A, // 10
267+
id: 0x000a, // 10
264268
id: 0x0010, // 16
265269
id: 0x0100, // 256
266270
```
@@ -271,9 +275,10 @@ id: 0x0000,
271275
id: 0x0009,
272276
```
273277

274-
For multi-line definitions, decimal goes on the `id:` line, M/O on opening brace:
278+
For multi-line definitions, decimal goes on the `id:` line, M/O above the key:
275279
```javascript
276-
operatingMode: { // Optional
280+
// Optional
281+
operatingMode: {
277282
id: 0x0025, // 37
278283
type: ZCLDataTypes.enum8({
279284
normal: 0,
@@ -300,7 +305,7 @@ attr3: { ... },
300305

301306
| Field | Required | Notes |
302307
|-------|----------|-------|
303-
| `id` | Yes | Always 4-digit hex format (0x0000); add decimal comment if > 9 |
308+
| `id` | Yes | Always 4-digit hex format (0x0000), lowercase digits; add decimal comment if > 9 |
304309
| `args` | If has params | Object with typed fields |
305310
| `response` | If expects response | Has own `id` and `args` |
306311
| `encodeMissingFieldsBehavior` | Controls the behavior of missing fields when encoding the struct | Set to `skip` if some fields are optional, omit if all fields are mandatory |
@@ -313,7 +318,8 @@ attr3: { ... },
313318
lockDoor: { id: 0x0000, ... }, // Mandatory
314319

315320
// --- Server to Client Commands ---
316-
operationEventNotification: { // Optional
321+
// Optional
322+
operationEventNotification: {
317323
id: 0x0020, // 32
318324
direction: Cluster.DIRECTION_SERVER_TO_CLIENT,
319325
...

0 commit comments

Comments
 (0)