tolingcode 2026.3.92 → 2026.3.811

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 CHANGED
@@ -1,300 +1,134 @@
1
1
  <p align="center">
2
- <img src="https://raw.githubusercontent.com/tolingcode/tolingcode/main/docs/logo.png" alt="TolingCode Logo">
2
+ <img src="https://raw.githubusercontent.com/tolingcode/tolingcode/main/docs/logo.png" width="120" alt="TolingCode Logo">
3
3
  </p>
4
- ![TolingCode Banner](https://raw.githubusercontent.com/tolingcode/tolingcode/main/docs/banner.png)
5
-
6
-
7
-
4
+ ![Banner](https://raw.githubusercontent.com/tolingcode/tolingcode/main/docs/banner.png)
8
5
  ![npm](https://img.shields.io/npm/v/tolingcode)
9
6
  ![downloads](https://img.shields.io/npm/dm/tolingcode)
10
7
  ![license](https://img.shields.io/badge/license-MIT-green)
11
- ![node](https://img.shields.io/badge/node-%3E=18-blue)
12
- ![platform](https://img.shields.io/badge/platform-cross--border-orange)
13
-
14
-
15
8
 
16
9
  # TolingCode CLI
17
10
 
18
- **TolingCode** 是一款可在个人设备上运行的 **跨境电商私人人工智能助手**。
19
-
20
- 它为跨境卖家和企业提供 **本地化 AI
21
- 自动化能力**,支持订单履约、库存管理、产品刊登、广告管理、数据分析等核心业务。
22
-
23
- 同时 **tolingcode skill 库** 可以兼容 **OpenClaw AI
24
- Agent**,用于构建跨境企业 **AI 数字员工**。
11
+ **跨境电商私人 AI 助手** - 在个人设备上运行的本地化 AI 自动化工具 , tolingcode Skills完全兼容openclaw。
25
12
 
26
- ------------------------------------------------------------------------
13
+ 为跨境卖家提供订单履约、库存管理、产品刊登、广告管理、数据分析等核心业务能力。
27
14
 
28
- # 核心特点
15
+ ---
29
16
 
30
- 特性 说明
31
- ------------ -------------------------------
32
- 本地运行 AI 在个人设备运行,不依赖云端
33
- 永不离线 本地模型可持续运行
34
- 响应迅速 避免云端延迟
35
- 数据本地化 API 数据可同步到本地数据库
36
- AI 员工 自动执行跨境电商任务
37
- Skill 生态 支持安装技能扩展能力
17
+ ## 安装
38
18
 
39
- ------------------------------------------------------------------------
40
-
41
- # 安装
42
-
43
- ``` bash
44
- 当前最新版本:2026.03.08
45
-
46
- 安装最新版本
19
+ ```bash
20
+ # 安装最新版本
47
21
  npm install -g tolingcode@latest
48
22
 
49
- 安装指定版本
50
- npm install -g tolingcode@2026.03.06
23
+ # 安装指定版本
24
+ npm install -g tolingcode@2026.03.09
51
25
  ```
52
- ------------------------------------------------------------------------
53
-
54
- # 核心能力
55
-
56
- ## 电商平台技能
57
-
58
- 功能 描述
59
- ---------- ------------------
60
- 订单履约 自动处理订单发货
61
- 智能备货 AI 预测库存
62
- 发票确认 自动核对发票
63
- 发货确认 同步物流信息
64
- 订单获取 拉取平台订单
65
- 库存编辑 修改库存
66
- 产品上架 自动发布商品
67
- 价格管理 修改产品价格
68
- 广告管理 自动调整广告
69
- 数据分析 获取平台报告
70
26
 
71
- ------------------------------------------------------------------------
27
+ **当前版本**: 2026.03.09
72
28
 
73
- ## 海外仓技能
29
+ ---
74
30
 
75
- 功能 描述
76
- ------------ -----------------
77
- 实时库存 获取仓库库存
78
- 出库单 查询出库
79
- 入库单 查询入库
80
- 创建出库单 创建订单出库
81
- LTL 出运 创建 LTL 运输单
82
- 运费查询 获取物流费用
31
+ ## 使用
83
32
 
84
- ------------------------------------------------------------------------
33
+ ### 安装技能 (Skill)
85
34
 
86
- ## 物流技能
87
-
88
- 功能
89
- ----------
90
- 物流报价
91
- 创建面单
92
- 物流跟踪
93
-
94
- 支持物流:
95
-
96
- - FedEx
97
- - UPS
98
- - DHL
99
- - Amazon Logistics
100
- - ITTRACK
101
-
102
-
103
- ------------------------------------------------------------------------
104
-
105
- # 使用
106
-
107
- ## 安装技能 (Skill)
108
-
109
- 安装最新版本
110
-
111
- ``` bash
35
+ ```bash
36
+ # 安装技能
112
37
  tolingcode install skills weather
113
- ```
114
-
115
- 安装指定版本
116
38
 
117
- ``` bash
118
- tolingcode install skills weather -v 2026.03.06
39
+ # 安装指定版本
40
+ tolingcode install skills weather -v 2026.03.08
119
41
  ```
120
42
 
121
- ------------------------------------------------------------------------
43
+ ### 安装应用 (App)
122
44
 
123
- ## 安装应用 (App)
124
-
125
- 安装到当前目录
126
-
127
- ``` bash
45
+ ```bash
46
+ # 安装到当前目录
128
47
  tolingcode install apps myapp
129
- ```
130
48
 
131
- 全局安装
132
-
133
- ``` bash
49
+ # 全局安装
134
50
  tolingcode install apps myapp -g
135
51
  ```
136
52
 
137
- ------------------------------------------------------------------------
138
-
139
- ## 查看可用包
140
-
141
- 列出所有包
53
+ ### 查看和搜索
142
54
 
143
- ``` bash
55
+ ```bash
56
+ # 列出所有包
144
57
  tolingcode list
145
- ```
146
-
147
- 只列出技能
148
58
 
149
- ``` bash
59
+ # 只列出技能
150
60
  tolingcode list skills
151
- ```
152
61
 
153
- 只列出应用
154
-
155
- ``` bash
156
- tolingcode list apps
62
+ # 搜索技能
63
+ tolingcode search weather
157
64
  ```
158
65
 
159
- ------------------------------------------------------------------------
66
+ ---
160
67
 
161
- ## 搜索技能
68
+ ## 核心能力
162
69
 
163
- ``` bash
164
- tolingcode search weather
165
- ```
166
-
167
- ------------------------------------------------------------------------
70
+ ### 电商平台技能
168
71
 
169
- # 发布技能(开发者)
72
+ | 功能 | 描述 |
73
+ |------|------|
74
+ | 订单履约 | 自动处理订单发货 |
75
+ | 智能备货 | AI 预测库存 |
76
+ | 产品上架 | 自动发布商品 |
77
+ | 价格管理 | 修改产品价格 |
78
+ | 广告管理 | 自动调整广告 |
79
+ | 数据分析 | 获取平台报告 |
170
80
 
171
- ``` bash
172
- tolingcode publish ./my-skill \
173
- --type skills \
174
- --name my-skill \
175
- --version 2026.03.06
176
- ```
81
+ ### 海外仓技能
177
82
 
178
- ------------------------------------------------------------------------
83
+ | 功能 | 描述 |
84
+ |------|------|
85
+ | 实时库存 | 获取仓库库存 |
86
+ | 出入库单 | 查询入库/出库 |
87
+ | 创建出库单 | 创建订单出库 |
88
+ | LTL 出运 | 创建 LTL 运输单 |
89
+ | 运费查询 | 获取物流费用 |
179
90
 
180
- # 版本规范
91
+ ### 物流技能
181
92
 
182
- 推荐使用 **日期版本号**
93
+ - 物流报价、创建面单、物流跟踪
94
+ - 支持:FedEx、UPS、DHL、Amazon Logistics、ITTRACK
183
95
 
184
- YYYY.MM.DD
96
+ ---
185
97
 
186
- 示例
98
+ ## 发布技能 (开发者)
187
99
 
188
- 版本 含义
189
- ------------ ------------------
190
- 2026.03.06 2026年3月6日版本
191
- latest 最新版本
100
+ ```bash
101
+ tolingcode publish ./my-skill \
102
+ --type skills \
103
+ --name my-skill \
104
+ --version 2026.03.09
105
+ ```
192
106
 
193
- ------------------------------------------------------------------------
107
+ ### 版本规范
194
108
 
195
- # 环境变量
109
+ 使用日期版本号:`YYYY.MM.DD`
196
110
 
197
- 自定义 registry
111
+ ---
198
112
 
199
- ``` bash
200
- export TOLINGCODE_REGISTRY=https://toling.me/api/registry
201
- ```
113
+ ## 支持平台
202
114
 
203
- 自定义 workspace
115
+ **电商平台**: Amazon、eBay、AliExpress、Wish、Shopee、Lazada、Mercado Libre、Etsy、Wayfair、TikTok Shop 等
204
116
 
205
- ``` bash
206
- export OPENCLAW_WORKSPACE=/path/to/workspace
207
- ```
117
+ **独立站**: Shopify、WooCommerce、Magento、BigCommerce
208
118
 
209
- ------------------------------------------------------------------------
119
+ **零售平台**: Walmart、Target、Costco、Best Buy 等
210
120
 
211
- # 开发
121
+ **海外仓**: 支持 100+ 海外仓系统 (中通国际、Walmart WFS、马士基、RMS 红鼠等)
212
122
 
213
- 本地调试 CLI
123
+ ---
214
124
 
215
- ``` bash
216
- cd tolingcode
217
- npm link
218
- tolingcode --help
219
- ```
125
+ ## 相关链接
220
126
 
221
- 发布 npm
127
+ - **Registry**: https://toling.me
128
+ - **GitHub**: https://github.com/tolingcode/tolingcode
129
+ - **问题反馈**: GitHub Issues
222
130
 
223
- ``` bash
224
- npm version patch
225
- npm publish
226
- ```
131
+ ---
227
132
 
228
- ------------------------------------------------------------------------
229
-
230
- # 项目结构
231
-
232
- tolingcode
233
-
234
- ├── bin
235
- │ └── tolingcode.js
236
-
237
- ├── docs
238
- │ └── SERVER.md
239
-
240
- ├── server
241
- │ └── registry.js
242
-
243
- ├── scripts
244
- │ └── publish-skill.ps1
245
-
246
- ├── package.json
247
- └── README.md
248
-
249
- ------------------------------------------------------------------------
250
-
251
- ## 主流电商平台
252
-
253
- 平台
254
- ---------------
255
- Amazon
256
- eBay
257
- AliExpress
258
- Wish
259
- Shopee
260
- Lazada
261
- Mercado Libre
262
- Etsy
263
- Wayfair
264
- Newegg
265
- Temu
266
- Shein
267
- TikTok Shop
268
- Shopify
269
- Walmart
270
- Target
271
- Costco
272
- Best Buy
273
- Home Depot
274
- Lowe's
275
-
276
- ------------------------------------------------------------------------
277
-
278
- ## 支持 100+ :CG仓、FBA仓
279
-
280
- ------------------------------------------------------------------------
281
-
282
- # 相关链接
283
-
284
- 项目 地址
285
- ---------- -------------------
286
- Registry https://toling.me
287
- 源代码 GitHub (待添加)
288
- 问题反馈 GitHub Issues
289
-
290
- ------------------------------------------------------------------------
291
-
292
- # 作者
293
-
294
- **韩宝军 (TolingCode)**
295
-
296
- ------------------------------------------------------------------------
297
-
298
- # License
299
-
300
- MIT License
133
+ **作者**: 韩宝军 (TolingCode)
134
+ **License**: MIT
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "tolingcode",
3
- "version": "2026.03.92",
3
+ "version": "2026.03.811",
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
@@ -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"
@@ -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
- });