Skip to content

Tool feature enhancements - #3

Merged
briananders merged 4 commits into
mainfrom
cursor/tool-feature-enhancements-259c
Mar 7, 2026
Merged

briananders merged 4 commits into
mainfrom
cursor/tool-feature-enhancements-259c

Conversation

@briananders

Copy link
Copy Markdown
Owner

Enhance the pageweight tool with new CLI options, output formats, a programmatic API, and improved error handling to increase versatility and user-friendliness.


Open in Web Open in Cursor 

New features:
- CLI argument parsing with --help, --version, --format, --output,
  --timeout, --budget, --height, --no-scroll flags
- Multiple output formats: table (default), JSON, CSV
- Page weight budget (--budget) for CI pipelines — exits with code 1
  if total page weight exceeds the specified threshold
- File output (--output) to write results to disk
- Configurable viewport height (--height) for non-square viewports
- Scroll control (--no-scroll) to skip scrolling
- Input validation for URL, viewport dimensions, format, and timeout
- Contextual error hints for network and timeout failures
- Auto-prepend https:// for URLs missing a protocol

Refactoring:
- Extract core logic into index.js as a programmatic API (analyze,
  formatTable, formatJSON, formatCSV, formatBytes, classifyResource)
- Fix package.json main field to point to the now-existing index.js
- Track failed network requests and include statusCode/mimeType in
  asset data for richer reporting

Testing:
- Add test suite (21 tests) covering formatBytes, classifyResource,
  formatTable, formatJSON, and formatCSV
- Bump version to 2.0.0

Co-authored-by: Brian Anders <briananders@users.noreply.github.com>
@cursor

cursor Bot commented Mar 7, 2026

Copy link
Copy Markdown

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

cursoragent and others added 3 commits March 7, 2026 02:21
New budget CLI flags:
  --budget-image <size>       Max total weight for all images combined
  --budget-media <size>       Max total weight for all media (video/audio)
  --budget-script <size>      Max total weight for all scripts combined
  --budget-stylesheet <size>  Max total weight for all stylesheets combined
  --budget-font <size>        Max total weight for all fonts combined
  --budget-document <size>    Max total weight for all documents combined
  --budget-per-asset <size>   Max weight for any single asset
  --budget-per-image <size>   Max weight for any single image
  --budget-per-media <size>   Max weight for any single media file

All budget flags can be combined. Each constraint is checked independently
and all violations are reported before exiting with code 1.

Programmatic API additions:
  - parseSizeString(str) - parse human-readable sizes like '1MB' to bytes
  - checkBudgets(assets, budgets) - validate assets against a budget
    config and return an array of violation objects

Tests: 47 passing (26 new tests for parseSizeString and checkBudgets)

Co-authored-by: Brian Anders <briananders@users.noreply.github.com>
Resolve README.md conflict by combining main's improved structure
(table of contents, features list, prerequisites, install methods,
how-it-works, contributing guide) with the feature branch's new
documentation (CLI options, budget parameters, output formats,
programmatic API).

Co-authored-by: Brian Anders <briananders@users.noreply.github.com>
Runs tests across Node.js 18, 20, and 22 on ubuntu-latest.
Triggers on pull requests targeting main and pushes to main.

To enforce this as a required check before merging, enable the
branch protection rule for 'main' in the repository settings:
  Settings > Branches > Add rule > Require status checks > 'Tests'

Co-authored-by: Brian Anders <briananders@users.noreply.github.com>
@briananders
briananders marked this pull request as ready for review March 7, 2026 04:47
@briananders
briananders merged commit 1d00dac into main Mar 7, 2026
3 checks passed
@briananders
briananders deleted the cursor/tool-feature-enhancements-259c branch March 7, 2026 04:49
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