Skip to content

Add dev-metrics feature and docs alignment#296

Open
lucifer1017 wants to merge 1 commit intorsksmart:mainfrom
lucifer1017:rsk-cli-devmetricsUpdate
Open

Add dev-metrics feature and docs alignment#296
lucifer1017 wants to merge 1 commit intorsksmart:mainfrom
lucifer1017:rsk-cli-devmetricsUpdate

Conversation

@lucifer1017
Copy link
Copy Markdown

Summary

  • Adding the GitHub + Rootstock developer metrics (dev-metrics) feature.

Changes

1. New dev-metrics command

  • Added src/commands/devmetrics.ts:

    • Aggregates GitHub repo activity and Rootstock on-chain usage into a single developer health report.
    • Supports output formats: table, json, and markdown.
    • Supports CI mode (--ci) which is equivalent to JSON output.
    • Accepts multiple --repo and --contract arguments and pairs them intelligently.
  • Updated bin/index.ts:

    • Imports devmetricsCommand.
    • Registers a new dev-metrics subcommand with options:
      • -r, --repo <owner/repo> (repeatable)
      • -c, --contract <address> (repeatable)
      • -f, --format <table|json|markdown> (default: table)
      • --ci
      • --github-token <token> (or GITHUB_TOKEN env var)
      • -t, --testnet

2. New devmetrics module

Added src/devmetrics with the following:

  • githubService.ts

    • Wraps @octokit/rest with timeouts, rate-limit inspection, and graceful fallback from authenticated to unauthenticated mode.
    • Exposes getMetrics(owner, repo) and getRateLimitStatus().
  • rootstockService.ts

    • Uses existing ViemProvider to gather on-chain metrics for a given contract:
      • Deployment block (via bounded binary search).
      • Approximate total transaction count (sampling + extrapolation).
      • Last transaction timestamp (recent-block scan).
      • Gas usage patterns (average / min / max).
  • types.ts

    • Shared types for GitHubMetrics, RootstockMetrics, DevMetricsReport, and OutputFormat.
  • validation.ts

    • Uses zod to validate:
      • Repositories in owner/repo format.
      • Contract addresses as 0x + 40 hex chars.
    • Exposes validateRepo and validateContractAddress.
  • formatters/

    • index.ts: formatDevMetricsReport(reports, format) dispatcher.
    • table.ts: Renders a colorized, table-based CLI report using cli-table3 + chalk.
    • json.ts: Renders a JSON array of DevMetricsReport.
    • markdown.ts: Renders a Markdown report (suitable for issues, PR comments, docs, etc.).

3. Dependencies

  • Updated package.json dependencies to support dev-metrics:

    • Added

      • @octokit/rest
      • zod
    • Reused existing dependencies from the project:

      • cli-table3, chalk, viem, etc.

4. Documentation

  • Updated README.md to align with the “plus” edition:

    • Added “Developer Metrics (GitHub + Rootstock)” feature section:

      • Usage examples for mainnet, testnet, JSON (CI), and Markdown output.
      • Documented all dev-metrics options and behavior (including MCP/external usage context).
    • Shifted the RNS Resolve section to feature 13, keeping the feature list consistent with the local edition.

Testing

Steps run locally:

  • cd rsk-cli
  • npm install
  • npm run build

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.

1 participant