website_audit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

website_audit

website_audit

描述

Description

对指定 URL 运行 Lighthouse 审计,产出结构化 JSON。返回
performance
分数与完整原始报告,便于在代理、流水线或质量门禁中消费与比对。
Run Lighthouse audit on the specified URL and generate structured JSON. Returns the
performance
score and complete original report, which is easy to consume and compare in proxies, pipelines or quality gates.

使用场景

Usage Scenarios

  • 开发阶段快速评估页面性能
  • PR/CI 中设定性能阈值做质量门禁
  • 上线前建立/对比性能基线
  • 定时巡检以发现性能回归
  • 用户提出“审计网站性能/生成 Lighthouse 报告/检测页面速度”等需求时触发
  • Quickly evaluate page performance during the development phase
  • Set performance thresholds as quality gates in PR/CI
  • Establish/compare performance baselines before going online
  • Regular inspection to detect performance regression
  • Triggered when users raise demands such as "audit website performance/generate Lighthouse report/detect page speed"

指令

Instructions

  1. 接收入参
    { url }
    ,校验为
    http/https
    且非空。
  2. 执行命令
    npx lighthouse <url> --output=json
    获取审计结果。
    • 在无头或 CI 环境可追加
      --chrome-flags="--headless=new"
  3. 解析 stdout 为 JSON,读取
    categories.performance.score
  4. 构造并返回:
    json
    { "score": <number>, "raw": { /* Lighthouse 完整 JSON */ } }
  5. 异常处理:捕获执行/解析错误,返回错误信息或抛出异常以便上层处理。
  1. Receive input parameter
    { url }
    , verify it is
    http/https
    and not empty.
  2. Execute the command
    npx lighthouse <url> --output=json
    to get audit results.
    • In headless or CI environments, you can append
      --chrome-flags="--headless=new"
      .
  3. Parse stdout to JSON, read
    categories.performance.score
    .
  4. Construct and return:
    json
    { "score": <number>, "raw": { /* Complete Lighthouse JSON */ } }
  5. Exception handling: Catch execution/parsing errors, return error information or throw exceptions for upper-layer processing.

示例(可选)

Example (Optional)

  • CLI:
    bash
    node dist/cli.js --url https://example.com
    # 或:npm link && website-audit --url https://example.com
  • 代码:
    ts
    import { websiteAuditSkill } from "websiteauditskill_henry";
    const res = await websiteAuditSkill({ url: "https://example.com" });
    console.log(res.score);
    // { score: 0.92, raw: { ... } }
  • CLI:
    bash
    node dist/cli.js --url https://example.com
    # Or: npm link && website-audit --url https://example.com
  • Code:
    ts
    import { websiteAuditSkill } from "websiteauditskill_henry";
    const res = await websiteAuditSkill({ url: "https://example.com" });
    console.log(res.score);
    // { score: 0.92, raw: { ... } }