editor-config

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Editor Config

编辑器配置

Purpose

用途

Drop a small, opinionated set of editor configuration files into a project. The skill is the source of truth — its bundled configs in
assets/
are what every target repo gets. To update the canonical configs, edit the files in this skill and commit; the next run propagates the change everywhere else.
在项目中添加一套小型、带有倾向性的编辑器配置文件。本Skill是权威数据源——其
assets/
目录下的打包配置文件是所有目标代码仓库的统一配置来源。如需更新标准配置,直接修改本Skill中的文件并提交;下次运行时,变更会同步到所有其他仓库。

When to Use This Skill

何时使用本Skill

Trigger phrases: "editor config", "editor-config", "init editor", "setup editor", "apply editor config", "sync editor config", "init zed", "init vscode", "set up .zed", "set up .vscode", "configure editor".
触发短语:"editor config"、"editor-config"、"init editor"、"setup editor"、"apply editor config"、"sync editor config"、"init zed"、"init vscode"、"set up .zed"、"set up .vscode"、"configure editor"。

Canonical Set

标准配置集合

Two editors, each with one or more target files:
EditorTargetSource
Zed
.zed/settings.json
assets/zed/settings.json
VSCode
.vscode/settings.json
assets/vscode/settings.json
VSCode
.vscode/extensions.json
assets/vscode/extensions.json
支持两款编辑器,每个编辑器对应一个或多个目标文件:
编辑器目标文件源文件
Zed
.zed/settings.json
assets/zed/settings.json
VSCode
.vscode/settings.json
assets/vscode/settings.json
VSCode
.vscode/extensions.json
assets/vscode/extensions.json

Sync Algorithm

同步算法

For each target file:
  • Missing in target → write our copy verbatim.
  • Already exists in target
    • settings.json
      files: deep-merge with our values winning every conflict. Keys the user has that we do not define are preserved.
    • extensions.json
      : union the
      recommendations
      and
      unwantedRecommendations
      arrays. No duplicates, order preserved with our entries appended first.
Existing files are read tolerantly —
//
line comments and
/* … */
block comments (valid in JSONC) are stripped before parsing. The output is always plain JSON.
The skill prints a per-file plan (
Write
,
Merge
,
Identical
) and asks for confirmation before writing.
针对每个目标文件:
  • 目标文件不存在 → 直接写入我们的配置副本。
  • 目标文件已存在
    • settings.json
      文件:深度合并,我们的配置值优先解决所有冲突。用户已设置但我们未定义的配置项将被保留。
    • extensions.json
      :对
      recommendations
      unwantedRecommendations
      数组执行合并去重操作。无重复项,我们的配置项会优先排在前面,保留原有顺序。
读取现有文件时会兼容特殊格式——解析前会移除
//
行注释和
/* … */
块注释(JSONC格式允许的注释)。输出结果始终为纯JSON格式。
本Skill会打印每个文件的处理计划(
Write
写入、
Merge
合并、
Identical
无变化),并在写入前请求确认。

Asking the User

用户交互规则

Every question in this skill is written as
AskUserQuestion
options. Use that tool where the host offers it, or the host's nearest structured-choice equivalent. Where the host has neither, ask the same question in normal chat as a numbered list of 2–5 options — recommended first, one short line of description each — and wait for the user to reply with a number.
本Skill中的所有问题均以
AskUserQuestion
选项形式编写。若宿主环境支持该工具则直接使用,或使用宿主环境中最接近的结构化选择功能。若两者都不支持,则在普通聊天中以2-5个选项的编号列表形式提问——推荐选项放在首位,每个选项配一行简短描述——等待用户回复数字。

Workflow

工作流程

  1. Determine editor selection.
    • If arguments include
      zed
      and/or
      vscode
      , use those.
    • Otherwise ask per Asking the User, accepting more than one pick:
      Question: Which editor configs should I set up?
      Header:   Editors
      Options:
        - Zed (Recommended) — Apply .zed/settings.json
        - VSCode            — Apply .vscode/settings.json and .vscode/extensions.json
      In chat, accept one or more numbers comma-separated (e.g.
      1,2
      ).
  2. Run the apply script for each selection.
    bash
    bash <skill-dir>/scripts/editor-config.sh [--dry-run] [--yes] <editor> [<editor> ...]
    <editor>
    is one of
    zed
    ,
    vscode
    . Flags:
    • --dry-run
      — print the plan and exit
    • --yes
      /
      -y
      — skip the per-run confirmation
    • -h
      ,
      --help
      — usage
  3. Review the plan. The script prints
    Target
    , then a per-file action (
    Write
    ,
    Merge
    ,
    Identical
    ).
  4. Confirm. Type
    y
    to apply. Anything else aborts.
  5. Verify. After apply, the changed files are listed. Run
    git status
    /
    git diff
    in the target repo to inspect.
  1. 确定编辑器选择
    • 若参数包含
      zed
      和/或
      vscode
      ,则直接使用这些参数。
    • 否则按照用户交互规则提问,允许多选:
      问题:我需要为哪些编辑器配置?
      标题:编辑器选项
      选项:
        - Zed(推荐)—— 应用.zed/settings.json配置
        - VSCode            —— 应用.vscode/settings.json和.vscode/extensions.json配置
      在聊天场景中,接受用户以逗号分隔的多个数字回复(例如
      1,2
      )。
  2. 为每个选中的编辑器运行应用脚本
    bash
    bash <skill-dir>/scripts/editor-config.sh [--dry-run] [--yes] <editor> [<editor> ...]
    <editor>
    可选值为
    zed
    vscode
    。参数说明:
    • --dry-run
      —— 打印处理计划后退出
    • --yes
      /
      -y
      —— 跳过运行前的确认步骤
    • -h
      ,
      --help
      —— 查看使用说明
  3. 查看处理计划。脚本会打印
    Target
    目标文件,以及每个文件的操作类型(
    Write
    写入、
    Merge
    合并、
    Identical
    无变化)。
  4. 确认操作。输入
    y
    确认应用,输入其他内容则终止操作。
  5. 验证结果。应用完成后会列出变更的文件。在目标代码仓库中运行
    git status
    /
    git diff
    命令检查变更内容。

Edge Cases

边缘情况处理

  • jq
    missing.
    The script requires
    jq
    for parsing and merging. Install with
    brew install jq
    (or your package manager).
  • JSONC with non-standard syntax. The comment stripper handles
    //
    and
    /* … */
    . Trailing commas are not handled — if the existing file has them, the script reports a parse error and exits without writing. Remove trailing commas and re-run.
  • Existing
    recommendations
    array contains a string we also define.
    The union de-duplicates by exact string match, so no double entries appear.
  • The user has set a key we also define to a different value. Ours wins — this is the explicit design. If a user customization needs to survive, remove that key from
    assets/<editor>/settings.json
    in this skill (the canonical set).
  • 缺少
    jq
    工具
    。脚本依赖
    jq
    进行解析和合并操作。可通过
    brew install jq
    (或对应包管理器)安装。
  • JSONC包含非标准语法。注释处理工具仅支持
    //
    /* … */
    注释。不支持 trailing commas(尾随逗号)——若现有文件包含尾随逗号,脚本会报告解析错误并退出,不执行写入操作。需移除尾随逗号后重新运行。
  • 现有
    recommendations
    数组包含与我们定义相同的字符串
    。合并去重操作会通过精确字符串匹配去重,不会出现重复项。
  • 用户设置了与我们相同的配置项但值不同。以我们的配置值为准——这是明确的设计规则。若用户的自定义配置需要保留,请从本Skill的
    assets/<editor>/settings.json
    (标准配置集合)中移除该配置项。

Updating the Canonical Configs

更新标准配置

The bundled files in
assets/
are the source of truth. Edit them in place and commit; the next run in any other repo picks up the new content.
When adding a brand-new target file:
  1. Drop the file into
    assets/<editor>/
    .
  2. Add a row to the Canonical Set table above.
  3. Extend the editor block in
    scripts/editor-config.sh
    (the
    apply_<editor>
    function and the
    TARGETS_<EDITOR>
    array).
When adding a brand-new editor:
  1. Create
    assets/<editor>/
    with the relevant files.
  2. Add the editor to the script's
    KNOWN_EDITORS
    list and add an
    apply_<editor>
    function.
  3. Add it to the Canonical Set table and the
    AskUserQuestion
    options.
assets/
目录下的打包文件是权威数据源。直接修改这些文件并提交;下次在其他仓库运行时,会自动获取新的配置内容。
添加新的目标文件时:
  1. 将文件放入
    assets/<editor>/
    目录。
  2. 在上方的标准配置集合表格中添加一行。
  3. 扩展
    scripts/editor-config.sh
    中的编辑器代码块(
    apply_<editor>
    函数和
    TARGETS_<EDITOR>
    数组)。
添加新的编辑器支持时:
  1. 创建
    assets/<editor>/
    目录并放入相关配置文件。
  2. 将编辑器添加到脚本的
    KNOWN_EDITORS
    列表中,并添加对应的
    apply_<editor>
    函数。
  3. 标准配置集合表格和
    AskUserQuestion
    选项中添加该编辑器。