agent-skills-mesh 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 xuhuale
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/README.en.md ADDED
@@ -0,0 +1,183 @@
1
+ <div align="center">
2
+ <h1>Agent Skills Mesh</h1>
3
+ <p><strong>A three-layer skill manager</strong> · single source of truth + symlink distribution</p>
4
+ <p>Unified skill management for all your AI agents (Claude / Codex / Cursor / Pi …)</p>
5
+ <p>
6
+ <img alt="license" src="https://img.shields.io/badge/license-MIT-blue?style=flat-square">
7
+ <img alt="runtime" src="https://img.shields.io/badge/runtime-Bun-f9f1e1?style=flat-square&logo=bun">
8
+ <img alt="typescript" src="https://img.shields.io/badge/TypeScript-5.8-3178c6?style=flat-square&logo=typescript&logoColor=white">
9
+ <img alt="tui" src="https://img.shields.io/badge/TUI-OpenTUI-fuchsia?style=flat-square">
10
+ </p>
11
+ <p>English · <a href="README.md">简体中文</a></p>
12
+ </div>
13
+
14
+ ---
15
+
16
+ Agent Skills Mesh (`asm`) splits skill management into three layers — **where skills come from, where they live, and which agents receive them**. A **single source of truth (SSOT)** stores each skill once; **symlinks** (directory junctions on Windows) distribute it to the agents you enable. Maintain a skill once, share it everywhere — no more duplicate drift.
17
+
18
+ <p align="center">
19
+ <img src="docs/image/preview.gif" alt="Agent Skills Mesh TUI preview" width="820">
20
+ </p>
21
+
22
+ > TUI preview (loop): Skill×Agent matrix → skill details → Source management → Doctor health checks
23
+
24
+ ### Features
25
+
26
+ - **Three-layer model** — `source` (origin) / `skill` (SSOT library) / `agent` (distribution), with clear separation of concerns
27
+ - **Single source of truth (SSOT)** — each skill stored once; change it once and every enabled agent stays in sync
28
+ - **Symlink / junction distribution** — enable/disable just creates/removes a link (symlink on macOS/Linux, directory junction on Windows): zero-copy, instant
29
+ - **Multiple source types** — git repo / local folder / single skill, auto-inferred
30
+ - **Full lifecycle** — search, add, update, remove, rebind orphans, batch operations
31
+ - **Interactive TUI** — built on [@opentui/solid](https://opentui.com): skill×agent matrix + web-style modal dialogs + fuzzy search
32
+ - **Health checks (doctor)** — external / broken-link / orphan / source-missing / conflict, with one-key locate & repair
33
+ - **Cross-agent unification** — one skill, enabled into any number of agents on demand
34
+ - **Smart + custom agent enablement** — `init` auto-enables agents by install detection; custom agents (any `skills_dir`) with centralized enable/disable/add/remove (built-ins cannot be removed)
35
+ - **Bilingual (zh/en)** — defaults to system locale (reads `AppleLanguages` on macOS, handling `$LANG` mismatch); full CLI/TUI coverage; switch via `--lang` / `ASM_LANG` / config / TUI `Shift+L`
36
+
37
+ ### Installation
38
+
39
+ > [!NOTE]
40
+ > Cross-platform standalone packages are being published (macOS ready, Linux/Windows pending CI matrix). For now, install from source.
41
+
42
+ **From source (currently available)**
43
+
44
+ ```bash
45
+ git clone https://github.com/<your-org>/agent-skills-mesh.git
46
+ cd agent-skills-mesh
47
+ bun install # requires Bun 1.3+
48
+ bun run src/cli/index.ts --help
49
+ ```
50
+
51
+ **npm global install (once platform packages are published)**
52
+
53
+ ```bash
54
+ npm i -g agent-skills-mesh
55
+ asm --help
56
+ ```
57
+
58
+ ### Quick Start
59
+
60
+ ```bash
61
+ asm init # initialize ~/.agent-skills-mesh
62
+ asm source add <git-repo-or-folder> # add a skill source (repo/folder/skill auto-inferred)
63
+ asm refresh # scan sources, build the index
64
+ asm skill search <keyword> # search indexable skills
65
+ asm skill add <name> # copy a skill from source into the SSOT
66
+ asm skill enable <name> --agent claude # enable: SSOT → agent symlink
67
+ asm tui # open the interactive TUI
68
+ ```
69
+
70
+ ### Usage
71
+
72
+ #### CLI (three layers)
73
+
74
+ | Layer | Command | Description |
75
+ |---|---|---|
76
+ | Top | `init` | Initialize home (config / index / state) |
77
+ | | `refresh` | Scan sources, rebuild the index |
78
+ | | `doctor` | Health checks + repair hints |
79
+ | | `tui` | Interactive TUI |
80
+ | **source** | `add <target>` | Add a source (repo/folder/skill auto-inferred; `--branch`/`--type` optional) |
81
+ | | `update [id]` | Pull/rescan sources, report updatable skills (does not overwrite SSOT) |
82
+ | | `remove <id>` | Remove a source (keeps orphans by default; `--purge` cascades) |
83
+ | | `list` | List sources |
84
+ | | `enable` / `disable <id>` | Enable / disable a source |
85
+ | **skill** | `search [query]` | Fuzzy search (name / displayName / description / tags) |
86
+ | | `add <name>` | Copy from source into the SSOT (`--source <id>` when multiple sources provide it) |
87
+ | | `list` / `info <name>` | List / show details |
88
+ | | `update [name]` | Update to the source's latest version (`--all` for all) |
89
+ | | `remove <name>` | Remove from SSOT + detach all agent symlinks |
90
+ | | `rebind <name> --source <id>` | Re-associate an orphan/existing skill with a source |
91
+ | | `enable` / `disable <name> --agent <id>` | Enable / disable: create / remove an agent symlink |
92
+
93
+ #### TUI
94
+
95
+ ```bash
96
+ asm tui
97
+ ```
98
+
99
+ Three tabs (`1`/`2`/`3` to switch):
100
+
101
+ | Tab | Content | Key actions |
102
+ |---|---|---|
103
+ | **Skill×Agent** | skill×agent matrix, cells `[on]`/`[off]`/`[!]` | `space` toggle · `a`/`d` batch row · `enter` review · `i` details |
104
+ | **Source** | source list | `a` add · `u` update · `d` remove · `e`/`x` enable/disable |
105
+ | **Doctor** | health issues + adoptable candidates | `f` fix selected · `F` fix all |
106
+
107
+ | Key | Action |
108
+ |---|---|
109
+ | `1` / `2` / `3` / `Tab` | Switch / cycle tab |
110
+ | `↑` `↓` `←` `→` / `h j k l` | Move cursor |
111
+ | `space` | Toggle cell (install / uninstall) |
112
+ | `enter` | Review pending (apply after dialog confirms) |
113
+ | `a` | Install whole row (all agents) |
114
+ | `A` (Shift+a) | Open agent manager dialog |
115
+ | `d` | Delete current skill (SSOT + symlinks) |
116
+ | `i` | Skill details |
117
+ | `/` | Fuzzy search |
118
+ | `L` (Shift+l) | Toggle zh / en |
119
+ | `ctrl + r` | Global refresh (rescan) |
120
+ | `?` | Help |
121
+ | `ESC` / `ctrl + c` | Close dialog / quit |
122
+
123
+ > Inside the agent manager dialog: `space` enable/disable agent · `a` add custom agent · `d` remove agent (built-ins cannot be removed)
124
+
125
+ > [!TIP]
126
+ > Every write operation (add / remove / enable / repair) pops up a **web-style modal confirmation** (semi-transparent overlay); cancel with `ESC`, clicking the overlay, or `ctrl+c`.
127
+
128
+ ### How It Works
129
+
130
+ ```
131
+ ┌─────────── source (origin) ─────────┐
132
+ │ git repo / folder / skill │
133
+ └───────────────┬──────────────────────┘
134
+ │ refresh scans
135
+
136
+ ┌─────────── skill (SSOT) ────────────┐
137
+ │ ~/.agent-skills-mesh/skills/<name> │ ← single source of truth, stored once
138
+ └───────────────┬──────────────────────┘
139
+ │ enable (creates a symlink)
140
+
141
+ ┌─────────── agent (distribution) ────┐
142
+ │ claude / codex / pi … │ ← symlink points to the SSOT
143
+ │ ~/.agent/skills/<name> │
144
+ └──────────────────────────────────────┘
145
+ ```
146
+
147
+ - **source** = where skills come from (remote repos, local dirs)
148
+ - **skill** = where they live (SSOT, centrally managed)
149
+ - **agent** = who receives them (symlinked into each agent's skills dir)
150
+
151
+ Each skill lives once in the SSOT; agents reference it via symlink and always see the latest version. Update the SSOT and every enabled agent picks it up.
152
+
153
+ ### Configuration
154
+
155
+ `~/.agent-skills-mesh/config.toml`:
156
+
157
+ ```toml
158
+ [agents.claude]
159
+ name = "Claude"
160
+ skills_dir = "~/.agent/skills" # symlink target
161
+ enabled = true
162
+
163
+ [agents.codex]
164
+ name = "Codex"
165
+ skills_dir = "~/.codex/skills"
166
+ enabled = true
167
+
168
+ # configure as many agents as you need …
169
+ ```
170
+
171
+ #### Language
172
+
173
+ The UI supports Chinese (zh-CN) and English (en), defaulting to system locale (Chinese system → zh-CN, others → en).
174
+
175
+ - **CLI**: `asm --lang zh skill list` (or `--lang en` / `--lang auto`); or set `ASM_LANG=zh`
176
+ - **TUI**: press `L` (Shift+l) at runtime to toggle zh/en instantly; preference is persisted to config
177
+ - **config**: `settings.language = "zh-CN" | "en" | "auto"` (default `auto`; manual setting takes precedence)
178
+
179
+ Priority: `--lang` flag > `ASM_LANG` > `config.language` > system locale > `en`
180
+
181
+ ### License
182
+
183
+ MIT
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ <div align="center">
2
+ <h1>Agent Skills Mesh</h1>
3
+ <p><strong>三层技能管理器</strong> · 单一可信源 + symlink 分发</p>
4
+ <p>统一管理你所有 AI agent(Claude / Codex / Cursor / Pi …)的 skills</p>
5
+ <p>
6
+ <img alt="license" src="https://img.shields.io/badge/license-MIT-blue?style=flat-square">
7
+ <img alt="runtime" src="https://img.shields.io/badge/runtime-Bun-f9f1e1?style=flat-square&logo=bun">
8
+ <img alt="typescript" src="https://img.shields.io/badge/TypeScript-5.8-3178c6?style=flat-square&logo=typescript&logoColor=white">
9
+ <img alt="tui" src="https://img.shields.io/badge/TUI-OpenTUI-fuchsia?style=flat-square">
10
+ </p>
11
+ <p><a href="README.en.md">English</a> · 简体中文</p>
12
+ </div>
13
+
14
+ ---
15
+
16
+ Agent Skills Mesh(命令名 `asm`)把"技能**从哪来**、**存在哪**、**分发给谁**"拆成三层,用**单一可信源(SSOT)**集中存每一份技能,再通过 **symlink**(Windows 上为 directory junction)分发到你启用的 agent。一份技能只维护一次,所有 agent 共享,告别多副本漂移。
17
+
18
+ <p align="center">
19
+ <img src="docs/image/preview.gif" alt="Agent Skills Mesh TUI 预览" width="820">
20
+ </p>
21
+
22
+ > TUI 预览(循环演示):Skill×Agent 矩阵 → 技能详情 → Source 来源管理 → Doctor 健康检查
23
+
24
+ ### 特性
25
+
26
+ - **三层模型** — `source`(来源)/ `skill`(技能库 SSOT)/ `agent`(启用分发),职责清晰
27
+ - **单一可信源(SSOT)** — 每份技能只存一份,一处变更,所有启用的 agent 同步
28
+ - **symlink / junction 分发** — 启用/禁用即建/删链接(macOS/Linux symlink,Windows directory junction),零拷贝、即时生效
29
+ - **多来源** — git 仓库 / 本地 folder / 单个 skill,自动推断类型
30
+ - **全生命周期** — 搜索、添加、更新、删除、rebind 孤儿、批量操作
31
+ - **交互式 TUI** — 基于 [@opentui/solid](https://opentui.com):skill×agent 矩阵 + web 风格浮层弹窗 + fuzzy 搜索
32
+ - **健康检查(doctor)** — external / broken-link / orphan / source-missing / conflict,一键定位与修复
33
+ - **跨 agent 统一** — 一个技能,按需启用到任意数量的 agent
34
+ - **agent 智能启用 + 自定义** — `init` 按安装探测自动启用;支持自定义 agent(任意 `skills_dir`),TUI/CLI 集中启停、添加、删除(内置不可删)
35
+ - **中英文双语** — 默认跟随系统语言(macOS 读 `AppleLanguages`,`$LANG` 不准也能识别);CLI/TUI 全覆盖;`--lang` / `ASM_LANG` / config / TUI `Shift+L` 多通道切换
36
+
37
+ ### 安装
38
+
39
+ > [!NOTE]
40
+ > 跨平台 standalone 平台包正在发布中(macOS 已就绪,Linux/Windows 待 CI matrix 实测)。当前推荐从源码安装。
41
+
42
+ **从源码(当前可用)**
43
+
44
+ ```bash
45
+ git clone https://github.com/<your-org>/agent-skills-mesh.git
46
+ cd agent-skills-mesh
47
+ bun install # 需 Bun 1.3+
48
+ bun run src/cli/index.ts --help
49
+ ```
50
+
51
+ **npm 全局安装(平台包发布后)**
52
+
53
+ ```bash
54
+ npm i -g agent-skills-mesh
55
+ asm --help
56
+ ```
57
+
58
+ ### 快速开始
59
+
60
+ ```bash
61
+ asm init # 初始化 ~/.agent-skills-mesh
62
+ asm source add <git-repo-or-folder> # 添加技能来源(自动推断 repo/folder/skill)
63
+ asm refresh # 扫描来源,构建索引
64
+ asm skill search <keyword> # 搜索可索引技能
65
+ asm skill add <name> # 从来源复制到 SSOT
66
+ asm skill enable <name> --agent claude # 启用:SSOT → agent symlink
67
+ asm tui # 打开交互式 TUI
68
+ ```
69
+
70
+ ### 使用
71
+
72
+ #### CLI(三层命令)
73
+
74
+ | 层 | 命令 | 说明 |
75
+ |---|---|---|
76
+ | 顶层 | `init` | 初始化 home(config / index / state) |
77
+ | | `refresh` | 扫描来源,重建索引 |
78
+ | | `doctor` | 健康检查 + 修复建议 |
79
+ | | `tui` | 交互式 TUI |
80
+ | **source** | `add <target>` | 添加来源(repo/folder/skill 自动推断,`--branch`/`--type` 可选) |
81
+ | | `update [id]` | 拉取/重扫来源,报告可更新技能(不自动覆盖 SSOT) |
82
+ | | `remove <id>` | 移除来源(默认保留孤儿,`--purge` 级联删除) |
83
+ | | `list` | 列出来源 |
84
+ | | `enable` / `disable <id>` | 启用/禁用来源 |
85
+ | **skill** | `search [query]` | fuzzy 搜索(name / displayName / description / tags) |
86
+ | | `add <name>` | 从来源复制到 SSOT(多来源时 `--source <id>` 指定) |
87
+ | | `list` / `info <name>` | 列出 / 详情 |
88
+ | | `update [name]` | 更新到来源最新版(`--all` 全部) |
89
+ | | `remove <name>` | 从 SSOT 删除 + 卸载所有 agent symlink |
90
+ | | `rebind <name> --source <id>` | 把孤儿/已有技能重新关联来源 |
91
+ | | `enable` / `disable <name> --agent <id>` | 启用/禁用:建/删 agent symlink |
92
+ | **agent** | `list` | 列出 agent(含安装检测 / 启停状态) |
93
+ | | `add <id> --skills-dir <path> [--name <n>]` | 添加自定义 agent(任意 skills_dir) |
94
+ | | `remove <id>` | 移除 agent(不删其 skills_dir) |
95
+ | | `enable` / `disable <id>` | 启用/禁用 agent(matrix 列 + symlink) |
96
+
97
+ #### TUI
98
+
99
+ ```bash
100
+ asm tui
101
+ ```
102
+
103
+ 三个 tab(`1`/`2`/`3` 切换):
104
+
105
+ | Tab | 内容 | 主要操作 |
106
+ |---|---|---|
107
+ | **Skill×Agent** | skill×agent 矩阵,单元格 `[on]`/`[off]`/`[!]` | `space` 切换 · `a`/`d` 批量行 · `enter` 审查 · `i` 详情 |
108
+ | **Source** | 来源列表 | `a` 添加 · `u` 更新 · `d` 删除 · `e`/`x` 启停 |
109
+ | **Doctor** | 健康问题 + 可 adopt 候选 | `f` 修复选中 · `F` 修复全部 |
110
+
111
+ | 键 | 作用 |
112
+ |---|---|
113
+ | `1` / `2` / `3` / `Tab` | 切换 / 循环切换 tab |
114
+ | `↑` `↓` `←` `→` / `h j k l` | 移动光标 |
115
+ | `space` | 切换单元格(install / uninstall) |
116
+ | `enter` | 审查 pending(弹窗确认后 apply) |
117
+ | `a` | 当前行全装(所有 agent) |
118
+ | `A`(Shift+a) | 打开 agent 管理弹窗 |
119
+ | `d` | 删除当前 skill(SSOT + symlink) |
120
+ | `i` | 技能详情 |
121
+ | `/` | fuzzy 搜索 |
122
+ | `L`(Shift+l) | 中 / 英 切换 |
123
+ | `ctrl + r` | 全局刷新(重新扫描) |
124
+ | `?` | 帮助 |
125
+ | `ESC` / `ctrl + c` | 关弹窗 / 退出 |
126
+
127
+ > agent 管理弹窗内:`space` 启停 agent · `a` 添加自定义 agent · `d` 删除 agent(内置不可删)
128
+
129
+ > [!TIP]
130
+ > 所有写操作(添加/删除/启用/修复)都会弹出 **web 风格浮层确认框**(半透明遮罩),`ESC` / 点击遮罩 / `ctrl+c` 可取消。
131
+
132
+ ### 工作原理
133
+
134
+ ```
135
+ ┌─────────── source(来源)──────────┐
136
+ │ git repo / folder / skill │
137
+ └───────────────┬────────────────────┘
138
+ │ refresh 扫描
139
+
140
+ ┌─────────── skill(SSOT)───────────┐
141
+ │ ~/.agent-skills-mesh/skills/<name> │ ← 单一可信源,只存一份
142
+ └───────────────┬────────────────────┘
143
+ │ enable(建 symlink)
144
+
145
+ ┌─────────── agent(分发)───────────┐
146
+ │ claude / codex / pi … │ ← symlink 指向 SSOT
147
+ │ ~/.agent/skills/<name> │
148
+ └────────────────────────────────────┘
149
+ ```
150
+
151
+ - **source** = 技能从哪来(远程仓库、本地目录)
152
+ - **skill** = 技能存在哪(SSOT,统一纳管)
153
+ - **agent** = 分发给谁(symlink 到各 agent 的 skills 目录)
154
+
155
+ 技能在 SSOT 只存一份;agent 通过 symlink 引用,永远指向最新;更新 SSOT 即所有启用的 agent 同步生效。
156
+
157
+ ### 配置
158
+
159
+ `~/.agent-skills-mesh/config.toml`:
160
+
161
+ ```toml
162
+ [agents.claude]
163
+ name = "Claude"
164
+ skills_dir = "~/.agent/skills" # symlink 落点
165
+ enabled = true
166
+
167
+ [agents.codex]
168
+ name = "Codex"
169
+ skills_dir = "~/.codex/skills"
170
+ enabled = true
171
+
172
+ # 可配置任意数量的 agent …
173
+ ```
174
+
175
+ #### 语言 / Language
176
+
177
+ 界面支持中文(zh-CN)与英文(en)双语,默认跟随系统 locale(中文系统→中文,其他→英文)。
178
+
179
+ - **CLI**:`asm --lang zh skill list`(或 `--lang en` / `--lang auto`);也可设环境变量 `ASM_LANG=zh`
180
+ - **TUI**:运行时按 `L`(Shift+l)即时切换中/英,偏好写回 config
181
+ - **config**:`settings.language = "zh-CN" | "en" | "auto"`(默认 `auto`,手动设置优先级最高)
182
+
183
+ 优先级:`--lang` flag > `ASM_LANG` > `config.language` > 系统 locale > `en`
184
+
185
+ ### TODO
186
+
187
+ #### bug
188
+
189
+ > bug 1–5 已于 2026-07-06 修复(task `07-06-cli-tui-bugfix`);bug 6(i18n)已于 2026-07-06 完成(task `07-06-i18n-zh-en-switch`)。
190
+
191
+ - [x] ~~cli 的 `skill` 语义~~ — 已修复:`skill list` 只列已 add 到 SSOT 的技能,`skill search` 列来源候选;TUI matrix 行同步为已入库
192
+ - [x] ~~CLI 输出未对齐~~ — 已修复:固定列宽 + 表头 + CJK 双宽对齐 + 长字段截断(`src/cli/columns.ts`)
193
+ - [x] ~~TUI add source 无法粘贴~~ — 已修复:PromptDialog 接入 opentui `usePaste`(支持 cmd+v / bracketed paste)
194
+ - [x] ~~TUI source skill 详情缺能力~~ — 已修复:多选标记已 add(`[✓]`/`[ ]`)+ `space` 批量勾选 + `return` 批量 add + `i` 查看 SKILL.md
195
+ - [x] ~~默认 agent 无视安装~~ — 已修复:`init` 按安装探测决定 enabled;新增 `asm agent list/add/remove/enable/disable`;TUI matrix 默认隐藏 disabled 列,`m` 打开 agent 管理弹窗(启停/添加/删除)
196
+ - [x] ~~提供中英文切换(i18n)~~ — 已完成:CLI/TUI 全覆盖中英双语,`--lang` / `ASM_LANG` / config / TUI `Shift+L` 多通道切换
197
+
198
+
199
+
200
+ #### 功能
201
+ - [ ] npm 跨平台平台包发布(macOS 已就绪,Linux/Windows 待 CI matrix 实测 native 二进制)
202
+ - [ ] 补 TUI 集成测试(discover / doctor / install-plan 端到端)
203
+ - [ ] render-smoke 自动化(CI 下 bun vitest pool + vite-plugin-solid)
204
+ - [ ] skill 版本 diff 可视化(来源 vs SSOT)
205
+ - [ ] 更多来源类型(OCI / zip 归档)
206
+ - [ ] 配置导入/导出 + 团队共享
207
+
208
+ ### License
209
+
210
+ MIT
package/bin/asm.js ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * asm launcher (design §2, standalone executable distribution).
4
+ *
5
+ * Resolves the platform-specific standalone executable and spawns it with the
6
+ * user's argv. The main npm package declares each `agent-skills-mesh-<plat>`
7
+ * package as an optionalDependency; npm installs only the one matching the
8
+ * host at install time, and this wrapper locates it.
9
+ *
10
+ * Why spawn with cwd = os.tmpdir(): a Bun standalone executable reads
11
+ * `<cwd>/bunfig.toml` at boot. If the user runs `asm` from a directory whose
12
+ * bunfig preloads another package (common in Bun + SolidJS projects), the exe
13
+ * fails with `preload not found`. Agent Skills Mesh never reads `process.cwd()`
14
+ * — all paths resolve from `ASM_HOME` — so launching from a clean temp cwd is
15
+ * safe and avoids the conflict entirely.
16
+ */
17
+ import { spawn } from "node:child_process"
18
+ import { createRequire } from "node:module"
19
+ import os from "node:os"
20
+ import path from "node:path"
21
+
22
+ const require = createRequire(import.meta.url)
23
+
24
+ /** Map host platform/arch to the npm package suffix. */
25
+ function derivePlatformSuffix() {
26
+ if (process.env.ASM_PLATFORM) return process.env.ASM_PLATFORM
27
+ const plat = process.platform // darwin | linux | win32
28
+ const arch = process.arch // arm64 | x64
29
+ // Linux musl: opt-in via ASM_LIBC=musl (auto-detect of libc is unreliable from Node).
30
+ if (plat === "linux" && process.env.ASM_LIBC === "musl") return `linux-${arch}-musl`
31
+ return `${plat}-${arch}`
32
+ }
33
+
34
+ /** Locate the standalone exe: ASM_STANDALONE_EXE (dev) > platform package (prod). */
35
+ function resolveExe() {
36
+ if (process.env.ASM_STANDALONE_EXE) {
37
+ // Resolve against the user's launch cwd (not the spawn cwd), so relative
38
+ // dev paths like ./dist/standalone/.../asm still work.
39
+ return path.resolve(process.env.ASM_STANDALONE_EXE)
40
+ }
41
+
42
+ const suffix = derivePlatformSuffix()
43
+ const pkg = `agent-skills-mesh-${suffix}`
44
+ const isWin = process.platform === "win32"
45
+ const exeName = isWin ? "asm.exe" : "asm"
46
+
47
+ let pkgDir
48
+ try {
49
+ pkgDir = path.dirname(require.resolve(`${pkg}/package.json`))
50
+ } catch {
51
+ console.error(`asm: standalone package not installed for this platform (${pkg}).`)
52
+ console.error(`asm: install it with: npm install -g ${pkg}`)
53
+ process.exit(127)
54
+ }
55
+ return path.join(pkgDir, exeName)
56
+ }
57
+
58
+ const exe = resolveExe()
59
+ const child = spawn(exe, process.argv.slice(2), {
60
+ stdio: "inherit",
61
+ cwd: os.tmpdir(),
62
+ env: process.env
63
+ })
64
+
65
+ child.on("error", (err) => {
66
+ console.error(`asm: failed to launch standalone executable: ${err.message}`)
67
+ process.exit(1)
68
+ })
69
+ child.on("exit", (code, signal) => {
70
+ if (signal) {
71
+ // Re-raise the same signal so calling shells see ctrl+c / SIGTERM semantics.
72
+ process.kill(process.pid, signal)
73
+ } else {
74
+ process.exit(code ?? 0)
75
+ }
76
+ })
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "agent-skills-mesh",
3
+ "version": "0.1.0",
4
+ "description": "三层技能管理器:单一可信源 + symlink/junction 分发,统一管理所有 AI agent 的 skills",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "xuhuale",
8
+ "keywords": [
9
+ "ai",
10
+ "agent",
11
+ "skills",
12
+ "cli",
13
+ "tui",
14
+ "claude",
15
+ "codex",
16
+ "cursor",
17
+ "symlink",
18
+ "opentui"
19
+ ],
20
+ "bin": {
21
+ "asm": "bin/asm.js"
22
+ },
23
+ "files": [
24
+ "bin",
25
+ "README.md",
26
+ "README.en.md",
27
+ "LICENSE"
28
+ ],
29
+ "scripts": {
30
+ "typecheck": "tsc --noEmit",
31
+ "build": "bun run scripts/build-standalone.ts",
32
+ "release": "bun run scripts/release.ts",
33
+ "test": "vitest run",
34
+ "dev": "bun run src/cli/index.ts"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public",
38
+ "registry": "https://registry.npmjs.org/"
39
+ },
40
+ "optionalDependencies": {
41
+ "agent-skills-mesh-darwin-arm64": "0.1.0",
42
+ "agent-skills-mesh-darwin-x64": "0.1.0",
43
+ "agent-skills-mesh-linux-x64": "0.1.0",
44
+ "agent-skills-mesh-win32-x64": "0.1.0"
45
+ },
46
+ "devDependencies": {
47
+ "@opentui/core": "^0.4.3",
48
+ "@opentui/keymap": "^0.4.3",
49
+ "@opentui/solid": "^0.4.3",
50
+ "@types/node": "^24.0.0",
51
+ "commander": "^15.0.0",
52
+ "gray-matter": "^4.0.3",
53
+ "solid-js": "^1.9.14",
54
+ "typescript": "^5.8.0",
55
+ "vitest": "^3.2.0"
56
+ }
57
+ }