iskills 0.2.40 → 0.2.45

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 (147) hide show
  1. package/README.md +120 -26
  2. package/README.zh-CN.md +142 -0
  3. package/bin/iskills.js +77 -2
  4. package/bin/opentui-register.mjs +10 -0
  5. package/bin/opentui-resolve-hook.mjs +12 -0
  6. package/bin/patch-react-reconciler.mjs +71 -0
  7. package/dist/src/cli.js +7 -5
  8. package/dist/src/cli.js.map +1 -1
  9. package/dist/src/commands/browser-actions.js +31 -31
  10. package/dist/src/commands/browser-actions.js.map +1 -1
  11. package/dist/src/commands/create.d.ts +1 -0
  12. package/dist/src/commands/create.js +36 -0
  13. package/dist/src/commands/create.js.map +1 -0
  14. package/dist/src/commands/index.d.ts +1 -0
  15. package/dist/src/commands/index.js +28 -9
  16. package/dist/src/commands/index.js.map +1 -1
  17. package/dist/src/commands/library.js +15 -28
  18. package/dist/src/commands/library.js.map +1 -1
  19. package/dist/src/domain/collection-write.d.ts +2 -0
  20. package/dist/src/domain/collection-write.js +44 -2
  21. package/dist/src/domain/collection-write.js.map +1 -1
  22. package/dist/src/domain/core.d.ts +29 -1
  23. package/dist/src/domain/core.js +125 -8
  24. package/dist/src/domain/core.js.map +1 -1
  25. package/dist/src/domain/types.d.ts +2 -0
  26. package/dist/src/ui/browser/browser.d.ts +2 -1
  27. package/dist/src/ui/browser/browser.js +213 -58
  28. package/dist/src/ui/browser/browser.js.map +1 -1
  29. package/dist/src/ui/browser/detail.d.ts +1 -1
  30. package/dist/src/ui/browser/detail.js +3 -3
  31. package/dist/src/ui/browser/detail.js.map +1 -1
  32. package/dist/src/ui/browser/footer.js +4 -3
  33. package/dist/src/ui/browser/footer.js.map +1 -1
  34. package/dist/src/ui/browser/format.d.ts +17 -6
  35. package/dist/src/ui/browser/format.js +54 -29
  36. package/dist/src/ui/browser/format.js.map +1 -1
  37. package/dist/src/ui/browser/index.js +9 -9
  38. package/dist/src/ui/browser/index.js.map +1 -1
  39. package/dist/src/ui/browser/layout.d.ts +1 -1
  40. package/dist/src/ui/browser/layout.js +1 -1
  41. package/dist/src/ui/browser/shortcut-help.d.ts +2 -0
  42. package/dist/src/ui/browser/shortcut-help.js +32 -12
  43. package/dist/src/ui/browser/shortcut-help.js.map +1 -1
  44. package/dist/src/ui/browser/types.d.ts +1 -1
  45. package/dist/src/ui/collection-match.js +1 -1
  46. package/dist/src/ui/collection-match.js.map +1 -1
  47. package/dist/src/ui/components/colors.d.ts +55 -5
  48. package/dist/src/ui/components/colors.js +58 -6
  49. package/dist/src/ui/components/colors.js.map +1 -1
  50. package/dist/src/ui/components/confirm.js +2 -2
  51. package/dist/src/ui/components/confirm.js.map +1 -1
  52. package/dist/src/ui/components/framed-panel.d.ts +3 -3
  53. package/dist/src/ui/components/framed-panel.js +29 -11
  54. package/dist/src/ui/components/framed-panel.js.map +1 -1
  55. package/dist/src/ui/components/link.js +13 -8
  56. package/dist/src/ui/components/link.js.map +1 -1
  57. package/dist/src/ui/components/modal-panel.d.ts +9 -0
  58. package/dist/src/ui/components/modal-panel.js +8 -0
  59. package/dist/src/ui/components/modal-panel.js.map +1 -0
  60. package/dist/src/ui/components/modal.js +3 -3
  61. package/dist/src/ui/components/modal.js.map +1 -1
  62. package/dist/src/ui/components/mouse/bounds.d.ts +1 -6
  63. package/dist/src/ui/components/mouse/bounds.js +1 -22
  64. package/dist/src/ui/components/mouse/bounds.js.map +1 -1
  65. package/dist/src/ui/components/mouse/clickable.d.ts +6 -4
  66. package/dist/src/ui/components/mouse/clickable.js +26 -10
  67. package/dist/src/ui/components/mouse/clickable.js.map +1 -1
  68. package/dist/src/ui/components/mouse/index.d.ts +2 -2
  69. package/dist/src/ui/components/mouse/index.js +2 -2
  70. package/dist/src/ui/components/mouse/index.js.map +1 -1
  71. package/dist/src/ui/components/mouse/parse.d.ts +1 -1
  72. package/dist/src/ui/components/mouse/parse.js +3 -3
  73. package/dist/src/ui/components/mouse/parse.js.map +1 -1
  74. package/dist/src/ui/components/mouse/provider.d.ts +17 -15
  75. package/dist/src/ui/components/mouse/provider.js +29 -85
  76. package/dist/src/ui/components/mouse/provider.js.map +1 -1
  77. package/dist/src/ui/components/multi-select.js +23 -7
  78. package/dist/src/ui/components/multi-select.js.map +1 -1
  79. package/dist/src/ui/components/options.d.ts +2 -1
  80. package/dist/src/ui/components/options.js +2 -1
  81. package/dist/src/ui/components/options.js.map +1 -1
  82. package/dist/src/ui/components/select.d.ts +4 -0
  83. package/dist/src/ui/components/select.js +31 -34
  84. package/dist/src/ui/components/select.js.map +1 -1
  85. package/dist/src/ui/components/spinner.d.ts +16 -0
  86. package/dist/src/ui/components/spinner.js +45 -0
  87. package/dist/src/ui/components/spinner.js.map +1 -0
  88. package/dist/src/ui/components/tabs.js +10 -6
  89. package/dist/src/ui/components/tabs.js.map +1 -1
  90. package/dist/src/ui/components/tag-editor.js +8 -5
  91. package/dist/src/ui/components/tag-editor.js.map +1 -1
  92. package/dist/src/ui/components/termcn.d.ts +3 -1
  93. package/dist/src/ui/components/termcn.js +5 -3
  94. package/dist/src/ui/components/termcn.js.map +1 -1
  95. package/dist/src/ui/components/text-input.d.ts +8 -1
  96. package/dist/src/ui/components/text-input.js +34 -68
  97. package/dist/src/ui/components/text-input.js.map +1 -1
  98. package/dist/src/ui/components/use-input.d.ts +21 -7
  99. package/dist/src/ui/components/use-input.js +61 -9
  100. package/dist/src/ui/components/use-input.js.map +1 -1
  101. package/dist/src/ui/footer/resolve-footer.js +11 -2
  102. package/dist/src/ui/footer/resolve-footer.js.map +1 -1
  103. package/dist/src/ui/import/review.js +13 -7
  104. package/dist/src/ui/import/review.js.map +1 -1
  105. package/dist/src/ui/import/skill-select.js +37 -7
  106. package/dist/src/ui/import/skill-select.js.map +1 -1
  107. package/dist/src/ui/import/types.d.ts +1 -1
  108. package/dist/src/ui/install/review.js +15 -10
  109. package/dist/src/ui/install/review.js.map +1 -1
  110. package/dist/src/ui/install/types.d.ts +4 -6
  111. package/dist/src/ui/install/types.js +1 -1
  112. package/dist/src/ui/overlay/bridge.js +4 -0
  113. package/dist/src/ui/overlay/bridge.js.map +1 -1
  114. package/dist/src/ui/overlay/dialogs.js +1 -1
  115. package/dist/src/ui/overlay/host.js +4 -4
  116. package/dist/src/ui/overlay/host.js.map +1 -1
  117. package/dist/src/ui/prompts/present.d.ts +1 -1
  118. package/dist/src/ui/prompts/present.js +4 -3
  119. package/dist/src/ui/prompts/present.js.map +1 -1
  120. package/dist/src/ui/search/index.js +7 -6
  121. package/dist/src/ui/search/index.js.map +1 -1
  122. package/dist/src/ui/shell/app-shell.d.ts +1 -1
  123. package/dist/src/ui/shell/app-shell.js +4 -6
  124. package/dist/src/ui/shell/app-shell.js.map +1 -1
  125. package/dist/src/ui/shell/footer.js +5 -8
  126. package/dist/src/ui/shell/footer.js.map +1 -1
  127. package/dist/src/ui/shell/lifecycle.d.ts +12 -0
  128. package/dist/src/ui/shell/lifecycle.js +30 -0
  129. package/dist/src/ui/shell/lifecycle.js.map +1 -0
  130. package/dist/src/ui/shell/run.d.ts +35 -10
  131. package/dist/src/ui/shell/run.js +175 -88
  132. package/dist/src/ui/shell/run.js.map +1 -1
  133. package/dist/src/ui/shell/terminal.d.ts +1 -1
  134. package/dist/src/ui/shell/terminal.js +1 -1
  135. package/dist/src/ui/tui/hooks.d.ts +45 -0
  136. package/dist/src/ui/tui/hooks.js +79 -0
  137. package/dist/src/ui/tui/hooks.js.map +1 -0
  138. package/dist/src/ui/tui/index.d.ts +2 -0
  139. package/dist/src/ui/tui/index.js +3 -0
  140. package/dist/src/ui/tui/index.js.map +1 -0
  141. package/dist/src/ui/tui/primitives.d.ts +12 -0
  142. package/dist/src/ui/tui/primitives.js +56 -0
  143. package/dist/src/ui/tui/primitives.js.map +1 -0
  144. package/dist/src/util/open-path.d.ts +2 -0
  145. package/dist/src/util/open-path.js +27 -0
  146. package/dist/src/util/open-path.js.map +1 -0
  147. package/package.json +11 -8
package/README.md CHANGED
@@ -1,48 +1,142 @@
1
1
  # iskills
2
2
 
3
- 独立的个人 Skill 收藏夹终端应用。TUI 是唯一交互界面形态;保留少量具有独立价值的 CLI。命令名和配置目录名为 `iskills`,支持 macOS、Linux 和 Node.js 24+。
3
+ [![npm](https://img.shields.io/npm/v/iskills)](https://www.npmjs.com/package/iskills)
4
+ [![Node.js](https://img.shields.io/node/v/iskills)](https://www.npmjs.com/package/iskills)
5
+ [![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux-lightgrey)](https://github.com/eightHundreds/iskills)
4
6
 
5
- 实现使用严格 TypeScript、Ink 和按 copy-owned 模式引入的 termcn 组件,按收藏操作、浏览交互、存储/发现、Git 生命周期和 CLI 路由拆分;发布包只包含编译后的 `dist/src`。
7
+ [中文](./README.zh-CN.md)
6
8
 
7
- ## 本地试用
9
+ **Personal skill collection for AI coding agents** — discover, collect, install, and maintain skills that agents load via `SKILL.md`.
10
+
11
+ `iskills` is a terminal-first app: a full-screen TUI for day-to-day work, plus a small set of CLI commands for search, import, install, and Git setup. One collection per developer; no cloud account, no team admin surface.
12
+
13
+ ## Why iskills
14
+
15
+ Agent skills scatter across repos, global dirs, and project folders. `iskills` keeps a **single personal collection** as the source of truth, then installs into the places your agents already look:
16
+
17
+ | You want to… | How |
18
+ | --- | --- |
19
+ | **Discover** | Live search [skills.sh](https://skills.sh), or scan local / agent global directories |
20
+ | **Collect** | Import paths or Git sources into your collection with metadata, tags, and same-origin checks |
21
+ | **Install** | Link (default) or copy skills into the current project or agent global dirs |
22
+ | **Maintain** | Browse, update, delete, note, tag, and optionally sync the collection with Git — all in the TUI |
23
+
24
+ Data integrity comes first: writes are transactional where it matters; conflicts never land in skills you are actively using.
25
+
26
+ ## Requirements
27
+
28
+ - **Node.js** 24+
29
+ - **macOS** or **Linux**
30
+ - A TTY for the interactive UI (`stdin` and `stdout`)
31
+ - **Git** optional — enable only if you want collection versioning / remote sync
32
+
33
+ > **UI language:** TUI and CLI help are currently Chinese.
34
+
35
+ ## Install
8
36
 
9
37
  ```bash
10
- pnpm link
11
- iskills --help
38
+ npm install -g iskills
39
+ # or
40
+ pnpm add -g iskills
12
41
  ```
13
42
 
14
- 默认收藏目录为 `$XDG_CONFIG_HOME/iskills`,未设置时使用 `~/.config/iskills`。收藏目录本身是 Git 仓库时自动提交变更并异步同步;Git 不是必需依赖。
43
+ Verify:
44
+
45
+ ```bash
46
+ iskills --version
47
+ iskills --help
48
+ ```
15
49
 
16
- ## 命令
50
+ ## Quick start
17
51
 
18
52
  ```bash
19
- iskills # 交互式主界面
20
- iskills search [关键词] # 实时搜索 skills.sh,选择后保存到收藏夹
21
- iskills import [路径或 Git URL] # 导入到收藏夹,原本地位置保留软链
22
- iskills import -g # 扫描常见 Agent 全局目录
23
- iskills import -g --agent pi # 扫描 Pi 专属全局目录 ~/.pi/agent/skills
24
- iskills add <技能> # 从收藏夹添加到当前项目
25
- iskills add <技能> -g # 从收藏夹添加到一个或多个 Agent 全局目录
26
- iskills add <技能> -g --agent pi # 添加到 Pi 专属全局目录 ~/.pi/agent/skills
27
- iskills add <技能> --copy # 复制并脱离收藏夹
28
- iskills init # 初始化收藏夹 Git,并可选配置远程仓库
29
- iskills init --remote <Git URL> # 配置或更新 origin
53
+ # Open the main browser (project · global · collection)
54
+ iskills
55
+
56
+ # Search skills.sh and save into your collection
57
+ iskills search react
58
+
59
+ # Import a local skill or a Git repository
60
+ iskills import ./my-skill
61
+ iskills import https://github.com/org/skills-repo.git
62
+
63
+ # Scan agent global skill directories
64
+ iskills import -g
65
+ iskills import -g --agent pi
66
+
67
+ # Create a new skill in the collection and open its directory
68
+ iskills create my-skill
69
+
70
+ # Install from your collection into this project (symlink)
71
+ iskills add my-skill
72
+
73
+ # Install into agent global dirs, or as a detached copy
74
+ iskills add my-skill -g --agent claude
75
+ iskills add my-skill --copy
76
+
77
+ # Optional: turn the collection into a Git repo (and set origin)
78
+ iskills init
79
+ iskills init --remote git@github.com:you/my-skills.git
30
80
  ```
31
81
 
32
- `iskills init` 首次运行时会询问是否配置远程仓库。配置后在主 TUI 的收藏夹 Tab 使用 `s` 同步 Git;浏览、删除、更新、同步、备注和标签维护均在主 TUI 完成。
82
+ In the main TUI, day-to-day work (browse, delete, update, notes, tags, sync) lives on the keyboard-driven browser. With a remote configured, press **`s`** on the Collection tab to sync.
83
+
84
+ ## Commands
85
+
86
+ | Command | Description |
87
+ | --- | --- |
88
+ | `iskills` | Main TUI — project / global / collection browser |
89
+ | `iskills search [query]` | Search TUI against skills.sh; save selections to the collection |
90
+ | `iskills create [name]` | Create a new skill in the collection and open its directory |
91
+ | `iskills import [source]` | Import a local path or Git URL |
92
+ | `iskills add [skill…]` | Install from the collection into a project or global agent dir |
93
+ | `iskills init` | Initialize Git for the collection (optional remote) |
94
+
95
+ Common flags (see `iskills help <command>` for the full set):
96
+
97
+ - **`import`:** `-g` / `--global`, `--agent <name>`, `--all`, `--replace`, `-y`
98
+ - **`add`:** `-g` / `--global`, `--agent <name>`, `--to <dir>`, `--copy`, `--replace`, `-y`
99
+ - **`init`:** `--remote <git-url>`
100
+ - **`search`:** `--replace`
33
101
 
34
- 冲突不会写入正在使用的 Skill。来源冲突保留在 `.local/conflicts`,由用户使用编辑器和 Git 手动解决;后续启动主 TUI 或运行保留的收藏操作时自动应用已提交的合并结果。
102
+ Supported `--agent` values: `agents`, `codex`, `claude`, `cursor`, `opencode`, `pi`, `zcode`, `trae`, `qoder`, `grok`.
35
103
 
36
- ## 开发文档
104
+ ## Collection layout
37
105
 
38
- - [CLI/TUI 交互规范](docs/cli-tui.md)
39
- - [领域不变量与数据完整性](docs/domain-invariants.md)
40
- - [终端 UI 架构 ADR](docs/adr/0001-terminal-ui-runtime.md)
41
- - [Agent Skills 目录支持调研](docs/agent-skills-support.md)
106
+ | Item | Location |
107
+ | --- | --- |
108
+ | Collection root | `$XDG_CONFIG_HOME/iskills`, or `~/.config/iskills` if unset |
109
+ | Git | Optional. When the collection is a Git repo, changes are auto-committed and can sync asynchronously |
110
+ | Source conflicts | `.local/conflicts` under the collection — resolve with an editor + Git |
42
111
 
43
- ## 验证
112
+ After you commit a merge resolution, the next main TUI start (or a retained collection command) applies the result. Active in-use skills are never overwritten by conflict material.
113
+
114
+ ## Development
44
115
 
45
116
  ```bash
117
+ git clone https://github.com/eightHundreds/iskills.git
118
+ cd iskills
119
+ pnpm install --frozen-lockfile
120
+ pnpm run build
121
+ pnpm start -- --help
122
+ pnpm run type-check
46
123
  pnpm test
47
124
  pnpm pack --dry-run
48
125
  ```
126
+
127
+ Stack: TypeScript (strict), OpenTUI, React. The published package ships compiled `dist/src` only.
128
+
129
+ ## Non-goals
130
+
131
+ - Skill marketplace, hosting, accounts, or cloud sync as a product
132
+ - Desktop or web GUI
133
+ - CI/CD or headless machine API as the primary interface
134
+ - Multi-user / org permissions
135
+
136
+ ## Contributing
137
+
138
+ Issues and pull requests are welcome. Please keep changes aligned with the interaction and domain specs under `docs/`, and run `pnpm test` before submitting.
139
+
140
+ ## License
141
+
142
+ See the repository root for license and third-party notices.
@@ -0,0 +1,142 @@
1
+ # iskills
2
+
3
+ [![npm](https://img.shields.io/npm/v/iskills)](https://www.npmjs.com/package/iskills)
4
+ [![Node.js](https://img.shields.io/node/v/iskills)](https://www.npmjs.com/package/iskills)
5
+ [![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux-lightgrey)](https://github.com/eightHundreds/iskills)
6
+
7
+ [English](./README.md)
8
+
9
+ **面向 AI coding agent 的个人 Skill 收藏夹** — 发现、收藏、安装并维护可通过 `SKILL.md` 被 Agent 加载的技能。
10
+
11
+ `iskills` 以终端为中心:日常使用全屏 TUI,并保留少量 CLI 入口用于搜索、导入、安装与 Git 初始化。每个收藏夹由单个开发者维护;无云账号、无团队权限面。
12
+
13
+ ## 为什么用 iskills
14
+
15
+ 技能往往散落在仓库、Agent 全局目录和项目目录里。`iskills` 用**一份个人收藏夹**作为真相源,再安装到 Agent 已经会扫描的位置:
16
+
17
+ | 你想… | 做法 |
18
+ | --- | --- |
19
+ | **发现** | 实时搜索 [skills.sh](https://skills.sh),或扫描本地 / Agent 全局目录 |
20
+ | **收藏** | 将本地路径或 Git 来源导入收藏夹,带 metadata、标签与同源判定 |
21
+ | **安装** | 默认软链(或复制)到当前项目或 Agent 全局目录 |
22
+ | **维护** | 在 TUI 中浏览、更新、删除、备注、打标签,并可选用 Git 同步收藏夹 |
23
+
24
+ 数据完整性优先:关键写入可回滚;冲突不会写入正在使用的技能。
25
+
26
+ ## 环境要求
27
+
28
+ - **Node.js** 24+
29
+ - **macOS** 或 **Linux**
30
+ - 交互界面需要 TTY(`stdin` 与 `stdout`)
31
+ - **Git** 可选 — 仅在需要收藏夹版本管理 / 远端同步时启用
32
+
33
+ > **界面语言:** 当前 TUI 与 CLI 帮助为中文。
34
+
35
+ ## 安装
36
+
37
+ ```bash
38
+ npm install -g iskills
39
+ # 或
40
+ pnpm add -g iskills
41
+ ```
42
+
43
+ 验证:
44
+
45
+ ```bash
46
+ iskills --version
47
+ iskills --help
48
+ ```
49
+
50
+ ## 快速开始
51
+
52
+ ```bash
53
+ # 打开主浏览器(当前项目 · 全局 · 收藏夹)
54
+ iskills
55
+
56
+ # 搜索 skills.sh 并保存到收藏夹
57
+ iskills search react
58
+
59
+ # 导入本地技能或 Git 仓库
60
+ iskills import ./my-skill
61
+ iskills import https://github.com/org/skills-repo.git
62
+
63
+ # 扫描 Agent 全局技能目录
64
+ iskills import -g
65
+ iskills import -g --agent pi
66
+
67
+ # 在收藏夹新建技能并打开目录
68
+ iskills create my-skill
69
+
70
+ # 从收藏夹安装到当前项目(软链)
71
+ iskills add my-skill
72
+
73
+ # 安装到 Agent 全局目录,或以副本脱离收藏夹
74
+ iskills add my-skill -g --agent claude
75
+ iskills add my-skill --copy
76
+
77
+ # 可选:将收藏夹初始化为 Git 仓库(并配置 origin)
78
+ iskills init
79
+ iskills init --remote git@github.com:you/my-skills.git
80
+ ```
81
+
82
+ 日常操作(浏览、删除、更新、备注、标签、同步)在主 TUI 的键盘浏览中完成。配置远程后,在收藏夹 Tab 按 **`s`** 同步。
83
+
84
+ ## 命令
85
+
86
+ | 命令 | 说明 |
87
+ | --- | --- |
88
+ | `iskills` | 主 TUI — 当前项目 / 全局 / 收藏夹浏览 |
89
+ | `iskills search [关键词]` | 独立搜索 TUI(skills.sh),选择后写入收藏夹 |
90
+ | `iskills create [名称]` | 在收藏夹新建技能并打开目录 |
91
+ | `iskills import [来源]` | 导入本地路径或 Git URL |
92
+ | `iskills add [技能…]` | 从收藏夹安装到项目或 Agent 全局目录 |
93
+ | `iskills init` | 初始化收藏夹 Git(可选远程) |
94
+
95
+ 常用参数(完整列表见 `iskills help <命令>`):
96
+
97
+ - **`import`:** `-g` / `--global`、`--agent <名称>`、`--all`、`--replace`、`-y`
98
+ - **`add`:** `-g` / `--global`、`--agent <名称>`、`--to <目录>`、`--copy`、`--replace`、`-y`
99
+ - **`init`:** `--remote <git-url>`
100
+ - **`search`:** `--replace`
101
+
102
+ `--agent` 可选:`agents`、`codex`、`claude`、`cursor`、`opencode`、`pi`、`zcode`、`trae`、`qoder`、`grok`。
103
+
104
+ ## 收藏夹布局
105
+
106
+ | 项 | 位置 |
107
+ | --- | --- |
108
+ | 收藏根目录 | `$XDG_CONFIG_HOME/iskills`;未设置时为 `~/.config/iskills` |
109
+ | Git | 可选。收藏夹本身是 Git 仓库时,变更会自动提交,并可异步同步 |
110
+ | 来源冲突 | 收藏夹下 `.local/conflicts` — 用编辑器 + Git 手动解决 |
111
+
112
+ 提交合并结果后,下次启动主 TUI(或运行保留的收藏操作)会自动应用。冲突内容不会写入正在使用的技能。
113
+
114
+ ## 开发
115
+
116
+ ```bash
117
+ git clone https://github.com/eightHundreds/iskills.git
118
+ cd iskills
119
+ pnpm install --frozen-lockfile
120
+ pnpm run build
121
+ pnpm start -- --help
122
+ pnpm run type-check
123
+ pnpm test
124
+ pnpm pack --dry-run
125
+ ```
126
+
127
+ 技术栈:严格模式 TypeScript、OpenTUI、React。发布包仅包含编译后的 `dist/src`。
128
+
129
+ ## 非目标
130
+
131
+ - 技能市场、托管、账号体系或云同步产品
132
+ - 桌面 / Web GUI
133
+ - 以 CI/CD 或无人脚本 / 机器 API 为主界面
134
+ - 多用户 / 组织级权限
135
+
136
+ ## 贡献
137
+
138
+ 欢迎 Issue 与 Pull Request。改动请对齐 `docs/` 下的交互与领域规范,提交前运行 `pnpm test`。
139
+
140
+ ## 许可
141
+
142
+ 许可与第三方声明见仓库根目录。
package/bin/iskills.js CHANGED
@@ -1,8 +1,83 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { main } from '../dist/src/cli.js';
3
+ /**
4
+ * Public entry: prefer a runtime that can load OpenTUI's native Zig core.
5
+ *
6
+ * - Bun: full CLI + interactive TUI
7
+ * - Node with node:ffi: full CLI + interactive TUI (when available)
8
+ * - Node without FFI: non-interactive CLI still works; re-exec under Bun when
9
+ * `bun` is on PATH so interactive browser/search/prompts match interactive TUI UX
10
+ *
11
+ * Set ISKILLS_FORCE_NODE=1 to skip Bun re-exec (tests / debugging).
12
+ */
13
+ import { spawnSync } from 'node:child_process';
14
+ import { existsSync } from 'node:fs';
15
+ import { createRequire } from 'node:module';
16
+ import { fileURLToPath } from 'node:url';
4
17
 
5
- import { InterruptError } from '../dist/src/ui/shell/terminal.js';
18
+ const FORCE_NODE = process.env.ISKILLS_FORCE_NODE === '1';
19
+ const ALREADY_REEXEC = process.env.ISKILLS_RUNTIME === '1';
20
+
21
+ function isBunRuntime() {
22
+ return Boolean(process.versions.bun) || typeof globalThis.Bun !== 'undefined';
23
+ }
24
+
25
+ function nodeHasFfi() {
26
+ try {
27
+ createRequire(import.meta.url)('node:ffi');
28
+ return true;
29
+ } catch {
30
+ return false;
31
+ }
32
+ }
33
+
34
+ function findBun() {
35
+ const whichCmd = process.platform === 'win32' ? 'where' : 'which';
36
+ const result = spawnSync(whichCmd, ['bun'], {
37
+ encoding: 'utf8',
38
+ env: process.env,
39
+ });
40
+ if (result.status !== 0) return undefined;
41
+ const first = (result.stdout || '')
42
+ .split(/\r?\n/)
43
+ .map((line) => line.trim())
44
+ .find(Boolean);
45
+ if (first && existsSync(first)) return first;
46
+ return undefined;
47
+ }
48
+
49
+ function shouldReexecToBun() {
50
+ if (FORCE_NODE || ALREADY_REEXEC || isBunRuntime()) return false;
51
+ if (nodeHasFfi()) return false;
52
+ return Boolean(findBun());
53
+ }
54
+
55
+ if (shouldReexecToBun()) {
56
+ const bun = findBun();
57
+ if (bun) {
58
+ const self = fileURLToPath(import.meta.url);
59
+ const result = spawnSync(bun, [self, ...process.argv.slice(2)], {
60
+ stdio: 'inherit',
61
+ env: {
62
+ ...process.env,
63
+ ISKILLS_RUNTIME: '1',
64
+ },
65
+ });
66
+ if (result.error) {
67
+ console.error(`错误:无法启动 Bun 运行时:${result.error.message}`);
68
+ process.exitCode = 1;
69
+ } else {
70
+ process.exit(result.status ?? 1);
71
+ }
72
+ }
73
+ }
74
+
75
+ // OpenTUI + react-reconciler need an ESM resolve hook under Node (extensionless subpaths).
76
+ // Bun resolves those without the hook; registering is harmless.
77
+ await import('./opentui-register.mjs');
78
+
79
+ const { main } = await import('../dist/src/cli.js');
80
+ const { InterruptError } = await import('../dist/src/ui/shell/terminal.js');
6
81
 
7
82
  main().catch((error) => {
8
83
  if (
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Register OpenTUI Node ESM resolve hook before loading the app.
3
+ * Shipped next to the bin so published packages keep TUI working under Node.
4
+ */
5
+ import { register } from 'node:module';
6
+ import { dirname, join } from 'node:path';
7
+ import { fileURLToPath, pathToFileURL } from 'node:url';
8
+
9
+ const here = dirname(fileURLToPath(import.meta.url));
10
+ register(pathToFileURL(join(here, 'opentui-resolve-hook.mjs')).href);
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Node ESM resolve hook: OpenTUI imports extensionless react-reconciler subpaths.
3
+ */
4
+ export async function resolve(specifier, context, nextResolve) {
5
+ if (
6
+ specifier === 'react-reconciler/constants' ||
7
+ specifier === 'react-reconciler/reflection'
8
+ ) {
9
+ return nextResolve(`${specifier}.js`, context);
10
+ }
11
+ return nextResolve(specifier, context);
12
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * OpenTUI imports `react-reconciler/constants` without `.js`.
3
+ * Node ESM needs an exports map; patch every installed copy under node_modules.
4
+ */
5
+ import { readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
6
+ import { join } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const root = fileURLToPath(new URL('..', import.meta.url));
10
+ const exportsMap = {
11
+ '.': {
12
+ require: './index.js',
13
+ default: './index.js',
14
+ },
15
+ './constants': {
16
+ require: './constants.js',
17
+ default: './constants.js',
18
+ },
19
+ './constants.js': './constants.js',
20
+ './reflection': {
21
+ require: './reflection.js',
22
+ default: './reflection.js',
23
+ },
24
+ './reflection.js': './reflection.js',
25
+ './package.json': './package.json',
26
+ };
27
+
28
+ function walk(dir, out, depth = 0) {
29
+ if (depth > 8) return;
30
+ let entries;
31
+ try {
32
+ entries = readdirSync(dir, { withFileTypes: true });
33
+ } catch {
34
+ return;
35
+ }
36
+ for (const entry of entries) {
37
+ if (entry.name === '.git' || entry.name === 'dist') continue;
38
+ const full = join(dir, entry.name);
39
+ if (entry.isDirectory()) {
40
+ if (entry.name === 'react-reconciler') {
41
+ out.push(join(full, 'package.json'));
42
+ } else if (entry.name === 'node_modules' || entry.name.startsWith('.') || entry.name === '.pnpm') {
43
+ walk(full, out, depth + 1);
44
+ } else if (depth < 4) {
45
+ walk(full, out, depth + 1);
46
+ }
47
+ }
48
+ }
49
+ }
50
+
51
+ const targets = [];
52
+ walk(join(root, 'node_modules'), targets);
53
+
54
+ let patched = 0;
55
+ for (const pkgPath of targets) {
56
+ try {
57
+ if (!statSync(pkgPath).isFile()) continue;
58
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
59
+ if (pkg.name !== 'react-reconciler') continue;
60
+ if (JSON.stringify(pkg.exports) === JSON.stringify(exportsMap)) continue;
61
+ pkg.exports = exportsMap;
62
+ writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
63
+ patched += 1;
64
+ } catch {
65
+ // ignore unreadable copies
66
+ }
67
+ }
68
+
69
+ if (patched > 0) {
70
+ console.log(`[patch-react-reconciler] patched ${patched} package.json file(s)`);
71
+ }
package/dist/src/cli.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { createRequire } from 'node:module';
2
- import { commandAdd, commandImport, commandInit, commandSearch, printHelp, } from './commands/index.js';
2
+ import { commandAdd, commandCreate, commandImport, commandInit, commandSearch, printHelp, } from './commands/index.js';
3
3
  import { commitCollection, ensureCollection, readState } from './domain/core.js';
4
4
  import { finalizeResolvedConflicts } from './domain/git.js';
5
5
  import { InterruptError } from './ui/shell/terminal.js';
6
6
  const packageVersion = createRequire(import.meta.url)('../../package.json').version;
7
- const PUBLIC_COMMANDS = new Set(['search', 'add', 'import', 'init']);
7
+ const PUBLIC_COMMANDS = new Set(['search', 'add', 'create', 'import', 'init']);
8
8
  async function run(argv) {
9
9
  const [command, ...rest] = argv;
10
10
  if (command === 'help' || command === '--help' || command === '-h') {
@@ -37,6 +37,8 @@ async function run(argv) {
37
37
  }
38
38
  if (command === 'add')
39
39
  return commandAdd(rest);
40
+ if (command === 'create')
41
+ return commandCreate(rest);
40
42
  if (command === 'import')
41
43
  return commandImport(rest);
42
44
  throw new Error(`未知命令:${command}`);
@@ -54,9 +56,9 @@ export async function main(argv = process.argv.slice(2)) {
54
56
  throw error;
55
57
  }
56
58
  finally {
57
- // Lazy: avoid static import of Ink UI on every CLI entry; only load to tear down.
58
- const { closeInk } = await import('./ui/shell/run.js');
59
- closeInk();
59
+ // Lazy: tear down without loading OpenTUI when no UI was mounted.
60
+ const { closeTui } = await import('./ui/shell/lifecycle.js');
61
+ closeTui();
60
62
  }
61
63
  }
62
64
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"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KAAK,KAAK;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,OAAO,KAAK,QAAQ;QAAE,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,QAAQ;QAAE,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,IAAI,KAAK,CAAC,QAAQ,OAAO,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACrD,IAAI,CAAC;QACH,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IACE,KAAK,YAAY,cAAc;YAC/B,CAAC,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC,EAC3D,CAAC;YACD,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC;YACvB,OAAO;QACT,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,kEAAkE;QAClE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC;QAC7D,QAAQ,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
@@ -1,8 +1,7 @@
1
1
  import { cp, rm } from 'node:fs/promises';
2
- import { homedir } from 'node:os';
3
- import { join, relative, sep } from 'node:path';
2
+ import { join, relative, resolve, sep } from 'node:path';
4
3
  import { setTimeout as delay } from 'node:timers/promises';
5
- import { AGENTS, assertRelativePath, baselinePath, collectionPaths, commitCollection, discoverSkills, errorMessage, exists, isGitSource, listCollection, listProjectGroups, parseGitSource, readMetadata, writeMetadata, } from '../domain/core.js';
4
+ import { assertRelativePath, baselinePath, collectionPaths, commitCollection, discoverSkills, errorMessage, exists, getAgent, isGitSource, listCollection, NO_PRESENT_AGENTS_ERROR, agentInstallTargets, listPresentAgents, listProjectGroups, parseGitSource, primaryPresentAgent, readMetadata, writeMetadata, } from '../domain/core.js';
6
5
  import { materializeSkillReferences, removeFromCollection, removeSkillLocations, } from '../domain/collection-write.js';
7
6
  import { cloneGitSource, syncCollection, updateGitSkill } from '../domain/git.js';
8
7
  import { Modal } from '../ui/overlay/static.js';
@@ -35,34 +34,25 @@ export async function loadBrowserData() {
35
34
  const canSync = await exists(join(collectionPaths().root, '.git'));
36
35
  return { projectGroups, collection, globalGroups, canSync };
37
36
  }
38
- const INSTALL_TARGETS = [
39
- {
40
- value: 'agents',
41
- projectLabel: '标准 Agent Skills (.agents/skills)',
42
- globalLabel: '标准 Agent Skills (~/.agents/skills)',
43
- },
44
- {
45
- value: 'claude',
46
- projectLabel: 'Claude Code (.claude/skills)',
47
- globalLabel: 'Claude Code (~/.claude/skills)',
48
- },
49
- {
50
- value: 'pi',
51
- globalLabel: 'Pi (~/.pi/agent/skills)',
52
- },
53
- ];
54
- async function defaultInstallAgents() {
37
+ async function installTargetsAndDefaults() {
38
+ const present = await listPresentAgents();
39
+ if (!present.length)
40
+ throw new Error(NO_PRESENT_AGENTS_ERROR);
41
+ const targets = agentInstallTargets(present);
42
+ // Available: tool root present. Project default: only if this project already has that skills dir
43
+ // (e.g. ~/.zcode exists → zcode is listed, but not pre-checked until .zcode/skills exists).
55
44
  const defaultProjectAgents = [];
56
- const defaultGlobalAgents = [];
57
- for (const option of INSTALL_TARGETS) {
58
- const agent = AGENTS[option.value];
59
- if (agent?.project && await exists(agent.project))
60
- defaultProjectAgents.push(option.value);
61
- const globalPath = agent?.global(homedir());
62
- if (globalPath && await exists(globalPath))
63
- defaultGlobalAgents.push(option.value);
45
+ for (const target of targets) {
46
+ if (!target.projectLabel)
47
+ continue;
48
+ const project = getAgent(target.value).project;
49
+ if (project && (await exists(resolve(project))))
50
+ defaultProjectAgents.push(target.value);
64
51
  }
65
- return { defaultProjectAgents, defaultGlobalAgents };
52
+ // Global: single primary default (agents first) to avoid multi-tool blast radius.
53
+ const primary = primaryPresentAgent(present);
54
+ const defaultGlobalAgents = primary ? [primary] : [];
55
+ return { targets, defaultProjectAgents, defaultGlobalAgents };
66
56
  }
67
57
  export async function loadDetailContext(skill, collection, frameHeight, frameWidth) {
68
58
  const { readState } = await import('../domain/core.js');
@@ -177,8 +167,18 @@ async function handleTags(host, skills) {
177
167
  host.setStatus('已加标签', true, 'normal');
178
168
  }
179
169
  async function handleAdd(host, skills) {
180
- const { defaultProjectAgents, defaultGlobalAgents } = await defaultInstallAgents();
181
- const install = await promptInstallReview(skills, INSTALL_TARGETS, defaultProjectAgents, defaultGlobalAgents);
170
+ let targets;
171
+ let defaultProjectAgents;
172
+ let defaultGlobalAgents;
173
+ try {
174
+ ({ targets, defaultProjectAgents, defaultGlobalAgents } =
175
+ await installTargetsAndDefaults());
176
+ }
177
+ catch (error) {
178
+ host.setStatus(errorMessage(error), false, 'error');
179
+ return;
180
+ }
181
+ const install = await promptInstallReview(skills, targets, defaultProjectAgents, defaultGlobalAgents);
182
182
  if (!install)
183
183
  return;
184
184
  try {