Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,28 @@ on:
pull_request:
branches: [main]

permissions:
contents: read

concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
workflow-lint:
name: GitHub Actions schema lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- run: python -m pip install --disable-pip-version-check check-jsonschema==0.39.0
- run: check-jsonschema --builtin-schema vendor.github-workflows .github/workflows/*.yml

docs-lint:
name: Markdown lint (changelog)
name: Markdown lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -17,14 +36,15 @@ jobs:
node-version: 20.x
cache: npm
- run: npm ci
- run: npm run lint:md:changelog
- run: npm run lint:md

test:
runs-on: ubuntu-latest
needs: docs-lint
needs: [docs-lint, workflow-lint]
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [18.x, 20.x, 22.x, 24.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -43,12 +63,22 @@ jobs:
exit 1
fi
- run: npm test
if: matrix.node-version != '24.x'
- run: npm run test:coverage
if: matrix.node-version == '24.x'
- name: Upload coverage report
if: always() && matrix.node-version == '24.x'
uses: actions/upload-artifact@v4
with:
name: cli-coverage
path: coverage/
if-no-files-found: error
- run: npm run test:workspaces

openclaw-bootstrap:
name: OpenClaw native bootstrap (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: docs-lint
needs: [docs-lint, workflow-lint]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -78,7 +108,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [18.x, 20.x, 22.x, 24.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down
61 changes: 42 additions & 19 deletions .github/workflows/keychain-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,33 @@ on:
push:
branches: [main]
paths:
- 'src/credentials/**'
- 'src/install/**'
- 'tests/credentials/**'
- 'tests/install/**'
- 'src/**'
- 'tests/**'
- 'scripts/smoke-keychain.mjs'
- 'package*.json'
- 'tsconfig*.json'
- '.github/workflows/keychain-matrix.yml'
pull_request:
branches: [main]
paths:
- 'src/credentials/**'
- 'src/install/**'
- 'tests/credentials/**'
- 'tests/install/**'
- 'src/**'
- 'tests/**'
- 'scripts/smoke-keychain.mjs'
- 'package*.json'
- 'tsconfig*.json'
- '.github/workflows/keychain-matrix.yml'
workflow_dispatch:

# Each job installs Node, builds, and runs the credential + install-step
# test suites against the real OS keychain backend. The unit tests (which
# mock spawn) pass on ubuntu-latest in the main CI; here we verify
# that the live system commands are available and callable.
permissions:
contents: read

concurrency:
group: keychain-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

# Shared cache/credential/MCP regressions run on every supported OS.
# The separate native smoke rejects file fallback and exercises actual
# keychain create/read/replace/delete with disposable dummy credentials.

jobs:
keychain-macos:
Expand All @@ -38,19 +48,28 @@ jobs:
# Create and unlock a temporary keychain so the macOS backend can
# write entries without prompting the System Keychain.
- name: Set up temporary keychain
shell: bash
run: |
original=$(security default-keychain -d user | xargs)
echo "SWITCHBOT_CI_ORIGINAL_KEYCHAIN=$original" >> "$GITHUB_ENV"
security create-keychain -p "" switchbot-ci.keychain
security set-keychain-settings -lut 3600 switchbot-ci.keychain
security unlock-keychain -p "" switchbot-ci.keychain
security list-keychains -d user -s switchbot-ci.keychain $(security list-keychains -d user | sed s/\"//g)
echo "SWITCHBOT_CI_KEYCHAIN=switchbot-ci.keychain" >> "$GITHUB_ENV"
security default-keychain -d user -s switchbot-ci.keychain

- name: Run credential + install-step tests
run: npm test -- tests/credentials tests/install
- name: Run account lifecycle regressions
run: npm run test:account-lifecycle
- name: Exercise native keychain lifecycle
run: npm run smoke:keychain

- name: Delete temporary keychain
if: always()
shell: bash
run: |
if [ -n "${SWITCHBOT_CI_ORIGINAL_KEYCHAIN:-}" ]; then
security default-keychain -d user -s "$SWITCHBOT_CI_ORIGINAL_KEYCHAIN"
fi
security delete-keychain switchbot-ci.keychain || true

keychain-linux:
Expand All @@ -76,12 +95,14 @@ jobs:

# Start a D-Bus session and unlock gnome-keyring so secret-tool can
# store entries. The keyring is unlocked with an empty password.
- name: Run credential + install-step tests inside D-Bus session
- name: Run lifecycle regressions and native smoke inside D-Bus session
shell: bash
run: |
eval "$(dbus-launch --sh-syntax)"
echo "" | gnome-keyring-daemon --daemonize --unlock --components=secrets
export DBUS_SESSION_BUS_ADDRESS
npm test -- tests/credentials tests/install
npm run test:account-lifecycle
npm run smoke:keychain

keychain-windows:
name: Keychain — Windows (Credential Manager)
Expand All @@ -97,5 +118,7 @@ jobs:

# Windows Credential Manager is available to any logged-in user on
# GitHub-hosted Windows runners; no extra setup required.
- name: Run credential + install-step tests
run: npm test -- tests/credentials tests/install
- name: Run account lifecycle regressions
run: npm run test:account-lifecycle
- name: Exercise native Credential Manager lifecycle
run: npm run smoke:keychain
8 changes: 7 additions & 1 deletion .github/workflows/npm-published-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,23 @@ jobs:
(github.event.workflow_run.event == 'release' || github.event.workflow_run.event == 'workflow_dispatch')
needs: [source, smoke, required-hosts]
runs-on: ubuntu-latest
concurrency:
group: npm-latest-promotion
cancel-in-progress: false
queue: max
permissions:
actions: read
contents: read
steps:
# Apply current promotion policy even when recovering an older candidate.
- uses: actions/checkout@v4
with:
ref: ${{ needs.source.outputs.revision }}
ref: ${{ github.workflow_sha }}
- uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: https://registry.npmjs.org
- run: npm ci --ignore-scripts
- name: Download authoritative candidate outcomes
uses: actions/download-artifact@v4
with:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ on:
description: 'Dry run — record candidate outcomes without publishing'
type: boolean
default: false

concurrency:
group: npm-candidate-publication
cancel-in-progress: false
queue: max

jobs:
publish:
runs-on: ubuntu-latest
Expand All @@ -30,6 +36,8 @@ jobs:
cache: npm
- run: npm ci
- run: npm run verify:release-gate
- name: Full CLI regression gate for the exact release source
run: npm test
- run: npm run verify:release

- name: Verify tag matches root CLI package.json version
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ on:
workflow_dispatch:
inputs:
physical_device_id:
description: "Physical device ID (idempotency + history). Will send turnOn, turnOn (replay), turnOff (conflict). Omit to skip."
description: "Physical device ID (idempotency flag + history). Sends ONE turnOn. Omit to skip."
required: false
ir_device_id:
description: "IR device ID (verification flag). Will send ONE turnOn IR transmission. Omit to skip."
required: false

permissions:
contents: read

defaults:
run:
shell: bash

jobs:
smoke:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -44,15 +51,16 @@ jobs:
run: |
node dist/index.js devices list --json > /tmp/list.json
echo "device count=$(jq '.data | length' /tmp/list.json)"
node dist/index.js doctor --json | jq '.data.summary'
node dist/index.js doctor --json | jq -e '.data.summary | objects'

- name: IR verification flag (destructive — real IR transmission)
if: ${{ inputs.ir_device_id != '' }}
env:
SWITCHBOT_TOKEN: ${{ secrets.SWITCHBOT_TOKEN }}
SWITCHBOT_SECRET: ${{ secrets.SWITCHBOT_SECRET }}
DEV: ${{ inputs.ir_device_id }}
run: |
node dist/index.js devices command "${{ inputs.ir_device_id }}" turnOn --json > /tmp/ir.json
node dist/index.js devices command "$DEV" turnOn --json > /tmp/ir.json
cat /tmp/ir.json
jq -e '.data.verification.verifiable == false' /tmp/ir.json
echo "PASS: data.verification.verifiable == false"
Expand Down Expand Up @@ -92,6 +100,6 @@ jobs:
kill $TAIL_PID 2>/dev/null || true
wait $TAIL_PID 2>/dev/null || true

node dist/index.js history stats "$DEV" --json | tee /tmp/stats.json | jq '.data'
node dist/index.js history range "$DEV" --since 5m --json | jq '.data | length'
node dist/index.js history stats "$DEV" --json | tee /tmp/stats.json | jq -e '.data | objects'
node dist/index.js history range "$DEV" --since 5m --json | jq -e '.data.records | arrays | length'
echo "PASS: history commands returned valid JSON"
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,43 @@ All notable changes to `@switchbot/openapi-cli` are documented in this file.
The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Catalog coverage for RGBICWW Light Bars, Smart Lock Ultra Max, Curtain 4, Robot Vacuum Cleaner K11 Plus Pro, AI Art Frame Luma, Outdoor Pan/Tilt Cam 3K, and Solar Pan/Tilt Cam 2K.
- Light Bars object commands, including `setLightEffect` with `effectId` 0–25; six existing documented lights also expose their light effects.
- Camera `latestImage` metadata with its expiry contract, Solar motion-detection controls, and Art Frame Luma upload/status support.
- CI workflow-schema validation, full Markdown lint, Node 24 regression/coverage gates, and isolated native credential create/replace/delete smoke checks on Linux, macOS, and Windows.

### Changed

- MCP output schemas now declare the existing structured `isError` / `structuredContent.error` result alongside successful object results; successful and error payload shapes are unchanged.
- Direct destructive commands remain blocked by default even with `--yes` or `confirm: true`; an explicit dev/override permission and confirmation, or an approved plan, is required. Physical devices cannot use IR `customize` dispatch.
- Solar motion-detection disable is destructive and prohibited from automation/policy preapproval.
- Successful credential mutations invalidate device, status, credential, and idempotency caches across running processes; implicit and explicit default profiles now share the legacy cache paths.
- Account changes reject obsolete in-flight reads and retained-client retries instead of crossing account boundaries. Existing MQTT subscriptions must be restarted.

### Fixed

- MCP now applies destructive-command safety to cold-cache devices identified only by `controlType`.
- HTTP MCP returns a protocol error instead of terminating if credentials change during request priming; unavailable replacement keychains cannot fall back to older file credentials.
- HTTP MCP honors explicit `--config` credentials for named-profile requests without relaxing profile-name or bearer-token checks.
- MCP tool credential-refresh failures retain structured runtime errors and allow recovery after credential repair.
- Rule JSON parameters avoid a redundant parse while preserving request and audit formats.
- Publication now runs the full CLI suite on the exact release source; queued publication/promotion runs preserve pending candidates, and promotion rejects SemVer downgrades before changing any `latest` tags.
- Historical candidate recovery uses the workflow revision's promotion policy instead of reviving older release tooling.
- Manual hardware smoke now fails on CLI pipeline errors and invalid JSON envelopes; empty history remains valid.

### Compatibility

- Rule RGB parameters retain both `setColor 255 0 0` and `setColor 255:0:0`; JSON objects preserve whitespace and can use YAML literal blocks.
- Rule dry-runs now require the target in the active profile's cache; missing inventory fails without a network request instead of reporting success.

### Notes

- Light Bars webhook field shapes are documented, but the exact `context.deviceType` identifier remains unconfirmed and is deliberately not mapped.

## [3.9.0]

### Added
Expand Down
Loading
Loading