fix: derive CLI version from package.json (v1.3.2)#4
Merged
chenliuyun merged 1 commit intomainfrom Apr 19, 2026
Merged
Conversation
Root cause: src/index.ts hardcoded `.version('2.1.0')`, decoupled from
package.json, so every release required two manual edits and one was
bound to drift. v1.3.1 shipped with `switchbot --version` reporting
`2.1.0` while package.json said `1.3.1`.
Fix (three layers):
- C: src/index.ts reads version via createRequire('../package.json') —
single source of truth. Version strings can no longer be hardcoded.
- A: tests/version.test.ts spawns `node dist/index.js --version` and
compares with package.json. vitest globalSetup runs `npm run build`
once per test run so the compiled CLI is always fresh.
- B: ci.yml adds a post-build step that runs the CLI and diffs its
output against package.json, failing the PR on drift.
Side changes:
- tests/commands/capabilities.test.ts fixture: '2.1.0' -> '0.0.0-test'
so grep for the stale version leaves no ghosts.
- package.json 1.3.1 -> 1.3.2, package-lock.json resynced.
Tests: 659/659 pass (658 existing + 1 new version drift guard).
chenliuyun
pushed a commit
that referenced
this pull request
Apr 20, 2026
… fix for bug #4) Convert all 10 plain-object inputSchemas to z.object({...}).strict() so unknown keys are rejected with JSON-RPC -32602, closing the silent-passthrough hole that allowed dryRun:true (or any unknown key) to reach the Smart Lock / Garage Door live API calls. Add dryRun:boolean?.optional() to send_command and run_scene; when true, returns { ok:true, dryRun:true, wouldSend:{...} } without any API call. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chenliuyun
pushed a commit
that referenced
this pull request
Apr 20, 2026
Document every fix landed in this branch beyond the history-aggregate feature: bugs #1, #4, #5, #6, #8, #9, #10, #11, #12, #13, #14, #15, #16, #17, #18 from the OpenClaw v2.4.0 smoke-test report. Call out the deferred items (#2, #7) explicitly so readers don't assume they were overlooked. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks
chenliuyun
pushed a commit
that referenced
this pull request
Apr 20, 2026
… fix for bug #4) Convert all 10 plain-object inputSchemas to z.object({...}).strict() so unknown keys are rejected with JSON-RPC -32602, closing the silent-passthrough hole that allowed dryRun:true (or any unknown key) to reach the Smart Lock / Garage Door live API calls. Add dryRun:boolean?.optional() to send_command and run_scene; when true, returns { ok:true, dryRun:true, wouldSend:{...} } without any API call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/index.ts:24hardcoded.version('2.1.0'), decoupled frompackage.json. Every release required two manual edits; v1.3.1 shipped withswitchbot --versionreporting2.1.0whilepackage.jsonsaid1.3.1.src/index.tsnow reads version viacreateRequire('../package.json')— single source of truth.tests/version.test.tsspawnsnode dist/index.js --versionand compares againstpackage.json.vitestglobalSetuprunsnpm run buildonce per test run..github/workflows/ci.ymlruns the compiled CLI post-build and diffs its output againstpackage.json, failing the PR on drift.package.json→1.3.2,package-lock.jsonresynced.Test plan
npm run buildcleannpm test— 659/659 pass across 37 files (658 existing + 1 new drift guard)node dist/index.js --versionprints1.3.2