@clawlabz/clawskin 1.0.0
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/CHANGELOG.md +98 -0
- package/CONTRIBUTING.md +40 -0
- package/LICENSE +21 -0
- package/README.md +137 -0
- package/docs/ARCHITECTURE.md +132 -0
- package/docs/PROGRESS.md +15 -0
- package/docs/ROADMAP.md +130 -0
- package/package.json +27 -0
- package/public/_headers +13 -0
- package/public/_redirects +1 -0
- package/public/app.html +595 -0
- package/public/css/app.css +379 -0
- package/public/css/style.css +415 -0
- package/public/index.html +324 -0
- package/public/js/app/AgentSlot.js +596 -0
- package/public/js/app/AgentStateMapper.js +213 -0
- package/public/js/app/ClawSkinApp.js +551 -0
- package/public/js/app/ConnectionPanel.js +142 -0
- package/public/js/app/DeviceIdentity.js +118 -0
- package/public/js/app/GatewayClient.js +284 -0
- package/public/js/app/SettingsManager.js +47 -0
- package/public/js/character/AnimationManager.js +69 -0
- package/public/js/character/BubbleManager.js +157 -0
- package/public/js/character/CharacterSprite.js +98 -0
- package/public/js/game.js +116 -0
- package/public/js/pets/Pet.js +303 -0
- package/public/js/pets/PetManager.js +102 -0
- package/public/js/scenes/CafeScene.js +594 -0
- package/public/js/scenes/HackerScene.js +527 -0
- package/public/js/scenes/OfficeScene.js +404 -0
- package/public/js/sprites/SpriteGenerator.js +927 -0
- package/public/js/state/AgentStateSync.js +89 -0
- package/public/js/state/DemoMode.js +65 -0
- package/public/js/ui/CharacterEditor.js +145 -0
- package/public/js/ui/ScenePicker.js +29 -0
- package/serve.cjs +132 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# ClawSkin Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.0] - 2026-03-01
|
|
4
|
+
|
|
5
|
+
### 重大更新:3/4 RPG 视角 + 移动系统重构 + 独立宠物系统
|
|
6
|
+
|
|
7
|
+
本次更新解决三个核心问题:角色被家具遮挡、移动不自然、宠物与角色绑定。
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
### 新增
|
|
12
|
+
|
|
13
|
+
- **独立宠物系统** (`js/pets/Pet.js`, `js/pets/PetManager.js`)
|
|
14
|
+
- 宠物不再绑定 Agent,拥有独立的 AI 行为循环
|
|
15
|
+
- 5 种宠物类型:猫 (walk)、狗 (walk)、机器人 (walk)、鸟 (fly)、仓鼠 (crawl)
|
|
16
|
+
- 宠物自主移动:随机漫步、找 Agent 蹭腿、找其他宠物互动、原地睡觉
|
|
17
|
+
- 鸟类飞行正弦波浮动 + 翅膀扇动动画
|
|
18
|
+
- 仓鼠偶发高速冲刺行为
|
|
19
|
+
- 宠物配置 localStorage 持久化,默认初始化猫 + 狗
|
|
20
|
+
- 支持动态增删任意数量的宠物
|
|
21
|
+
|
|
22
|
+
- **POI 漫游系统** (`AgentSlot.js`)
|
|
23
|
+
- Agent 空闲时 25% 概率前往 POI(水机、书架、窗户、植物)
|
|
24
|
+
- 15% 概率走向同事工位进行社交互动
|
|
25
|
+
- 到达 POI 后显示表情气泡(☕ 🌤️ 📖 👋 🌿)
|
|
26
|
+
- 漫游范围扩大至全画面区域
|
|
27
|
+
|
|
28
|
+
- **新宠物精灵** (`SpriteGenerator.js`)
|
|
29
|
+
- `_drawBird()`: 蓝色身体、橙色喙/爪、2 帧翅膀扇动动画
|
|
30
|
+
- `_drawHamster()`: 小麦色、粉色鼓腮、圆耳朵、2 帧尾巴摆动
|
|
31
|
+
|
|
32
|
+
### 改进
|
|
33
|
+
|
|
34
|
+
- **3/4 俯视视角** — 采用经典 RPG 视角(类 Stardew Valley / Pokemon)
|
|
35
|
+
- 角色站在桌子后方(Y 值更小 = 画面偏上 = 视觉偏远)
|
|
36
|
+
- 桌子在角色前方(Y 值更大 = 画面偏下 = 视觉偏近)
|
|
37
|
+
- 角色上半身完全可见,不再被家具遮挡
|
|
38
|
+
|
|
39
|
+
- **家具精灵重绘** (`SpriteGenerator.js`)
|
|
40
|
+
- 桌子:3/4 视角可见桌面顶部 + 正面,木纹细节,48×20px
|
|
41
|
+
- 显示器 → 笔记本电脑:键盘底座 + 倾斜屏幕,Apple 风格 logo,20×16px
|
|
42
|
+
- 椅子:可见椅座坐垫 + 椅背 + 脚轮,16×18px
|
|
43
|
+
|
|
44
|
+
- **三阶段渲染管线** (`ClawSkinApp.js`)
|
|
45
|
+
- Phase 1: 渲染所有椅子(永远可见)
|
|
46
|
+
- Phase 2: 按 Y 坐标排序渲染角色(深度排序)
|
|
47
|
+
- Phase 3: 渲染所有桌面 + 笔记本 + 咖啡杯(永远可见)
|
|
48
|
+
- Phase 4: 渲染独立宠物
|
|
49
|
+
|
|
50
|
+
- **平滑移动** (`AgentSlot.js`)
|
|
51
|
+
- 所有移动使用线性插值 (lerp),告别瞬移/闪现
|
|
52
|
+
- 返回工位也是平滑行走,不再直接 teleport
|
|
53
|
+
- 移动速度提升:0.06~0.08(原 0.04~0.06)
|
|
54
|
+
- 行走时带自然的正弦波摇晃效果
|
|
55
|
+
|
|
56
|
+
### 修复
|
|
57
|
+
|
|
58
|
+
- 修复 Agent 漫游时桌子/椅子消失的问题 — 家具现在永远渲染
|
|
59
|
+
- 修复宠物跟随 Agent 一起瞬移的问题 — 宠物已完全解耦
|
|
60
|
+
- 修复 Agent 漫游后闪现回工位的问题 — 改为平滑走回
|
|
61
|
+
- 修复多 Agent 场景中角色遮挡关系错误 — 引入 Y-sort 深度排序
|
|
62
|
+
|
|
63
|
+
### 文件变更
|
|
64
|
+
|
|
65
|
+
| 文件 | 类型 | 说明 |
|
|
66
|
+
|------|------|------|
|
|
67
|
+
| `js/sprites/SpriteGenerator.js` | 修改 | 重绘家具精灵 (3/4 视角),新增鸟/仓鼠精灵 |
|
|
68
|
+
| `js/scenes/OfficeScene.js` | 修改 | 工位坐标重新计算,renderDesk 渲染顺序调整 |
|
|
69
|
+
| `js/app/ClawSkinApp.js` | 修改 | 三阶段渲染管线,集成 PetManager,Agent 社交引用 |
|
|
70
|
+
| `js/app/AgentSlot.js` | 重写 | lerp 平滑移动,POI 漫游系统,社交行为 |
|
|
71
|
+
| `js/character/CharacterSprite.js` | 修改 | 移除宠物渲染代码 |
|
|
72
|
+
| `js/pets/Pet.js` | **新建** | 独立宠物实体类 |
|
|
73
|
+
| `js/pets/PetManager.js` | **新建** | 宠物集合管理器 |
|
|
74
|
+
| `app.html` | 修改 | 添加 Pet/PetManager script 标签 |
|
|
75
|
+
| `index.html` | 修改 | 添加 Pet/PetManager script 标签 |
|
|
76
|
+
| `app.html` | 修改 | 添加 Pet/PetManager script 标签 |
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## [0.1.0] - 2026-02-28
|
|
81
|
+
|
|
82
|
+
### 初始版本
|
|
83
|
+
|
|
84
|
+
- 纯 Canvas 2D 渲染,零外部依赖
|
|
85
|
+
- 32×32 像素角色程序化生成(16 帧动画)
|
|
86
|
+
- 5 种肤色、7 种发色、5 种发型、5 种服装类型
|
|
87
|
+
- 4 种配饰:眼镜、帽子、耳机、鸭舌帽
|
|
88
|
+
- 3 种宠物:猫、狗、机器人
|
|
89
|
+
- 3 个场景:办公室、黑客地下室、咖啡馆
|
|
90
|
+
- 8 种状态动画:idle、typing、thinking、executing、browsing、error、sleeping、waving
|
|
91
|
+
- 对话气泡系统
|
|
92
|
+
- 捏脸编辑器 UI
|
|
93
|
+
- Demo 模式(模拟状态切换)
|
|
94
|
+
- 多 Agent 支持(工位自动布局)
|
|
95
|
+
- Gateway WebSocket 连接(OpenClaw 协议)
|
|
96
|
+
- 点击 Agent 打开编辑器
|
|
97
|
+
- localStorage 配置持久化
|
|
98
|
+
- 嵌入式 iframe 页面
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! Here's how to get started.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
1. **Fork** the repo and clone your fork
|
|
8
|
+
2. Create a **feature branch**: `git checkout -b feat/my-feature`
|
|
9
|
+
3. Make your changes
|
|
10
|
+
4. **Test** locally to make sure everything works
|
|
11
|
+
5. **Commit** with a clear message: `git commit -m "feat: add new scene"`
|
|
12
|
+
6. **Push** and open a **Pull Request**
|
|
13
|
+
|
|
14
|
+
## Commit Convention
|
|
15
|
+
|
|
16
|
+
We loosely follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
17
|
+
|
|
18
|
+
- `feat:` — New feature
|
|
19
|
+
- `fix:` — Bug fix
|
|
20
|
+
- `docs:` — Documentation only
|
|
21
|
+
- `style:` — Formatting, no logic change
|
|
22
|
+
- `refactor:` — Code restructuring
|
|
23
|
+
- `chore:` — Maintenance tasks
|
|
24
|
+
|
|
25
|
+
## Code Style
|
|
26
|
+
|
|
27
|
+
- ES Modules (`import/export`)
|
|
28
|
+
- 2-space indentation
|
|
29
|
+
- Single quotes for strings
|
|
30
|
+
- Descriptive variable names
|
|
31
|
+
|
|
32
|
+
## Reporting Issues
|
|
33
|
+
|
|
34
|
+
- Use [GitHub Issues](../../issues)
|
|
35
|
+
- Include steps to reproduce
|
|
36
|
+
- Include browser/Node.js version if relevant
|
|
37
|
+
|
|
38
|
+
## Questions?
|
|
39
|
+
|
|
40
|
+
Open a [Discussion](../../discussions) or reach out in the issue tracker.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ClawLabz
|
|
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,137 @@
|
|
|
1
|
+
# 🎨 ClawSkin
|
|
2
|
+
|
|
3
|
+
**Pixel Agent Skin Engine** — Give your AI assistant a face, an office, and a daily life.
|
|
4
|
+
|
|
5
|
+
A pixel character engine that visualizes AI agent states in real-time. Pure Canvas 2D, zero dependencies, zero build tools.
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="https://img.shields.io/badge/Canvas_2D-Procedural-blue" alt="Canvas 2D">
|
|
9
|
+
<img src="https://img.shields.io/badge/JavaScript-ES6+-yellow?logo=javascript&logoColor=white" alt="JavaScript">
|
|
10
|
+
<img src="https://img.shields.io/badge/Dependencies-0-brightgreen" alt="Zero Dependencies">
|
|
11
|
+
<img src="https://img.shields.io/badge/Build-None-brightgreen" alt="Zero Build">
|
|
12
|
+
<img src="https://img.shields.io/github/license/clawlabz/clawskin" alt="License">
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
## ✨ Features
|
|
16
|
+
|
|
17
|
+
- 🧑🎨 **Character Customization** — 5 skin tones × 5 hairstyles × 5 outfits × 4 accessories × 5 pets = 2,500+ combinations
|
|
18
|
+
- 🏠 **3 Scenes** — Office, Hacker Den, Cozy Café (each with ambient animations and particles)
|
|
19
|
+
- 🎬 **8 State Animations** — idle, thinking, typing, executing, browsing, error, wave, sleeping
|
|
20
|
+
- 💬 **Dialogue Bubbles** — Typewriter effect with emoji support
|
|
21
|
+
- 👥 **Multi-Agent** — Display multiple AI agents simultaneously with independent states
|
|
22
|
+
- 🐾 **Pixel Pets** — Cats, dogs, robots, birds, hamsters with autonomous AI behavior
|
|
23
|
+
- 🎮 **Demo Mode** — Runs standalone without any backend connection
|
|
24
|
+
- 📦 **Zero Dependencies** — Pure static files, just Node.js to serve
|
|
25
|
+
|
|
26
|
+
## 🚀 Quick Start
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git clone https://github.com/clawlabz/clawskin.git
|
|
30
|
+
cd clawskin
|
|
31
|
+
npm start
|
|
32
|
+
# → http://localhost:3000
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Opens the ClawSkin app and auto-connects to your local OpenClaw Gateway (`ws://localhost:18789`).
|
|
36
|
+
|
|
37
|
+
> **Why `npm start` instead of opening the HTML directly?**
|
|
38
|
+
> Browsers block WebSocket connections from `file://` pages due to origin restrictions.
|
|
39
|
+
> The built-in server runs on `http://localhost` which Gateway accepts. Zero dependencies — just Node.js.
|
|
40
|
+
|
|
41
|
+
### CLI Options
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm start # Default: localhost:3000, opens browser
|
|
45
|
+
npm start -- --no-open # Don't open browser
|
|
46
|
+
npm start -- --port 8080 # Custom port
|
|
47
|
+
npm start -- --host 0.0.0.0 # Expose to network (see Security below)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 🏗️ Architecture
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
clawSkin/
|
|
54
|
+
├── public/
|
|
55
|
+
│ ├── index.html # Landing page (demo + customization)
|
|
56
|
+
│ ├── app.html # Full-screen app (main product)
|
|
57
|
+
│ ├── css/
|
|
58
|
+
│ └── js/
|
|
59
|
+
│ ├── app/ # ClawSkinApp, GatewayClient, Settings
|
|
60
|
+
│ ├── scenes/ # Office / Hacker / Café scenes
|
|
61
|
+
│ ├── character/ # Sprite rendering + animations
|
|
62
|
+
│ ├── sprites/ # Procedural sprite generator
|
|
63
|
+
│ ├── pets/ # Pet entity + manager
|
|
64
|
+
│ ├── state/ # Agent state sync + demo mode
|
|
65
|
+
│ └── ui/ # Character editor + scene picker
|
|
66
|
+
├── serve.cjs # Zero-dependency HTTP server
|
|
67
|
+
└── docs/
|
|
68
|
+
└── ARCHITECTURE.md # Detailed architecture doc
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Character Layer System
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
Layer 5: Accessory — glasses / hat / headphones
|
|
75
|
+
Layer 4: Hair — 5 styles with color variants
|
|
76
|
+
Layer 3: Outfit — hoodie / suit / lab coat / ...
|
|
77
|
+
Layer 2: Expression — happy / thinking / confused / sleepy
|
|
78
|
+
Layer 1: Body — base 32×32 pixel humanoid + skin tone
|
|
79
|
+
Layer 0: Shadow
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Agent State Mapping
|
|
83
|
+
|
|
84
|
+
| Agent State | Pixel Character Behavior |
|
|
85
|
+
|-------------|-------------------------|
|
|
86
|
+
| `idle` | Sitting, drinking coffee, petting cat |
|
|
87
|
+
| `thinking` | Thought bubble "..." |
|
|
88
|
+
| `writing` | Fast typing, screen flickers |
|
|
89
|
+
| `executing` | Walks to server rack |
|
|
90
|
+
| `browsing` | Staring at screen, occasional clicks |
|
|
91
|
+
| `error` | ❌ above head, frustrated expression |
|
|
92
|
+
| `heartbeat` | Waves at window |
|
|
93
|
+
| `sleeping` | Head on desk 💤 |
|
|
94
|
+
|
|
95
|
+
## 🔒 Security
|
|
96
|
+
|
|
97
|
+
ClawSkin is designed to run locally as a companion UI. Here are the security considerations:
|
|
98
|
+
|
|
99
|
+
### Local server (`serve.cjs`)
|
|
100
|
+
|
|
101
|
+
- **Binds to `127.0.0.1` by default** — only accessible from your machine. Use `--host 0.0.0.0` explicitly if you need network access.
|
|
102
|
+
- **`/api/config` endpoint** — returns the Gateway URL detected from `~/.openclaw/openclaw.json` for auto-connect convenience. **Auth tokens are never served** by this endpoint; users must enter tokens manually in the UI.
|
|
103
|
+
- **Security headers** — CSP, X-Content-Type-Options, X-Frame-Options, and Referrer-Policy are set on all responses.
|
|
104
|
+
|
|
105
|
+
### Browser storage
|
|
106
|
+
|
|
107
|
+
- **Settings** (Gateway URL, scene choice, character config) are persisted in `localStorage`.
|
|
108
|
+
- **Gateway auth token** is stored in `localStorage` after the user enters it manually. This is standard browser behavior (same as any web app with "remember me"). The token never leaves the browser.
|
|
109
|
+
- **Device identity** — An Ed25519 keypair is generated and stored in `localStorage` for Gateway device pairing. The private key is stored as base64url in plaintext. This is a known tradeoff: `localStorage` is accessible to any JavaScript on the same origin. For a locally-run pixel companion, this is acceptable. If you need stronger protection, use the browser in a dedicated profile.
|
|
110
|
+
|
|
111
|
+
### WebSocket connection
|
|
112
|
+
|
|
113
|
+
- ClawSkin requests **read-only scopes** (`operator.read`, `operator.events`) from the Gateway — it does not request admin privileges.
|
|
114
|
+
- For remote connections, use `wss://` (e.g. via Tailscale Serve) to encrypt traffic.
|
|
115
|
+
|
|
116
|
+
## 🔗 Part of the Claw Ecosystem
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
ClawSkin (you are here) → ClawArena → ClawGenesis
|
|
120
|
+
Free / visual hook Light game Deep simulation
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
ClawSkin characters can be reused as avatars in [ClawArena](https://github.com/clawlabz/clawarena) spectating scenes.
|
|
124
|
+
|
|
125
|
+
## 🤝 Contributing
|
|
126
|
+
|
|
127
|
+
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
128
|
+
|
|
129
|
+
Ideas for contributions:
|
|
130
|
+
- 🎨 New scenes (bedroom, spaceship, garden...)
|
|
131
|
+
- 👕 New outfit/hairstyle/accessory sprites
|
|
132
|
+
- 🐾 New pet companions
|
|
133
|
+
- 🌐 i18n support
|
|
134
|
+
|
|
135
|
+
## 📄 License
|
|
136
|
+
|
|
137
|
+
[MIT](LICENSE) © 2026 ClawLabz
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# ClawSkin 技术架构
|
|
2
|
+
|
|
3
|
+
## 产品定位
|
|
4
|
+
像素 Agent 皮肤引擎 —— 给 AI 助手一张脸、一间办公室、一段日常。
|
|
5
|
+
|
|
6
|
+
## 技术栈
|
|
7
|
+
|
|
8
|
+
| 层面 | 技术 | 说明 |
|
|
9
|
+
|------|------|------|
|
|
10
|
+
| 渲染引擎 | Phaser 3.80 (CDN) | 成熟2D像素游戏引擎,支持动画/粒子/物理 |
|
|
11
|
+
| 前端框架 | 原生 JS + Phaser | 保持轻量,嵌入式组件不需要Vue |
|
|
12
|
+
| 角色系统 | Sprite Sheet (PNG) | 32x32像素,8方向 + 状态动画 |
|
|
13
|
+
| 场景系统 | Tiled Map Editor → JSON | 瓦片地图,可扩展 |
|
|
14
|
+
| 状态同步 | WebSocket / SSE | 连接 OpenClaw Gateway 获取 Agent 状态 |
|
|
15
|
+
| 配置存储 | localStorage + JSON 文件 | 角色配置、场景偏好 |
|
|
16
|
+
| 部署 | 静态文件 (Vercel/Cloudflare Pages) | 零后端,纯前端 |
|
|
17
|
+
|
|
18
|
+
## 目录结构
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
clawSkin/
|
|
22
|
+
├── public/
|
|
23
|
+
│ ├── index.html # 主页面(展示 + 捏脸 + 场景选择)
|
|
24
|
+
│ ├── assets/
|
|
25
|
+
│ │ ├── sprites/ # 角色 sprite sheets
|
|
26
|
+
│ │ │ ├── base/ # 基础身体(不同肤色)
|
|
27
|
+
│ │ │ ├── hair/ # 发型图层
|
|
28
|
+
│ │ │ ├── outfit/ # 服装图层
|
|
29
|
+
│ │ │ ├── accessory/ # 配饰图层(眼镜/帽子/耳机)
|
|
30
|
+
│ │ │ └── pet/ # 宠物伴侣
|
|
31
|
+
│ │ ├── tiles/ # 场景瓦片素材
|
|
32
|
+
│ │ ├── scenes/ # 预设场景 JSON (from Tiled)
|
|
33
|
+
│ │ └── effects/ # 粒子效果(雨/雪/星星/代码雨)
|
|
34
|
+
│ ├── js/
|
|
35
|
+
│ │ ├── game.js # Phaser Game 主入口
|
|
36
|
+
│ │ ├── scenes/
|
|
37
|
+
│ │ │ ├── OfficeScene.js # 像素办公室
|
|
38
|
+
│ │ │ ├── HackerScene.js # 黑客地下室
|
|
39
|
+
│ │ │ ├── StudyScene.js # 温馨书房
|
|
40
|
+
│ │ │ ├── SpaceScene.js # 太空站
|
|
41
|
+
│ │ │ ├── CafeScene.js # 咖啡馆
|
|
42
|
+
│ │ │ ├── ZenScene.js # 日式禅室
|
|
43
|
+
│ │ │ ├── LabScene.js # 实验室
|
|
44
|
+
│ │ │ └── CityScene.js # 像素城市
|
|
45
|
+
│ │ ├── character/
|
|
46
|
+
│ │ │ ├── CharacterBuilder.js # 捏脸系统
|
|
47
|
+
│ │ │ ├── CharacterSprite.js # 角色精灵渲染
|
|
48
|
+
│ │ │ └── AnimationManager.js # 动画状态机
|
|
49
|
+
│ │ ├── state/
|
|
50
|
+
│ │ │ ├── AgentStateSync.js # OpenClaw 状态同步
|
|
51
|
+
│ │ │ └── BubbleManager.js # 对话气泡管理
|
|
52
|
+
│ │ └── ui/
|
|
53
|
+
│ │ ├── CharacterEditor.js # 捏脸 UI
|
|
54
|
+
│ │ └── ScenePicker.js # 场景选择器
|
|
55
|
+
│ └── css/
|
|
56
|
+
│ └── style.css
|
|
57
|
+
├── docs/
|
|
58
|
+
│ ├── ARCHITECTURE.md # 本文件
|
|
59
|
+
│ └── PROGRESS.md # 进度记录
|
|
60
|
+
└── scripts/
|
|
61
|
+
└── generate-sprites.js # 精灵图生成工具
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 核心模块设计
|
|
65
|
+
|
|
66
|
+
### 1. 角色系统 (Character System)
|
|
67
|
+
|
|
68
|
+
**图层合成**: 角色由多个图层叠加渲染
|
|
69
|
+
```
|
|
70
|
+
Layer 5: 配饰 (accessory) — 眼镜/帽子/耳机
|
|
71
|
+
Layer 4: 发型 (hair)
|
|
72
|
+
Layer 3: 服装 (outfit) — 格子衫/西装/实验服
|
|
73
|
+
Layer 2: 表情 (expression) — 开心/思考/困惑/困倦
|
|
74
|
+
Layer 1: 身体 (body) — 基础像素人形 + 肤色
|
|
75
|
+
Layer 0: 阴影 (shadow)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**角色配置 JSON**:
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"id": "agent-001",
|
|
82
|
+
"name": "二狗",
|
|
83
|
+
"body": { "type": "default", "skin": "#FFD5C2" },
|
|
84
|
+
"hair": { "type": "short_messy", "color": "#333333" },
|
|
85
|
+
"outfit": { "type": "hoodie", "color": "#4A90D9" },
|
|
86
|
+
"accessory": { "type": "round_glasses" },
|
|
87
|
+
"pet": { "type": "pixel_cat", "color": "#FF9900" },
|
|
88
|
+
"expression": "happy"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 2. 状态联动 (Agent State Sync)
|
|
93
|
+
|
|
94
|
+
| OpenClaw Agent 状态 | 像素角色行为 | 动画 |
|
|
95
|
+
|---------------------|-------------|------|
|
|
96
|
+
| idle | 坐椅子喝咖啡/发呆/摸猫 | idle_sit, idle_coffee, idle_pet |
|
|
97
|
+
| thinking | 头上思考气泡 "..." | think_bubble |
|
|
98
|
+
| writing | 快速打字,屏幕闪烁 | typing_fast |
|
|
99
|
+
| executing | 走到服务器机柜操作 | walk_to_server, operate |
|
|
100
|
+
| browsing | 盯屏幕,偶尔点击 | browse_scroll |
|
|
101
|
+
| error | 头上❌,沮丧表情 | error_shake |
|
|
102
|
+
| heartbeat | 向窗外挥手 | wave |
|
|
103
|
+
| sleeping | 趴桌子睡觉💤 | sleep_zzz |
|
|
104
|
+
|
|
105
|
+
**同步协议**: 通过 SSE 或 WebSocket 连接 OpenClaw Gateway
|
|
106
|
+
```
|
|
107
|
+
GET /api/agent/{id}/status → { state: "writing", message: "处理邮件...", since: timestamp }
|
|
108
|
+
WS /ws/agent/{id}/events → { type: "state_change", state: "thinking", data: {...} }
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 3. 场景系统 (Scene System)
|
|
112
|
+
|
|
113
|
+
每个场景 = Phaser Scene 子类:
|
|
114
|
+
- 背景层 (tilemap)
|
|
115
|
+
- 家具/物品层 (interactive objects)
|
|
116
|
+
- 角色层 (character sprite)
|
|
117
|
+
- 气泡/UI层 (dialogue bubbles, status icons)
|
|
118
|
+
- 粒子层 (ambient effects: rain, snow, stars, code rain)
|
|
119
|
+
|
|
120
|
+
## MVP 范围 (Phase 1)
|
|
121
|
+
|
|
122
|
+
1. ✅ Phaser 3 引擎初始化 + 基础渲染管线
|
|
123
|
+
2. ✅ 3 个场景: 办公室、黑客地下室、咖啡馆
|
|
124
|
+
3. ✅ 基础角色: 3种体型 × 5种发型 × 5种服装 × 3种配饰
|
|
125
|
+
4. ✅ 8种状态动画 (idle/thinking/typing/executing/browsing/error/wave/sleep)
|
|
126
|
+
5. ✅ 对话气泡系统 (打字机效果)
|
|
127
|
+
6. ✅ 模拟状态切换 (Demo模式,无需真实OpenClaw连接)
|
|
128
|
+
7. ✅ 捏脸 UI (HTML overlay)
|
|
129
|
+
8. ✅ 主页: 产品展示 + Demo
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
*Created: 2026-02-28*
|
package/docs/PROGRESS.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# ClawSkin 开发进度
|
|
2
|
+
|
|
3
|
+
## Phase 1 - MVP
|
|
4
|
+
- [ ] Phaser 3 引擎初始化 + 基础渲染
|
|
5
|
+
- [ ] 像素角色精灵系统 (32x32, 图层合成)
|
|
6
|
+
- [ ] 3 个场景: 办公室、黑客地下室、咖啡馆
|
|
7
|
+
- [ ] 8种状态动画
|
|
8
|
+
- [ ] 对话气泡系统
|
|
9
|
+
- [ ] 捏脸 UI
|
|
10
|
+
- [ ] 嵌入式 iframe 页面
|
|
11
|
+
- [ ] Demo 模式(模拟状态切换)
|
|
12
|
+
- [ ] 主页展示
|
|
13
|
+
|
|
14
|
+
## 开发日志
|
|
15
|
+
- 2026-02-28 23:30 - 项目初始化,架构文档完成
|
package/docs/ROADMAP.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# ClawSkin Product Roadmap
|
|
2
|
+
|
|
3
|
+
**Created**: 2026-03-01
|
|
4
|
+
**Status**: In Development
|
|
5
|
+
|
|
6
|
+
## Vision
|
|
7
|
+
|
|
8
|
+
ClawSkin is a real-time pixel character visualization for OpenClaw AI agents.
|
|
9
|
+
Two modes of use:
|
|
10
|
+
1. **Local Mode** — Download and open locally, auto-connects to `localhost:18789`
|
|
11
|
+
2. **Online Mode** — Visit clawskin.io/app, enter Gateway URL + Token, connect remotely
|
|
12
|
+
|
|
13
|
+
## Gateway WS Protocol (Reverse-Engineered from OpenClaw Source)
|
|
14
|
+
|
|
15
|
+
### Connection Flow
|
|
16
|
+
```
|
|
17
|
+
1. Browser opens WebSocket to Gateway URL (ws://host:18789 or wss://...)
|
|
18
|
+
2. Gateway sends: { type: "event", event: "connect.challenge", payload: { nonce } }
|
|
19
|
+
3. Client sends RPC: { type: "req", id: uuid, method: "connect", params: { auth: { token }, ... } }
|
|
20
|
+
4. Gateway responds: { type: "res", id: uuid, ok: true, payload: { snapshot: {...} } }
|
|
21
|
+
5. Gateway pushes events: { type: "event", event: "chat"|"agent"|"presence", payload: {...} }
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### RPC Format
|
|
25
|
+
```json
|
|
26
|
+
// Request
|
|
27
|
+
{ "type": "req", "id": "uuid", "method": "method.name", "params": {} }
|
|
28
|
+
|
|
29
|
+
// Response
|
|
30
|
+
{ "type": "res", "id": "uuid", "ok": true, "payload": {} }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Key Methods
|
|
34
|
+
| Method | Purpose |
|
|
35
|
+
|--------|---------|
|
|
36
|
+
| `connect` | Auth + handshake |
|
|
37
|
+
| `status` | Gateway status (uptime, health) |
|
|
38
|
+
| `health` | Health check |
|
|
39
|
+
| `chat.history` | Get chat message history |
|
|
40
|
+
| `chat.send` | Send a message |
|
|
41
|
+
| `sessions.list` | List active sessions |
|
|
42
|
+
| `agent.identity.get` | Get agent name/avatar |
|
|
43
|
+
|
|
44
|
+
### Real-Time Events
|
|
45
|
+
| Event | Data | Maps To |
|
|
46
|
+
|-------|------|---------|
|
|
47
|
+
| `chat` (state=delta) | Streaming text | → `typing` animation |
|
|
48
|
+
| `chat` (state=final) | Completed response | → `idle` animation |
|
|
49
|
+
| `agent` (stream=tool, phase=start) | Tool call starting | → `executing` animation |
|
|
50
|
+
| `agent` (stream=tool, phase=result) | Tool call done | → `idle` animation |
|
|
51
|
+
| `agent` (stream=lifecycle) | Fallback/model switch | → `thinking` animation |
|
|
52
|
+
|
|
53
|
+
### Agent State Mapping
|
|
54
|
+
```
|
|
55
|
+
Gateway Event → ClawSkin State
|
|
56
|
+
─────────────────────────────────────────────────────
|
|
57
|
+
No active run, idle → idle (sitting, coffee, petting cat)
|
|
58
|
+
chat.send received, waiting → thinking (thought bubble "...")
|
|
59
|
+
chat delta streaming → typing (fast keyboard animation)
|
|
60
|
+
tool phase=start (exec/browser/etc) → executing (walks to server rack)
|
|
61
|
+
tool phase=start (web_fetch/search) → browsing (staring at screen)
|
|
62
|
+
tool phase=result with error → error (❌ above head)
|
|
63
|
+
chat state=final → idle (back to relaxed)
|
|
64
|
+
No activity for 30min+ → sleeping (head on desk 💤)
|
|
65
|
+
Heartbeat event → waving (waves at window)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Architecture
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
clawSkin/
|
|
72
|
+
├── index.html # Marketing/landing page (existing)
|
|
73
|
+
├── app.html # ★ Product app page
|
|
74
|
+
├── css/
|
|
75
|
+
│ ├── style.css # Landing page styles (existing)
|
|
76
|
+
│ └── app.css # ★ App-specific styles
|
|
77
|
+
├── js/
|
|
78
|
+
│ ├── app/
|
|
79
|
+
│ │ ├── ClawSkinApp.js # ★ Main app controller
|
|
80
|
+
│ │ ├── GatewayClient.js # ★ OpenClaw WS protocol client
|
|
81
|
+
│ │ ├── ConnectionPanel.js # ★ Connect UI (URL/Token input)
|
|
82
|
+
│ │ ├── AgentStateMapper.js # ★ Gateway events → character states
|
|
83
|
+
│ │ └── SettingsManager.js # ★ localStorage persistence
|
|
84
|
+
│ ├── character/ # (existing) sprite/animation system
|
|
85
|
+
│ ├── scenes/ # (existing) office/hacker/cafe
|
|
86
|
+
│ ├── sprites/ # (existing) procedural generation
|
|
87
|
+
│ ├── state/ # (existing, refactor DemoMode)
|
|
88
|
+
│ └── ui/ # (existing) editor/picker
|
|
89
|
+
├── docs/
|
|
90
|
+
│ ├── ARCHITECTURE.md
|
|
91
|
+
│ ├── ROADMAP.md # This file
|
|
92
|
+
│ └── PROGRESS.md
|
|
93
|
+
└── package.json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Development Phases
|
|
97
|
+
|
|
98
|
+
### Phase 1: Gateway Connection (Current)
|
|
99
|
+
- [x] Reverse-engineer OpenClaw WS protocol
|
|
100
|
+
- [ ] Build GatewayClient.js (WS connect, auth, RPC, event handling)
|
|
101
|
+
- [ ] Build AgentStateMapper.js (event → character state)
|
|
102
|
+
- [ ] Build ConnectionPanel.js (URL/Token input + auto-detect)
|
|
103
|
+
- [ ] Build app.html (product page)
|
|
104
|
+
- [ ] Local auto-detection (try localhost:18789 on load)
|
|
105
|
+
- [ ] localStorage persistence (connection settings + character config)
|
|
106
|
+
|
|
107
|
+
### Phase 2: Polish & UX
|
|
108
|
+
- [ ] Connection status indicator (connected/disconnected/reconnecting)
|
|
109
|
+
- [ ] Agent identity display (name + avatar from Gateway)
|
|
110
|
+
- [ ] Chat activity indicator (show what agent is working on)
|
|
111
|
+
- [ ] Smooth state transitions (don't jump between states)
|
|
112
|
+
- [ ] Mobile responsive app page
|
|
113
|
+
- [ ] HTTPS/WSS guidance for remote connections
|
|
114
|
+
|
|
115
|
+
### Phase 3: Distribution
|
|
116
|
+
- [ ] Package as OpenClaw Skill (`clawhub install clawskin`)
|
|
117
|
+
- [ ] Deploy landing page to clawskin.io
|
|
118
|
+
- [ ] npm package (`npx clawskin` to run locally)
|
|
119
|
+
- [ ] GitHub Pages for online mode
|
|
120
|
+
|
|
121
|
+
## Technical Constraints
|
|
122
|
+
|
|
123
|
+
### HTTPS → WS Security
|
|
124
|
+
- HTTPS pages can only connect to `wss://` (not `ws://`)
|
|
125
|
+
- Exception: `ws://localhost` is allowed from HTTPS (browser whitelist)
|
|
126
|
+
- Remote users need Tailscale Serve (`wss://machine.ts.net`)
|
|
127
|
+
- Local mode (`file://` or local HTTP) has no restrictions
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
*Last updated: 2026-03-01*
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clawlabz/clawskin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Pixel Agent Skin Engine \u2014 Procedural 32\u00d732 character generator with scenes, animations & customization",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pixel",
|
|
8
|
+
"agent",
|
|
9
|
+
"skin",
|
|
10
|
+
"character",
|
|
11
|
+
"avatar"
|
|
12
|
+
],
|
|
13
|
+
"author": "ClawLabz",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://github.com/clawlabz/clawskin",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/clawlabz/clawskin.git"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"start": "node serve.cjs",
|
|
22
|
+
"start:silent": "node serve.cjs --no-open"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"clawskin": "./serve.cjs"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/public/_headers
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
X-Content-Type-Options: nosniff
|
|
3
|
+
Referrer-Policy: strict-origin-when-cross-origin
|
|
4
|
+
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; connect-src 'self' ws: wss:; img-src 'self' data:; frame-ancestors 'self'
|
|
5
|
+
|
|
6
|
+
/*.html
|
|
7
|
+
Cache-Control: no-cache
|
|
8
|
+
|
|
9
|
+
/js/*
|
|
10
|
+
Cache-Control: public, max-age=3600
|
|
11
|
+
|
|
12
|
+
/css/*
|
|
13
|
+
Cache-Control: public, max-age=3600
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/ /app.html 302
|