Skip to content

Commit a1419f5

Browse files
authored
Merge pull request #181 from orlin369/main
Mark SDS011 examples as under development
2 parents 8302f50 + 7ae9e4c commit a1419f5

File tree

140 files changed

+966
-1121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+966
-1121
lines changed

.github/workflows/ci-cd.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
pull_request_target:
7+
types:
8+
- closed
9+
paths:
10+
- '**/*.shelly.js'
11+
- 'examples-manifest.json'
12+
13+
jobs:
14+
15+
# Runs on every PR - blocks merge if checks fail
16+
check:
17+
if: github.event_name == 'pull_request'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.12'
27+
28+
- name: Run integrity checks
29+
run: |
30+
python ./tools/check-manifest-integrity.py \
31+
--check-headers \
32+
--check-sync
33+
34+
# Runs after PR is merged - generates JSON and MD files
35+
generate:
36+
if: >
37+
github.event_name == 'pull_request_target' &&
38+
github.event.pull_request.merged == true
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
44+
- name: Setup Python
45+
uses: actions/setup-python@v5
46+
with:
47+
python-version: '3.12'
48+
49+
- name: Run integrity checks
50+
run: |
51+
python ./tools/check-manifest-integrity.py \
52+
--check-headers \
53+
--check-sync
54+
55+
- name: Generate JSON and MD files
56+
run: |
57+
python ./tools/sync-manifest-md.py --extract-metadata --remove-missing
58+
python ./tools/sync-manifest-json.py ./examples-manifest.json
59+
git config user.name github-actions
60+
git config user.email github-actions@github.com
61+
git add .
62+
git diff --cached --quiet || git commit -m "Sync manifest and update legacy docs (${{ github.event.pull_request.title }})"
63+
git push

.github/workflows/generate-md-file.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

AGENTS.md

Lines changed: 96 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ Scripts follow a **two-header pattern** for documentation:
7878
* @title Human-Readable Title
7979
* @description Brief description of what the script does. Keep it concise
8080
* (1-2 sentences). Mention firmware requirements if applicable.
81+
* @status production
82+
* @link https://github.com/ALLTERCO/shelly-script-examples/blob/main/path/to/file.shelly.js
8183
*/
8284

8385
/**
@@ -159,8 +161,14 @@ main();
159161
|-------------|---------|----------|
160162
| `@title` | Short name for manifest/index | Yes |
161163
| `@description` | Brief description (1-2 sentences) | Yes |
164+
| `@status` | `production` or `under development` | Yes |
165+
| `@link` | URL to file on ALLTERCO GitHub repo | Yes |
162166
| Detailed block | Hardware, protocol, components | For hardware/complex scripts |
163167

168+
**Note:** Only files with `@status production` are included in the manifest
169+
(`examples-manifest.json`) and the index (`SHELLY_MJS.md`). Files with
170+
`@status under development` are excluded from both.
171+
164172
**When to include detailed documentation:**
165173
- Hardware interfacing scripts (UART, SPI, I2C devices)
166174
- Setup scripts that create virtual components
@@ -266,7 +274,7 @@ BLE.Scanner.Subscribe(function(ev, result) {
266274

267275
## Manifest File (CRITICAL)
268276

269-
The `examples-manifest.json` is the central registry for all scripts. **Every new script MUST be added here.**
277+
The `examples-manifest.json` is the central registry for all production scripts. Only files with `@status production` in their JSDoc header are included.
270278

271279
### Manifest Entry Format
272280
```json
@@ -279,8 +287,9 @@ The `examples-manifest.json` is the central registry for all scripts. **Every ne
279287
```
280288

281289
### After Adding a Script
282-
1. Add entry to `examples-manifest.json`
283-
2. CI/CD automatically regenerates `SHELLY_MJS.md` on merge
290+
1. Add the standard JSDoc header with `@status production`
291+
2. CI/CD checks run on PR: headers, sync, and status validation
292+
3. After merge: `sync-manifest-md.py` syncs the manifest, `sync-manifest-json.py` regenerates `SHELLY_MJS.md`
284293

285294
---
286295

@@ -303,6 +312,7 @@ main ←── dev ←── feature/xyz
303312
- `git commit` - Always ask before committing
304313
- `git merge` - Always ask before merging
305314
- `git push` - Always ask before pushing
315+
- Every commit request must follow the rules in this `AGENTS.md` file.
306316

307317
Example prompts:
308318
- "Changes are ready. May I commit them?"
@@ -335,7 +345,6 @@ Example prompts:
335345
- Detailed bullet point 1
336346
- Detailed bullet point 2
337347
338-
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
339348
EOF
340349
)"
341350
```
@@ -524,11 +533,90 @@ Shelly.call('Switch.Set', { id: 0, on: true }, function(result, error_code, erro
524533
## Tools
525534
526535
### Script Upload
527-
- `tools/put_script.py` - Python uploader with chunked transfer
528-
- `tools/upload-script.sh` - Bash uploader for Linux/Mac
536+
- `tools/put_script.py` - Upload script to a Shelly device (stop, upload in chunks, start)
537+
538+
### CI/CD & Manifest
539+
- `tools/check-manifest-integrity.py` - Check-only integrity validation (CI gate)
540+
- `tools/sync-manifest-md.py` - Syncs manifest JSON with production files on disk
541+
- `tools/sync-manifest-json.py` - Generates SHELLY_MJS.md from manifest
529542
530-
### Documentation
531-
- `tools/json-to-md.py` - Generates SHELLY_MJS.md from manifest
543+
### Tool Reference
544+
545+
| Tool | Purpose | Usage |
546+
|------|---------|-------|
547+
| `put_script.py` | Upload script to device | `python tools/put_script.py <host> <slot_id> <file>` |
548+
| `check-manifest-integrity.py` | Validate headers and sync (CI gate) | `python tools/check-manifest-integrity.py --check-headers --check-sync` |
549+
| `sync-manifest-md.py` | Add/remove manifest entries from file headers | `python tools/sync-manifest-md.py --extract-metadata` |
550+
| `sync-manifest-json.py` | Regenerate SHELLY_MJS.md from manifest | `python tools/sync-manifest-json.py ./examples-manifest.json` |
551+
552+
---
553+
554+
## Verification Workflow
555+
556+
### Trigger Word: `verify`
557+
558+
When the user says **`verify`** (or `check`, `run verification`), the agent MUST
559+
execute the full verification pipeline described below. The goal is to
560+
synchronize all generated files, validate every production script, and report
561+
or fix any issues found.
562+
563+
### Step-by-Step Pipeline
564+
565+
Run the following steps **in order**. If a step fails, attempt to fix the
566+
issue automatically, then re-run from that step.
567+
568+
#### 1. Sync manifest from file headers
569+
570+
```bash
571+
python tools/sync-manifest-md.py --extract-metadata
572+
```
573+
574+
- Scans every `.shelly.js` file for `@status production`
575+
- Adds new production files to `examples-manifest.json` (with extracted
576+
`@title` and `@description`)
577+
- Reports removed or skipped files
578+
- **Fix:** If a file is missing its header, add the standard JSDoc header
579+
to the file and re-run
580+
581+
#### 2. Regenerate SHELLY_MJS.md
582+
583+
```bash
584+
python tools/sync-manifest-json.py ./examples-manifest.json
585+
```
586+
587+
- Reads `examples-manifest.json` and writes `SHELLY_MJS.md`
588+
- **Important:** Use `./examples-manifest.json` (forward-slash relative
589+
path) to avoid Windows path issues
590+
591+
#### 3. Run integrity checks
592+
593+
```bash
594+
python tools/check-manifest-integrity.py --check-headers --check-sync
595+
```
596+
597+
- `--check-headers` — Verifies every manifest entry has a valid standard
598+
JSDoc header (`@title`, `@description`, `@status`, `@link`)
599+
- `--check-sync` — Verifies every `@status production` file on disk has
600+
a corresponding manifest entry and vice-versa
601+
- **This is the same check that CI runs on pull requests**
602+
603+
#### 4. Report results
604+
605+
After all steps complete, report to the user:
606+
- Total number of manifest entries
607+
- Any files added, removed, or fixed
608+
- Final pass/fail status from the integrity check
609+
- If any issues remain that cannot be auto-fixed, list them clearly
610+
611+
### Common Issues and Fixes
612+
613+
| Issue | Cause | Fix |
614+
|-------|-------|-----|
615+
| `TODO: Add title` in manifest | `sync-manifest-md.py` ran without `--extract-metadata` | Change `@status` to `draft`, re-sync, change back to `production`, re-sync with `--extract-metadata` |
616+
| Missing header | New script without JSDoc | Add the standard two-header block to the file |
617+
| Sync mismatch | File on disk but not in manifest | Run `sync-manifest-md.py --extract-metadata` |
618+
| Manifest entry but no file | File was deleted or renamed | Run `sync-manifest-md.py --remove-missing` |
619+
| Windows path error in `sync-manifest-json.py` | Backslash path passed as argument | Use `./examples-manifest.json` (forward slashes) |
532620
533621
---
534622
@@ -547,4 +635,3 @@ Shelly.call('Switch.Set', { id: 0, on: true }, function(result, error_code, erro
547635
- [Shelly Support Forum](https://www.shelly-support.eu/)
548636
- [GitHub Issues](https://github.com/ALLTERCO/shelly-script-examples/issues)
549637
550-

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
All notable changes to this project will be documented in this file.
44

55
## 2026-02
6+
- Add `switch-input/rgbw-remote-controll.shelly.js` and register it in the manifest/index
7+
- Restructure loose HTTP integration scripts into per-script folders with matching README files
8+
- Fix incomplete Prometheus move (update manifest, @link, README, delete old file)
9+
- Move Telegram files into http-integrations/telegram directory
10+
- Clarify in `AGENTS.md` that all commit requests must follow AGENTS rules
11+
- Add Python shebang and UTF-8 encoding headers to all `tools/*.py` scripts
12+
- Remove deprecated `tools/upload-script.sh` and its documentation section
13+
- Enhance put_script.py with full lifecycle (stop, upload, start) and error handling
14+
- Move BLU Assistant and Cury to Collections section in README
15+
- Remove Apache 2.0 license header comments from legacy JS and Python examples
616
- Add AGENTS.md with coding standards and contribution guidelines
717
- Reorganize documentation structure (separate CHANGELOG.md, update README.md)
818
- Add The Pill UART peripheral collection (Roomba, MODBUS, RFID, SDS011/018, YS-IRTM)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ This repository is designed for:
3232
## Collections
3333

3434
- [The Pill](the_pill/README.md) - UART peripherals and hardware integrations
35+
- [BLU Assistant](blu-assistant/README.md) - BLE device provisioning, configuration, and management scripts
36+
- [Cury](cury/README.md) - Expressive light patterns and visual feedback for Shelly Cury devices
3537

3638
## Repository Layout
3739

3840
- [ble/](ble/README.md) - BLE/BLU sensors, buttons, and gateways
39-
- [blu-assistant/](blu-assistant/README.md) - BLU Assistant device management scripts
4041
- [howto/](howto/README.md) - Minimal examples and tutorials
4142
- [http-integrations/](http-integrations/README.md) - HTTP endpoints, notifications, and external services
4243
- [lora/](lora/README.md) - LoRa send/receive and device control examples

0 commit comments

Comments
 (0)