Преглед изворни кода

feat(skills): 验证 Hermes _org 企业预置机制并落地

## 查清三层技能归属(读源码 + 容器实测)
- builtin 53 个:/opt/hermes/skills/ 由 skills_sync.py 同步,
  官方已内置「用户改过不覆盖」,不用管
- 模板实测(R730 v1-20261127):skills/ 只有 12 分类 58 个全内置,
  零公司技能、无 custom/platform/_org、无 git 配置 → 新容器缺技能的根因
- platform/ 是空壳:脚本创建了但 Hermes 不认

## _org 才是 Hermes 原生企业机制(端到端验证通过)
源码:skill_utils.py ORG_MIRROR_DIR_NAME="_org"
      prompt_builder.py:_build_skills_manifest 决定加载
实测:建 _org/fmode/<技能>/ + .active_org → skills list 显示 enabled
      删 .active_org → 立即隐藏
      root 属主 755/644 → 用户 rm/改写 BLOCKED
      不需要服务端配合,同步协议可选

## 落地
- provision.sh 支持 scope=org(_org/<org_id>/,root 属主 + .active_org)
- manifest v3:企微技能改 org 级预置,owner root:root
- refresh-container-skills.mjs 同步支持 org scope
- 测试容器已实装验证:container-wecom-setup │ _org │ enabled,
  用户删除 BLOCKED,custom/ 旧副本已清

## 踩坑
只 chown root 不改文件权限 → hermes 读不到。
必须目录 755 + 文件 644(root 拥有、所有人可读)。

## 待办
开通链路走主容器(fmode-provisioning.js:8),主容器是单点,需优化

Co-Authored-By: Claude Code <noreply@anthropic.com>
Huccct пре 1 дан
родитељ
комит
af75c58b02

+ 19 - 0
cloud/skills/container-provision-job/provision.sh

@@ -278,6 +278,25 @@ PY
     src=$(printf '%s' "$rest" | cut -f2)
     files=$(printf '%s' "$rest" | cut -f3)
     kind=$(printf '%s' "$rest" | cut -f4)
+    # scope=org 时落到 _org/<org_id>/,属主 root(用户改不了,见规范 §0b)
+    if [ "$scope" = "org" ]; then
+      local org_id="${FMODE_ORG_ID:-fmode}"
+      dest="$DST/skills/_org/$org_id/$name"
+      install -d -o 0 -g 0 -m 0755 "$dest"
+      local IFS_OLD="$IFS"; IFS=','
+      for f in $files; do
+        install -o 0 -g 0 -m 0644 "$src/$f" "$dest/$f"
+      done
+      IFS="$IFS_OLD"
+      chmod 0755 "$dest"/*.py 2>/dev/null || true
+      # 激活标记:没有它 _org 整体不加载
+      install -d -o 0 -g 0 -m 0755 "$DST/skills/_org"
+      printf '%s' "$org_id" > "$DST/skills/_org/.active_org"
+      chmod 0644 "$DST/skills/_org/.active_org"
+      count=$((count + 1))
+      echo "[SKILL] 已下发(org) $name -> $dest"
+      continue
+    fi
     dest="$DST/skills/$scope/$name"
     install -d -o 10000 -g 10000 -m 0755 "$dest"
     local IFS_OLD="$IFS"; IFS=','

+ 22 - 8
cloud/skills/container-skill-manifest.json

@@ -1,6 +1,6 @@
 {
-  "$comment": "容器技能下发清单(2026-12-03 v2)。provision.sh 开通时下发;scripts/refresh-container-skills.mjs 刷新存量容器。v2 起支持远程仓库:source.type=repo 表示从 skills-storage 仓库拉取,容器内可直接 git clone 更新。新增/替换技能只改这里。",
-  "version": 2,
+  "$comment": "容器技能下发清单(2026-12-03 v3)。三层:builtin(Hermes自带,不管) / org(公司预置,_org/,root属主,用户改不了) / custom(用户自建,可改可删)。provision.sh 开通时下发;scripts/refresh-container-skills.mjs 刷新存量容器。新增/替换技能只改这里。",
+  "version": 3,
   "repos": {
     "skills-storage": {
       "url": "https://git.fmode.cn/nkkj/skills-storage.git",
@@ -13,18 +13,23 @@
   "skills": [
     {
       "name": "container-wecom-setup",
-      "scope": "custom",
+      "scope": "org",
       "source": {
         "type": "repo",
         "repo": "skills-storage",
         "path": "custom/container-wecom-setup",
         "fallback": "cloud/skills/container-wecom-setup"
       },
-      "files": ["SKILL.md", "wecom_setup.py"],
-      "executable": ["wecom_setup.py"],
-      "owner": "hermes:hermes",
+      "files": [
+        "SKILL.md",
+        "wecom_setup.py"
+      ],
+      "executable": [
+        "wecom_setup.py"
+      ],
+      "owner": "root:root",
       "required": true,
-      "reason": "容器内接通企微渠道。缺它时容器会误走企微云端微服务路径、向用户索取 Fmode 登录态(2026-12-03 实测)。"
+      "reason": "容器内接通企微渠道,属公司预置能力,用户不应删除/篡改。缺它时容器会误走企微云端微服务路径、向用户索取 Fmode 登录态(2026-12-03 实测)。"
     }
   ],
   "excluded": [
@@ -39,6 +44,15 @@
   ],
   "notes": {
     "updateFlow": "改技能 → 推 skills-storage 仓库 → 容器执行 refresh 脚本(或重开容器)。宿主机侧不下发内容,只下发拉取指令。",
-    "offlineFallback": "容器拉不到仓库时用宿主机侧 fallback 目录(cloud/skills/)兜底,保证开通不被外网依赖卡住。"
+    "offlineFallback": "容器拉不到仓库时用宿主机侧 fallback 目录(cloud/skills/)兜底,保证开通不被外网依赖卡住。",
+    "layers": {
+      "builtin": "Hermes 镜像自带(53 个),skills_sync.py 同步,用户改过的不覆盖",
+      "org": "公司预置,落 _org/<org_id>/,属主 root,用户不可改",
+      "custom": "用户自建,落 custom/,属主 hermes,用户可改可删"
+    }
+  },
+  "org": {
+    "id": "fmode",
+    "comment": "企业预置技能的 org_id,落到 /opt/data/skills/_org/fmode/。属主 root,用户改不了(2026-12-03 验证)。"
   }
 }

+ 11 - 0
docs/00-tracking/操作追踪.md

@@ -10404,3 +10404,14 @@ Call log:
 - 2026-12-03 10:10:00+08:00:**改写两份以已删除容器为基准的文档**。`容器接入标准流程-SOP-v3` → v3.1、`新容器接入优化-对齐lj-test基线` → v2。保留全部行为基线内容,改的是:参考实现改为当前测试容器 + 明确标注 lj-test 已于 2026-12-02 删除 + 指出技能下发已改清单驱动。规范文档 `docs/05-operations/容器技能下发与替换规范.md` 补「远程技能仓库」完整维护流程(含容器网络实测表、为什么开通时用 fallback)。
 
 - 2026-12-03 10:20:00+08:00:**skills-storage 远程技能仓库端到端打通**。用户重试推送成功(首次 403,重试后 `* [new branch] master -> master`)。验证链:①容器 `git ls-remote` 能读到 HEAD ②容器 `git clone` 成功拉到 README.md + custom/container-wecom-setup/ ③`refresh-container-skills.mjs --from-repo --apply` 执行成功 ④容器内 `/opt/data/skills/custom/container-wecom-setup/` 文件就位(SKILL.md 6546B / wecom_setup.py 6397B,属主 hermes:hermes)⑤`hermes skills list` 显示 `container-wecom-setup ... enabled`。**结论:远程技能仓库方案可用**。推送需 GitLab 写权限,容器只读。
+
+- 2026-12-03 10:40:00+08:00:**三层技能归属查清 + `_org` 企业预置机制验证通过**。用户问「53 个内置技能是我们管的吗、用户能否有自己 git 仓库」。查证结论(读 Hermes 源码 + 容器实测):
+  - builtin 53 个来自 `/opt/hermes/skills/`,由 `skills_sync.py` 同步,**官方已内置「用户改过的不覆盖」逻辑**,不用管
+  - **模板实测**(R730 `/opt/fmode-templates/default`,v1-20261127,49M):`skills/` 只有 12 分类 58 个全内置技能,**零公司技能**,无 `custom/`/`platform/`/`_org/`,无 `.gitconfig`、无凭据。→ 新容器缺企微技能的根因就是模板没带
+  - **`platform/` 目录是空壳**:开通脚本创建了,但 Hermes 不认(`grep -c platform` 返回 0)。我此前「放 platform 强制」的建议是错的
+  - **`_org` 才是 Hermes 原生企业机制**:`skill_utils.py:36 ORG_MIRROR_DIR_NAME="_org"`,`prompt_builder.py:_build_skills_manifest` 决定加载逻辑
+  - **实测通过**:建 `_org/fmode/<技能>/` + `.active_org(fmode)` → `hermes skills list` 显示 `test-org-skill │ _org │ enabled`;删 `.active_org` 立即隐藏;root 属主 755/644 时用户 `rm`/`改写`均 BLOCKED。**不需要服务端配合**,同步协议是可选的
+  - **踩坑**:只 `chown root` 不改文件权限 → hermes 读不到(返回 0)。必须目录 755 + 文件 644
+  - 落地:provision.sh 支持 `scope=org`(落 `_org/<org_id>/`,root 属主 + `.active_org`);manifest v3 企微技能改 org;refresh 脚本 `--apply` 同步支持。已在测试容器实装并验证:`container-wecom-setup │ _org │ enabled`,用户删除 BLOCKED,custom/ 旧副本已清
+
+- 2026-12-03 10:40:00+08:00:**开通链路确认走主容器,待优化**。`fmode-provisioning.js:8` 明写「进阶/企业 → DM 主容器 → R730 docker run」。主容器是单点,它不可用则开通停摆;主容器本身也只是在跑 provision.sh。用户确认「后续需要进行优化」。

+ 185 - 0
docs/03-interface/容器取证-agent-node-1796264480663.md

@@ -0,0 +1,185 @@
+# 容器取证问答:agent-node
+
+- 时间:2026-12-03T02:21:20.662Z
+- 房间:`!g4y7HGzstyhYseK5UOHZn5Fy58lJAcnJP7noa2VY9us`(临时房间,可保留查阅)
+- 消息统计:正文 5 段 / 工具过程 1 段 / 文件 0 个
+- 结束原因:收到 ✅ reaction
+
+## 我发出的问题
+
+```text
+# 问题清单:主容器过往开通容器时的 git 仓库与技能配置做法
+
+请只回答你**实际做过/知道**的,不确定就说「不确定」,不要推测。
+
+## Q1 开通容器时是否配置过 git 仓库
+
+你以往执行 `container-provision-job` 开通新容器时,是否给容器配置过任何 git 仓库(clone、remote、凭据)?
+如果有:
+- 配置在哪个路径
+- 用的是哪个 Git 服务(git.fmode.cn / 其他)
+- 是系统级 git config 还是仓库级
+- 凭据存在哪里(.git-credentials / credential helper / 别的)
+
+如果从来没配过,直接说「没配过」。
+
+## Q2 容器里的技能是怎么来的
+
+你开通的容器里,除了 Hermes 内置技能,有没有预置过公司自有的技能?
+如果有,是通过什么方式放进 `/opt/data/skills/` 的:
+- 模板目录拷贝(/opt/fmode-templates/default)
+- 插件安装
+- git clone
+- 其他
+
+## Q3 是否用过 Hermes 的 _org 企业技能机制
+
+容器里 `/opt/data/skills/_org/` 这个目录,你见过或配置过吗?
+如果有:`_org/<org_id>/.active_org` 这个标记文件是怎么产生的?它对接的是什么服务?
+
+## Q4 用户自己装技能
+
+用户想自己添加技能,你平时怎么做的?有没有标准的放置路径和命名约定?
+
+## Q5 你现在知道的技能来源清单
+
+列出你知道的所有技能来源(内置 / 模板 / 插件 / 用户自建 / 其他),各占多少。
+```
+
+## 容器回答(原文,按时间顺序,未删改)
+
+### 1【prose】
+
+```text
+我会基于实际可以查到的证据来回答。我先做一次容器审计,再给出答案。
+```
+
+### 2【prose】
+
+```text
+```
+cd /opt/data && for f in .gitconfig ....
+```
+📚 Reading skill container-provision-job
+```
+
+### 3【prose】
+
+```text
+* ```
+cd /opt/data && for f in .gitconfig ....
+```
+📚 Reading skill container-provision-job
+💻 terminal
+```
+echo "=== remote of skill repos ===";...
+```
+```
+
+### 4【prose】
+
+```text
+* ```
+cd /opt/data && for f in .gitconfig ....
+```
+📚 Reading skill container-provision-job
+💻 terminal
+```
+echo "=== remote of skill repos ===";...
+```
+```
+echo "=== 模板目录是否存在 ==="; ls -ld /opt/...
+```
+```
+
+### 5【prose】
+
+```text
+# 回答:只讲我实际查到、实际做过的
+
+## Q1 开通容器时是否配置过 git 仓库
+
+**没配过。** 开通容器时,我从未在容器内配置任何 git 仓库、remote 或凭据。证据如下:
+
+`container-provision-job` 技能 v5.0.0 的完整脚本里,**没有一行 git 操作**:只做了 `cp -a` 模板拷贝、写 `.env`、打 4 个补丁(app-reporter、process-notice、deliverable-ack、safe-gc)、`docker create` 和注册 cron,然后结束。
+
+作为对比,**我本机**(当前这个主容器)确实有 git 痕迹,但那是我自己运行过程中产生的,并非开通流程的一部分:
+- `/opt/data/.gitconfig`:只有 `user.name=LiuYuYang`、`user.email=liuyuyang@fmode.cn`、`safe.directory=*`
+- **没有任何 credential helper**,也没有 `~/.git-credentials`
+- 部分技能仓库的 remote 里**明文写有密码**:`https://fmode:Feima666@git.fmode.cn/fmode/xxx.git`(如 `fmode-product-lab`、`projects/fmode-skills`),服务是 **git.fmode.cn(Gogs)**
+- `skill-image` 是双推:`gogs → git.fmode.cn/fmode/skill-image.git`,`origin → github.com/fmodecn/fmode-image.git`
+
+这暴露一个真实问题:**凭据以明文形式嵌在 remote URL 里,没有使用凭证管理**。这是本机长期积累的结果,不是开通容器时的标准动作。
+
+## Q2 容器里的技能是怎么来的
+
+**预置过,但只是「随模板一起拷过来」,没有单独的技能安装步骤。**
+
+机制是:使用 `cp -a /opt/fmode-templates/default/. → targetDir/`。技能就放在模板的 `/opt/data/skills/` 里,整目录拷贝后自然被带入。技能里只额外创建了两个空目录:
+
+```
+/opt/data/skills/platform/   # 平台技能
+/opt/data/skills/custom/     # 用户技能
+```
+
+四个来源中,**git clone 和插件安装都没有在开通流程里用过**。
+
+⚠️ 一处必须说明的不确定:`/opt/fmode-templates/default` 在**本容器内看不到**(本机既无 `/opt/fmode-templates`,也无 `/opt/fmode-containers`;模板位于 R730 宿主机上)。所以模板里究竟预置了哪些具体技能,我只能从「拷过来的结果」反推,**没有直接验证过模板内容**。
+
+## Q3 有没有用过 `_org` 企业技能机制
+
+**没见过,也没有配置过。**
+
+实测结果:
+- 本机 `/opt/data/skills/_org` **不存在**(`ls` 返回空)
+- 全盘 `find /opt/data -maxdepth 3 -name "_org"` **零命中**
+- 以 `org_id`、`active_org` 扫描 `config.yaml` 和技能清单,**零命中**
+- 87 个顶层技能目录里,没有任何 `_org` 相关项
+
+因此,**`_org/<org_id>/.active_org` 这个标记文件是谁产生的、对接什么服务,我不确定。** 我没有任何实测依据,也不做推测。开通脚本里出现的只有 `skills/platform` 和 `skills/custom` 两个分类目录。
+
+## Q4 用户自己装技能,我平时怎么做
+
+我的实际做法按场景分为三种,**没有统一的『标准放置路径 + 命名约定』成文规范**,这点要说实话:
+
+1. **单个技能**:使用 `skill_manage(action='create')`,落到 `/opt/data/skills/<name>/SKILL.md`。目录名和 `name` 字段一致,小写加连字符,不超过 64 字符。这条是 Hermes 内置约束,不是我定的。
+2. **成组技能(DWS、飞书、钉钉等)**:**符号链接**指向 `/opt/data/home/.agents/skills/<name>`。例如:
+   ```
+   dingtalk-doc -> ../home/.agents/skills/dingtalk-doc
+   ```
+   这类不是我在开通时建立的,而是后续接入的。
+3. **内部禁用文件**:`.archive/`(70 个)、`.curator_backups/`、`.curator_ledger.jsonl`(5.3MB)都是技能管理器的自动产物,不是人工整理的。
+
+`skills/platform` 和 `skills/custom` 在开通脚本里**被创建了**,但实际检查发现,本机**这两个目录不存在**,说明这个分类约定在实际执行中**没有落地**。
+
+## Q5 技能来源清单(按实测统计)
+
+本机 `/opt/data/skills/` 顶层 **87 项**(不含隐藏目录):
+
+| 来源 | 判断依据 | 数量 |
+|---|---|---|
+| Hermes 内置(bundled) | 在 `.bundled_manifest` 里有名称:哈希 | 约 30+(清单按字典序排列,我未逐个数完精确值) |
+| 公司自建技能 | 带独立 SKILL.md,v1~v5 版本号迭代痕迹 | 约 40(最大头) |
+| 符号链接到 `.agents/skills` | `dingtalk-*` 共 17 个 | 17 |
+| git 仓库克隆 | 目录内有 `.git` 和 remote | 3(skill-image、fmode-product-lab、fmode-skills) |
+| 插件 / 模板拷贝 | `.hub/`(taps/index-cache/scan-cache)是为插件与 hub 预留的 | 不确定具体数量 |
+| `_org` 企业技能 | — | **0** |
+
+**占比我不给精确数字**:`bundled_manifest` 我只看前 20 行,其余需要逐行统计才能给出准确结果;我不想给出估算值,以免误导你。
+
+---
+
+**需要我补哪块?** 比如:① 精确统计 87 个目录的来源归类;② 把 remote 里的明文密码改成 credential helper(这块确实该修);③ 让 R730 上的模板目录内容可见,以便确认实际情况。
+```
+
+### 6【ack】
+
+```text
+✅ 容器已标记完成
+```
+
+---
+
+## 工具过程(仅供核对,非回答内容)
+
+- `💻 terminal ``` ls -la /opt/data/skills/ 2>/dev/null ... ````

+ 36 - 0
docs/03-interface/问-主容器-容器git与技能配置-20261203.md

@@ -0,0 +1,36 @@
+# 问题清单:主容器过往开通容器时的 git 仓库与技能配置做法
+
+请只回答你**实际做过/知道**的,不确定就说「不确定」,不要推测。
+
+## Q1 开通容器时是否配置过 git 仓库
+
+你以往执行 `container-provision-job` 开通新容器时,是否给容器配置过任何 git 仓库(clone、remote、凭据)?
+如果有:
+- 配置在哪个路径
+- 用的是哪个 Git 服务(git.fmode.cn / 其他)
+- 是系统级 git config 还是仓库级
+- 凭据存在哪里(.git-credentials / credential helper / 别的)
+
+如果从来没配过,直接说「没配过」。
+
+## Q2 容器里的技能是怎么来的
+
+你开通的容器里,除了 Hermes 内置技能,有没有预置过公司自有的技能?
+如果有,是通过什么方式放进 `/opt/data/skills/` 的:
+- 模板目录拷贝(/opt/fmode-templates/default)
+- 插件安装
+- git clone
+- 其他
+
+## Q3 是否用过 Hermes 的 _org 企业技能机制
+
+容器里 `/opt/data/skills/_org/` 这个目录,你见过或配置过吗?
+如果有:`_org/<org_id>/.active_org` 这个标记文件是怎么产生的?它对接的是什么服务?
+
+## Q4 用户自己装技能
+
+用户想自己添加技能,你平时怎么做的?有没有标准的放置路径和命名约定?
+
+## Q5 你现在知道的技能来源清单
+
+列出你知道的所有技能来源(内置 / 模板 / 插件 / 用户自建 / 其他),各占多少。

+ 67 - 0
docs/05-operations/容器技能下发与替换规范.md

@@ -23,6 +23,73 @@
 
 ## 二、三条铁律
 
+### 0. 三层技能与归属(2026-12-03 实测确认)
+
+容器里一共三类技能,**只有后两类需要管**:
+
+| 层 | 路径 | 数量 | 属主 | 谁管 |
+|---|---|---|---|---|
+| **builtin** | `/opt/hermes/skills/` → `skills_sync.py` 同步到 `/opt/data/skills/` | 53 | 镜像 | ❌ **Hermes 自带,不用管** |
+| **公司预置** | `/opt/data/skills/_org/<org_id>/` | 按需 | **root:root** | ✅ **我们管** |
+| **用户自建** | `/opt/data/skills/custom/` | 按需 | hermes:hermes | ✅ 用户管 |
+
+**`skills_sync.py` 的官方行为**(读源码确认):
+
+```
+用户改过的技能 → SKIP(不覆盖)
+用户删掉的技能 → 不重新加回
+只有【没改过】的才跟着上游更新
+```
+
+这正是「公司预置 / 用户自定义」分层的设计依据。
+
+### 0b. `_org` 企业预置机制(2026-12-03 端到端验证通过)
+
+**这是 Hermes 原生的企业技能机制,不是我们造的。**
+
+| 项 | 值 |
+|---|---|
+| 目录 | `/opt/data/skills/_org/<org_id>/<技能名>/SKILL.md` |
+| 激活标记 | `/opt/data/skills/_org/.active_org`(内容 = org_id) |
+| 生效条件 | **`.active_org` 存在** 且内容匹配 `_org/` 下的目录名 |
+
+**源码依据**(`agent/prompt_builder.py:_build_skills_manifest`):
+
+```python
+if root == skills_dir and "_org" in dirs and active_org is None:
+    dirs.remove("_org")                  # 无标记 → 整个 _org 被跳过
+elif root == org_root:
+    dirs[:] = [d for d in dirs if d == active_org]   # 只加载当前 org
+```
+
+**实测结果**(2026-12-03,容器 `agent-node-app-inibhjxchb`):
+
+| 验证项 | 结果 |
+|---|---|
+| 建 `_org/fmode/test-org-skill/` + `.active_org` | ✅ `hermes skills list` 显示 `test-org-skill │ _org │ local │ enabled` |
+| 删掉 `.active_org` | ✅ 技能立即隐藏(返回 0) |
+| `hermes` 用户改 `.active_org` | ✅ **BLOCKED**(Permission denied) |
+| `hermes` 用户删技能目录 | ✅ **BLOCKED** |
+| 与 Hermes org 同步协议的关系 | **可选**。只写本地目录就能生效,不需要服务端配合 |
+
+**所以可以做到「公司强制预置、用户改不了」,且不依赖云端服务。**
+
+#### 部署要求(踩过的坑)
+
+```bash
+# 1. 建目录和技能
+mkdir -p /opt/data/skills/_org/fmode/<技能名>
+# 2. 写激活标记
+echo fmode > /opt/data/skills/_org/.active_org
+# 3. 🔴 属主必须是 root,权限必须可读
+chown -R root:root /opt/data/skills/_org
+find /opt/data/skills/_org -type d -exec chmod 755 {} \;
+find /opt/data/skills/_org -type f -exec chmod 644 {} \;
+```
+
+坑:只 `chown root` 不改文件权限时,hermes 读不到(我实测过一次,`skills list` 返回 0)。
+**目录 755 + 文件 644 是必须的**——root 拥有、所有人可读,才能「用户改不了但能读」。
+
 ### 1. 清单是唯一真源
 
 新增或替换技能,**只改** `cloud/skills/container-skill-manifest.json`,不改脚本。

+ 23 - 6
scripts/refresh-container-skills.mjs

@@ -87,17 +87,30 @@ function buildScript(containers, opts) {
     lines.push(`echo "[CONTAINER] ${c}"`);
     for (const skill of enabled) {
       const files = readSkillFiles(skill);
-      const dir = `/opt/data/skills/${skill.scope || 'custom'}/${skill.name}`;
+      /*
+       * scope=org → 落到 _org/<org_id>/,属主 root、755/644,
+       * 用户改不了(见规范 §0b)。custom → 落 custom/,属主 hermes。
+       */
+      const isOrg = (skill.scope || 'custom') === 'org';
+      const orgId = manifest.org?.id || 'fmode';
+      const dir = isOrg
+        ? `/opt/data/skills/_org/${orgId}/${skill.name}`
+        : `/opt/data/skills/${skill.scope || 'custom'}/${skill.name}`;
       lines.push(`docker exec ${c} mkdir -p ${dir}`);
       for (const [name, b64] of Object.entries(files)) {
-        // base64 -d 写入后 chown 回 hermes(容器内 uid 10000)
         lines.push(
           `echo "${b64}" | base64 -d | docker exec -i ${c} sh -c "cat > ${dir}/${name}"`,
         );
       }
-      lines.push(`docker exec ${c} chmod 0755 ${dir}/*.py 2>/dev/null || true`);
-      lines.push(`docker exec ${c} chown -R 10000:10000 ${dir} 2>/dev/null || true`);
-      lines.push(`echo "[SKILL] ${skill.name} -> ${dir}"`);
+      if (isOrg) {
+        lines.push(`docker exec ${c} sh -c 'printf "%s" ${orgId} > /opt/data/skills/_org/.active_org'`);
+        lines.push(`docker exec ${c} chown -R 0:0 /opt/data/skills/_org`);
+        lines.push(`docker exec ${c} sh -c 'find /opt/data/skills/_org -type d -exec chmod 755 {} \\; && find /opt/data/skills/_org -type f -exec chmod 644 {} \\;'`);
+      } else {
+        lines.push(`docker exec ${c} chmod 0755 ${dir}/*.py 2>/dev/null || true`);
+        lines.push(`docker exec ${c} chown -R 10000:10000 ${dir} 2>/dev/null || true`);
+      }
+      lines.push(`echo "[SKILL] ${skill.name} -> ${dir}${isOrg ? ' (org, root 属主)' : ''}"`);
     }
     if (opts.restartGateway) {
       lines.push(`docker exec ${c} /command/s6-svc -r /run/service/gateway-default || echo "[WARN] 重启网关失败"`);
@@ -130,7 +143,11 @@ function writeTmp(content) {
 if (has('--list')) {
   console.log(`清单: ${basename(MANIFEST)}(${enabled.length} 个启用)`);
   for (const s of enabled) {
-    console.log(`  · ${s.name}  → /opt/data/skills/${s.scope || 'custom'}/${s.name}/  ${s.required ? '[必需]' : '[可选]'}`);
+    const orgId = manifest.org?.id || 'fmode';
+    const shown = (s.scope || 'custom') === 'org'
+      ? `/opt/data/skills/_org/${orgId}/${s.name}/`
+      : `/opt/data/skills/${s.scope || 'custom'}/${s.name}/`;
+    console.log(`  · ${s.name}  → ${shown}  ${s.required ? '[必需]' : '[可选]'}`);
   }
   const off = (manifest.skills ?? []).filter((s) => s.disabled);
   if (off.length) {