Skip to content

Commit 6ab54ff

Browse files
authored
Merge pull request #62 from OpenWonderLabs/feat/claude-code-setup
feat: claude-code setup command + plugin marketplace fixes (v3.7.7)
2 parents eb0f27e + f14f5d2 commit 6ab54ff

23 files changed

Lines changed: 856 additions & 43 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
33
"name": "switchbot",
4+
"owner": {
5+
"name": "OpenWonderLabs",
6+
"email": "developer@wondertechlabs.com"
7+
},
48
"plugins": [
59
{
610
"name": "switchbot",
7-
"source": "./packages/codex-plugin/plugins/switchbot",
8-
"policy": {
9-
"installation": "AVAILABLE",
10-
"authentication": "ON_INSTALL"
11-
},
11+
"source": "./packages/claude-code-plugin/plugins/switchbot",
12+
"description": "Control SwitchBot smart-home devices from Claude Code via MCP.",
1213
"category": "Productivity"
1314
}
1415
]

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
99

1010
## [Unreleased]
1111

12+
## [3.7.7]
13+
14+
### Added
15+
16+
- **`switchbot claude-code setup` command** — 6-step pipeline that bootstraps Claude Code integration end-to-end: verify `claude` CLI on PATH, optionally install `@switchbot/openapi-cli`, register the MCP server via `claude mcp add --scope user`, authenticate, and run a health check. Supports `--yes` (non-interactive), `--skip`, `--dry-run`, `--json`. Paste `npx @switchbot/openapi-cli claude-code setup` into Claude Code chat to set up without opening a terminal.
17+
- **Claude Code Plugin Marketplace support**`.claude-plugin/marketplace.json` now correctly points to `packages/claude-code-plugin/plugins/switchbot` so `/plugin marketplace add OpenWonderLabs/switchbot-openapi-cli` followed by `/plugin install switchbot@switchbot` works end-to-end. `smoke-codex-git-sparse.mjs` extended to validate both the Claude Code and Codex marketplace entry points.
18+
19+
### Fixed
20+
21+
- **`switchbot auth login` clears device/status cache** — switching accounts no longer returns stale data from the previous account's cache. `clearCache()` and `clearStatusCache()` are called immediately after new credentials are saved.
22+
- **`codex setup --help` / `claude-code setup --help`** — both commands now list `--dry-run` and `--json` under a "Global flags that also apply to this command" section so users do not have to discover them from the README.
23+
1224
## [3.7.5]
1325

1426
### Fixed

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,14 @@ Example body:
2828
The CHANGELOG itself follows Keep a Changelog + SemVer, with a
2929
**Changed (BREAKING)** section whenever a release introduces a breaking
3030
change (even in a patch version).
31+
32+
## Plugin hook strategies
33+
34+
The two plugin packages use different `onInstall` hook strategies — this is intentional:
35+
36+
| Package | Hook command | Reason |
37+
|---------|-------------|--------|
38+
| `packages/claude-code-plugin` | `node ../bin/auth.js` (relative path) | Claude Code installs the full npm package; `bin/` is always adjacent. |
39+
| `packages/codex-plugin` | `switchbot-codex-auth` (global binary) | Codex may install only the `plugins/switchbot/` sub-directory, placing it in `~/.codex/plugins/switchbot/`. A relative path to `bin/auth.js` would escape the plugin directory and fail. Using the globally-installed binary works regardless of install layout. |
40+
41+
When changing either hook, preserve this distinction. Do not "unify" them without first verifying that both installation layouts still resolve the hook correctly.

README.md

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,16 @@ Then restart Codex and confirm it's working.
9595
**Or install directly:**
9696

9797
```bash
98-
npm install -g @switchbot/codex-plugin
99-
switchbot-codex-install # registers the plugin with Codex
100-
switchbot auth login # browser OAuth — saves to OS keychain
98+
npm install -g @switchbot/openapi-cli @switchbot/codex-plugin
99+
switchbot codex setup # one-shot bootstrap: register, auth, verify
100+
```
101+
102+
**Or install via Codex Plugin Marketplace** (requires Codex CLI with marketplace support):
103+
104+
```bash
105+
codex plugin marketplace add OpenWonderLabs/switchbot-openapi-cli
106+
codex plugin add switchbot@switchbot
107+
switchbot auth login
101108
```
102109

103110
---
@@ -107,9 +114,10 @@ switchbot auth login # browser OAuth — saves to OS keychain
107114
The OpenClaw skill is published to npm as [`@switchbot/openclaw-skill`](https://www.npmjs.com/package/@switchbot/openclaw-skill).
108115

109116
```bash
110-
openclaw plugins install @switchbot/openclaw-skill # via OpenClaw plugin manager (recommended)
117+
npm install -g @switchbot/openapi-cli # required CLI
118+
openclaw plugins install @switchbot/openclaw-skill # via OpenClaw plugin manager (recommended)
111119
# or
112-
npm install -g @switchbot/openclaw-skill # via npm
120+
npm install -g @switchbot/openclaw-skill # via npm
113121

114122
switchbot-openclaw setup # verify CLI install and credentials
115123
switchbot auth login # browser OAuth — saves to OS keychain
@@ -121,27 +129,40 @@ switchbot auth login # browser OAuth — saves to OS keychain
121129

122130
## Claude Code integration
123131

124-
**Step 0 — verify first.** If the MCP server is already configured (e.g. via a managed environment or prior setup), no additional steps are needed:
132+
**Already configured? Paste into Claude Code chat:**
125133

126-
```bash
127-
switchbot doctor --json
134+
```
135+
Is my SwitchBot integration working? Please check and list my devices.
136+
```
137+
138+
Claude will call `account_overview` or `switchbot doctor` to verify — no terminal needed.
139+
140+
**Fresh setup — paste into Claude Code chat:**
141+
142+
```
143+
Please set up my SwitchBot integration by running:
144+
npx @switchbot/openapi-cli claude-code setup
128145
```
129146

130-
If 24 tools are visible and the integration is healthy, you're done.
147+
Claude will run the setup command via the Bash tool. It installs the CLI if missing, registers the MCP server via `claude mcp add --scope user`, and opens a browser login if credentials are not yet configured. Restart Claude Code afterwards to load the MCP tools.
131148

132-
**Fresh setup:**
149+
**Or run manually in your terminal:**
133150

134151
```bash
135152
npm install -g @switchbot/openapi-cli
136-
claude mcp add switchbot -- switchbot mcp serve --tools all
137-
switchbot auth login # browser OAuth — saves to OS keychain
153+
switchbot claude-code setup
138154
```
139155

140-
Run `switchbot doctor --json` afterwards to confirm everything is working.
156+
The optional skill package [`@switchbot/claude-code-plugin`](https://www.npmjs.com/package/@switchbot/claude-code-plugin) bundles the SKILL.md context document. Install it only if your environment does not already load the skill automatically.
141157

142-
The optional skill package [`@switchbot/claude-code-plugin`](https://www.npmjs.com/package/@switchbot/claude-code-plugin) bundles the SKILL.md context document and install hook. Install it only if your environment does not already load the skill automatically.
158+
**Or install via Claude Code Plugin Marketplace** (requires Claude Code with plugin marketplace support enabled):
159+
160+
```
161+
/plugin marketplace add OpenWonderLabs/switchbot-openapi-cli
162+
/plugin install switchbot@switchbot
163+
```
143164

144-
**Note:** The root `marketplace.json` file in this repo is for Codex CLI Route B (git sparse clone) and points to the Codex plugin at `packages/codex-plugin/plugins/switchbot`. Claude Code users register via `claude mcp add` and do not use this file.
165+
**Note:** The root `marketplace.json` in this repo is for Codex CLI Route B (git sparse clone) and points to `packages/codex-plugin/plugins/switchbot`. The `.claude-plugin/marketplace.json` is for Claude Code Plugin Marketplace and points to `packages/claude-code-plugin/plugins/switchbot`.
145166

146167
---
147168

marketplace.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
{
22
"name": "switchbot",
3+
"interface": {
4+
"displayName": "SwitchBot"
5+
},
36
"plugins": [
47
{
58
"name": "switchbot",
6-
"source": "./packages/codex-plugin/plugins/switchbot"
9+
"source": "./packages/codex-plugin/plugins/switchbot",
10+
"policy": {
11+
"installation": "AVAILABLE",
12+
"authentication": "ON_INSTALL"
13+
},
14+
"category": "Productivity"
715
}
816
]
917
}

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@switchbot/openapi-cli",
3-
"version": "3.7.6",
3+
"version": "3.7.7",
44
"description": "SwitchBot smart home CLI — control devices, run scenes, stream real-time events, and integrate AI agents via MCP. Full API v1.1 coverage.",
55
"keywords": [
66
"switchbot",

packages/claude-code-plugin/.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"name": "OpenWonderLabs"
1616
},
1717
"source": "./plugins/switchbot",
18-
"category": "productivity",
18+
"category": "Productivity",
1919
"homepage": "https://github.com/OpenWonderLabs/switchbot-openapi-cli"
2020
}
2121
]

packages/claude-code-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@switchbot/claude-code-plugin",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"type": "module",
55
"description": "SwitchBot Claude Code plugin — wires Claude Code to the SwitchBot CLI MCP server (24 tools, zero Node.js dependencies)",
66
"homepage": "https://github.com/OpenWonderLabs/switchbot-openapi-cli/tree/main/packages/claude-code-plugin",
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{
22
"name": "switchbot",
3+
"displayName": "SwitchBot",
34
"version": "0.1.0",
45
"description": "Control SwitchBot smart-home devices from Claude Code via MCP.",
56
"author": {
67
"name": "OpenWonderLabs"
78
},
8-
"homepage": "https://github.com/OpenWonderLabs/switchbot-openapi-cli"
9+
"repository": "https://github.com/OpenWonderLabs/switchbot-openapi-cli",
10+
"homepage": "https://github.com/OpenWonderLabs/switchbot-openapi-cli",
11+
"license": "MIT",
12+
"keywords": ["switchbot", "smart-home", "iot", "mcp"]
913
}

0 commit comments

Comments
 (0)