config-merge

config-merge: A tool for layered configuration merging and validation. Supports priority merging across default/system/task layers, field-level validation and automatic fixes (conflict resolution), configuration snapshots and restore, diffing two configurations, and dry-run assertion checks; schema can be injected. Common triggers: configuration merge, layered config, config validation, config snapshot, config diff, default merge, automatic conflict fix.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "config-merge" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-b76ebc8df5b42dd1e1b52b19b5776bea64cd231c6cfbcd38cb83dda21bcc7025. Verify the upstream source and version against https://skillhub.cn/skills/user_3ff3c268/config-merge before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

config-merge: A tool for layered configuration merging and validation. Supports priority merging across default/system/task layers, field-level validation and automatic fixes (conflict resolution), configuration snapshots and restore, diffing two configurations, and dry-run assertion checks; schema can be injected. Common triggers: configuration merge, layered config, config validation, config snapshot, config diff, default merge, automatic conflict fix.

0 Downloads

Introduction source: third_party · user_3ff3c268 · 1.2.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter


name: config-merge
display_name: 多环境配置合并校验工具(默认/系统/任务三层)
description: 配置分层合并与校验工具。支持 default/system/task 三层优先级合并、字段级校验与自动修正(冲突修复)、配置快照与恢复、两份配置差异对比,以及 dry-run 断言验证。schema 可注入。触发词:配置合并、分层配置、配置校验、配置快照、配置 diff、默认值合并、配置冲突自动修复。
market_desc: 多来源配置不再打架——default/system/task 三层按优先级自动合并,字段级校验+冲突自动修复(如最大延迟小于最小延迟时自动纠正),还能快照存档、diff 对比、dry-run 预演。适合 dev/test/prod 多环境管理的后端与运维,做完直接复用,零依赖。 【闭环归属】本技能是「API/数据接入管线闭环」的第 3 步(共 5 步:解析→对齐→合并→换算→导出)。要可交付的数据资产,配齐这 5 个技能即可;总控入口:api-data-pipeline。
version: 1.2.0
changelog: 升级 v1.2.0:中性化署名、场景拓宽、补充闭环归属交叉引用。

config-merge —— 配置分层合并与校验

把「默认值 / 系统配置 / 任务配置」三层合并成一份最终配置,自动校验、自动修复冲突,并支持快照与 diff。 纯函数实现(Node ESM,零依赖,仅用内置 node:crypto)。schema 可注入。

适用场景

  • 有「全局默认 + 用户设置 + 单次任务参数」三层配置的工具 / 服务
  • 配置冲突需要自动修复(如 delayMax < delayMin → 自动纠正)
  • 任务前 dry-run 预演、配置版本快照与回归 diff

提供的函数

函数 说明
resolveConfig({defaults,system,task,schema?}) 三层合并 + 校验 + 自动修复,返回含 _meta/configHash 的结果
diffConfigs(c1, c2) 对比两份配置,返回差异字段列表
configSnapshot(resolved) / configFromSnapshot(str) 快照存档 / 恢复
freezeConfig(resolved) 冻结为不可变快照
runAssertions(resolved, fns) 运行断言集合(dry-run 验证)
commonAssertions 常用断言构造器:range / gte / truthy

schema 字段规则:

  • systemOnly: true —— 该字段任务层不可覆盖(只取系统/默认)
  • validator(v) —— 值校验,不合法则跳过该来源
  • autoFix(resolved) —— 返回 {value, message} 时自动修正并记录冲突

用法

import { resolveConfig, diffConfigs, runAssertions, commonAssertions } from './scripts/config-merge.mjs';

const resolved = resolveConfig({
  defaults: { maxPages: 10, delayMin: 3000, delayMax: 8000 },
  system:   { delayMin: 5000 },
  task:     { maxPages: 5, delayMax: 1000 },  // delayMax 小于 delayMin,会被自动修复
  schema: {
    delayMax: { autoFix: (r) => r.delayMax < r.delayMin
      ? { value: r.delayMin + 2000, message: '最大延迟小于最小延迟,已自动修正' } : null },
  },
});
// resolved.delayMax === 7000; resolved._meta.conflicts 含一条自动修复记录

const check = runAssertions(resolved, [commonAssertions.gte('delayMax', 'delayMin')]);
// check.success === true

设计要点

  • 优先级严格 task > system > default;校验失败跳过该来源降级取下一层。
  • 所有自动修复都会写入 _meta.conflicts(标记 autoFixed:true),便于审计。
  • configHash 由配置内容生成(不含 _meta),可用于缓存失效判断。

自测

node scripts/config-merge.mjs --selftest

Current listing version

1.2.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value82/100

Highlights

  • 解决多环境配置合并的实际痛点,支持三层优先级合并与自动冲突修复
  • 适用于后端/运维场景,具备快照、diff、dry-run 等完整功能闭环
Trigger Precision95/100

Highlights

  • 触发词覆盖全面且精准,包含配置合并、分层配置、校验、快照等核心功能点
Structure and Standards92/100

Highlights

  • 结构清晰完整,包含适用场景、函数说明、代码示例和设计要点
  • frontmatter 规范,提供端到端使用示例
Execution Reliability90/100

Highlights

  • 工具来源明确(Node ESM 零依赖),参数说明清晰
  • 覆盖主要异常处理,提供自测命令和 dry-run 验证机制
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.