@hagicode/skillsbase 0.1.0-dev.1.1.426f4b0
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 +21 -0
- package/README.md +132 -0
- package/README.zh-CN.md +127 -0
- package/bin/skillsbase.mjs +44 -0
- package/dist/cli.mjs +1109 -0
- package/package.json +53 -0
- package/templates/actions/skillsbase-manage/action.yml +96 -0
- package/templates/actions/skillsbase-sync/action.yml +44 -0
- package/templates/docs/maintainer-workflow.md +32 -0
- package/templates/skills/README.md +9 -0
- package/templates/sources.yaml +25 -0
- package/templates/workflows/skills-manage.yml +54 -0
- package/templates/workflows/skills-sync.yml +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HagiCode
|
|
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.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# @hagicode/skillsbase
|
|
2
|
+
|
|
3
|
+
[中文文档](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@hagicode/skillsbase)
|
|
6
|
+
[](https://www.npmjs.com/package/@hagicode/skillsbase)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
|
|
10
|
+
`skillsbase` is a standalone Node.js CLI for bootstrapping and maintaining managed skills repositories.
|
|
11
|
+
It ships the CLI and templates only. The generated `skills/` content belongs in the target repository, not in this package repository.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
Requirements:
|
|
16
|
+
|
|
17
|
+
- Node.js `>= 22.12.0`
|
|
18
|
+
- npm `>= 10.9.2`
|
|
19
|
+
|
|
20
|
+
Install globally:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install --global @hagicode/skillsbase
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then run:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
skillsbase --help
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
Initialize a managed repository:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
skillsbase init --repo /path/to/target-repo
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Sync managed skills from `sources.yaml`:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
skillsbase sync --repo /path/to/target-repo
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Add one skill and sync immediately:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
skillsbase add documentation-writer --repo /path/to/target-repo
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Remove one skill and sync immediately:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
skillsbase remove documentation-writer --repo /path/to/target-repo
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Generate managed GitHub Actions assets:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
skillsbase github_action --repo /path/to/target-repo --kind all
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Commands
|
|
65
|
+
|
|
66
|
+
| Command | Purpose | Example |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| `init` | Create the managed repository baseline. | `skillsbase init --repo ./my-skills-repo` |
|
|
69
|
+
| `sync` | Reconcile managed skills from `sources.yaml`. | `skillsbase sync --repo ./my-skills-repo` |
|
|
70
|
+
| `sync --check` | Validate drift without writing files. | `skillsbase sync --check --repo ./my-skills-repo` |
|
|
71
|
+
| `add <skill-name>` | Add a skill to a source block, then run sync. | `skillsbase add documentation-writer --repo ./my-skills-repo` |
|
|
72
|
+
| `remove <skill-name>` | Remove a skill from a source block, then run sync. | `skillsbase remove documentation-writer --repo ./my-skills-repo` |
|
|
73
|
+
| `github_action` | Generate managed GitHub Actions workflow or action files. | `skillsbase github_action --repo ./my-skills-repo --kind workflow` |
|
|
74
|
+
|
|
75
|
+
Global options:
|
|
76
|
+
|
|
77
|
+
- `--repo <path>`: target repository path, defaults to the current directory
|
|
78
|
+
- `--help`, `-h`: show help
|
|
79
|
+
- `--version`, `-v`: show version
|
|
80
|
+
|
|
81
|
+
## Managed Repository Contract
|
|
82
|
+
|
|
83
|
+
`skillsbase` manages files in the target repository, including:
|
|
84
|
+
|
|
85
|
+
- `sources.yaml`: the single source of truth for source roots, naming rules, include lists, and defaults
|
|
86
|
+
- `skills/<name>/SKILL.md`: managed skill output converted from installed source content
|
|
87
|
+
- `skills/<name>/.skill-source.json`: source, conversion, target-path, and install metadata
|
|
88
|
+
- `docs/maintainer-workflow.md`: maintainer guidance generated from the bundled templates
|
|
89
|
+
- `.github/workflows/skills-sync.yml`: reusable workflow for validation and sync checks
|
|
90
|
+
- `.github/actions/skillsbase-sync/action.yml`: reusable composite action
|
|
91
|
+
|
|
92
|
+
## Non-Interactive Defaults
|
|
93
|
+
|
|
94
|
+
- The target repository defaults to the current working directory.
|
|
95
|
+
- `init` defaults the source roots to:
|
|
96
|
+
- first-party: `$HOME/.agents/skills`
|
|
97
|
+
- system: `$HOME/.codex/skills/.system`
|
|
98
|
+
- `add` writes to the first declared source block unless `--source <key>` is provided.
|
|
99
|
+
- `remove` deletes from the only matching source block automatically; if multiple source blocks include the same skill, pass `--source <key>`.
|
|
100
|
+
- `add`, `remove`, and `sync` accept `--allow-missing-sources` to keep path-resolution behavior consistent in CI or repo-external execution.
|
|
101
|
+
- `github_action` defaults to `--kind workflow`.
|
|
102
|
+
- When the CLI does not have enough context to write safely, it fails with diagnostics instead of prompting interactively.
|
|
103
|
+
|
|
104
|
+
## Development
|
|
105
|
+
|
|
106
|
+
Common commands for working on this package:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npm run build
|
|
110
|
+
npm run cli -- --help
|
|
111
|
+
npm test
|
|
112
|
+
npm run smoke
|
|
113
|
+
npm run pack:check
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The published entry point is `bin/skillsbase.mjs`. In development, `npm run cli -- <args>` runs the TypeScript entry directly.
|
|
117
|
+
|
|
118
|
+
## Publishing Notes
|
|
119
|
+
|
|
120
|
+
The GitHub Actions workflow supports two npm authentication modes:
|
|
121
|
+
|
|
122
|
+
- Preferred: npm trusted publishing via GitHub Actions OIDC
|
|
123
|
+
- Fallback: `NPM_TOKEN` repository secret mapped to `NODE_AUTH_TOKEN`
|
|
124
|
+
|
|
125
|
+
Before relying on trusted publishing, make sure the npm package settings for `@hagicode/skillsbase` trust the `HagiCode-org/skillsbase` repository.
|
|
126
|
+
Use workflow filename `npm-publish.yml` in npm trusted publisher settings, not the full `.github/workflows/...` path.
|
|
127
|
+
If the package has not been published before, that is still acceptable as long as the `hagicode` scope already exists and the publishing identity can create `@hagicode/skillsbase`.
|
|
128
|
+
The npm docs currently require Node.js `>= 22.14.0` and npm `>= 11.5.1` for trusted publishing.
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT. See [LICENSE](./LICENSE).
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# @hagicode/skillsbase
|
|
2
|
+
|
|
3
|
+
[English README](./README.md)
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@hagicode/skillsbase)
|
|
6
|
+
[](https://www.npmjs.com/package/@hagicode/skillsbase)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
|
|
9
|
+
`skillsbase` 是一个独立的 Node.js CLI,用于初始化并维护受管 skills 仓库。
|
|
10
|
+
本仓库只提供 CLI 与模板,不提交目标仓库中的 `skills/` 产物。
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
要求:
|
|
15
|
+
|
|
16
|
+
- Node.js `>= 22.12.0`
|
|
17
|
+
- npm `>= 10.9.2`
|
|
18
|
+
|
|
19
|
+
全局安装:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install --global @hagicode/skillsbase
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
安装后可直接执行:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
skillsbase --help
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 快速开始
|
|
32
|
+
|
|
33
|
+
初始化受管仓库:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
skillsbase init --repo /path/to/target-repo
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
按 `sources.yaml` 同步技能:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
skillsbase sync --repo /path/to/target-repo
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
添加单个技能并立即同步:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
skillsbase add documentation-writer --repo /path/to/target-repo
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
删除单个技能并立即同步:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
skillsbase remove documentation-writer --repo /path/to/target-repo
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
生成受管 GitHub Actions 资产:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
skillsbase github_action --repo /path/to/target-repo --kind all
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 命令
|
|
64
|
+
|
|
65
|
+
| 命令 | 用途 | 示例 |
|
|
66
|
+
| --- | --- | --- |
|
|
67
|
+
| `init` | 创建受管仓库基础结构 | `skillsbase init --repo ./my-skills-repo` |
|
|
68
|
+
| `sync` | 按 `sources.yaml` 对账并同步技能 | `skillsbase sync --repo ./my-skills-repo` |
|
|
69
|
+
| `sync --check` | 只校验漂移,不写文件 | `skillsbase sync --check --repo ./my-skills-repo` |
|
|
70
|
+
| `add <skill-name>` | 将技能写入 source block 后执行同步 | `skillsbase add documentation-writer --repo ./my-skills-repo` |
|
|
71
|
+
| `remove <skill-name>` | 从 source block 删除技能后执行同步 | `skillsbase remove documentation-writer --repo ./my-skills-repo` |
|
|
72
|
+
| `github_action` | 生成受管 GitHub Actions 工作流或 action 文件 | `skillsbase github_action --repo ./my-skills-repo --kind workflow` |
|
|
73
|
+
|
|
74
|
+
全局选项:
|
|
75
|
+
|
|
76
|
+
- `--repo <path>`:目标仓库路径,默认当前目录
|
|
77
|
+
- `--help`、`-h`:显示帮助
|
|
78
|
+
- `--version`、`-v`:显示版本
|
|
79
|
+
|
|
80
|
+
## 受管仓库约定
|
|
81
|
+
|
|
82
|
+
`skillsbase` 会在目标仓库中管理以下文件:
|
|
83
|
+
|
|
84
|
+
- `sources.yaml`:来源根目录、命名规则、包含列表与默认值的单一真相源
|
|
85
|
+
- `skills/<name>/SKILL.md`:由安装源内容转换得到的受管技能输出
|
|
86
|
+
- `skills/<name>/.skill-source.json`:来源、转换、目标路径与安装元数据
|
|
87
|
+
- `docs/maintainer-workflow.md`:由模板生成的维护说明
|
|
88
|
+
- `.github/workflows/skills-sync.yml`:用于校验与同步检查的工作流
|
|
89
|
+
- `.github/actions/skillsbase-sync/action.yml`:可复用 composite action
|
|
90
|
+
|
|
91
|
+
## 非交互默认行为
|
|
92
|
+
|
|
93
|
+
- 目标仓库默认是当前工作目录。
|
|
94
|
+
- `init` 默认来源根目录为:
|
|
95
|
+
- first-party:`$HOME/.agents/skills`
|
|
96
|
+
- system:`$HOME/.codex/skills/.system`
|
|
97
|
+
- `add` 默认写入第一个已声明的 source block;如需指定,传 `--source <key>`。
|
|
98
|
+
- `remove` 若仅命中一个 source block,会直接删除;若同名技能存在于多个 source block,必须显式传 `--source <key>`。
|
|
99
|
+
- `add`、`remove`、`sync` 均接受 `--allow-missing-sources`,以便在 CI 或仓库外 cwd 下保持一致的路径解析与失败语义。
|
|
100
|
+
- `github_action` 默认使用 `--kind workflow`。
|
|
101
|
+
- 若上下文不足以安全写入,CLI 会直接失败并输出诊断,不会进入交互提问。
|
|
102
|
+
|
|
103
|
+
## 开发
|
|
104
|
+
|
|
105
|
+
常用命令:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npm run build
|
|
109
|
+
npm run cli -- --help
|
|
110
|
+
npm test
|
|
111
|
+
npm run smoke
|
|
112
|
+
npm run pack:check
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
发布入口为 `bin/skillsbase.mjs`。开发期可用 `npm run cli -- <args>` 直接运行 TypeScript 入口。
|
|
116
|
+
|
|
117
|
+
## 发布说明
|
|
118
|
+
|
|
119
|
+
GitHub Actions 发布流支持两种 npm 认证模式:
|
|
120
|
+
|
|
121
|
+
- 推荐:GitHub Actions OIDC 的 npm trusted publishing
|
|
122
|
+
- 兜底:仓库 `NPM_TOKEN` secret,经 `NODE_AUTH_TOKEN` 注入
|
|
123
|
+
|
|
124
|
+
若使用 trusted publishing,需先在 npm 的 `@hagicode/skillsbase` 包设置中,将 `HagiCode-org/skillsbase` 配置为 trusted publisher。
|
|
125
|
+
在 npm trusted publisher 设置里填写的 workflow filename 应为 `npm-publish.yml`,不要填完整的 `.github/workflows/...` 路径。
|
|
126
|
+
如果这个包还没有首发,只要 npm 上已经存在 `hagicode` scope,且当前发布身份有权创建 `@hagicode/skillsbase`,也仍然可以正常发布。
|
|
127
|
+
npm 官方当前要求 Node.js `>= 22.14.0` 且 npm `>= 11.5.1`。
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { access } from "node:fs/promises";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
|
|
8
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const bundledEntry = path.resolve(moduleDir, "..", "dist", "cli.mjs");
|
|
10
|
+
const sourceEntry = path.resolve(moduleDir, "..", "src", "cli-entry.ts");
|
|
11
|
+
|
|
12
|
+
async function canAccess(targetPath) {
|
|
13
|
+
try {
|
|
14
|
+
await access(targetPath);
|
|
15
|
+
return true;
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (await canAccess(bundledEntry)) {
|
|
22
|
+
await import(pathToFileURL(bundledEntry).href);
|
|
23
|
+
} else if (await canAccess(sourceEntry)) {
|
|
24
|
+
const exitCode = await new Promise((resolve, reject) => {
|
|
25
|
+
const child = spawn(process.execPath, ["--import", "tsx", sourceEntry, ...process.argv.slice(2)], {
|
|
26
|
+
stdio: "inherit",
|
|
27
|
+
env: process.env,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
child.on("error", reject);
|
|
31
|
+
child.on("exit", (code, signal) => {
|
|
32
|
+
if (signal) {
|
|
33
|
+
reject(new Error(`skillsbase CLI terminated with signal ${signal}.`));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
resolve(code ?? 1);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
process.exitCode = exitCode;
|
|
42
|
+
} else {
|
|
43
|
+
throw new Error("Unable to locate the skillsbase CLI entrypoint.");
|
|
44
|
+
}
|