npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

synthia-doctor

v0.0.2

Published

Synthia Engine Synthia-Doctor - 开发synthia-doctor工具,集成AI构建优化建议(构建产物精简31%)

Readme

synthia-doctor

Synthia Engine Doctor - 构建健康检查、性能分析与基础优化建议。

功能特性(当前实现)

  • 🔧 CLI 集成: 作为 Synthia 插件注册 synthia doctor 命令,支持 --check--analyze--optimize(当前为占位实现,输出提示与说明)。
  • 🧩 插件形态: 默认导出函数式插件,可由 synthia CLI 自动加载。
  • 🧠 程序化 API: 提供 SynthiaDoctorSynthiaOptimizerSimpleAnalyzer 以及相关类型,便于以代码方式生成报告与建议。

安装

# 作为项目依赖安装
npm install synthia-doctor

# 或通过 synthia CLI 安装(如果你使用全局/项目内 synthia 插件管理)
synthia plugin --install synthia-doctor

在 synthia 中启用(可选)

如果你的项目使用 synthia 配置加载插件,可在 synthia.config.js 中声明:

import { defineConfig } from 'synthia-cli';
import { doctorPlugin } from 'synthia-doctor';

export default defineConfig({
  plugins: [
    doctorPlugin({
      enabled: true,
      rules: [],
      fix: false,
      output: 'console',
      format: 'table',
    }),
  ],
});

注意: 由于 CommonJS 模块限制,请直接导入插件函数,不要导入类型定义。如果需要类型提示,可以在配置对象中使用 as const 断言。

插件加载器会在 node_modules/synthia-doctor/dist/plugin.js 中查找默认导出的插件函数。

CLI 使用

# 健康检查(占位实现,输出说明与指引)
synthia doctor --check

# 分析构建产物(占位实现,输出说明与指引)
synthia doctor --analyze

# 生成 AI 优化建议(占位实现,输出说明与指引)
synthia doctor --optimize

当前 CLI 子命令均已注册但尚未接入真实分析/优化流程,后续版本会补全实际逻辑与报告产出。

程序化使用

本包同时导出可编程 API:

import {
  SynthiaDoctor,
  SynthiaOptimizer,
  SimpleAnalyzer,
  type DependencyAnalysis,
  type PerformanceAnalysis,
  type CodeQualityAnalysis,
  type AnalysisOptions,
  type HealthCheck,
  type AnalysisResult,
} from 'synthia-doctor';

async function main() {
  const doctor = new SynthiaDoctor(process.cwd());

  // 1) 运行健康检查(内部为估算示例实现)
  const health: HealthCheck = await doctor.checkHealth();
  doctor.displayHealthReport(health);

  // 2) 使用优化器生成基础建议
  const optimizer = new SynthiaOptimizer({ optimize: true, cache: true });
  const basic = optimizer.applyBasicOptimizations();
  optimizer.displayResults(basic);

  // 3) 生成分析报告(示例:传入占位的分析数据并输出到 ./doctor-report)
  const analysis = {
    stats: SimpleAnalyzer.createEmptyStats(),
    dependencies: {
      dependencies: [],
      unusedDependencies: [],
      duplicateDependencies: [],
      outdatedDependencies: [],
    } as DependencyAnalysis,
    performance: {
      bundleSize: { total: 0, gzipped: 0, chunks: [] },
      buildTime: { total: 0, phases: [] },
      metrics: { firstContentfulPaint: 0, largestContentfulPaint: 0 },
    } as PerformanceAnalysis,
    codeQuality: {
      complexity: { average: 0, max: 0, files: [] },
      duplication: { percentage: 0, lines: 0 },
      coverage: { lines: 0, functions: 0, branches: 0, statements: 0 },
    },
  };

  await doctor.generateReport(analysis, './doctor-report');
}

main().catch(console.error);

导出

  • SynthiaDoctor
  • SynthiaOptimizer
  • SimpleAnalyzer
  • DependencyAnalysisPerformanceAnalysisCodeQualityAnalysis
  • AnalysisOptionsHealthCheckAnalysisResult
  • 默认导出:default 为插件函数,用于 synthia 插件系统加载

环境变量

  • OPENAI_API_KEY:若后续启用基于 OpenAI 的 AI 优化能力可使用(当前 CLI 占位)。

许可证

MIT