@namewta/skills-hub 0.1.29 → 0.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/README.md +23 -4
  2. package/THIRD_PARTY_NOTICES.md +17 -0
  3. package/cli.mjs +13 -2
  4. package/install.mjs +186 -41
  5. package/licenses/nanobot-MIT.txt +21 -0
  6. package/package.json +2 -1
  7. package/scripts/init-persistence.mjs +26 -6
  8. package/scripts/persistence/changes.md +5 -4
  9. package/scripts/persistence/dev.md +2 -2
  10. package/scripts/persistence/home.md +11 -0
  11. package/skills/dev/dev-architecture/SKILL.md +1 -1
  12. package/skills/dev/dev-archive/SKILL.md +1 -1
  13. package/skills/dev/dev-archive/references/change-closure.md +2 -2
  14. package/skills/dev/dev-build/references/implement-task-graph.md +3 -3
  15. package/skills/dev/dev-debug/SKILL.md +1 -1
  16. package/skills/dev/dev-grill/references/decision-interview.md +1 -1
  17. package/skills/dev/dev-handoff/SKILL.md +1 -1
  18. package/skills/dev/dev-handoff/assets/handoff.md +1 -1
  19. package/skills/dev/dev-handoff/references/handoff-method.md +2 -0
  20. package/skills/dev/dev-help/references/guide-setup.md +33 -1
  21. package/skills/dev/dev-intake/SKILL.md +2 -0
  22. package/skills/dev/dev-intake/assets/brief.md +2 -0
  23. package/skills/dev/dev-issue/SKILL.md +2 -2
  24. package/skills/dev/dev-issue/references/github-operations.md +5 -3
  25. package/skills/dev/dev-issue-fix/SKILL.md +2 -2
  26. package/skills/dev/dev-issue-fix/assets/fix-prompt.md +2 -0
  27. package/skills/dev/dev-issue-fix/references/fix-method.md +4 -2
  28. package/skills/dev/dev-issue-fix/references/verify-existing-fix.md +1 -1
  29. package/skills/dev/dev-issue-setup/SKILL.md +2 -2
  30. package/skills/dev/dev-issue-setup/assets/collection-prompt.md +2 -2
  31. package/skills/dev/dev-issue-setup/assets/configuration.yaml +3 -2
  32. package/skills/dev/dev-issue-setup/assets/source-report.md +36 -0
  33. package/skills/dev/dev-issue-setup/references/method-index.md +1 -0
  34. package/skills/dev/dev-issue-setup/references/setup-method.md +4 -2
  35. package/skills/dev/dev-issue-setup/references/source-adapter.md +18 -1
  36. package/skills/dev/dev-issue-triage/SKILL.md +2 -2
  37. package/skills/dev/dev-issue-triage/assets/triage-prompt.md +2 -0
  38. package/skills/dev/dev-issue-triage/references/triage-method.md +5 -1
  39. package/skills/dev/dev-parallel/references/program-coordination.md +2 -2
  40. package/skills/dev/dev-plan/references/plan-template.md +3 -1
  41. package/skills/dev/dev-plan/references/research-method.md +1 -1
  42. package/skills/dev/dev-review/SKILL.md +1 -1
  43. package/skills/dev/dev-setup/SKILL.md +25 -10
  44. package/skills/dev/dev-setup/agents/openai.yaml +2 -2
  45. package/skills/dev/dev-setup/assets/environment.md +54 -19
  46. package/skills/dev/dev-setup/assets/team.md +4 -0
  47. package/skills/dev/dev-setup/references/configure-team.md +13 -2
  48. package/skills/dev/dev-setup/references/host-resources.md +170 -41
  49. package/skills/dev/dev-verify/SKILL.md +1 -1
  50. package/skills/dev/dev-verify/references/evidence-storage.md +3 -3
  51. package/skills/dev/dev-verify/references/verification-maintenance.md +1 -1
  52. package/skills/dev/dev-workflow/SKILL.md +1 -1
  53. package/skills/dev/dev-workflow/references/decision-trail.md +1 -1
  54. package/skills/dev/dev-workflow/references/delegate-role.md +1 -1
  55. package/skills/dev/dev-workflow/references/execution-support.md +4 -2
  56. package/skills/dev/dev-workflow/references/execution.md +1 -1
  57. package/skills/dev/dev-workflow/references/operating-method.md +3 -3
  58. package/skills/dev/dev-workflow/references/phase-boundaries.md +3 -3
  59. package/skills/home/home-doctor/SKILL.md +30 -0
  60. package/skills/home/home-doctor/references/diagnosis.md +40 -0
  61. package/skills/home/home-doctor/scripts/doctor.mjs +178 -0
  62. package/skills/home/home-history/SKILL.md +35 -0
  63. package/skills/home/home-history/assets/event.md +22 -0
  64. package/skills/home/home-history/assets/resumption.md +19 -0
  65. package/skills/home/home-history/references/history-method.md +90 -0
  66. package/skills/home/home-history/references/tools.md +57 -0
  67. package/skills/home/home-history/scripts/files.mjs +252 -0
  68. package/skills/home/home-history/scripts/history.mjs +184 -0
  69. package/skills/home/home-integrate/SKILL.md +23 -0
  70. package/skills/home/home-integrate/assets/integration.md +25 -0
  71. package/skills/home/home-integrate/references/integration.md +59 -0
  72. package/skills/home/home-knowledge/SKILL.md +37 -0
  73. package/skills/home/home-knowledge/assets/candidate.md +19 -0
  74. package/skills/home/home-knowledge/assets/exclusions.md +6 -0
  75. package/skills/home/home-knowledge/assets/topic.md +27 -0
  76. package/skills/home/home-knowledge/references/knowledge-method.md +55 -0
  77. package/skills/home/home-knowledge/references/maintenance.md +74 -0
  78. package/skills/home/home-knowledge/references/tools.md +55 -0
  79. package/skills/home/home-knowledge/scripts/files.mjs +252 -0
  80. package/skills/home/home-knowledge/scripts/knowledge.mjs +150 -0
  81. package/skills/home/home-map/SKILL.md +23 -0
  82. package/skills/home/home-map/assets/relations.md +25 -0
  83. package/skills/home/home-map/references/relations.md +60 -0
  84. package/skills/home/home-route/SKILL.md +32 -0
  85. package/skills/home/home-route/references/routing.md +54 -0
  86. package/skills/home/home-route/scripts/route.mjs +332 -0
  87. package/skills/home/home-setup/SKILL.md +46 -0
  88. package/skills/home/home-setup/assets/environment.md +18 -0
  89. package/skills/home/home-setup/assets/home-navigation.md +13 -0
  90. package/skills/home/home-setup/assets/local.schema.json +15 -0
  91. package/skills/home/home-setup/assets/preferences.md +16 -0
  92. package/skills/home/home-setup/assets/profile.md +19 -0
  93. package/skills/home/home-setup/assets/repos.schema.json +255 -0
  94. package/skills/home/home-setup/assets/team.md +24 -0
  95. package/skills/home/home-setup/references/configuration.md +71 -0
  96. package/skills/home/home-setup/references/environment.md +34 -0
  97. package/skills/home/home-setup/references/registry.md +130 -0
  98. package/skills/home/home-setup/scripts/registry.mjs +268 -0
  99. package/skills/home/home-workflow/SKILL.md +37 -0
  100. package/skills/home/home-workflow/assets/coordination.md +24 -0
  101. package/skills/home/home-workflow/assets/project-brief.md +25 -0
  102. package/skills/home/home-workflow/references/coordination.md +41 -0
  103. package/skills/home/home-workflow/references/delegation.md +86 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # skills-hub
2
2
 
3
- 按领域和独立技能分组组织的中文 Agent Skills,覆盖软件开发、系统维护、服务器运维和专门工具。每个技能包含使用入口、完整方法及所需模板、示例和脚本,可以单独安装,也可以按任务组合使用。
3
+ 按领域和独立技能分组组织的中文 Agent Skills,覆盖个人 Home、软件开发、系统维护、服务器运维和专门工具。每个技能包含使用入口、完整方法及所需模板、示例和脚本,可以单独安装,也可以按任务组合使用。
4
4
 
5
5
  ## 安装
6
6
 
@@ -16,6 +16,9 @@ npx @namewta/skills-hub list
16
16
  # 安装整个开发分组
17
17
  npx @namewta/skills-hub install --domain dev
18
18
 
19
+ # 构建、运营和管理个人 Home Repo
20
+ npx @namewta/skills-hub install --domain home
21
+
19
22
  # 单独安装 Issue 撰写与维护技能
20
23
  npx @namewta/skills-hub install --skill dev-issue
21
24
 
@@ -34,7 +37,7 @@ npx @namewta/skills-hub install --domain upstream-skills --dry-run
34
37
 
35
38
  交互界面默认勾选当前项目已安装的技能。使用 ↑/↓ 移动、Tab 展开或收拢领域、空格勾选、←/→ 翻页,按 Enter 查看安装确认。按 `/` 可搜索名称、分组或中文用途。非交互环境使用带 `--domain`、`--skill` 或 `--all` 的安装命令。
36
39
 
37
- 技能安装到当前项目的 `.agents/skills/<技能名>/`。重复安装时,相同内容保持不变,有差异的同名技能先备份再替换。安装器只复制文件,不执行技能中的工具;技能是否自动加载由所用 Agent 决定,也可以直接读取对应的 `SKILL.md`。
40
+ 技能的完整本体安装到当前项目的 `.agents/skills/<技能名>/`,并尝试建立 `.claude/skills/<技能名>` 到该本体的目录符号链接。两个入口读取同一份资源。Windows 创建链接遇到 `EPERM` 时,安装器继续安装技能,并提示如何补建链接。重复安装会保留相同的本体并尝试补齐缺失链接,有差异的同名本体先备份再替换。入口位置有用户文件、目录或错向链接时会报告冲突。技能由实际宿主发现,也可显式读取 `SKILL.md`。安装过程中技能工具不会运行。
38
41
 
39
42
  全局命令、源码离线安装、备份恢复和旧版本迁移见[安装说明](docs/usage/installation.md)。
40
43
 
@@ -42,6 +45,7 @@ npx @namewta/skills-hub install --domain upstream-skills --dry-run
42
45
 
43
46
  | 分组 | 用途 | 常用入口 |
44
47
  | --- | --- | --- |
48
+ | `home` | Home Repo 构建、项目登记、用户配置、分层协作、持久知识和历史运营 | [home-workflow](skills/home/home-workflow/SKILL.md)、[home-setup](skills/home/home-setup/SKILL.md) |
45
49
  | `dev` | 需求澄清、设计、原型、计划、实现、验证、交付和项目知识 | [dev-help](skills/dev/dev-help/SKILL.md)、[dev-workflow](skills/dev/dev-workflow/SKILL.md) |
46
50
  | `system` | 主机检查、磁盘清理、代理、软件配置和终端协作 | [system-inspect](skills/system/system-inspect/SKILL.md) |
47
51
  | `ops` | 多项目、多服务器与共享服务的巡检、维护、恢复和操作历史 | [ops-workflow](skills/ops/ops-workflow/SKILL.md) |
@@ -86,11 +90,25 @@ npx @namewta/skills-hub install --domain upstream-skills --dry-run
86
90
 
87
91
  `upstream-skills` 只是安装分组,各技能按自身用途工作。中文说明与原版保持对应,代码、API、文件名和可执行命令保留。Archify 的完整交付检查需要 Chrome/Chromium;Modern Web Guidance 仍通过原 CLI 检索最新资料,返回内容可能是英文。运行前提与中文范围见[上游独立技能说明](docs/usage/upstream-skills.md)。
88
92
 
93
+ ## 个人 Home Repo
94
+
95
+ 在自己的 Home 仓库安装 `home` 后,可直接使用 `home-setup` 建立项目地图和按需配置,也可由 `home-workflow` 按任务调用八个方法。已有 clone 原地登记,不要求移动到 Home 下面。Agent、CLI、模型、思考参数和派遣方式由用户选择;保存配置不会启动任务。
96
+
97
+ Home 了解各项目基本背景和管理关系。涉及项目内部知识、代码、技能或验证时,由当地 Agent 进入实际项目读取和完成;项目可继续依当地规则派遣子 Agent。每层派遣记录归当地所选技能,Home 保留管理摘要与证据指针。Home 的现行知识、历史事件和当前执行状态各有明确位置,可由新会话读取普通 Markdown 接续。
98
+
99
+ ```text
100
+ 使用 home-setup:登记这些已有项目,沿用真实目录;先保存我明确选择的协作方式。
101
+ 使用 home-workflow:向项目 A 查询接口约定,让项目 B 验证兼容性,回报各自版本和证据。
102
+ 使用 home-history:查明当时为什么选择这个方案,再指出当前知识是否已经更正。
103
+ ```
104
+
105
+ 完整用法、方法归属和验证边界见 [Home 说明](docs/home/overview.md)。
106
+
89
107
  ## 项目结构
90
108
 
91
109
  | 位置 | 内容 |
92
110
  | --- | --- |
93
- | `skills/<domain>/<domain>-xxx/` | 按职责整合的开发、系统和运维技能 |
111
+ | `skills/<domain>/<domain>-xxx/` | 按职责整合的 Home、开发、系统和运维技能 |
94
112
  | `upstream-skills/zh-<原名>/` | 与原技能一一对应的独立中文运行包 |
95
113
  | `materials/` | 固定版本的来源原件、中文对照和逐文件运行映射 |
96
114
  | `docs/` | 使用说明、架构解释和维护规范 |
@@ -98,7 +116,7 @@ npx @namewta/skills-hub install --domain upstream-skills --dry-run
98
116
 
99
117
  安装器直接扫描两个运行根,完整复制所选技能的 `SKILL.md`、`references/`、`assets/`、`scripts/` 和其他配套资源。安装后所有技能位于 `.agents/skills/` 同一层级。`materials/` 供维护时对照,不参与技能发现或安装。
100
118
 
101
- 项目资料按领域保存:开发在 `.agents/dev/`,系统维护在 `.agents/system/`,运维在 `.agents/ops/`。安装 dev 或 system 技能时,安装器补根 `.gitignore` 的 `/temp/`;日志和截图等原件按需写到 `temp/dev/` 或 `temp/system/`。Change 的 `evidences/` 只放与 `tasks/` 完全同名的 `.md`,完成整体验收后才写 Change 根 `evidence.md`。独立上游分组不创建 `.agents/upstream-skills/`。详见[领域持久化与迁移](docs/reference/persistence-roots.md)。
119
+ 项目资料按领域保存:Home 在 `.agents/home/`,开发在 `.agents/dev/`,系统维护在 `.agents/system/`,运维在 `.agents/ops/`。远端 Issue 的完整正文、讨论和必要方案附件归所属 Change 的 `source/`,设计、计划、确认原型及正式结论随 Change 跟踪。安装 dev 或 system 技能时,安装器补根 `.gitignore` 的 `/temp/`;执行日志、调试截图和测量等过程原件按需写到 `temp/dev/` 或 `temp/system/`。Change 的 `evidences/` 只放与 `tasks/` 完全同名的 `.md`,完成整体验收后才写 Change 根 `evidence.md`。独立上游分组不创建 `.agents/upstream-skills/`。详见[领域持久化与迁移](docs/reference/persistence-roots.md)。
102
120
 
103
121
  ## 文档导航
104
122
 
@@ -108,6 +126,7 @@ npx @namewta/skills-hub install --domain upstream-skills --dry-run
108
126
  | 安装、升级、恢复备份或迁移旧包 | [安装说明](docs/usage/installation.md) |
109
127
  | 组合开发技能,处理原型与交接 | [开发流程](docs/development/workflow.md)、[可交互原型](docs/development/prototype.md)、[开发交接](docs/development/handoff.md) |
110
128
  | 新建完整 Issue、更新正文或追加评论 | [Issue 撰写与维护](docs/development/issues.md) |
129
+ | 构建、运营和管理个人 Home | [Home 说明](docs/home/overview.md)、[方法归属](docs/home/method-ownership.md) |
111
130
  | 维护服务器和项目运行关系 | [运维说明](docs/operations/overview.md) |
112
131
  | 用 Herdr TUI 或 Core 启动 agent、派发任务和收取结果 | [Herdr 协作](docs/usage/herdr-coordination.md) |
113
132
  | 使用和更新独立中文技能 | [上游独立技能](docs/usage/upstream-skills.md) |
@@ -21,6 +21,7 @@
21
21
  | [openai/skills — Sentry](https://github.com/openai/skills/tree/main/skills/.curated/sentry),OpenAI 及贡献者 | `skills/.curated/sentry`;只读错误观测、范围核对与脱敏方法用于 `ops-inspect`。 | [Apache 2.0](licenses/openai-sentry-Apache-2.0.txt);[清单](materials/openai-sentry/manifest.tsv) |
22
22
  | [HumanLayer](https://github.com/humanlayer/humanlayer) / [Dex Horthy](https://github.com/dexhorthy),QueryTale, Inc. d/b/a HumanLayer | 既有 PR 视觉说明中的 show-me 方法;已作中文翻译和流程适配。NOTICE 中列出的其他程序组件未因此一并收录。 | [Apache 2.0](licenses/humanlayer-Apache-2.0.txt)、[NOTICE](licenses/humanlayer-NOTICE.txt) |
23
23
  | [abdiraimov-otabek/dashboard-design-skill](https://github.com/abdiraimov-otabek/dashboard-design-skill),Otabek Abdiraimov | 固定版本 `skills/dashboard-design/` 的 11 份 Markdown;完整翻译后独立提供 `zh-dashboard-design`。不包含来源仓库根部的示例页面、图片与 Claude 插件配置。 | [MIT](licenses/dashboard-design-skill-MIT.txt);[清单](materials/dashboard-design-skill/manifest.tsv) |
24
+ | [HKUDS/nanobot](https://github.com/HKUDS/nanobot),Xubin Ren 与 nanobot 贡献者 | `nanobot/skills/memory` 的完整短技能及中文底稿;采用按需读取、来源边界、已确认长期知识、读后更新、修复引用和历史检索方法。 | [MIT](licenses/nanobot-MIT.txt);[清单](materials/nanobot-memory/manifest.tsv) |
24
25
 
25
26
  ### 整合内容的修改范围
26
27
 
@@ -35,6 +36,7 @@
35
36
  - `system-herdr` 保留完整 CLI 方法;客户端启动示例与按 pane 的 task/report 文件通信属于本地扩展。
36
37
  - `system-herdr-core` 的运行版采用用户明确选用的触发条件,并增加客户端启动示例及按 Core 终端地址派发 task/report 的方法。许可原文与现有 Herdr Apache 2.0 文件字节相同。
37
38
  - ops 将调查、经验和只读观测方法适配到本领域的 registry、run、项目资料与实际工具能力。领域之间不因此产生自动安装依赖。
39
+ - home 采用 Matt 的直接负责人、上下文指针、按主题组织知识和交接资料方法,将来源中常驻会话、固定回顾频率和整套开发链改为用户按需选择的项目协作;现行知识、历史和用户配置分别由所属技能维护。nanobot 的记忆方法适配为 `.agents/home/` 下的 Markdown,保留项目当地知识归属,不接入其全局工作区、私有 history.jsonl、游标或 Dream 运行时。具体来源和研究取舍见 [Home 来源](docs/home/sources.md)。
38
40
  - issue 初始化、分诊和复现修复保留 pstack 较早 [Benny 自动化资料](https://github.com/cursor/plugins/tree/6b0300214a09fd6029cfb7077043125758cd1fd2/pstack/automations/benny)的方法;通用来源接口和项目配置属于本地适配,原 Slack 分支保留其身份核对与回读要求。
39
41
 
40
42
  ## 独立中文上游技能
@@ -125,6 +127,21 @@ Lucide 与 Unsplash 补充法律文件的来源 URL、取得时间、摘要和
125
127
 
126
128
  v0.1.29 继续按用户要求,移除其他 dev 运行技能对环境初始化技能的提及。环境与资源信息改为直接复用已有记录的有效部分,缺失或过期时依据实际执行主机核对;模板不要求预先建立环境文件。该调整保留资源预留、独立判断、覆盖和工作树回收机制,不改变上游来源版本或已复核对象。
127
129
 
130
+ 本轮依据 [Issue #18](https://github.com/NAMEWTA/skills-hub/issues/18) 的 2026-11-25 方法研究,补充结果口径、有界校准和会话、重任务、工作树的联合预算。上表已列出的原生并发、工作树、cgroup、系统预留与过载处理来源继续沿用;以下只列新增的具体参考。源码链接固定到研究所用提交,滚动文档的研究日期不表示其内容永久不变,实际配置仍按安装版本核对。
131
+
132
+ | 增量参考 | 采用与不采用的边界 |
133
+ | --- | --- |
134
+ | Gemini CLI [subagents](https://geminicli.com/docs/core/subagents/)、[安装要求](https://geminicli.com/docs/get-started/installation/) | 区分独立上下文、实际执行资源与环境要求;不把安装页内存建议换算成每个 Agent 的固定成本。 |
135
+ | xAI Grok Build [更新记录](https://x.ai/changelog/build)、固定源码 [admission.rs](https://github.com/xai-org/grok-build/blob/2bdd1d6a6369de0e8c68132ea4539e9abd9e14a8/crates/codegen/xai-grok-tools/src/implementations/grok_build/task/admission.rs)、[auto_gc.rs](https://github.com/xai-org/grok-build/blob/2bdd1d6a6369de0e8c68132ea4539e9abd9e14a8/crates/codegen/xai-fast-worktree/src/auto_gc.rs) | 核对会话准入、workflow 运行池和回收策略各自的作用域;不以旧版本说明推断当前并发或清理能力,会话结束也不视为磁盘已释放。 |
136
+ | GitHub Copilot CLI [命令参考](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference)、[/fleet](https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli/speed-up-task-completion) | 将任务独立性、会话树与产品限制、本地资源分别核对;不把产品可创建的会话数当作硬件安全容量。 |
137
+ | obra/superpowers [dispatching-parallel-agents](https://github.com/obra/superpowers/blob/22f0b463e7a5e579904dd6211a520321035526f7/skills/dispatching-parallel-agents/SKILL.md) | 借鉴按独立问题分工,沿用本项目 task 与会话分离及会话复用约定;不把每项 task 固定映射为一个新会话。上表工作树方法中的自动安装与基线测试不作为普通只读评估的默认步骤。 |
138
+ | AI-CFD-Scientist [resource_probe.py](https://github.com/csml-rpi/AI-CFD-Scientist/blob/27eb2e82793ef9f1d190257e10020aa158a81b9a/src/cfd_langgraph/scheduling/resource_probe.py)、[scheduler.py](https://github.com/csml-rpi/AI-CFD-Scientist/blob/27eb2e82793ef9f1d190257e10020aa158a81b9a/src/cfd_langgraph/scheduling/scheduler.py) | 借鉴单项进程树校准、结合 CPU 与内存估算及压力下暂缓新增;不采用未测时按核数猜人数、强制至少一个名额、等待超时后带压启动的策略,不引入其 Python 调度器。 |
139
+ | Linux [PSI](https://docs.kernel.org/accounting/psi.html) | 配合已有 cgroup 来源解释持续压力与恢复观察;保护线、观察窗口和恢复条件按实际环境说明来源,不声称存在全平台通用的安全常数。 |
140
+ | Node.js 22.14 [os.availableParallelism()](https://nodejs.org/download/release/v22.14.0/docs/api/os.html#osavailableparallelism)、[process.constrainedMemory()](https://nodejs.org/download/release/v22.14.0/docs/api/process.html#processconstrainedmemory) | 按接口语义与可见平台约束解释观测;不把并行度估计等同于 Agent 数,也不把内存接口返回 `0` 直接解释为零 RAM 或无限容量。 |
141
+ | Playwright [并行测试](https://playwright.dev/docs/test-parallel)、CMake [构建并发](https://cmake.org/cmake/help/latest/envvar/CMAKE_BUILD_PARALLEL_LEVEL.html) | 记录实际工具版本下的内部 workers 或 jobs,并核对限制是否生效;不让多个工作树各自无条件使用整机并行度。 |
142
+
143
+ 报告中的当前观测、已验证运行规模、建议并发和实际极限分别表述;默认只读、按已有授权有界校准、证据不足时保留未知,以及当前数量超出建议时停止扩张,均是本项目的适配。来源中的团队人数建议、配置默认值与安装要求不能代替实际容量证据。本轮只作方法研究与适配,不执行或导入来源脚本,不新增运行依赖或全量材料副本,也不更新材料的逐文件审校状态和已有历史声明。
144
+
128
145
  ### Issue 撰写与维护
129
146
 
130
147
  `dev-issue` 将以下资料作为正文完整性、仓库上下文和远程写入语义的对照,自行组织面向 GitHub 的创建、更新与评论流程。完整规格和本地切片方法继续分别由 `dev-spec`、`dev-plan` 维护,不复制其正文或增加第二个材料归属。以下网页和较新源码未整篇翻译收录,也不改变材料父清单的固定版本。
package/cli.mjs CHANGED
@@ -42,6 +42,7 @@ export async function interactive({ argv = [], project = process.cwd(), ui = pro
42
42
  }
43
43
  }
44
44
  ui.note(project, '目标项目(技能写入 .agents/skills/)');
45
+ ui.note('安装器尝试在 .claude/skills/ 建立指向 .agents/skills/ 的目录符号链接。Windows 创建链接遇到 EPERM 时仍会安装技能。同名文件、目录或错向链接会阻止安装。', '技能入口');
45
46
  const installer = createInstaller();
46
47
  const skills = installer.catalog();
47
48
  const initialNames = installer.installedNames(skills, project);
@@ -50,7 +51,7 @@ export async function interactive({ argv = [], project = process.cwd(), ui = pro
50
51
  const selected = select(skills, [], names);
51
52
  if (!selected.length) throw new Error('请至少勾选一个技能。');
52
53
  ui.note(formatSummary(selected.map(skill => skill.name)), `${selected.length} 个技能`);
53
- if (selected.some(skill => ['dev', 'system', 'ops'].includes(skill.domain))) {
54
+ if (selected.some(skill => ['dev', 'system', 'ops', 'home'].includes(skill.domain))) {
54
55
  ui.note('将补齐所选领域的持久化目录和简短 AGENTS.md;固定模板自动更新,业务记录保留,预览不写入。', '领域初始化');
55
56
  }
56
57
  if (selected.some(skill => skill.domain === 'dev' || skill.domain === 'system')) {
@@ -59,6 +60,9 @@ export async function interactive({ argv = [], project = process.cwd(), ui = pro
59
60
  if (selected.some(skill => skill.domain === 'dev')) {
60
61
  ui.note('如缺少规则,将在项目根 .gitignore 追加 /.agents/dev/worktree/。', '开发工作树');
61
62
  }
63
+ if (selected.some(skill => skill.domain === 'home')) {
64
+ ui.note('如缺少规则,将补项目根 .gitignore 的 /.agents/home/local.json 默认规则,保留项目例外;Home 业务资料由相应技能按需创建。', 'Home 本机映射');
65
+ }
62
66
  if (!await ask(ui.confirm({ message: dryRun ? '检查安装计划?(不写入文件)' : '安装或更新以上技能?(有差异的现有技能会先备份)', initialValue: true }))) {
63
67
  ui.cancel('已取消,未修改文件。'); return 0;
64
68
  }
@@ -69,7 +73,14 @@ export async function interactive({ argv = [], project = process.cwd(), ui = pro
69
73
  const output = [];
70
74
  spinner.start(dryRun ? '正在检查计划' : '正在安装');
71
75
  let code;
72
- try { code = main(command, { project, stdout: line => output.push(line), stderr: line => output.push(pc.red(line)) }); }
76
+ try {
77
+ code = main(command, {
78
+ project,
79
+ stdout: line => output.push(line),
80
+ stderr: line => output.push(pc.red(line)),
81
+ warn: line => output.push(pc.yellow(line)),
82
+ });
83
+ }
73
84
  finally { spinner.stop('检查与文件操作结束'); }
74
85
  ui.note(output.join('\n'), '结果');
75
86
  ui.outro(code === 0 ? pc.green(dryRun ? '预览完成,未写入文件。' : '安装完成。') : pc.red('安装失败;请检查以上路径、权限或运行错误。'));
package/install.mjs CHANGED
@@ -77,7 +77,7 @@ export function select(skills, domains = [], names = [], allSkills = false) {
77
77
  return skills.filter((skill) => allSkills || domains.includes(skill.domain) || names.includes(skill.name));
78
78
  }
79
79
 
80
- export function createInstaller({ repository = repositoryRoot, fsOps = fs } = {}) {
80
+ export function createInstaller({ repository = repositoryRoot, fsOps = fs, platform = process.platform } = {}) {
81
81
  const skillRoot = path.join(repository, 'skills');
82
82
  const upstreamRoot = path.join(repository, 'upstream-skills');
83
83
  const licenseRoot = path.join(repository, 'licenses');
@@ -132,6 +132,16 @@ export function createInstaller({ repository = repositoryRoot, fsOps = fs } = {}
132
132
  }
133
133
  }
134
134
 
135
+ function checkDirectoryPath(project, directory) {
136
+ if (!isWithin(directory, project)) throw new InstallError(`Destination is outside the current project: ${directory}`);
137
+ let current = project;
138
+ checkDirectory(current);
139
+ for (const part of path.relative(project, directory).split(path.sep).filter(Boolean)) {
140
+ current = path.join(current, part);
141
+ checkDirectory(current);
142
+ }
143
+ }
144
+
135
145
  function installedNames(skills, project) {
136
146
  const agents = path.join(project, '.agents');
137
147
  const target = path.join(agents, 'skills');
@@ -142,6 +152,55 @@ export function createInstaller({ repository = repositoryRoot, fsOps = fs } = {}
142
152
  }).map(({ name }) => name);
143
153
  }
144
154
 
155
+ function planLink(name, project, canonical) {
156
+ const relative = `.claude/skills/${name}`;
157
+ const destination = path.join(project, '.claude', 'skills', name);
158
+ const target = path.relative(path.dirname(destination), canonical);
159
+ const stat = exists(destination);
160
+ if (!stat) return { path: relative, destination, target, kind: 'link' };
161
+ if (!stat.isSymbolicLink()) {
162
+ throw new InstallError(`Claude skill entry conflict: ${destination} is not a symlink. Expected a directory symlink to ${canonical}; existing content was not changed.`);
163
+ }
164
+ const previous = fsOps.readlinkSync(destination);
165
+ const resolved = path.resolve(path.dirname(destination), previous);
166
+ // 预期本体尚未安装时,准确指向它的断链仍是可保留的入口。
167
+ let matches = path.relative(resolved, canonical) === '';
168
+ if (exists(canonical)) {
169
+ try {
170
+ matches = path.relative(fsOps.realpathSync(destination), fsOps.realpathSync(canonical)) === '' &&
171
+ fsOps.statSync(destination).isDirectory();
172
+ }
173
+ catch (error) {
174
+ if (!['ENOENT', 'ENOTDIR', 'ELOOP'].includes(error.code)) throw error;
175
+ matches = false;
176
+ }
177
+ }
178
+ if (!matches) {
179
+ throw new InstallError(`Claude skill entry conflict: ${destination} -> ${previous}. Expected ${canonical}; the existing link and its target were not changed.`);
180
+ }
181
+ return { path: relative, destination, target: previous, kind: 'preserved' };
182
+ }
183
+
184
+ function checkLinkParents(project) {
185
+ for (const relative of ['.agents', '.agents/skills', '.claude', '.claude/skills']) {
186
+ checkDirectory(path.join(project, relative));
187
+ }
188
+ }
189
+
190
+ function verifyLink(action, project) {
191
+ checkLinkParents(project);
192
+ checkDirectory(action.destination);
193
+ const actual = planLink(action.name, project, action.destination);
194
+ const expectedKind = action.link.kind === 'skipped' ? 'link' : 'preserved';
195
+ if (actual.kind !== expectedKind || actual.target !== action.link.target ||
196
+ (actual.kind === 'preserved' && path.relative(fsOps.realpathSync(actual.destination), fsOps.realpathSync(action.destination)) !== '')) {
197
+ throw new InstallError(`Claude skill link verification failed: ${action.link.destination}`);
198
+ }
199
+ if (actual.kind === 'link') return;
200
+ const manifest = path.join(actual.destination, 'SKILL.md');
201
+ if (!exists(manifest)?.isFile()) throw new InstallError(`Expected a regular skill entry: ${manifest}`);
202
+ }
203
+
145
204
  function plan(skills, project, replace = true) {
146
205
  const actualProject = fsOps.realpathSync(project);
147
206
  for (const source of [skillRoot, upstreamRoot, licenseRoot]) {
@@ -149,41 +208,60 @@ export function createInstaller({ repository = repositoryRoot, fsOps = fs } = {}
149
208
  throw new InstallError("Run from the target project, outside this repository's source skills and licenses directories (including upstream-skills).");
150
209
  }
151
210
  }
211
+ project = actualProject;
152
212
  const agents = path.join(project, '.agents');
153
213
  const target = path.join(agents, 'skills');
154
214
  for (const filename of [agents, target, path.join(agents, '.skills-hub-backups')]) checkDirectory(filename);
215
+ checkLinkParents(project);
155
216
  const actions = [];
156
217
  const conflicts = [];
157
218
  const packages = skills.map((skill) => ({ source: skill.source, name: skill.name, destination: path.join(target, skill.name) }));
158
219
  for (const item of packages) {
159
- checkDirectory(item.destination);
160
- let kind;
161
- if (!exists(item.destination)) kind = 'install';
162
- else if (treeDigest(item.source, fsOps) === treeDigest(item.destination, fsOps)) kind = 'unchanged';
163
- else if (replace) kind = 'replace';
164
- else { conflicts.push(item.name); continue; }
165
- actions.push({ ...item, kind });
220
+ try {
221
+ checkDirectory(item.destination);
222
+ let kind;
223
+ if (!exists(item.destination)) kind = 'install';
224
+ else if (treeDigest(item.source, fsOps) === treeDigest(item.destination, fsOps)) kind = 'unchanged';
225
+ else if (replace) kind = 'replace';
226
+ else throw new InstallError(`Existing packages differ: ${item.name}. Inspect them first; --replace saves backups before replacement.`);
227
+ actions.push({ ...item, kind, link: planLink(item.name, project, item.destination) });
228
+ } catch (error) { conflicts.push(error.message); }
166
229
  }
230
+ try { planPersistence(skills, project, fsOps); }
231
+ catch (error) { conflicts.push(error.message); }
167
232
  if (conflicts.length) {
168
- throw new InstallError(`Existing packages differ: ${conflicts.join(', ')}. No skills were changed. Inspect them first; --replace saves backups before replacement.`);
233
+ throw new InstallError(`Installation conflicts; no files were changed:\n${conflicts.join('\n')}`);
169
234
  }
170
- planPersistence(skills, project, fsOps);
171
235
  return actions;
172
236
  }
173
237
 
174
238
  function persistencePlan(skills, project) { return planPersistence(skills, project, fsOps); }
175
239
 
176
240
  function apply(skills, project, replace = true) {
241
+ project = fsOps.realpathSync(project);
177
242
  let actions = plan(skills, project, replace);
178
243
  let persistence = persistencePlan(skills, project);
179
- if (actions.every((action) => action.kind === 'unchanged') && persistence.every(item => item.action === 'preserve')) {
244
+ if (actions.every((action) => action.kind === 'unchanged' && action.link.kind === 'preserved') && persistence.every(item => item.action === 'preserve')) {
245
+ for (const action of actions) verifyLink(action, project);
180
246
  return { actions, backup: null, persistence };
181
247
  }
182
248
  const agents = path.join(project, '.agents');
183
- fsOps.mkdirSync(agents, { recursive: true });
184
249
  const locks = [];
250
+ let staging = null;
251
+ let backup = null;
252
+ const journal = { skills: [], persistence: [], links: [], directories: [] };
253
+ const recoveryErrors = [];
254
+ let failure = null;
255
+ function ensureDirectory(directory) {
256
+ checkDirectoryPath(project, directory);
257
+ if (!exists(directory)) {
258
+ fsOps.mkdirSync(directory);
259
+ journal.directories.push(directory);
260
+ }
261
+ }
185
262
  try {
186
- // 先取得旧版共用锁,使改名前后的安装器不会同时写入 .agents/skills。
263
+ ensureDirectory(agents);
264
+ // 先取得旧版共用锁;链接补建也与现有安装事务互斥。
187
265
  for (const name of ['.skills-wta-install.lock', '.skills-hub-install.lock']) {
188
266
  const lock = path.join(agents, name);
189
267
  try { fsOps.mkdirSync(lock); }
@@ -193,28 +271,21 @@ export function createInstaller({ repository = repositoryRoot, fsOps = fs } = {}
193
271
  }
194
272
  locks.push(lock);
195
273
  }
196
- } catch (error) {
197
- for (const lock of locks.reverse()) fsOps.rmdirSync(lock);
198
- throw error;
199
- }
200
- let staging = null;
201
- let backup = null;
202
- const completed = [];
203
- const persistenceJournal = [];
204
- try {
205
274
  actions = plan(skills, project, replace);
206
275
  persistence = persistencePlan(skills, project);
207
- staging = fsOps.mkdtempSync(path.join(agents, '.skills-hub-stage-'));
276
+ if (actions.some(action => action.kind !== 'unchanged')) staging = fsOps.mkdtempSync(path.join(agents, '.skills-hub-stage-'));
208
277
  for (const action of actions) {
209
278
  if (action.kind !== 'unchanged') {
210
279
  fsOps.cpSync(action.source, path.join(staging, action.name), { recursive: true, errorOnExist: true, force: false });
211
280
  }
212
281
  }
213
- fsOps.mkdirSync(path.join(agents, 'skills'), { recursive: true });
282
+ ensureDirectory(path.join(agents, 'skills'));
214
283
  if (actions.some((action) => action.kind === 'replace')) {
215
284
  const stamp = new Date().toISOString().replace(/[-:]/g, '').replace(/\.\d{3}Z$/, 'Z');
216
- backup = path.join(agents, '.skills-hub-backups', `${stamp}-${randomUUID().replaceAll('-', '').slice(0, 8)}`);
217
- fsOps.mkdirSync(backup, { recursive: true });
285
+ const backups = path.join(agents, '.skills-hub-backups');
286
+ ensureDirectory(backups);
287
+ backup = path.join(backups, `${stamp}-${randomUUID().replaceAll('-', '').slice(0, 8)}`);
288
+ ensureDirectory(backup);
218
289
  }
219
290
  for (const action of actions) {
220
291
  if (action.kind === 'unchanged') continue;
@@ -222,29 +293,93 @@ export function createInstaller({ repository = repositoryRoot, fsOps = fs } = {}
222
293
  if (action.kind === 'replace') {
223
294
  previous = path.join(backup, action.name);
224
295
  fsOps.renameSync(action.destination, previous);
225
- completed.push({ destination: action.destination, previous });
296
+ journal.skills.push({ destination: action.destination, previous });
226
297
  }
227
298
  fsOps.renameSync(path.join(staging, action.name), action.destination);
228
- if (previous === null) completed.push({ destination: action.destination, previous });
299
+ if (previous === null) journal.skills.push({ destination: action.destination, previous });
300
+ }
301
+ applyPersistence(persistence, project, fsOps, journal.persistence);
302
+ ensureDirectory(path.join(project, '.claude'));
303
+ ensureDirectory(path.join(project, '.claude', 'skills'));
304
+ for (const action of actions) {
305
+ checkLinkParents(project);
306
+ checkDirectory(action.destination);
307
+ const current = planLink(action.name, project, action.destination);
308
+ if (current.kind !== action.link.kind || current.target !== action.link.target) {
309
+ throw new InstallError(`Claude skill entry changed during installation: ${action.link.destination}`);
310
+ }
311
+ if (action.link.kind === 'link') {
312
+ try { fsOps.symlinkSync(action.link.target, action.link.destination, 'dir'); }
313
+ catch (error) {
314
+ if (platform === 'win32' && error.code === 'EPERM') {
315
+ action.link.kind = 'skipped';
316
+ continue;
317
+ }
318
+ throw new InstallError(`Cannot create directory symlink ${action.link.destination} -> ${action.link.target}: ${error.code ?? ''} ${error.message}`);
319
+ }
320
+ journal.links.push(action.link);
321
+ }
322
+ verifyLink(action, project);
323
+ }
324
+ for (const action of actions) {
325
+ verifyLink(action, project);
326
+ if (treeDigest(action.source, fsOps) !== treeDigest(action.destination, fsOps)) {
327
+ throw new InstallError(`Installed skill verification failed: ${action.destination}`);
328
+ }
329
+ }
330
+ if (persistencePlan(skills, project).some(item => item.action !== 'preserve')) {
331
+ throw new InstallError('Project initialization verification failed; check the reported paths and retry.');
229
332
  }
230
- applyPersistence(persistence, project, fsOps, persistenceJournal);
231
- return { actions, backup, persistence };
232
333
  } catch (error) {
233
- const recoveryErrors = rollbackPersistence(persistenceJournal, fsOps);
234
- for (const item of completed.reverse()) {
334
+ failure = error;
335
+ for (const link of [...journal.links].reverse()) {
235
336
  try {
337
+ checkLinkParents(project);
338
+ const stat = exists(link.destination);
339
+ if (!stat) continue;
340
+ if (!stat.isSymbolicLink() || fsOps.readlinkSync(link.destination) !== link.target) {
341
+ throw new InstallError('The created link changed; preserving the current entry for manual recovery.');
342
+ }
343
+ fsOps.unlinkSync(link.destination);
344
+ } catch (recoveryError) { recoveryErrors.push(`${link.destination}: ${recoveryError.message}`); }
345
+ }
346
+ recoveryErrors.push(...rollbackPersistence(journal.persistence, fsOps));
347
+ for (const item of [...journal.skills].reverse()) {
348
+ try {
349
+ checkDirectoryPath(project, path.dirname(item.destination));
350
+ if (item.previous !== null) checkDirectoryPath(project, path.dirname(item.previous));
236
351
  if (exists(item.destination)) fsOps.rmSync(item.destination, { recursive: true });
237
352
  if (item.previous !== null) fsOps.renameSync(item.previous, item.destination);
238
353
  } catch (recoveryError) { recoveryErrors.push(`${item.destination}: ${recoveryError.message}`); }
239
354
  }
355
+ } finally {
356
+ if (staging !== null) {
357
+ try { checkDirectoryPath(project, path.dirname(staging)); fsOps.rmSync(staging, { recursive: true, force: true }); }
358
+ catch (error) { recoveryErrors.push(`${staging}: ${error.message}`); }
359
+ }
360
+ for (const lock of locks.reverse()) {
361
+ try { checkDirectoryPath(project, lock); fsOps.rmdirSync(lock); }
362
+ catch (error) { recoveryErrors.push(`${lock}: ${error.message}`); }
363
+ }
364
+ if (failure) {
365
+ for (const directory of [...journal.directories].reverse()) {
366
+ try { checkDirectoryPath(project, directory); fsOps.rmdirSync(directory); }
367
+ catch (error) {
368
+ if (!['ENOENT', 'ENOTEMPTY', 'EEXIST'].includes(error.code)) recoveryErrors.push(`${directory}: ${error.message}`);
369
+ }
370
+ }
371
+ }
372
+ }
373
+ if (failure) {
240
374
  if (recoveryErrors.length) {
241
- throw new InstallError(`Installation failed: ${error.message}. Some files need manual recovery.${backup ? ` Keep ${backup}.` : ''} ${recoveryErrors.join('; ')}`);
375
+ throw new InstallError(`Installation failed: ${failure.message}. Some files need manual recovery.${backup ? ` Keep ${backup}.` : ''} ${recoveryErrors.join('; ')}`);
242
376
  }
243
- throw new InstallError(`Installation failed; changes to skill directories and project initialization files were rolled back: ${error.message}`);
244
- } finally {
245
- if (staging !== null) fsOps.rmSync(staging, { recursive: true, force: true });
246
- for (const lock of locks.reverse()) fsOps.rmdirSync(lock);
377
+ throw new InstallError(`Installation failed; changes to skill directories, Claude links and project initialization files were rolled back: ${failure.message}`);
247
378
  }
379
+ if (recoveryErrors.length) {
380
+ throw new InstallError(`Installation files were updated, but temporary artifacts need manual cleanup: ${recoveryErrors.join('; ')}`);
381
+ }
382
+ return { actions, backup, persistence };
248
383
  }
249
384
  return { catalog, installedNames, plan, apply, persistencePlan };
250
385
  }
@@ -254,10 +389,13 @@ export function catalog(repository = repositoryRoot) { return createInstaller({
254
389
  const usage = `Usage: skills-hub <list|install> [--domain DOMAIN ...] [--skill NAME ...] [--all]
255
390
  skills-hub install <selection> [--dry-run] [--replace]
256
391
 
257
- Install complete skills into the current project's .agents/skills/. No destination option.
392
+ Install complete skills into the current project's .agents/skills/ and link each selected .claude/skills/<name> to that same skill. No destination option.
393
+ On Windows, EPERM while creating a Claude directory symlink skips that link and prints a warning. Reinstall with symlink permission to add it.
394
+ Conflicting Claude entries are never replaced.
258
395
  --domain upstream-skills selects the independent Chinese upstream skills; it creates no domain navigation.
259
- Selected dev/system/ops domains initialize domain AGENTS.md navigation; managed templates are updated and business records are preserved.
396
+ Selected dev/system/ops/home domains initialize domain AGENTS.md navigation; managed templates are updated and business records are preserved.
260
397
  Dev or system selections add /temp/ to the project .gitignore when missing; dev also adds /.agents/dev/worktree/.
398
+ Home selections add /.agents/home/local.json to .gitignore; Home business records are created on demand by their owning skills.
261
399
  --dry-run Preview without writing files.
262
400
  Differing selected skills are backed up and replaced automatically.
263
401
  --replace Accepted for compatibility; replacement is already the default.
@@ -284,7 +422,9 @@ function parseArguments(argv) {
284
422
  return result;
285
423
  }
286
424
 
287
- export function main(argv = process.argv.slice(2), { repository = repositoryRoot, project = process.cwd(), stdout = console.log, stderr = console.error } = {}) {
425
+ export function main(argv = process.argv.slice(2), {
426
+ repository = repositoryRoot, project = process.cwd(), stdout = console.log, stderr = console.error, warn = console.warn,
427
+ } = {}) {
288
428
  let args;
289
429
  try { args = parseArguments(argv); }
290
430
  catch (error) { stderr(`${error.message}\n${usage}`); return 2; }
@@ -311,11 +451,16 @@ export function main(argv = process.argv.slice(2), { repository = repositoryRoot
311
451
  ? { actions: installer.plan(selected, actualProject, args.replace), backup: null, persistence: installer.persistencePlan(selected, actualProject) }
312
452
  : installer.apply(selected, actualProject, args.replace);
313
453
  stdout(`Destination: ${path.join(actualProject, '.agents', 'skills')}`);
454
+ stdout(`Claude entries: ${path.join(actualProject, '.claude', 'skills')}`);
314
455
  for (const action of actions) {
315
- stdout(`${args.dryRun ? 'would ' : ''}${action.kind.padEnd(9)} ${action.name}`);
456
+ const prefix = args.dryRun ? 'would ' : '';
457
+ stdout(`${prefix}${action.kind.padEnd(9)} ${action.name} | ${prefix}${action.link.kind.padEnd(9)} ${action.link.path} -> ${action.link.target}`);
316
458
  }
317
459
  for (const item of persistence) stdout(`${args.dryRun ? 'would ' : ''}${item.action.padEnd(9)} ${item.path}`);
318
460
  if (backup !== null) stdout(`Backups: ${backup}`);
461
+ if (actions.some(action => action.link.kind === 'skipped')) {
462
+ warn('警告:标记为 skipped 的 .claude/skills/ 软链接未创建(EPERM)。技能已安装到 .agents/skills/。以管理员身份打开终端,或启用 Windows 开发人员模式,再重跑原安装命令补齐链接。');
463
+ }
319
464
  return 0;
320
465
  } catch (error) { stderr(`Error: ${error.message}`); return 1; }
321
466
  }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present Xubin Ren and the nanobot contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namewta/skills-hub",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "独立中文 Agent Skills:按领域安装,覆盖开发交付、项目知识与系统维护。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -29,6 +29,7 @@
29
29
  "check:package": "node scripts/check-package.mjs",
30
30
  "check:statechart": "node scripts/check-statechart-replay.mjs",
31
31
  "check:upstream": "node scripts/check-upstream-runtime.mjs",
32
+ "check:claude": "node scripts/check-claude-discovery.mjs",
32
33
  "test": "node scripts/check.mjs --full",
33
34
  "build": "node scripts/check.mjs --full",
34
35
  "hooks": "node scripts/install-hooks.mjs"
@@ -15,6 +15,7 @@ const targets = [
15
15
  ['dev', 'context', '.agents/dev/context'],
16
16
  ['system', 'system', '.agents/system'],
17
17
  ['ops', 'ops', '.agents/ops'],
18
+ ['home', 'home', '.agents/home'],
18
19
  ];
19
20
 
20
21
  function inspect(project, relative, fsOps) {
@@ -42,11 +43,12 @@ function ensureIgnoreRules(previous, rules) {
42
43
 
43
44
  const eol = original.match(/\r?\n/)?.[0] ?? '\n';
44
45
  let content = previous;
45
- if (original && missing.includes('/temp/')) {
46
- // 默认规则先于用户规则,不覆盖项目已有的重新纳入规则。
46
+ const defaults = missing.filter(rule => ['/temp/', '/.agents/home/local.json'].includes(rule));
47
+ if (original && defaults.length) {
48
+ // 新默认规则先于用户规则,保留用户对运行原件和本机映射的明确例外。
47
49
  const bom = text.startsWith('\uFEFF') ? 3 : 0;
48
- content = Buffer.concat([previous.subarray(0, bom), Buffer.from('/temp/' + eol), previous.subarray(bom)]);
49
- missing.splice(missing.indexOf('/temp/'), 1);
50
+ content = Buffer.concat([previous.subarray(0, bom), Buffer.from(defaults.join(eol) + eol), previous.subarray(bom)]);
51
+ for (const rule of defaults) missing.splice(missing.indexOf(rule), 1);
50
52
  }
51
53
  if (!missing.length) return content;
52
54
  const separator = original && !original.endsWith('\n') ? eol : '';
@@ -63,6 +65,7 @@ export function planPersistence(skills, project, fsOps = fs) {
63
65
  const ignoreRules = [];
64
66
  if (domains.has('dev')) ignoreRules.push('/.agents/dev/worktree/');
65
67
  if (domains.has('dev') || domains.has('system')) ignoreRules.push('/temp/');
68
+ if (domains.has('home')) ignoreRules.push('/.agents/home/local.json');
66
69
  if (ignoreRules.length) {
67
70
  entries.push(['.gitignore', previous => ensureIgnoreRules(previous ?? Buffer.alloc(0), ignoreRules)]);
68
71
  }
@@ -95,11 +98,11 @@ export function applyPersistence(plan, project, fsOps = fs, journal = []) {
95
98
  const directory = path.join(project, ...parts.slice(0, index + 1));
96
99
  if (!fsOps.lstatSync(directory, { throwIfNoEntry: false })) {
97
100
  fsOps.mkdirSync(directory);
98
- journal.push({ path: directory, directory: true });
101
+ journal.push({ project, path: directory, directory: true });
99
102
  }
100
103
  }
101
104
  const descriptor = fsOps.openSync(item.destination, item.action === 'update' ? 'r+' : 'wx');
102
- journal.push({ path: item.destination, directory: false, previous: item.previous });
105
+ journal.push({ project, path: item.destination, directory: false, previous: item.previous });
103
106
  try {
104
107
  fsOps.writeFileSync(descriptor, item.content);
105
108
  fsOps.ftruncateSync(descriptor, item.content.length);
@@ -112,6 +115,23 @@ export function rollbackPersistence(journal, fsOps = fs) {
112
115
  const errors = [];
113
116
  for (const item of [...journal].reverse()) {
114
117
  try {
118
+ // 回滚也不跟随安装期间被替换的父目录或文件链接。
119
+ const relative = path.relative(item.project, item.path);
120
+ if (!relative || relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
121
+ throw new Error('回滚路径不在原项目内:' + item.path);
122
+ }
123
+ let current = item.project;
124
+ const parts = relative.split(path.sep);
125
+ for (let index = -1; index < parts.length; index += 1) {
126
+ if (index >= 0) current = path.join(current, parts[index]);
127
+ const stat = fsOps.lstatSync(current, { throwIfNoEntry: false });
128
+ if (!stat) continue;
129
+ if (stat.isSymbolicLink()) throw new Error('回滚拒绝符号链接:' + current);
130
+ const directory = index < parts.length - 1 || item.directory;
131
+ if (directory ? !stat.isDirectory() : !stat.isFile()) {
132
+ throw new Error('回滚路径类型已变化:' + current);
133
+ }
134
+ }
115
135
  if (item.previous) fsOps.writeFileSync(item.path, item.previous);
116
136
  else if (item.directory) fsOps.rmdirSync(item.path);
117
137
  else fsOps.unlinkSync(item.path);
@@ -1,6 +1,7 @@
1
1
  # 当前变更
2
2
 
3
- - 活跃任务在 `./<YYYY-MM-DD-slug>/` 保存目标、规格和进展,各阶段沿用原记录。原件放项目根 `temp/dev/`,不进 Git。
4
- - 出票即建 `evidences/` 下与 `tasks/` 完全同名的一份普通 `.md`,初始标「未验证」。目录只含同名报告,失败和复验更新原文件;整体验收后才写 Change 根 `evidence.md`。
5
- - 原型用 `prototype/index.html` 及资源;`prototype-review.md` 记实际走查、版本与用户确认范围。资源变化后重核受影响确认,不由 Agent 代签。
6
- - 完成交付或明确不实施后,由 `dev-archive` 将长期知识提炼到 `../notes/`,把 Change 分类归入 `../archive/changes/`。
3
+ - 活跃任务在 `./<YYYY-MM-DD-slug>/` 跟踪目标、规格、设计讨论、计划和进展。
4
+ - 远端 Issue 先关联或新建 Change,完整正文、可取得的讨论及方案附件进 `source/` 并跟踪;同源复用,更新保留版本。
5
+ - 出票即建 `evidences/` 下与 `tasks/` 完全同名的普通 `.md`,初始标「未验证」。失败、复验更新原报告;整体验收后写根 `evidence.md`。
6
+ - 原型用 `prototype/`,走查版本与确认范围记 `prototype-review.md`。正式资料跟踪,日志、调试截图等过程原件放项目根 `temp/dev/`。
7
+ - 完成或明确不实施后由 `dev-archive` 提炼知识到 `../notes/`,连同来源和正式资料归入 `../archive/changes/`。