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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@agentskillmania/settings-yaml

v0.3.0

Published

A robust configuration management library for loading, merging, and managing YAML-based settings with deep merge support, default value fallback, and runtime override capabilities.

Readme

@agentskillmania/settings-yaml

npm version License: MIT English Documentation

YAML 配置管理库。深度合并、默认值回退、运行时覆盖。一行初始化,点号路径读写,按需持久化。

特色

  • 深度合并 — 递归合并嵌套对象,数组按元素逐项合并
  • 默认值回退 — 根据默认 YAML 模板自动创建配置文件
  • 运行时覆盖 — 支持临时覆盖(如命令行参数),优先级最高
  • 不可变值 — 返回的配置对象已被冻结
  • 点号路径访问 — 通过 server.port 风格的路径读写嵌套值

安装

pnpm add @agentskillmania/settings-yaml

快速开始

import { Settings } from '@agentskillmania/settings-yaml';

const settings = new Settings('~/.config/myapp/config.yaml');

await settings.initialize({
  defaultYaml: `
    server:
      port: 3000
      host: localhost
  `,
});

const config = settings.getValues();
console.log(config.server.port); // 3000

合并优先级

配置按以下优先级合并(从高到低):

  1. 传给 initialize()override 对象
  2. 磁盘上已有的配置文件
  3. defaultYaml 默认模板

API 参考

constructor(configPath: string)

创建 Settings 实例。支持绝对路径、相对路径和 ~/ 主目录路径。

async initialize(options?): Promise<void>

  • 配置文件不存在且提供了 defaultYaml:使用默认值创建文件
  • 配置文件不存在且未提供 defaultYaml:抛出错误
  • 配置文件已存在:读取并与 defaultYaml 深度合并
  • override 值具有最高优先级
  • 自动创建中间目录

getValues(): T

返回深度合并后的配置对象,已被冻结。

has(keyPath: string): boolean

使用点号路径检查嵌套 key 是否存在。

settings.has('server.port'); // true

set(keyPath: string, value: unknown): void

更新内存中的嵌套值。需调用 save() 持久化。

settings.set('server.port', 8080);

toObject(): Record<string, unknown>

返回当前配置的可变深拷贝。

async save(): Promise<void>

将内存中的配置写回磁盘。

settings.set('llm.model', 'gpt-4o');
await settings.save();

示例

// 默认值 + 运行时覆盖
await settings.initialize({
  defaultYaml: `server: { port: 3000 }`,
  override: { server: { port: 9000 } },
});
// 结果: { server: { port: 9000 } }

// 读取并修改
await settings.initialize();
if (settings.has('debug')) {
  settings.set('debug', false);
  await settings.save();
}

License

MIT