Skip to content

Commit 73bc430

Browse files
committed
refactor: split plugin runtime and installer packages
1 parent 70c26bf commit 73bc430

48 files changed

Lines changed: 1864 additions & 2567 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish.yml

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
types: [created]
66
workflow_dispatch:
77

8+
concurrency:
9+
group: publish-npm
10+
cancel-in-progress: false
11+
812
jobs:
913
publish:
1014
runs-on: ubuntu-latest
@@ -19,16 +23,65 @@ jobs:
1923
- name: Setup Node.js
2024
uses: actions/setup-node@v4
2125
with:
22-
node-version: '24'
23-
registry-url: 'https://registry.npmjs.org'
26+
node-version: "24"
27+
registry-url: "https://registry.npmjs.org"
2428

2529
- name: Install dependencies
2630
run: npm ci
2731

28-
- name: Build
32+
- name: Verify version alignment
33+
run: npm run verify:versions
34+
35+
- name: Run tests
36+
run: npm test
37+
38+
- name: Build packages
2939
run: npm run build
3040

31-
- name: Publish to npm
32-
run: npm publish --provenance --access public
41+
- name: Verify publish tarballs
42+
run: npm run pack:check
43+
44+
- name: Resolve package versions
45+
id: versions
46+
run: |
47+
echo "runtime_version=$(node --input-type=module -e \"import fs from 'node:fs'; const pkg = JSON.parse(fs.readFileSync('./packages/runtime/package.json', 'utf8')); console.log(pkg.version);\")" >> "$GITHUB_OUTPUT"
48+
echo "installer_version=$(node --input-type=module -e \"import fs from 'node:fs'; const pkg = JSON.parse(fs.readFileSync('./packages/installer/package.json', 'utf8')); console.log(pkg.version);\")" >> "$GITHUB_OUTPUT"
49+
50+
- name: Check runtime package publish state
51+
id: runtime_publish_state
52+
run: |
53+
if npm view "@aitoearn/openclaw-plugin@${{ steps.versions.outputs.runtime_version }}" version >/dev/null 2>&1; then
54+
echo "should_publish=false" >> "$GITHUB_OUTPUT"
55+
else
56+
echo "should_publish=true" >> "$GITHUB_OUTPUT"
57+
fi
58+
59+
- name: Check installer package publish state
60+
id: installer_publish_state
61+
run: |
62+
if npm view "@aitoearn/aitoearn-openclaw-cli@${{ steps.versions.outputs.installer_version }}" version >/dev/null 2>&1; then
63+
echo "should_publish=false" >> "$GITHUB_OUTPUT"
64+
else
65+
echo "should_publish=true" >> "$GITHUB_OUTPUT"
66+
fi
67+
68+
- name: Publish runtime package
69+
if: steps.runtime_publish_state.outputs.should_publish == 'true'
70+
run: npm publish --workspace @aitoearn/openclaw-plugin --provenance --access public
3371
env:
3472
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
73+
74+
- name: Publish installer package
75+
if: steps.installer_publish_state.outputs.should_publish == 'true'
76+
run: npm publish --workspace @aitoearn/aitoearn-openclaw-cli --provenance --access public
77+
env:
78+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
79+
80+
- name: Report skipped packages
81+
run: |
82+
if [ "${{ steps.runtime_publish_state.outputs.should_publish }}" != "true" ]; then
83+
echo "Runtime package @aitoearn/openclaw-plugin@${{ steps.versions.outputs.runtime_version }} is already published; skipping."
84+
fi
85+
if [ "${{ steps.installer_publish_state.outputs.should_publish }}" != "true" ]; then
86+
echo "Installer package @aitoearn/aitoearn-openclaw-cli@${{ steps.versions.outputs.installer_version }} is already published; skipping."
87+
fi

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
node_modules/
22
dist/
3+
packages/*/dist/
4+
*.tgz
35
*.openapi.yaml
6+
docs/
47
.claude/
5-
.idea
8+
.idea/

README.md

Lines changed: 8 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,14 @@
1-
# AiToEarn OpenClaw Plugin
1+
# AiToEarn OpenClaw Monorepo
22

3-
AiToEarn 社交媒体管理工具的 OpenClaw 插件。
3+
这个仓库现在拆成三个部分:
44

5-
## 一键安装
5+
- `packages/runtime`:真正发布给 OpenClaw 的运行时插件包 `@aitoearn/openclaw-plugin`
6+
- `packages/installer`:负责 `npx` 安装与配置引导的 CLI 包 `@aitoearn/aitoearn-openclaw-cli`
7+
- `packages/shared`:内部共享的 setup / config / MCP 客户端逻辑,不单独发布
68

7-
```bash
8-
npx -y @aitoearn/openclaw-plugin
9-
```
10-
11-
这个命令会自动:
12-
13-
1. 将当前插件包安装到 OpenClaw 的扩展目录
14-
2. 自动检测是否为已有安装
15-
3. 首次安装时引导输入 API Key 和环境
16-
4. 验证连通性
17-
5. 写入 `plugins.entries.aitoearn.config`
18-
19-
## 手动配置
20-
21-
```bash
22-
openclaw config set plugins.entries.aitoearn.enabled true --strict-json
23-
openclaw config set plugins.entries.aitoearn.config.apiKey "your-api-key"
24-
openclaw config set plugins.entries.aitoearn.config.baseUrl "https://aitoearn.ai/api"
25-
```
26-
27-
如果你想使用 SecretRef,也可以改成 OpenClaw 标准写法,例如:
28-
29-
```bash
30-
openclaw config set plugins.entries.aitoearn.config.apiKey \
31-
--ref-provider default \
32-
--ref-source env \
33-
--ref-id AITOEARN_API_KEY
34-
```
35-
36-
## 获取 API Key
37-
38-
1. 打开 [aitoearn.ai](https://aitoearn.ai/)(国际)或 [aitoearn.cn](https://aitoearn.cn/)(中国)
39-
2. 注册并登录
40-
3. 点击左侧菜单 **设置**
41-
4.**API Key** 中点击创建,复制生成的 Key
42-
43-
如果你的 npm 版本会在首次执行时提示确认安装包,统一使用:
9+
常用命令:
4410

4511
```bash
46-
npx -y @aitoearn/openclaw-plugin
12+
npm test
13+
npm run build
4714
```
48-
49-
升级插件:
50-
51-
```bash
52-
npx -y @aitoearn/openclaw-plugin upgrade
53-
```
54-
55-
再次执行默认命令时,如果检测到已有 `aitoearn` 配置,会自动按升级处理并跳过 setup。
56-
57-
完成配置后,重启 Gateway:
58-
59-
```bash
60-
openclaw gateway restart
61-
```
62-
63-
插件会根据 `baseUrl` 自动判定环境并注入本地环境工具:
64-
65-
- `*.aitoearn.cn` => `China`
66-
- `*.aitoearn.ai` => `Global`
67-
- 其他域名 => `self-hosted`
68-
69-
启动后会注册 `getAiToEarnEnvironment`,并且只注册当前环境允许的 `publishPostTo*`
70-
71-
## MCP Tools 同步
72-
73-
插件会在 Gateway 启动时自动从 AiToEarn MCP 拉取最新 tools,并缓存到 OpenClaw state dir。
74-
75-
- AiToEarn 新增或调整 tools 后,不需要升级这个插件包
76-
- 只需要重启 Gateway,让插件在启动时重新同步
77-
- 如果启动时远端暂时不可用,插件会优先回退到上一次成功同步的本地快照

package-lock.json

Lines changed: 58 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,18 @@
11
{
2-
"name": "@aitoearn/openclaw-plugin",
2+
"name": "aitoearn-openclaw-workspace",
3+
"private": true,
34
"version": "1.0.8",
45
"type": "module",
5-
"main": "./dist/index.js",
6-
"types": "./dist/index.d.ts",
7-
"bin": {
8-
"openclaw-plugin": "dist/src/cli.js"
9-
},
10-
"files": [
11-
"dist",
12-
"skills",
13-
"openclaw.plugin.json",
14-
"README.md",
15-
"package.json"
6+
"workspaces": [
7+
"packages/shared",
8+
"packages/runtime",
9+
"packages/installer"
1610
],
17-
"openclaw": {
18-
"extensions": [
19-
"./dist/index.js"
20-
],
21-
"install": {
22-
"npmSpec": "@aitoearn/openclaw-plugin",
23-
"defaultChoice": "npm"
24-
},
25-
"compat": {
26-
"pluginApi": ">=2026.3.24"
27-
},
28-
"build": {
29-
"openclawVersion": ">=2026.3.24"
30-
}
31-
},
32-
"repository": {
33-
"type": "git",
34-
"url": "git+https://github.com/yikart/aitoearn-openclaw-plugin.git"
35-
},
3611
"scripts": {
37-
"prebuild": "node --input-type=module -e \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true });\"",
38-
"build": "tsc -p tsconfig.build.json",
39-
"dev": "tsc -p tsconfig.build.json --watch",
40-
"prepack": "npm run build",
41-
"test": "vitest"
42-
},
43-
"dependencies": {
44-
"@clack/prompts": "^1.1.0",
45-
"@modelcontextprotocol/sdk": "^1.12.0",
46-
"@sinclair/typebox": "^0.34.0",
47-
"json5": "^2.2.3",
48-
"openclaw": ">=2026.3.24",
49-
"zod": "^3.24.0"
12+
"verify:versions": "node ./scripts/check-workspace-versions.mjs",
13+
"build": "npm run verify:versions && npm run build --workspaces --if-present",
14+
"test": "npm run verify:versions && npm run test --workspaces --if-present",
15+
"pack:check": "npm run verify:versions && npm pack --dry-run --workspace @aitoearn/openclaw-plugin && npm pack --dry-run --workspace @aitoearn/aitoearn-openclaw-cli"
5016
},
5117
"devDependencies": {
5218
"typescript": "^5.4.0",

packages/installer/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# AiToEarn OpenClaw Installer
2+
3+
用这个包提供 `npx` 安装体验:
4+
5+
```bash
6+
npx -y @aitoearn/aitoearn-openclaw-cli
7+
```
8+
9+
升级已通过 npm 安装的 AiToEarn OpenClaw 插件:
10+
11+
```bash
12+
npx -y @aitoearn/aitoearn-openclaw-cli upgrade
13+
```
14+
15+
运行时插件包是 `@aitoearn/openclaw-plugin`,安装与更新由宿主 `openclaw plugins install/update` 完成。

packages/installer/package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@aitoearn/aitoearn-openclaw-cli",
3+
"version": "1.0.8",
4+
"type": "module",
5+
"main": "./dist/installer/src/cli.js",
6+
"types": "./dist/installer/src/cli.d.ts",
7+
"bin": {
8+
"aitoearn-openclaw": "dist/installer/src/cli.js"
9+
},
10+
"files": [
11+
"dist",
12+
"README.md",
13+
"package.json"
14+
],
15+
"repository": {
16+
"type": "git",
17+
"url": "git+https://github.com/yikart/aitoearn-openclaw-plugin.git"
18+
},
19+
"scripts": {
20+
"prebuild": "node --input-type=module -e \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true });\"",
21+
"build": "tsc -p tsconfig.json",
22+
"prepack": "npm run build",
23+
"test": "vitest run --config ../../vitest.config.ts"
24+
},
25+
"dependencies": {
26+
"@clack/prompts": "^1.1.0",
27+
"@modelcontextprotocol/sdk": "^1.12.0",
28+
"json5": "^2.2.3",
29+
"openclaw": ">=2026.3.24",
30+
"zod": "^3.24.0"
31+
}
32+
}

0 commit comments

Comments
 (0)