diff --git a/.claude/skills/StrixCamDB-Add/SKILL.md b/.claude/skills/StrixCamDB-Add/SKILL.md new file mode 100644 index 0000000..069d5d4 --- /dev/null +++ b/.claude/skills/StrixCamDB-Add/SKILL.md @@ -0,0 +1,213 @@ +--- +name: StrixCamDB-Add +description: Add new brands, camera models, or stream URLs to StrixCamDB. Use when user wants to add camera data to the database, mentions adding a brand/model/URL, or provides camera stream information. +argument-hint: "[description of what to add]" +disable-model-invocation: true +--- + +# StrixCamDB-Add + +You are editing the StrixCamDB camera database. Follow the rules below exactly. + +Chat with the user in Russian. All data in JSON files -- in English. + +### CRITICAL RULE -- READ-ONLY FOR EXISTING DATA + +You can ONLY ADD new data: new brands, new streams, new models. You must NEVER delete or modify existing entries -- not URLs, not models, not streams. Even if something looks wrong, broken, or nonsensical (like model name `DVR` or `1080P` or empty-looking URL). These entries may be valid for specific cameras. + +If you see something suspicious -- tell the user. But don't touch it without explicit confirmation. + +--- + +## STEP 1: Determine the operation + +If the user provided details in the command arguments -- parse them and determine what to do automatically. If not -- ask using AskUserQuestion: + +**What do you want to do?** +1. **Add new brand** -- create a new JSON file for a brand that doesn't exist yet +2. **Add stream URL** -- add a new stream entry to an existing brand +3. **Add model to stream** -- add a model name to an existing stream's `models` array + +--- + +## STEP 2: Collect required information + +### For "Add new brand" + +Ask (or parse from input): +- Brand name (human-readable, e.g. `Hikvision`) +- At least one stream URL with protocol and port + +Brand ID is auto-generated from brand name: lowercase, spaces to hyphens, special chars removed. + +### For "Add stream URL" + +Ask (or parse from input): +- Brand name or brand_id (search in `brands/` directory if unclear) +- URL path (e.g. `/Streaming/Channels/101`) +- Protocol (`rtsp`, `http`, `https`, `rtsps`, `rtmp`, `mms`, `bubble`, `rtp`) +- Port number (e.g. `554`, `80`. Use `0` if unknown) +- Which models this stream works for (list of model names, or `*` for all) + +### For "Add model to stream" + +Ask (or parse from input): +- Brand name or brand_id +- Model name to add +- Which stream(s) to add it to (show existing streams, let user pick) + +--- + +## STEP 3: Validate before writing + +### Brand file structure + +Every brand file is `brands/{brand_id}.json`: + +```json +{ + "version": 2, + "brand": "Brand Name", + "brand_id": "brand-name", + "streams": [ + { + "id": "brand-name-1", + "url": "/path/to/stream", + "protocol": "rtsp", + "port": 554, + "models": ["Model-A", "Model-B"], + "notes": "Optional notes" + } + ] +} +``` + +### Root fields + +| Field | Type | Required | Rules | +|-------|------|----------|-------| +| `version` | int | yes | Always `2` | +| `brand` | string | yes | Human-readable name, capitalized properly | +| `brand_id` | string | yes | Lowercase, hyphens only, must match filename | +| `streams` | array | yes | At least one stream | + +### Stream fields + +| Field | Type | Required | Rules | +|-------|------|----------|-------| +| `id` | string | yes | Format: `{brand_id}-{N}` where N is sequential. Must be unique within file | +| `url` | string | yes | URL path only (no protocol://host:port prefix). Can contain placeholders | +| `protocol` | string | yes | One of: `rtsp`, `http`, `https`, `rtsps`, `rtmp`, `mms`, `bubble`, `rtp` | +| `port` | int | yes | 0-65535. Use `0` if unknown (means "use default for protocol") | +| `models` | array | yes | Non-empty. Use `["*"]` if stream works for all models of this brand | +| `notes` | string | no | Only add if genuinely useful context exists | + +### Supported URL placeholders + +| Placeholder | Description | Example | +|-------------|-------------|---------| +| `[CHANNEL]` | Channel number, 0-based | `0`, `1`, `2` | +| `[CHANNEL+1]` | Channel number, 1-based | `1`, `2`, `3` | +| `[USERNAME]` | Login username | `admin` | +| `[PASSWORD]` | Login password | `12345` | +| `[WIDTH]` | Video width | `1920` | +| `[HEIGHT]` | Video height | `1080` | +| `[IP]` | Camera IP address | `192.168.1.100` | +| `[PORT]` | Port number | `554` | +| `[AUTH]` | Base64-encoded `username:password` | | + +Alternative forms: `[USER]`, `[PASS]`, `[PWD]`, `[PASWORD]`, `{CHANNEL}`, `{channel+1}` -- all supported. + +### Validation rules + +1. `brand_id` must match the filename (without `.json`) +2. Every `id` must be unique within the file +3. No duplicate streams -- same `protocol:port:url` combination must not appear twice +4. `url` must not be empty +5. `models` must not be empty +6. `port` must be integer 0-65535 +7. `protocol` must be a non-empty string +8. If brand file already exists -- read it first, don't overwrite + +--- + +## STEP 4: Write changes + +### Adding a new brand + +1. Verify file `brands/{brand_id}.json` does NOT exist +2. Create the file with `version: 2`, brand info, and streams +3. Stream IDs start from `{brand_id}-1` + +### Adding a stream to existing brand + +1. Read existing `brands/{brand_id}.json` +2. Find the highest existing stream ID number (e.g. if last is `dahua-47`, next is `dahua-48`) +3. Append new stream to the `streams` array +4. Write file back with `indent=2`, `ensure_ascii=False`, trailing newline + +### Adding a model to existing stream + +1. Read existing `brands/{brand_id}.json` +2. Find the target stream by ID or URL +3. Add model name to the `models` array (if not already present) +4. Write file back + +### JSON formatting rules + +- 2-space indent +- No trailing commas +- `ensure_ascii: false` (preserve Unicode) +- Single trailing newline at end of file +- Keys order in root: `version`, `brand`, `brand_id`, `streams` +- Keys order in stream: `id`, `url`, `protocol`, `port`, `models`, `notes` + +--- + +## STEP 5: Verify + +After writing: +1. Run `python3 scripts/validate.py` to check for errors +2. If validation fails -- fix the issue immediately +3. Show the user what was changed (brief summary) + +### Consistency check -- IMPORTANT + +Before finishing, check for problems and report them to the user immediately: +- Duplicate streams (same `protocol:port:url`) within the brand file +- Model names that look like categories, not real models (e.g. `DVR`, `PTZ`, `1080P`, `Other`) -- warn the user but don't block +- Unknown protocol values not listed in `schemas/brand.schema.json` -- warn the user, suggest running `/StrixCamDB-New-Protocol-Or-Placeholders` +- Placeholder in URL that is not documented in README.md -- warn the user +- Any other inconsistencies between schemas, README, and actual data -- report immediately + +--- + +## STEP 6: Commit and version + +Ask the user using AskUserQuestion: + +**Question:** "Commit changes?" +- **Commit only** -- commit to main, CI will update latest release automatically +- **Commit + fix version** -- commit and create a version tag (ask for version, e.g. `v0.2.0`) +- **Don't commit** -- leave changes uncommitted + +### If committing: + +1. Stage changed files: `git add brands/{brand_id}.json` +2. Commit with message in AlexxIT style: + - New brand: `Add {brand} camera database` + - New stream: `Add stream URL for {brand}` + - New model: `Add {model} to {brand}` +3. Push to main: `git push origin main` + +### If fixing version: + +1. After commit and push, create tag: `git tag v{X.Y.Z}` +2. Push tag: `git push origin v{X.Y.Z}` +3. Confirm that CI will create a versioned release + +### Commit message rules -- ABSOLUTE: +- One line, imperative verb, no period at the end +- No `feat:`, `fix:`, `chore:` prefixes +- No emoji, no "Co-Authored-By", no mention of AI/Claude +- Examples: `Add Reolink camera database`, `Add RTSP stream for TP-Link Tapo`, `Add DS-2CD2047 to Hikvision` diff --git a/.claude/skills/StrixCamDB-New-Protocol-Or-Placeholders/SKILL.md b/.claude/skills/StrixCamDB-New-Protocol-Or-Placeholders/SKILL.md new file mode 100644 index 0000000..4a99c5c --- /dev/null +++ b/.claude/skills/StrixCamDB-New-Protocol-Or-Placeholders/SKILL.md @@ -0,0 +1,155 @@ +--- +name: StrixCamDB-New-Protocol-Or-Placeholders +description: Add a new protocol or placeholder to StrixCamDB. Updates schemas, README, and skill definitions to support the new value across the entire project. +argument-hint: "[protocol name or placeholder]" +disable-model-invocation: true +--- + +# StrixCamDB-New-Protocol-Or-Placeholders + +You are adding a new protocol or URL placeholder to the StrixCamDB project. This requires updating multiple files to keep everything in sync. + +Chat with the user in Russian. All file content -- in English. + +--- + +## STEP 1: Determine the operation + +If the user provided details in the command arguments -- parse them. If not -- ask using AskUserQuestion: + +**What do you want to add?** +1. **New protocol** -- e.g. `webrtc`, `onvif`, `p2p` +2. **New placeholder** -- e.g. `[STREAM]`, `[PROFILE]` +3. **Both** -- new protocol and new placeholder at the same time + +--- + +## STEP 2: Collect information + +### For new protocol + +Ask (or parse from input): +- Protocol name (lowercase, e.g. `webrtc`) +- Short description (what it does, when it's used) +- Default port (if known, otherwise `0`) + +### For new placeholder + +Ask (or parse from input): +- Placeholder name in bracket format (e.g. `[STREAM]`) +- What it represents (e.g. "Stream profile index") +- Example value (e.g. `0`, `main`) +- Are there alternative forms? (e.g. `{stream}`, `[STREAM_ID]`) + +--- + +## STEP 3: Update files + +### 3A: Adding a new protocol + +Update these 4 files: + +**1. `schemas/brand.schema.json`** + +Find the `protocol` field description in `$defs/stream/properties/protocol`. Add the new protocol to the description list. + +Before: +``` +"description": "Network protocol: rtsp, http, https, mms, rtmp, rtsps, bubble, rtp, or future protocols" +``` +After (example adding `webrtc`): +``` +"description": "Network protocol: rtsp, http, https, mms, rtmp, rtsps, bubble, rtp, webrtc, or future protocols" +``` + +**2. `schemas/preset.schema.json`** + +Same change -- find `protocol` field description in `$defs/preset_stream/properties/protocol` and add the new protocol. + +**3. `README.md`** + +Find the protocol table in the "Database Format" section under "Stream fields". Add the new protocol to the `protocol` field description cell, keeping the same comma-separated format. + +**4. `.claude/skills/StrixCamDB-Add/SKILL.md`** + +Two places to update: + +a) In the "For Add stream URL" section, find the protocol list: +``` +- Protocol (`rtsp`, `http`, `https`, `rtsps`, `rtmp`, `mms`, `bubble`, `rtp`) +``` +Add the new protocol. + +b) In the "Stream fields" table, find the `protocol` row and add the new protocol to the description. + +--- + +### 3B: Adding a new placeholder + +Update these 3 files: + +**1. `schemas/brand.schema.json`** + +Find the `url` field description in `$defs/stream/properties/url`. Add the new placeholder to the list. + +**2. `README.md`** + +Find the "Placeholders" section. Add a new row to the table: + +```markdown +| `[NEW_PLACEHOLDER]` | Description of what it does | +``` + +If there are alternative forms, add them to the note below the table. + +**3. `.claude/skills/StrixCamDB-Add/SKILL.md`** + +Find the "Supported URL placeholders" table. Add a new row with the placeholder, description, and example value. + +If there are alternative forms, add them to the "Alternative forms" line below the table. + +--- + +## STEP 4: Verify + +1. Read each updated file and confirm the changes are correct +2. Run `python3 scripts/validate.py` to make sure nothing broke +3. Show the user a summary of all changes + +### Consistency check -- IMPORTANT + +Before finishing, compare ALL sources of truth and report any discrepancies to the user: +- Protocol list in `schemas/brand.schema.json` vs `schemas/preset.schema.json` vs `README.md` vs `StrixCamDB-Add/SKILL.md` -- must be identical +- Placeholder list in `schemas/brand.schema.json` vs `README.md` vs `StrixCamDB-Add/SKILL.md` -- must be identical +- If any file is out of sync (e.g. someone added a protocol to README but not to schema) -- fix it now and tell the user +- If `brands/*.json` contains protocol values not listed in schemas -- warn the user + +--- + +## STEP 5: Commit + +Ask the user using AskUserQuestion: + +**Commit changes?** +- **Commit only** -- commit to main, CI updates latest release +- **Commit + fix version** -- commit and create a version tag (ask for version) +- **Don't commit** -- leave uncommitted + +### If committing: + +1. Stage all changed files +2. Commit message in AlexxIT style: + - Protocol: `Add {protocol} protocol support to database schema` + - Placeholder: `Add {placeholder} placeholder support` + - Both: `Add {protocol} protocol and {placeholder} placeholder support` +3. Push to main + +### If fixing version: + +1. After push, create tag: `git tag v{X.Y.Z}` +2. Push tag: `git push origin v{X.Y.Z}` + +### Commit message rules -- ABSOLUTE: +- One line, imperative verb, no period at the end +- No `feat:`, `fix:`, `chore:` prefixes +- No emoji, no "Co-Authored-By", no mention of AI/Claude