tolingcode 2026.3.93 → 2026.3.812

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