editor-config
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEditor 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 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.
assets/在项目中添加一套小型、带有倾向性的编辑器配置文件。本Skill是权威数据源——其目录下的打包配置文件是所有目标代码仓库的统一配置来源。如需更新标准配置,直接修改本Skill中的文件并提交;下次运行时,变更会同步到所有其他仓库。
assets/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:
| Editor | Target | Source |
|---|---|---|
| Zed | | |
| VSCode | | |
| VSCode | | |
支持两款编辑器,每个编辑器对应一个或多个目标文件:
| 编辑器 | 目标文件 | 源文件 |
|---|---|---|
| Zed | | |
| VSCode | | |
| VSCode | | |
Sync Algorithm
同步算法
For each target file:
- Missing in target → write our copy verbatim.
- Already exists in target →
- files: deep-merge with our values winning every conflict. Keys the user has that we do not define are preserved.
settings.json - : union the
extensions.jsonandrecommendationsarrays. No duplicates, order preserved with our entries appended first.unwantedRecommendations
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 (, , ) and asks for
confirmation before writing.
WriteMergeIdentical针对每个目标文件:
- 目标文件不存在 → 直接写入我们的配置副本。
- 目标文件已存在 →
- 文件:深度合并,我们的配置值优先解决所有冲突。用户已设置但我们未定义的配置项将被保留。
settings.json - :对
extensions.json和recommendations数组执行合并去重操作。无重复项,我们的配置项会优先排在前面,保留原有顺序。unwantedRecommendations
读取现有文件时会兼容特殊格式——解析前会移除行注释和块注释(JSONC格式允许的注释)。输出结果始终为纯JSON格式。
///* … */本Skill会打印每个文件的处理计划(写入、合并、无变化),并在写入前请求确认。
WriteMergeIdenticalAsking the User
用户交互规则
Every question in this skill is written as 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.
AskUserQuestion本Skill中的所有问题均以选项形式编写。若宿主环境支持该工具则直接使用,或使用宿主环境中最接近的结构化选择功能。若两者都不支持,则在普通聊天中以2-5个选项的编号列表形式提问——推荐选项放在首位,每个选项配一行简短描述——等待用户回复数字。
AskUserQuestionWorkflow
工作流程
-
Determine editor selection.
-
If arguments includeand/or
zed, use those.vscode -
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.jsonIn chat, accept one or more numbers comma-separated (e.g.).1,2
-
-
Run the apply script for each selection.bash
bash <skill-dir>/scripts/editor-config.sh [--dry-run] [--yes] <editor> [<editor> ...]is one of<editor>,zed. Flags:vscode- — print the plan and exit
--dry-run - /
--yes— skip the per-run confirmation-y - ,
-h— usage--help
-
Review the plan. The script prints, then a per-file action (
Target,Write,Merge).Identical -
Confirm. Typeto apply. Anything else aborts.
y -
Verify. After apply, the changed files are listed. Run/
git statusin the target repo to inspect.git diff
-
确定编辑器选择
-
若参数包含和/或
zed,则直接使用这些参数。vscode -
否则按照用户交互规则提问,允许多选:
问题:我需要为哪些编辑器配置? 标题:编辑器选项 选项: - Zed(推荐)—— 应用.zed/settings.json配置 - VSCode —— 应用.vscode/settings.json和.vscode/extensions.json配置在聊天场景中,接受用户以逗号分隔的多个数字回复(例如)。1,2
-
-
为每个选中的编辑器运行应用脚本bash
bash <skill-dir>/scripts/editor-config.sh [--dry-run] [--yes] <editor> [<editor> ...]可选值为<editor>或zed。参数说明:vscode- —— 打印处理计划后退出
--dry-run - /
--yes—— 跳过运行前的确认步骤-y - ,
-h—— 查看使用说明--help
-
查看处理计划。脚本会打印目标文件,以及每个文件的操作类型(
Target写入、Write合并、Merge无变化)。Identical -
确认操作。输入确认应用,输入其他内容则终止操作。
y -
验证结果。应用完成后会列出变更的文件。在目标代码仓库中运行/
git status命令检查变更内容。git diff
Edge Cases
边缘情况处理
- missing. The script requires
jqfor parsing and merging. Install withjq(or your package manager).brew install jq - 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 array contains a string we also define. The union de-duplicates by exact string match, so no double entries appear.
recommendations - 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 in this skill (the canonical set).
assets/<editor>/settings.json
- 缺少工具。脚本依赖
jq进行解析和合并操作。可通过jq(或对应包管理器)安装。brew install jq - JSONC包含非标准语法。注释处理工具仅支持和
//注释。不支持 trailing commas(尾随逗号)——若现有文件包含尾随逗号,脚本会报告解析错误并退出,不执行写入操作。需移除尾随逗号后重新运行。/* … */ - 现有数组包含与我们定义相同的字符串。合并去重操作会通过精确字符串匹配去重,不会出现重复项。
recommendations - 用户设置了与我们相同的配置项但值不同。以我们的配置值为准——这是明确的设计规则。若用户的自定义配置需要保留,请从本Skill的(标准配置集合)中移除该配置项。
assets/<editor>/settings.json
Updating the Canonical Configs
更新标准配置
The bundled files in are the source of truth. Edit them in place and
commit; the next run in any other repo picks up the new content.
assets/When adding a brand-new target file:
- Drop the file into .
assets/<editor>/ - Add a row to the Canonical Set table above.
- Extend the editor block in (the
scripts/editor-config.shfunction and theapply_<editor>array).TARGETS_<EDITOR>
When adding a brand-new editor:
- Create with the relevant files.
assets/<editor>/ - Add the editor to the script's list and add an
KNOWN_EDITORSfunction.apply_<editor> - Add it to the Canonical Set table and the options.
AskUserQuestion
assets/添加新的目标文件时:
- 将文件放入目录。
assets/<editor>/ - 在上方的标准配置集合表格中添加一行。
- 扩展中的编辑器代码块(
scripts/editor-config.sh函数和apply_<editor>数组)。TARGETS_<EDITOR>
添加新的编辑器支持时:
- 创建目录并放入相关配置文件。
assets/<editor>/ - 将编辑器添加到脚本的列表中,并添加对应的
KNOWN_EDITORS函数。apply_<editor> - 在标准配置集合表格和选项中添加该编辑器。
AskUserQuestion