tolingcode 1.0.4 → 2026.3.8-1
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/README.md +80 -52
- package/docs/banner.png +0 -0
- package/docs/logo.png +0 -0
- package/package.json +6 -1
- package/QUICKSTART.md +0 -196
- package/scripts/publish-skill.ps1 +0 -74
- package/scripts/publish.bat +0 -30
- package/server/registry.js +0 -220
package/README.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/tolingcode/tolingcode/main/docs/logo.png" width="120" alt="TolingCode Logo">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
1
9
|
# TolingCode CLI
|
|
2
10
|
|
|
3
|
-
|
|
11
|
+
**跨境电商私人 AI 助手** - 在个人设备上运行的本地化 AI 自动化工具
|
|
12
|
+
|
|
13
|
+
为跨境卖家提供订单履约、库存管理、产品刊登、广告管理、数据分析等核心业务能力。
|
|
14
|
+
|
|
15
|
+
---
|
|
4
16
|
|
|
5
17
|
## 安装
|
|
6
18
|
|
|
@@ -9,22 +21,26 @@
|
|
|
9
21
|
npm install -g tolingcode@latest
|
|
10
22
|
|
|
11
23
|
# 安装指定版本
|
|
12
|
-
npm install -g tolingcode@2026.
|
|
24
|
+
npm install -g tolingcode@2026.03.09
|
|
13
25
|
```
|
|
14
26
|
|
|
27
|
+
**当前版本**: 2026.03.09
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
15
31
|
## 使用
|
|
16
32
|
|
|
17
|
-
###
|
|
33
|
+
### 安装技能 (Skill)
|
|
18
34
|
|
|
19
35
|
```bash
|
|
20
|
-
#
|
|
36
|
+
# 安装技能
|
|
21
37
|
tolingcode install skills weather
|
|
22
38
|
|
|
23
39
|
# 安装指定版本
|
|
24
|
-
tolingcode install skills weather -v 2026.03.
|
|
40
|
+
tolingcode install skills weather -v 2026.03.08
|
|
25
41
|
```
|
|
26
42
|
|
|
27
|
-
###
|
|
43
|
+
### 安装应用 (App)
|
|
28
44
|
|
|
29
45
|
```bash
|
|
30
46
|
# 安装到当前目录
|
|
@@ -34,73 +50,85 @@ tolingcode install apps myapp
|
|
|
34
50
|
tolingcode install apps myapp -g
|
|
35
51
|
```
|
|
36
52
|
|
|
37
|
-
###
|
|
53
|
+
### 查看和搜索
|
|
38
54
|
|
|
39
55
|
```bash
|
|
40
|
-
#
|
|
56
|
+
# 列出所有包
|
|
41
57
|
tolingcode list
|
|
42
58
|
|
|
43
|
-
#
|
|
59
|
+
# 只列出技能
|
|
44
60
|
tolingcode list skills
|
|
45
61
|
|
|
46
|
-
#
|
|
47
|
-
tolingcode
|
|
62
|
+
# 搜索技能
|
|
63
|
+
tolingcode search weather
|
|
48
64
|
```
|
|
49
65
|
|
|
50
|
-
|
|
66
|
+
---
|
|
51
67
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
## 核心能力
|
|
69
|
+
|
|
70
|
+
### 电商平台技能
|
|
71
|
+
|
|
72
|
+
| 功能 | 描述 |
|
|
73
|
+
|------|------|
|
|
74
|
+
| 订单履约 | 自动处理订单发货 |
|
|
75
|
+
| 智能备货 | AI 预测库存 |
|
|
76
|
+
| 产品上架 | 自动发布商品 |
|
|
77
|
+
| 价格管理 | 修改产品价格 |
|
|
78
|
+
| 广告管理 | 自动调整广告 |
|
|
79
|
+
| 数据分析 | 获取平台报告 |
|
|
55
80
|
|
|
56
|
-
###
|
|
81
|
+
### 海外仓技能
|
|
82
|
+
|
|
83
|
+
| 功能 | 描述 |
|
|
84
|
+
|------|------|
|
|
85
|
+
| 实时库存 | 获取仓库库存 |
|
|
86
|
+
| 出入库单 | 查询入库/出库 |
|
|
87
|
+
| 创建出库单 | 创建订单出库 |
|
|
88
|
+
| LTL 出运 | 创建 LTL 运输单 |
|
|
89
|
+
| 运费查询 | 获取物流费用 |
|
|
90
|
+
|
|
91
|
+
### 物流技能
|
|
92
|
+
|
|
93
|
+
- 物流报价、创建面单、物流跟踪
|
|
94
|
+
- 支持:FedEx、UPS、DHL、Amazon Logistics、ITTRACK
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 发布技能 (开发者)
|
|
57
99
|
|
|
58
100
|
```bash
|
|
59
|
-
tolingcode publish ./my-skill
|
|
101
|
+
tolingcode publish ./my-skill \
|
|
102
|
+
--type skills \
|
|
103
|
+
--name my-skill \
|
|
104
|
+
--version 2026.03.09
|
|
60
105
|
```
|
|
61
106
|
|
|
62
|
-
|
|
107
|
+
### 版本规范
|
|
63
108
|
|
|
64
|
-
|
|
109
|
+
使用日期版本号:`YYYY.MM.DD`
|
|
65
110
|
|
|
66
|
-
|
|
67
|
-
- `latest` - 最新版本
|
|
111
|
+
---
|
|
68
112
|
|
|
69
|
-
##
|
|
113
|
+
## 支持平台
|
|
70
114
|
|
|
71
|
-
|
|
72
|
-
# 自定义 registry 地址(默认:https://toling.me/api/registry)
|
|
73
|
-
export TOLINGCODE_REGISTRY=https://registry.toling.me/api/registry
|
|
115
|
+
**电商平台**: Amazon、eBay、AliExpress、Wish、Shopee、Lazada、Mercado Libre、Etsy、Wayfair、TikTok Shop 等
|
|
74
116
|
|
|
75
|
-
|
|
76
|
-
export OPENCLAW_WORKSPACE=/path/to/workspace
|
|
77
|
-
```
|
|
117
|
+
**独立站**: Shopify、WooCommerce、Magento、BigCommerce
|
|
78
118
|
|
|
79
|
-
|
|
119
|
+
**零售平台**: Walmart、Target、Costco、Best Buy 等
|
|
80
120
|
|
|
81
|
-
|
|
82
|
-
# 本地测试
|
|
83
|
-
cd tolingcode
|
|
84
|
-
npm link
|
|
85
|
-
tolingcode --help
|
|
86
|
-
|
|
87
|
-
# 发布到 npm
|
|
88
|
-
npm version patch # 或 minor/major
|
|
89
|
-
npm publish
|
|
90
|
-
```
|
|
121
|
+
**海外仓**: 支持 100+ 海外仓系统 (中通国际、Walmart WFS、马士基、RMS 红鼠等)
|
|
91
122
|
|
|
92
|
-
|
|
123
|
+
---
|
|
93
124
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
└── README.md
|
|
102
|
-
```
|
|
125
|
+
## 相关链接
|
|
126
|
+
|
|
127
|
+
- **Registry**: https://toling.me
|
|
128
|
+
- **GitHub**: https://github.com/tolingcode/tolingcode
|
|
129
|
+
- **问题反馈**: GitHub Issues
|
|
130
|
+
|
|
131
|
+
---
|
|
103
132
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
MIT
|
|
133
|
+
**作者**: 韩宝军 (TolingCode)
|
|
134
|
+
**License**: MIT
|
package/docs/banner.png
ADDED
|
Binary file
|
package/docs/logo.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tolingcode",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2026.03.08-1",
|
|
4
4
|
"description": "TolingCode CLI - Install skills and apps from toling.me",
|
|
5
5
|
"main": "bin/tolingcode.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"bin",
|
|
8
|
+
"docs",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
6
11
|
"bin": {
|
|
7
12
|
"tolingcode": "bin/tolingcode.js",
|
|
8
13
|
"tlc": "bin/tolingcode.js"
|
package/QUICKSTART.md
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
# TolingCode 快速开始指南
|
|
2
|
-
|
|
3
|
-
## 🎯 目标
|
|
4
|
-
|
|
5
|
-
创建一个类似 `clawhub` 的 CLI 工具,通过 `toling.me` 托管和分发 skills 和 apps。
|
|
6
|
-
|
|
7
|
-
## 📦 使用流程
|
|
8
|
-
|
|
9
|
-
### 1. 用户安装 CLI
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install -g tolingcode@latest
|
|
13
|
-
# 或指定版本
|
|
14
|
-
npm install -g tolingcode@2026.03.06
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### 2. 用户安装 Skill
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
tolingcode install skills weather
|
|
21
|
-
tolingcode install skills weather -v 2026.03.06
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### 3. 开发者发布 Skill
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
# 方法 1: 使用 publish 命令(需要 API 支持)
|
|
28
|
-
tolingcode publish ./my-skill --type skills --name my-skill --version 2026.03.06
|
|
29
|
-
|
|
30
|
-
# 方法 2: 手动上传
|
|
31
|
-
tar -czf my-skill-2026.03.06.tar.gz -C ./my-skill .
|
|
32
|
-
scp my-skill-2026.03.06.tar.gz user@toling.me:/var/www/toling.me/packages/skills/
|
|
33
|
-
# 然后更新 registry.json
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## 🚀 部署步骤
|
|
37
|
-
|
|
38
|
-
### 第一步:准备 toling.me 服务器
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
# SSH 登录服务器
|
|
42
|
-
ssh user@toling.me
|
|
43
|
-
|
|
44
|
-
# 创建目录
|
|
45
|
-
sudo mkdir -p /var/www/toling.me/{packages/skills,packages/apps,api}
|
|
46
|
-
sudo chown -R $USER:$USER /var/www/toling.me
|
|
47
|
-
|
|
48
|
-
# 安装 Node.js (如果没有)
|
|
49
|
-
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
|
|
50
|
-
sudo apt-get install -y nodejs
|
|
51
|
-
|
|
52
|
-
# 安装依赖
|
|
53
|
-
cd /var/www/toling.me/api
|
|
54
|
-
npm init -y
|
|
55
|
-
npm install express multer
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### 第二步:部署服务端代码
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
# 上传 registry.js 到服务器
|
|
62
|
-
scp registry.js user@toling.me:/var/www/toling.me/api/
|
|
63
|
-
|
|
64
|
-
# 创建 systemd 服务
|
|
65
|
-
sudo tee /etc/systemd/system/tolingcode-registry.service > /dev/null <<EOF
|
|
66
|
-
[Unit]
|
|
67
|
-
Description=TolingCode Registry Server
|
|
68
|
-
After=network.target
|
|
69
|
-
|
|
70
|
-
[Service]
|
|
71
|
-
Type=simple
|
|
72
|
-
User=www-data
|
|
73
|
-
WorkingDirectory=/var/www/toling.me/api
|
|
74
|
-
ExecStart=/usr/bin/node registry.js
|
|
75
|
-
Restart=on-failure
|
|
76
|
-
|
|
77
|
-
[Install]
|
|
78
|
-
WantedBy=multi-user.target
|
|
79
|
-
EOF
|
|
80
|
-
|
|
81
|
-
# 启动服务
|
|
82
|
-
sudo systemctl daemon-reload
|
|
83
|
-
sudo systemctl enable tolingcode-registry
|
|
84
|
-
sudo systemctl start tolingcode-registry
|
|
85
|
-
sudo systemctl status tolingcode-registry
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### 第三步:配置 Nginx
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# 编辑 Nginx 配置
|
|
92
|
-
sudo nano /etc/nginx/sites-available/toling.me
|
|
93
|
-
|
|
94
|
-
# 添加以下内容:
|
|
95
|
-
server {
|
|
96
|
-
listen 443 ssl;
|
|
97
|
-
server_name toling.me;
|
|
98
|
-
|
|
99
|
-
ssl_certificate /etc/letsencrypt/live/toling.me/fullchain.pem;
|
|
100
|
-
ssl_certificate_key /etc/letsencrypt/live/toling.me/privkey.pem;
|
|
101
|
-
|
|
102
|
-
root /var/www/toling.me;
|
|
103
|
-
|
|
104
|
-
# API
|
|
105
|
-
location /api/ {
|
|
106
|
-
proxy_pass http://localhost:3000;
|
|
107
|
-
proxy_set_header Host $host;
|
|
108
|
-
proxy_set_header X-Real-IP $remote_addr;
|
|
109
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
# Packages
|
|
113
|
-
location /packages/ {
|
|
114
|
-
alias /var/www/toling.me/packages/;
|
|
115
|
-
autoindex on;
|
|
116
|
-
add_header Content-Type application/octet-stream;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
# 测试并重载
|
|
121
|
-
sudo nginx -t
|
|
122
|
-
sudo systemctl reload nginx
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### 第四步:发布 CLI 到 npm
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
# 在本地开发机器上
|
|
129
|
-
cd tolingcode
|
|
130
|
-
|
|
131
|
-
# 登录 npm
|
|
132
|
-
npm login
|
|
133
|
-
|
|
134
|
-
# 发布
|
|
135
|
-
npm version 1.0.0
|
|
136
|
-
npm publish
|
|
137
|
-
|
|
138
|
-
# 验证
|
|
139
|
-
npm view tolingcode
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### 第五步:发布第一个 Skill
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
# 创建测试 skill
|
|
146
|
-
mkdir -p test-skill
|
|
147
|
-
echo '{"name": "test", "description": "Test skill"}' > test-skill/SKILL.md
|
|
148
|
-
|
|
149
|
-
# 发布
|
|
150
|
-
cd tolingcode
|
|
151
|
-
node bin/tolingcode.js publish ../test-skill --type skills --name test-skill --version 2026.03.06
|
|
152
|
-
|
|
153
|
-
# 或者手动上传
|
|
154
|
-
tar -czf test-skill-2026.03.06.tar.gz -C ../test-skill .
|
|
155
|
-
scp test-skill-2026.03.06.tar.gz user@toling.me:/var/www/toling.me/packages/skills/
|
|
156
|
-
|
|
157
|
-
# 更新 registry.json (SSH 到服务器编辑)
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## ✅ 测试
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
# 安装 CLI
|
|
164
|
-
npm install -g tolingcode@latest
|
|
165
|
-
|
|
166
|
-
# 列出可用技能
|
|
167
|
-
tolingcode list skills
|
|
168
|
-
|
|
169
|
-
# 安装技能
|
|
170
|
-
tolingcode install skills test-skill
|
|
171
|
-
|
|
172
|
-
# 验证安装
|
|
173
|
-
ls ~/.openclaw/workspace/skills/
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## 📝 注意事项
|
|
177
|
-
|
|
178
|
-
1. **版本命名**: 使用 `YYYY.MM.DD` 格式,便于追踪发布日期
|
|
179
|
-
2. **认证**: 生产环境需要添加 API 认证(API Key 或 JWT)
|
|
180
|
-
3. **HTTPS**: 确保 toling.me 配置了 SSL 证书
|
|
181
|
-
4. **备份**: 定期备份 registry.json 和 packages 目录
|
|
182
|
-
5. **监控**: 添加日志和监控,跟踪下载量和错误
|
|
183
|
-
|
|
184
|
-
## 🔧 后续扩展
|
|
185
|
-
|
|
186
|
-
- [ ] 添加用户认证系统
|
|
187
|
-
- [ ] 支持私有包(需要 token)
|
|
188
|
-
- [ ] 添加下载统计
|
|
189
|
-
- [ ] Web 管理界面
|
|
190
|
-
- [ ] 自动版本递增
|
|
191
|
-
- [ ] 依赖管理
|
|
192
|
-
- [ ] 包签名验证
|
|
193
|
-
|
|
194
|
-
---
|
|
195
|
-
|
|
196
|
-
有问题?查看 `docs/SERVER.md` 获取详细服务端文档。
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env pwsh
|
|
2
|
-
# TolingCode Skill Publish Script (PowerShell)
|
|
3
|
-
# Usage: .\publish-skill.ps1 <skill-name> [version]
|
|
4
|
-
|
|
5
|
-
param(
|
|
6
|
-
[Parameter(Mandatory=$true)]
|
|
7
|
-
[string]$SkillName,
|
|
8
|
-
|
|
9
|
-
[string]$Version = (Get-Date -Format "yyyy.MM.dd"),
|
|
10
|
-
|
|
11
|
-
[string]$ServerHost = "iZwz91qi4kjnj5l58gbhj5Z",
|
|
12
|
-
[string]$ServerUser = "root",
|
|
13
|
-
[string]$SkillSource = "C:\Users\Administrator\.openclaw\workspace\skills"
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
Write-Host "📦 Publishing $SkillName@$Version" -ForegroundColor Blue
|
|
17
|
-
Write-Host ""
|
|
18
|
-
|
|
19
|
-
# 1. Check source exists
|
|
20
|
-
$sourcePath = Join-Path $SkillSource $SkillName
|
|
21
|
-
if (!(Test-Path $sourcePath)) {
|
|
22
|
-
Write-Host "❌ Skill not found: $sourcePath" -ForegroundColor Red
|
|
23
|
-
exit 1
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
Write-Host "✓ Source: $sourcePath" -ForegroundColor Green
|
|
27
|
-
|
|
28
|
-
# 2. Create tar.gz
|
|
29
|
-
$tarFile = "$SkillName-$Version.tar.gz"
|
|
30
|
-
Write-Host "📦 Creating $tarFile..." -ForegroundColor Yellow
|
|
31
|
-
tar -czf $tarFile -C $SkillSource $SkillName
|
|
32
|
-
|
|
33
|
-
if (!(Test-Path $tarFile)) {
|
|
34
|
-
Write-Host "❌ Failed to create tarball" -ForegroundColor Red
|
|
35
|
-
exit 1
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
Write-Host "✓ Created: $tarFile ($(Get-Item $tarFile).Length bytes)" -ForegroundColor Green
|
|
39
|
-
|
|
40
|
-
# 3. Upload to server
|
|
41
|
-
Write-Host "📤 Uploading to server..." -ForegroundColor Yellow
|
|
42
|
-
scp $tarFile "${ServerUser}@${ServerHost}:/var/www/toling.me/packages/skills/"
|
|
43
|
-
|
|
44
|
-
if ($LASTEXITCODE -ne 0) {
|
|
45
|
-
Write-Host "❌ Upload failed" -ForegroundColor Red
|
|
46
|
-
exit 1
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
Write-Host "✓ Uploaded to /var/www/toling.me/packages/skills/" -ForegroundColor Green
|
|
50
|
-
Write-Host ""
|
|
51
|
-
Write-Host "📝 Next step: Update registry.json on server" -ForegroundColor Yellow
|
|
52
|
-
Write-Host ""
|
|
53
|
-
Write-Host "SSH to server and run:" -ForegroundColor Gray
|
|
54
|
-
Write-Host @"
|
|
55
|
-
cat >> /var/www/toling.me/registry.json << 'EOF'
|
|
56
|
-
{
|
|
57
|
-
"skills": {
|
|
58
|
-
"$SkillName": {
|
|
59
|
-
"description": "$SkillName skill",
|
|
60
|
-
"latestVersion": "$Version",
|
|
61
|
-
"versions": {
|
|
62
|
-
"$Version": {
|
|
63
|
-
"publishedAt": "$(Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ")"
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
"apps": {}
|
|
69
|
-
}
|
|
70
|
-
EOF
|
|
71
|
-
"@
|
|
72
|
-
|
|
73
|
-
Write-Host ""
|
|
74
|
-
Write-Host "🎉 Done!" -ForegroundColor Green
|
package/scripts/publish.bat
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
REM TolingCode Publish Script (Windows)
|
|
3
|
-
REM Usage: publish.bat <skill-path> <name> [version]
|
|
4
|
-
|
|
5
|
-
SET SKILL_PATH=%1
|
|
6
|
-
SET NAME=%2
|
|
7
|
-
SET VERSION=%3
|
|
8
|
-
|
|
9
|
-
IF "%VERSION%"=="" (
|
|
10
|
-
REM Use today's date as version
|
|
11
|
-
FOR /F "tokens=2-4 delims=/ " %%A IN ('date /T') DO (SET VERSION=%%C.%%B.%%A)
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
ECHO Publishing %NAME%@%VERSION%...
|
|
15
|
-
|
|
16
|
-
REM Create tarball (requires tar.exe on Windows 10+)
|
|
17
|
-
tar -czf %NAME%-%VERSION%.tar.gz -C %SKILL_PATH% .
|
|
18
|
-
|
|
19
|
-
ECHO Created: %NAME%-%VERSION%.tar.gz
|
|
20
|
-
ECHO.
|
|
21
|
-
ECHO Next steps:
|
|
22
|
-
ECHO 1. Upload to toling.me: scp %NAME%-%VERSION%.tar.gz user@toling.me:/var/www/toling.me/packages/skills/
|
|
23
|
-
ECHO 2. Update registry.json on server
|
|
24
|
-
ECHO.
|
|
25
|
-
ECHO Or use the API (when implemented):
|
|
26
|
-
ECHO curl -X POST https://toling.me/api/registry/publish ^
|
|
27
|
-
ECHO -F "type=skills" ^
|
|
28
|
-
ECHO -F "name=%NAME%" ^
|
|
29
|
-
ECHO -F "version=%VERSION%" ^
|
|
30
|
-
ECHO -F "package=@%NAME%-%VERSION%.tar.gz"
|
package/server/registry.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
// TolingCode Registry Server - Simple Node.js Implementation
|
|
2
|
-
// Deploy this on toling.me
|
|
3
|
-
|
|
4
|
-
const express = require('express');
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const multer = require('multer');
|
|
8
|
-
const crypto = require('crypto');
|
|
9
|
-
|
|
10
|
-
const app = express();
|
|
11
|
-
const PORT = process.env.PORT || 3000;
|
|
12
|
-
|
|
13
|
-
// Paths
|
|
14
|
-
const BASE_DIR = process.env.REGISTRY_BASE_DIR || '/var/www/toling.me';
|
|
15
|
-
const REGISTRY_FILE = path.join(BASE_DIR, 'registry.json');
|
|
16
|
-
const PACKAGES_DIR = path.join(BASE_DIR, 'packages');
|
|
17
|
-
|
|
18
|
-
// Ensure directories exist
|
|
19
|
-
if (!fs.existsSync(PACKAGES_DIR)) {
|
|
20
|
-
fs.mkdirSync(path.join(PACKAGES_DIR, 'skills'), { recursive: true });
|
|
21
|
-
fs.mkdirSync(path.join(PACKAGES_DIR, 'apps'), { recursive: true });
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Initialize registry if not exists
|
|
25
|
-
if (!fs.existsSync(REGISTRY_FILE)) {
|
|
26
|
-
fs.writeFileSync(REGISTRY_FILE, JSON.stringify({ skills: {}, apps: {} }, null, 2));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Middleware
|
|
30
|
-
app.use(express.json());
|
|
31
|
-
const upload = multer({ dest: path.join(BASE_DIR, 'uploads') });
|
|
32
|
-
|
|
33
|
-
// Helper: Read registry
|
|
34
|
-
function getRegistry() {
|
|
35
|
-
return JSON.parse(fs.readFileSync(REGISTRY_FILE, 'utf-8'));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Helper: Write registry
|
|
39
|
-
function saveRegistry(data) {
|
|
40
|
-
fs.writeFileSync(REGISTRY_FILE, JSON.stringify(data, null, 2));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Helper: Calculate file hash
|
|
44
|
-
function hashFile(filePath) {
|
|
45
|
-
const content = fs.readFileSync(filePath);
|
|
46
|
-
return crypto.createHash('sha256').update(content).digest('hex');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// GET /api/registry/:type/:name - Get package info
|
|
50
|
-
app.get('/api/registry/:type/:name', (req, res) => {
|
|
51
|
-
const { type, name } = req.params;
|
|
52
|
-
const { version = 'latest' } = req.query;
|
|
53
|
-
|
|
54
|
-
if (!['skills', 'apps'].includes(type)) {
|
|
55
|
-
return res.status(400).json({ error: 'Invalid type. Use "skills" or "apps"' });
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const registry = getRegistry();
|
|
59
|
-
const pkg = registry[type]?.[name];
|
|
60
|
-
|
|
61
|
-
if (!pkg) {
|
|
62
|
-
return res.status(404).json({ error: `Package ${name} not found` });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const ver = version === 'latest' ? pkg.latestVersion : version;
|
|
66
|
-
const verInfo = pkg.versions?.[ver];
|
|
67
|
-
|
|
68
|
-
if (!verInfo) {
|
|
69
|
-
return res.status(404).json({ error: `Version ${ver} not found` });
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
res.json({
|
|
73
|
-
name,
|
|
74
|
-
type,
|
|
75
|
-
version: ver,
|
|
76
|
-
description: pkg.description || '',
|
|
77
|
-
downloadUrl: `https://toling.me/packages/${type}/${name}-${ver}.tar.gz`,
|
|
78
|
-
latestVersion: pkg.latestVersion,
|
|
79
|
-
versions: Object.keys(pkg.versions || {}).sort().reverse()
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// GET /api/registry/list - List all packages
|
|
84
|
-
app.get('/api/registry/list', (req, res) => {
|
|
85
|
-
const { type = 'all' } = req.query;
|
|
86
|
-
const registry = getRegistry();
|
|
87
|
-
const result = [];
|
|
88
|
-
|
|
89
|
-
const types = type === 'all' ? ['skills', 'apps'] : [type];
|
|
90
|
-
|
|
91
|
-
types.forEach(t => {
|
|
92
|
-
if (registry[t]) {
|
|
93
|
-
Object.entries(registry[t]).forEach(([name, pkg]) => {
|
|
94
|
-
result.push({
|
|
95
|
-
name,
|
|
96
|
-
type: t,
|
|
97
|
-
version: pkg.latestVersion,
|
|
98
|
-
description: pkg.description || '',
|
|
99
|
-
latestVersion: pkg.latestVersion
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
res.json(result);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// GET /api/registry/search - Search packages
|
|
109
|
-
app.get('/api/registry/search', (req, res) => {
|
|
110
|
-
const { q } = req.query;
|
|
111
|
-
if (!q) {
|
|
112
|
-
return res.status(400).json({ error: 'Query parameter "q" is required' });
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const registry = getRegistry();
|
|
116
|
-
const result = [];
|
|
117
|
-
const query = q.toLowerCase();
|
|
118
|
-
|
|
119
|
-
['skills', 'apps'].forEach(type => {
|
|
120
|
-
if (registry[type]) {
|
|
121
|
-
Object.entries(registry[type]).forEach(([name, pkg]) => {
|
|
122
|
-
if (name.toLowerCase().includes(query) ||
|
|
123
|
-
(pkg.description && pkg.description.toLowerCase().includes(query))) {
|
|
124
|
-
result.push({
|
|
125
|
-
name,
|
|
126
|
-
type,
|
|
127
|
-
version: pkg.latestVersion,
|
|
128
|
-
description: pkg.description || ''
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
res.json(result);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
// POST /api/registry/publish - Publish a package (requires auth)
|
|
139
|
-
app.post('/api/registry/publish', upload.single('package'), (req, res) => {
|
|
140
|
-
// TODO: Add authentication (API key, JWT, etc.)
|
|
141
|
-
const { type, name, version } = req.body;
|
|
142
|
-
|
|
143
|
-
if (!type || !name || !version) {
|
|
144
|
-
return res.status(400).json({ error: 'Missing required fields: type, name, version' });
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (!['skills', 'apps'].includes(type)) {
|
|
148
|
-
return res.status(400).json({ error: 'Invalid type. Use "skills" or "apps"' });
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (!req.file) {
|
|
152
|
-
return res.status(400).json({ error: 'No package file uploaded' });
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const registry = getRegistry();
|
|
156
|
-
|
|
157
|
-
// Initialize type if not exists
|
|
158
|
-
if (!registry[type]) {
|
|
159
|
-
registry[type] = {};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Initialize package if not exists
|
|
163
|
-
if (!registry[type][name]) {
|
|
164
|
-
registry[type][name] = {
|
|
165
|
-
description: req.body.description || '',
|
|
166
|
-
latestVersion: version,
|
|
167
|
-
versions: {}
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Add version
|
|
172
|
-
const fileHash = hashFile(req.file.path);
|
|
173
|
-
registry[type][name].versions[version] = {
|
|
174
|
-
publishedAt: new Date().toISOString(),
|
|
175
|
-
hash: `sha256:${fileHash}`,
|
|
176
|
-
size: req.file.size
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// Update latest version
|
|
180
|
-
registry[type][name].latestVersion = version;
|
|
181
|
-
|
|
182
|
-
// Move file to packages directory
|
|
183
|
-
const destDir = path.join(PACKAGES_DIR, type);
|
|
184
|
-
const destFile = path.join(destDir, `${name}-${version}.tar.gz`);
|
|
185
|
-
|
|
186
|
-
if (!fs.existsSync(destDir)) {
|
|
187
|
-
fs.mkdirSync(destDir, { recursive: true });
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
fs.renameSync(req.file.path, destFile);
|
|
191
|
-
|
|
192
|
-
// Save registry
|
|
193
|
-
saveRegistry(registry);
|
|
194
|
-
|
|
195
|
-
// Cleanup uploads dir
|
|
196
|
-
try {
|
|
197
|
-
fs.unlinkSync(req.file.path);
|
|
198
|
-
} catch (e) {}
|
|
199
|
-
|
|
200
|
-
res.json({
|
|
201
|
-
success: true,
|
|
202
|
-
name,
|
|
203
|
-
type,
|
|
204
|
-
version,
|
|
205
|
-
downloadUrl: `https://toling.me/packages/${type}/${name}-${version}.tar.gz`
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
// Serve static packages
|
|
210
|
-
app.use('/packages', express.static(path.join(BASE_DIR, 'packages')));
|
|
211
|
-
|
|
212
|
-
// Health check
|
|
213
|
-
app.get('/health', (req, res) => {
|
|
214
|
-
res.json({ status: 'ok', timestamp: new Date().toISOString() });
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
app.listen(PORT, () => {
|
|
218
|
-
console.log(`TolingCode Registry Server running on port ${PORT}`);
|
|
219
|
-
console.log(`Base directory: ${BASE_DIR}`);
|
|
220
|
-
});
|