Skip to content

feat: local-dev config, sign-in notifier, and internal simplification - #82

Merged
minarc merged 1 commit into
mainfrom
feat/local-dev-config-and-signin-notifier
Jul 8, 2026
Merged

minarc merged 1 commit into
mainfrom
feat/local-dev-config-and-signin-notifier

Conversation

@minarc

@minarc minarc commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A batch of plugin improvements: a central config module with a one-switch local-dev environment, an event-driven sign-in success/failure notifier, a banner redesign, and internal control-flow simplification. Prod behavior is preserved (verified byte-identical via a before/after golden diff across all telemetry-gate modes).

What's included

Central config + local-dev environment

  • New scripts/lib/config.js: single precedence resolver (env > settings > dev-bundle > prod) for every URL/id/knob, plus a SKILLMETER_ENV=dev master switch → isolated ~/.skillbench-dev + dev endpoints, keeping the real GitHub sign-in/refresh flow.
  • paths.js sources STATE_DIR/CRED_FILE from config; scattered resolvers migrated.
  • De-dup: one JWT decoder (lib/jwt), one org normalizer (lib/org-scope).

⚠️ Two dev constants are placeholders in config.js and must be filled before dev use: DEV_GITHUB_CLIENT_ID and the exact DEV_ACTIVATE_URL host.

Sign-in notifier (FileChanged)

  • Dedicated STATE_DIR/signin-result.json sentinel written by the background sign-in poller (success/failure/discarded).
  • SessionStart registers it via watchPaths; a FileChanged hook (on_signin_result.js) surfaces the outcome (welcome banner + OSC 777 desktop notification) without re-running /skillmeter:signin. Deduped by ts.

Banner redesign

  • Compact content-sized box, SkillMeter · skillbench branding, no ANSI (the systemMessage renderer prints escapes literally).
  • welcomeBanner shows the current repo's actually-tracked org (getRepoScopeDecision) instead of the full org membership.
  • New telemetryActiveBanner when telemetry is capturing this session.
  • Sign-in banner now shows after /skillmeter:signout (the signed_out sentinel still blocks silent gh auto-relogin, but no longer suppresses the nudge).

Internal simplification (output byte-identical)

  • Collapse the two divergent telemetry gates into one (runHook resolves the gate once; session_start reacts via options.onGate).
  • Remove the dead 401/403 → refresh → unauth retry ladder in transfer.js.
  • Shrink logger.js to export only { runHook }; consumers import from lib/*.

Housekeeping

  • Migrate monitor declaration to experimental.monitors in plugin.json.
  • Bump plugin version to 0.17.0.

Verification

  • Golden before/after diff across all gate modes (opted_out / not_enabled / globally_disabled / auto_org-capture / opted_in-out-of-scope): systemMessage + events byte-identical; only the intended banner/version/watchPaths changes appear.
  • node --test skillmeter/test/harness.test.js → 20/20.
  • claude plugin validate skillmeter → ✔ passed.
  • Sign-in notifier + scope-aware banner integration-tested (in-scope repo → "Tracking @org", out-of-scope → "not tracked").

Not yet verified (needs a live session)

watchPaths/FileChanged actual firing on the home-dir sentinel, create-event behavior, and min host version. Degrades gracefully (older Claude Code ignores watchPaths → falls back to the re-run UX).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added clearer sign-in result notifications, including success and failure messages in the terminal.
    • Improved status banners for sign-in required and active telemetry states.
    • Added support for a new monitored sign-in result event.
  • Bug Fixes

    • Sign-in, telemetry, and session flows now use more consistent configuration values.
    • Improved handling of credential writes and license checks for more reliable behavior.

Central configuration + local-dev environment:
- Add scripts/lib/config.js: one precedence resolver (env > settings >
  dev-bundle > prod) for all URLs/ids/knobs, plus a single SKILLMETER_ENV=dev
  master switch (isolated ~/.skillbench-dev + dev endpoints, real sign-in flow).
- paths.js sources STATE_DIR/CRED_FILE from config; migrate scattered resolvers
  (license-activation, signin, jwt, github-api, transfer, retry_daemon, banner).
- De-duplicate the triplicated JWT decoder (-> lib/jwt) and the two org
  normalizers (-> lib/org-scope).

Sign-in success/failure notifier (FileChanged):
- credstore writes a dedicated STATE_DIR/signin-result.json sentinel on
  interactive sign-in completion (kept separate from credentials.json, which
  refresh rewrites often).
- SessionStart registers it via hookSpecificOutput.watchPaths; a FileChanged
  hook (on_signin_result.js) surfaces the result (welcome banner + OSC 777
  notification) without the user re-running /skillmeter:signin. Deduped by ts.

Banner redesign:
- Compact content-sized box, "SkillMeter · skillbench" branding, no ANSI
  (the systemMessage renderer prints escapes literally).
- welcomeBanner shows the current repo's actually-tracked org
  (getRepoScopeDecision) instead of the full org membership.
- New telemetryActiveBanner shown when telemetry is capturing this session.
- Sign-in banner shows after /skillmeter:signout (signed_out still blocks
  silent gh auto-relogin, but no longer suppresses the nudge).

Internal simplification (output byte-identical, verified via golden diff):
- Collapse the two divergent telemetry gates into one (runHook resolves the
  gate once; session_start reacts via options.onGate).
- Remove the dead 401/403 -> refresh -> unauth retry ladder in transfer.js.
- Shrink logger.js to export only { runHook }; consumers import from lib/*.

Housekeeping:
- Migrate monitor declaration to experimental.monitors in plugin.json.
- Bump plugin version to 0.17.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8617fad5-cd40-49a5-bfde-2aa2d1c97d47

📥 Commits

Reviewing files that changed from the base of the PR and between c105bee and 18f4e54.

📒 Files selected for processing (20)
  • skillmeter/.claude-plugin/plugin.json
  • skillmeter/bin/sk-jwt
  • skillmeter/hooks/hooks.json
  • skillmeter/scripts/credstore.js
  • skillmeter/scripts/lib/banner.js
  • skillmeter/scripts/lib/config.js
  • skillmeter/scripts/lib/github-api.js
  • skillmeter/scripts/lib/jwt.js
  • skillmeter/scripts/lib/license-activation.js
  • skillmeter/scripts/lib/paths.js
  • skillmeter/scripts/lib/transfer.js
  • skillmeter/scripts/logger.js
  • skillmeter/scripts/monitors/retry_daemon.js
  • skillmeter/scripts/on_signin_result.js
  • skillmeter/scripts/session_end.js
  • skillmeter/scripts/session_start.js
  • skillmeter/scripts/signin.js
  • skillmeter/scripts/stop.js
  • skillmeter/scripts/telemetry.js
  • skillmeter/scripts/user_prompt_expansion_signin.js

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


Walkthrough

This PR centralizes Skillmeter configuration resolution in a new lib/config.js module, refactors credstore.js to add atomic writes, license-validity checks, and a sign-in result sentinel, introduces an on_signin_result.js notifier wired via hooks.json, simplifies logger.js's hook gating to a single runHook export, removes auth-refresh retry from transfer.js, updates banner.js's rendering API, and adjusts session_start.js/signin.js/user_prompt_expansion_signin.js to use repo-scope decisions for banners.

Changes

Skillmeter centralized config, credstore sentinel, and hook refactor

Layer / File(s) Summary
Centralized config module
skillmeter/scripts/lib/config.js, skillmeter/scripts/lib/github-api.js, skillmeter/scripts/lib/jwt.js, skillmeter/scripts/lib/license-activation.js, skillmeter/scripts/lib/paths.js, skillmeter/scripts/lib/transfer.js, skillmeter/scripts/monitors/retry_daemon.js, skillmeter/bin/sk-jwt
New config module resolves env/settings/default precedence for URLs, OAuth constants, state paths, and numeric knobs; consumers now pull values from it instead of local logic or env parsing.
Credstore atomic writes, license validity, sign-in sentinel
skillmeter/scripts/credstore.js
Adds atomicWriteJson, hasValidLicense, normalizeOrgList usage, and sign-in sentinel read/write/ensure exports.
Sign-in notifier and hook wiring
skillmeter/hooks/hooks.json, skillmeter/scripts/on_signin_result.js
New FileChanged hook triggers a script that dedupes and emits banners/OSC 777 notifications based on sign-in result status.
Banner rendering API
skillmeter/scripts/lib/banner.js
Replaces single welcomeBanner(orgs) with box-rendered welcomeBanner(scope), signInRequiredBanner(), telemetryActiveBanner(org).
Logger hook gate simplification
skillmeter/scripts/logger.js
Narrows exports to only runHook, removes tryRefreshLicense/checkOptIn, adds unified gate with onGate/defaultGateMessaging.
Transfer auth-retry removal
skillmeter/scripts/lib/transfer.js
Removes 401/403 refresh-and-retry branches in event log and transcript uploads.
Hook script import realignment
skillmeter/scripts/session_end.js, skillmeter/scripts/stop.js, skillmeter/scripts/telemetry.js
Import transfer/settings helpers from their new source modules.
Session start orchestration
skillmeter/scripts/session_start.js
Splits into prepareSession() and runSessionStartHook() with gate-driven banner/messaging logic.
Sign-in flow via config and repo-scope
skillmeter/scripts/signin.js, skillmeter/scripts/user_prompt_expansion_signin.js
Uses centralized OAuth config, persists sign-in results, and switches banner inputs to getRepoScopeDecision.
Manifest version and experimental config
skillmeter/.claude-plugin/plugin.json
Bumps version and adds experimental.monitors path.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Signin as signin.js
  participant Credstore as credstore.js
  participant Hooks as hooks.json Watcher
  participant Notifier as on_signin_result.js
  participant Banner as banner.js

  Signin->>Credstore: writeSigninResult(status, ts)
  Hooks->>Notifier: FileChanged signin-result.json
  Notifier->>Credstore: readSigninResult()
  alt already notified for ts
    Notifier-->>Notifier: exit silently
  else success
    Notifier->>Banner: welcomeBanner(repoScopeDecision)
    Notifier-->>Notifier: emit OSC 777 + systemMessage
  else failure
    Notifier-->>Notifier: emit error message + retry instruction
  end
Loading

Possibly related PRs

Suggested reviewers: jhunlee-dev

Poem

Config burrowed into one warm den,
Credentials sealed atomic, safe again.
A sentinel watches, whispers "success!",
While logger sheds its clutter and mess.
Hop hop — banners bloom anew,
This rabbit thumps approval for you! 🐇✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/local-dev-config-and-signin-notifier

Comment @coderabbitai help to get the list of available commands.

@minarc
minarc requested a review from jhunlee-dev July 8, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants