Repository navigation
Expose sk-* utilities via bin/ - #45
Conversation
|
Caution Review failedPull request was closed or merged during review WalkthroughThree new executable Node.js CLI scripts added to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Claude Code plugins add everything in bin/ to the Bash tool's PATH
while the plugin is active. This commit ships three utilities there,
named to match the plugin's sk-* slash command namespace:
sk-telemetry {enable|disable|status}
Thin wrapper around scripts/telemetry.js. Same effect as the
/skillmeter:sk-telemetry slash command but runs in under 50ms
because it doesn't go through Claude's tool-use loop twice.
sk-jwt
Prints the stored license JWT's decoded metadata in a tidy
block: iss/sub, org id + login, github_id, telemetry_endpoint,
iat, exp, validity status relative to the 5-minute refresh
skew, and the device id stored alongside. Never prints the raw
token body. Uses the unsafe decoder from credstore (no
signature check) because the output is local diagnostic only.
sk-refresh
Clears any stored license JWT, resets the gh silent-failure
cooldown, then runs scripts/activate.js. Useful for swapping
tenants without waiting 15 minutes for natural expiry, recover-
ing from a rotated license, or testing the silent-gh path.
All three resolve the plugin root from __dirname (bin/ sits at the
plugin root), so they work whether CLAUDE_PLUGIN_ROOT is injected
by Claude Code or the binary is invoked from a bare shell.
The sk- prefix matches the slash command names the user already
types (/skillmeter:sk-activate, /skillmeter:sk-telemetry). `sk`
alone is the skim fuzzy finder's binary on some systems; the multi-
part sk-* names don't collide with it.
Verified:
- node -c on all three files
- sk-telemetry status → prints current state
- sk-jwt with seeded valid token → full metadata block, status=valid
- sk-jwt with seeded expired token → status=EXPIRED
- sk-refresh against a seeded license + cooldown → stderr
"clearing stored license JWT", license_jwt reset to null,
cooldown reset to 0, then activate.js begins the silent-gh
flow (terminated before network call)
Files have executable bit set (git preserves mode).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
skillmeter/bin/skillmeter-show-jwt (1)
31-33: Keepshowcommand read-only (avoid implicit device ID creation).
credstore.getDeviceId(LOG_DIR)creates and persists a new device ID when absent. For an inspection utility, a non-mutating read path would be safer to avoid changing credential state during diagnostics.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skillmeter/bin/skillmeter-show-jwt` around lines 31 - 33, The show command currently calls credstore.getDeviceId(LOG_DIR) which auto-creates and persists a device ID; change the script to use a non-mutating read instead (e.g., credstore.getDeviceIdIfExists or credstore.peekDeviceId) so the inspection remains read-only, and fall back to "(none)" if that read returns null/undefined; if such a non-creating accessor doesn't exist, add one to credstore and use it here (referencing token, getLicenseToken, getDeviceId/peekDeviceId, and LOG_DIR to locate the change).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@skillmeter/bin/skillmeter-show-jwt`:
- Around line 51-55: The ternary branch producing "expiring soon" is unreachable
because expired (computed by isLicenseTokenExpired(token)) already applies a
5-minute skew, so any token with secsUntilExp < 60 will be marked expired;
remove the unreachable branch and simplify statusLabel to only check expired vs
not expired (i.e., set statusLabel based on expired and otherwise "valid") by
updating the expression around statusLabel (referencing statusLabel, expired,
isLicenseTokenExpired, and secsUntilExp).
---
Nitpick comments:
In `@skillmeter/bin/skillmeter-show-jwt`:
- Around line 31-33: The show command currently calls
credstore.getDeviceId(LOG_DIR) which auto-creates and persists a device ID;
change the script to use a non-mutating read instead (e.g.,
credstore.getDeviceIdIfExists or credstore.peekDeviceId) so the inspection
remains read-only, and fall back to "(none)" if that read returns
null/undefined; if such a non-creating accessor doesn't exist, add one to
credstore and use it here (referencing token, getLicenseToken,
getDeviceId/peekDeviceId, and LOG_DIR to locate the change).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9c5c793d-8fdc-4c04-9bde-6682f2b015b9
📒 Files selected for processing (3)
skillmeter/bin/skillmeter-force-refreshskillmeter/bin/skillmeter-show-jwtskillmeter/bin/skillmeter-telemetry
| const statusLabel = expired | ||
| ? "EXPIRED (or within 5-minute refresh skew)" | ||
| : secsUntilExp !== null && secsUntilExp < 60 | ||
| ? "expiring soon" | ||
| : "valid"; |
There was a problem hiding this comment.
expiring soon status is currently unreachable.
Because expired is computed via isLicenseTokenExpired(token) (5-minute skew), any token under 60s is already classified into the first branch. The expiring soon branch never executes.
Suggested simplification
-const statusLabel = expired
- ? "EXPIRED (or within 5-minute refresh skew)"
- : secsUntilExp !== null && secsUntilExp < 60
- ? "expiring soon"
- : "valid";
+const statusLabel = expired
+ ? "EXPIRED (or within 5-minute refresh skew)"
+ : "valid";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const statusLabel = expired | |
| ? "EXPIRED (or within 5-minute refresh skew)" | |
| : secsUntilExp !== null && secsUntilExp < 60 | |
| ? "expiring soon" | |
| : "valid"; | |
| const statusLabel = expired | |
| ? "EXPIRED (or within 5-minute refresh skew)" | |
| : "valid"; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@skillmeter/bin/skillmeter-show-jwt` around lines 51 - 55, The ternary branch
producing "expiring soon" is unreachable because expired (computed by
isLicenseTokenExpired(token)) already applies a 5-minute skew, so any token with
secsUntilExp < 60 will be marked expired; remove the unreachable branch and
simplify statusLabel to only check expired vs not expired (i.e., set statusLabel
based on expired and otherwise "valid") by updating the expression around
statusLabel (referencing statusLabel, expired, isLicenseTokenExpired, and
secsUntilExp).
0107a7a to
3909cb7
Compare
Summary
Claude Code plugins add everything in
bin/to the Bash tool's PATH while the plugin is active. This PR ships three utilities there, named to match the plugin'ssk-*slash command namespace (/skillmeter:sk-activate,/skillmeter:sk-telemetry):/skillmeter:sk-telemetry disable(slash)! sk-telemetry disable(bin)Both flows stay supported; this is additive.
Utilities
sk-telemetry {enable|disable|status}— thin wrapper aroundscripts/telemetry.js. Same effect as the slash command, no LLM roundtrip.sk-jwt— prints decoded license JWT metadata (iss/sub, org id + login, github_id, telemetry_endpoint, iat, exp, validity vs the 5-minute refresh skew, device id). Never prints the raw token body. Uses the credstore's unsafe decoder since output is local diagnostic only.sk-refresh— clears stored license + resets gh silent-failure cooldown, then runsscripts/activate.js. Useful for tenant swaps, rotated licenses, or testing the silent path.Design
All three resolve the plugin root from
path.resolve(__dirname, "..")(bin/sits at plugin root), so they work:CLAUDE_PLUGIN_ROOTis injectedbin/dir!prefix, which runs the binary with the plugin's PATH entry availableNo code duplication:
sk-telemetrydelegates toscripts/telemetry.jsviarequire();sk-refreshdelegates toscripts/activate.jsthe same way.Naming
sk-*matches the plugin's slash command namespace, which users already type.skalone is theskimfuzzy finder's binary on some systems; the multi-partsk-telemetry/sk-jwt/sk-refreshnames don't collide with it.Verified
node -con all three filessk-telemetry status— prints current statesk-jwtwith seeded valid token — full metadata block, statusvalidsk-jwtwith seeded expired token — statusEXPIREDsk-refreshagainst a seeded license + 24h cooldown — stderrclearing stored license JWT, license_jwt reset to null, cooldown reset to 0, then activate.js starts the silent-gh flow (terminated before real network call in the test)Executable bits set (git preserves mode).
🤖 Generated with Claude Code
Summary by CodeRabbit
sk-jwtcommand to view stored license information and device ID with decoded token details and validity status.sk-refreshcommand to clear stored license and re-trigger the activation workflow.sk-telemetrycommand to manage telemetry settings withenable,disable, andstatusoptions.