Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ WeChat original voice can be prepared for playback, native quotes and retained l

### Added

- Pixel Avatars can be a goblin, with pointed ears through the hair, small tusks and suggested green skin, and left and right side hair can each have their own style and color; the goblin keeps head turns and speaking mouths in Window Companions, random covers both species, and existing Avatars render unchanged ([#1210](https://github.com/BotHarness/DeepSeekBot/issues/1210), [ADR-0148](docs/adr/0148-avatar-species-and-custom-parts-extend-one-pixel-rig.md)).

- The welcome now offers a daily evening check-in at 21:00 with the browser time zone and current DM shown before selection; missing time zones are confirmed first, and existing model setup retains the complete request for explicit sending ([#1228](https://github.com/BotHarness/DeepSeekBot/issues/1228)).

- The Bot Marketplace now shows each Bot's Profile banner: a thumbnail on every row and a full banner at the top of the detail view, with a neutral placeholder when a Bot has none. The Marketplace Worker reads `banner` from `.botharness/bot.json`; a pixel scene is drawn locally, and an uploaded image loads from the repository at the indexed commit ([#1093](https://github.com/BotHarness/BotHarness/issues/1093)).
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

### Added

- 像素头像可以选择哥布林:尖耳朵穿出头发、带小獠牙、配建议的绿色肤色;左右侧发可以分别选择样式和颜色。哥布林在 Window Companion 中同样支持转头和说话嘴型,随机也会覆盖两个物种,已有头像渲染不变([#1210](https://github.com/BotHarness/DeepSeekBot/issues/1210)、[ADR-0148](docs/adr/0148-avatar-species-and-custom-parts-extend-one-pixel-rig.md))。

- 欢迎消息提供每天 21:00 的晚间问候示例,选择前显示浏览器时区与当前私聊;无法识别时区时先询问,既有模型配置流程保留完整请求并等待明确发送([#1228](https://github.com/BotHarness/DeepSeekBot/issues/1228))。

- Bot 市场现在会显示每个 Bot 的资料横幅:列表每一行有缩略图,详情页顶部是完整横幅;没有横幅的 Bot 显示中性占位。市场 Worker 从 `.botharness/bot.json` 读取 `banner`:像素场景在本地绘制,上传的图片按收录时的提交从仓库加载([#1093](https://github.com/BotHarness/BotHarness/issues/1093))。
Expand Down
23 changes: 23 additions & 0 deletions docs/assets/pr/1210-goblin-species/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# #1210 Goblin Avatar Species and split side hair

Captured on an isolated DSH instance running this branch with `@botharness/pixel-avatar` 0.3.0 built in.

## Editing

| Species: human → goblin, keeping the saved hair and outfit | Left and right side hair with their own colors |
| ---------------------------------------------------------- | ------------------------------------------------------------ |
| ![goblin species](editor-goblin-en-light.webp) | ![split hair colors](editor-split-hair-colors-en-light.webp) |

## Window Companion speaking (simulated)

The speech is simulated. A test script drives the companion's own closed, half-open and open mouth layers at text pace. No model reply was involved, and the close-up is scaled ×4 with CSS for the recording only.

![goblin speaking](goblin-speaking.gif)

![companion close-up](companion-speaking-en-light.webp)

Full flow, from editing to saving to the companion speaking:

![full flow](goblin-species-flow.gif)

The same recording as video: [goblin-species-flow.mp4](goblin-species-flow.mp4)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
83 changes: 71 additions & 12 deletions packages/client/src/client/avatar-appearance-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import {
AVATAR_FAMILIES,
AVATAR_HAIR_PARTS,
AVATAR_PARTS,
AVATAR_PIECE_COLORS,
AVATAR_PRESETS,
AVATAR_RANGES,
AVATAR_SPECIES,
AVATAR_SPECIES_SWATCHES,
detailedAvatarRecipe,
type IllustratedAvatarRecipe,
AVATAR_SWATCHES,
withAvatarSpecies,
avatarSvg,
seededAvatarRecipe,
type AvatarFamily,
Expand Down Expand Up @@ -44,20 +48,34 @@ interface FamilySpec {

const FAMILIES: Record<AvatarFamily, FamilySpec> = {
illustrated: {
parts: { ...AVATAR_PARTS, ...AVATAR_HAIR_PARTS },
colors: AVATAR_COLORS,
swatches: AVATAR_SWATCHES,
parts: {
species: AVATAR_SPECIES,
...AVATAR_PARTS,
...AVATAR_HAIR_PARTS,
rightSideHair: AVATAR_HAIR_PARTS.sideHair,
},
colors: [...AVATAR_COLORS, ...AVATAR_PIECE_COLORS],
swatches: {
...AVATAR_SWATCHES,
leftSideHairColor: AVATAR_SWATCHES.hairColor,
rightSideHairColor: AVATAR_SWATCHES.hairColor,
},
ranges: AVATAR_RANGES,
presets: AVATAR_PRESETS,
categories: [
'presets',
'species',
'hair',
...Object.keys(AVATAR_HAIR_PARTS),
'bangs',
'sideHair',
'rightSideHair',
'backHair',
...Object.keys(AVATAR_PARTS).filter((part) => part !== 'backdrop' && part !== 'hair'),
'shape',
'colors',
],
option: (part, value) => `profile.avatar.option.${part}.${value}` as Key,
option: (part, value) =>
`profile.avatar.option.${part === 'rightSideHair' ? 'sideHair' : part}.${value}` as Key,
seeded: seededAvatarRecipe,
},
line: {
Expand All @@ -80,10 +98,18 @@ const FAMILIES: Record<AvatarFamily, FamilySpec> = {
type Fields = Record<string, string | number>;

const DETAIL = new Set<string>([...Object.keys(AVATAR_HAIR_PARTS), ...Object.keys(AVATAR_RANGES)]);
const SPLIT = new Set<string>(['species', 'sideHair', 'rightSideHair', ...AVATAR_PIECE_COLORS]);

function withPart(recipe: AvatarRecipe, key: string, value: string | number): AvatarRecipe {
if (recipe.family !== 'illustrated')
return { ...(recipe as unknown as Fields), [key]: value } as unknown as AvatarRecipe;
if (key === 'species')
return withAvatarSpecies(recipe, value as IllustratedAvatarRecipe['species'] & string);
if (SPLIT.has(key))
return {
...withAvatarSpecies(recipe, recipe.species ?? 'human'),
[key]: value,
} as IllustratedAvatarRecipe;
if (DETAIL.has(key))
return {
...(detailedAvatarRecipe(recipe) as unknown as Fields),
Expand All @@ -92,24 +118,43 @@ function withPart(recipe: AvatarRecipe, key: string, value: string | number): Av
const next = { ...recipe, [key]: value } as IllustratedAvatarRecipe;
if (key !== 'hair' || recipe.bangs === undefined) return next;
const { bangs: _b, sideHair: _s, backHair: _h, ...plain } = next;
const split = detailedAvatarRecipe(plain);
const split = detailedAvatarRecipe(plain as unknown as IllustratedAvatarRecipe);
return {
...split,
...(split.assetVersion === 2
? { rightSideHair: split.sideHair as NonNullable<IllustratedAvatarRecipe['rightSideHair']> }
: {}),
spacing: next.spacing ?? 0,
height: next.height ?? 0,
hairLength: next.hairLength ?? 0,
};
} as IllustratedAvatarRecipe;
}

function shuffled(recipe: AvatarRecipe): AvatarRecipe {
const spec = FAMILIES[recipe.family];
const pick = <T,>(values: readonly T[]) => values[Math.floor(Math.random() * values.length)]!;
const next: Fields = { ...(recipe as unknown as Fields) };
for (const [part, values] of Object.entries(spec.parts)) next[part] = pick(values);
for (const color of spec.colors) next[color] = pick(spec.swatches[color]!);
const own = (key: string) => !SPLIT.has(key) || recipe.family !== 'illustrated';
for (const [part, values] of Object.entries(spec.parts)) if (own(part)) next[part] = pick(values);
for (const color of spec.colors) if (own(color)) next[color] = pick(spec.swatches[color]!);
for (const [key, [min, max]] of Object.entries(spec.ranges))
next[key] = min + Math.floor(Math.random() * (max - min + 1));
return next as unknown as AvatarRecipe;
if (recipe.family !== 'illustrated') return next as unknown as AvatarRecipe;
const species = pick(AVATAR_SPECIES);
const random = withAvatarSpecies(next as unknown as IllustratedAvatarRecipe, species);
for (const color of AVATAR_PIECE_COLORS) delete random[color];
return {
...random,
sideHair: pick(AVATAR_HAIR_PARTS.sideHair),
rightSideHair: pick(AVATAR_HAIR_PARTS.sideHair),
skinColor: pick(AVATAR_SPECIES_SWATCHES[species]),
};
}

function swatchesFor(spec: FamilySpec, fields: Fields, key: string): readonly string[] {
if (key !== 'skinColor' || fields['family'] !== 'illustrated') return spec.swatches[key]!;
const species = (fields['species'] ?? 'human') as keyof typeof AVATAR_SPECIES_SWATCHES;
return AVATAR_SPECIES_SWATCHES[species];
}

function OptionTile({
Expand Down Expand Up @@ -371,7 +416,7 @@ export function AvatarAppearanceEditor({
{spec.colors.map((key) => (
<div key={key} className="bh-avatar-color-row">
<span>{t(`profile.avatar.${key}` as Key)}</span>
{spec.swatches[key]!.map((value) => (
{swatchesFor(spec, fields, key).map((value) => (
<button
key={value}
type="button"
Expand All @@ -387,9 +432,23 @@ export function AvatarAppearanceEditor({
name={key}
type="color"
aria-label={t(`profile.avatar.${key}` as Key)}
value={String(fields[key])}
value={String(fields[key] ?? fields['hairColor'])}
onChange={(event) => set(key, event.currentTarget.value)}
/>
{fields[key] !== undefined &&
(AVATAR_PIECE_COLORS as readonly string[]).includes(key) ? (
<button
type="button"
className="bh-avatar-color-reset"
data-avatar-color-reset={key}
onClick={() => {
const { [key]: _removed, ...rest } = draft as unknown as Fields;
update(rest as unknown as AvatarRecipe);
}}
>
{t('profile.avatar.followHairColor')}
</button>
) : null}
</div>
))}
</div>
Expand Down
18 changes: 16 additions & 2 deletions packages/client/src/client/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,14 @@ export const zh = {
'profile.avatar.unsupported':
'这个头像使用的版本当前不可用,暂时显示保存时的静态图片,无法编辑或播放角色动画。原始设置已保留,版本恢复后会自动还原。',
'profile.avatar.bangs': '刘海',
'profile.avatar.sideHair': '侧发',
'profile.avatar.sideHair': '左侧发',
'profile.avatar.rightSideHair': '右侧发',
'profile.avatar.species': '物种',
'profile.avatar.option.species.human': '人类',
'profile.avatar.option.species.goblin': '哥布林',
'profile.avatar.leftSideHairColor': '左侧发色',
'profile.avatar.rightSideHairColor': '右侧发色',
'profile.avatar.followHairColor': '跟随发色',
'profile.avatar.backHair': '后发',
'profile.avatar.hairLength': '发长',
'profile.avatar.option.bangs.crop': '短刘海',
Expand Down Expand Up @@ -4194,7 +4201,14 @@ My relationship with you, established lore and topics to avoid: [fill in].
'profile.avatar.unsupported':
'This Avatar uses a version that is not available right now, so its saved still image is shown and editing and character animation are paused. The original design is kept and returns when the version is available again.',
'profile.avatar.bangs': 'Bangs',
'profile.avatar.sideHair': 'Side hair',
'profile.avatar.sideHair': 'Left side hair',
'profile.avatar.rightSideHair': 'Right side hair',
'profile.avatar.species': 'Species',
'profile.avatar.option.species.human': 'Person',
'profile.avatar.option.species.goblin': 'Goblin',
'profile.avatar.leftSideHairColor': 'Left side hair color',
'profile.avatar.rightSideHairColor': 'Right side hair color',
'profile.avatar.followHairColor': 'Follow hair color',
'profile.avatar.backHair': 'Back hair',
'profile.avatar.hairLength': 'Hair length',
'profile.avatar.option.bangs.crop': 'Short',
Expand Down
74 changes: 73 additions & 1 deletion packages/client/test/avatar-appearance-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
AVATAR_HAIR_PARTS,
AVATAR_PARTS,
AVATAR_PRESETS,
AVATAR_SPECIES,
AVATAR_SPECIES_SWATCHES,
isIllustratedAvatarRecipe,
seededAvatarRecipe,
} from '../../core/src/bots/avatar-appearance.js';
import { LINE_PARTS, LINE_PRESETS, seededLineRecipe } from '../../core/src/bots/avatar-line.js';

Check warning on line 20 in packages/client/test/avatar-appearance-editor.test.ts

View workflow job for this annotation

GitHub Actions / lint, format, typecheck, test, build, docs

eslint(no-unused-vars)

packages/client/test/avatar-appearance-editor.test.ts:20:22: Identifier 'LINE_PRESETS' is imported but never used.
import { zhTranslate } from '../src/client/locale.js';

describe('Profile Avatar Appearance editing', () => {
Expand Down Expand Up @@ -211,6 +214,75 @@
}
});

it('saves a goblin with separately styled and colored side hair', async () => {
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
const save = vi.fn(async () => true);
const container = document.createElement('div');
document.body.append(container);
const root = createRoot(container);
const bot = {
slug: 'grub',
displayName: 'Grub',
roles: [],
aggregateState: 'idle',
workspaces: [],
createdAt: '',
};
const click = async (selector: string) =>
act(() => container.querySelector<HTMLButtonElement>(selector)!.click());
try {
await act(() =>
root.render(
createElement(AvatarAppearanceEditor, {
bot,
channelId: 'dm-grub',
onSave: save,
t: zhTranslate,
}),
),
);
await click('[data-avatar-edit]');
await click('[data-avatar-category="species"]');
expect(container.querySelectorAll('[data-avatar-option^="species:"]')).toHaveLength(
AVATAR_SPECIES.length,
);
await click('[data-avatar-option="species:goblin"]');
expect(
container
.querySelector('[data-avatar-option="species:goblin"]')
?.getAttribute('aria-pressed'),
).toBe('true');
await click('[data-avatar-category="sideHair"]');
await click('[data-avatar-option="sideHair:long"]');
await click('[data-avatar-category="rightSideHair"]');
await click('[data-avatar-option="rightSideHair:none"]');
await click('[data-avatar-category="colors"]');
const skin = AVATAR_SPECIES_SWATCHES.goblin;
expect(container.querySelectorAll('[data-avatar-option^="skinColor:"]')).toHaveLength(
skin.length,
);
await click('[data-avatar-option="leftSideHairColor:#e2b04a"]');
await click('[data-avatar-option="rightSideHairColor:#3fc1b8"]');
await click('[data-avatar-color-reset="rightSideHairColor"]');
expect(container.querySelector('[data-avatar-color-reset="rightSideHairColor"]')).toBeNull();
await click('[data-avatar-save]');
const saved = (save.mock.calls[0] as unknown[])[1] as Record<string, unknown>;
expect(saved).toMatchObject({
assetVersion: 2,
species: 'goblin',
sideHair: 'long',
rightSideHair: 'none',
leftSideHairColor: '#e2b04a',
skinColor: skin[0],
});
expect(saved).not.toHaveProperty('rightSideHairColor');
expect(isIllustratedAvatarRecipe(saved)).toBe(true);
} finally {
await act(() => root.unmount());
container.remove();
}
});

it('switches families without substituting parts and saves a bounded line recipe', async () => {
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
const save = vi.fn(async () => true);
Expand Down Expand Up @@ -292,7 +364,7 @@
recipe: {
family: 'illustrated',
schemaVersion: 1,
assetVersion: 2,
assetVersion: 999,
rigVersion: 1,
tail: 'swirl',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"./package.json": "./package.json"
},
"dependencies": {
"@botharness/pixel-avatar": "0.2.0",
"@botharness/pixel-avatar": "0.3.0",
"@botharness/pixel-banner": "0.1.0",
"@resvg/resvg-js": "2.6.2",
"silk-wasm": "3.7.1"
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/bots/avatar-appearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export {
AVATAR_COLORS,
AVATAR_HAIR_PARTS,
AVATAR_PARTS,
AVATAR_PIECE_COLORS,
AVATAR_PRESETS,
AVATAR_RANGES,
AVATAR_SPECIES,
AVATAR_SPECIES_SWATCHES,
AVATAR_SWATCHES,
AVATAR_TURNS,
canonicalRecipe as canonicalAvatarRecipe,
Expand All @@ -30,10 +33,13 @@ export {
pixelAvatarSvg as illustratedAvatarSvg,
pixelSymbolCells,
seededRecipe as seededAvatarRecipe,
withSpecies as withAvatarSpecies,
type AvatarColor,
type AvatarHairPart,
type AvatarPart,
type AvatarPieceColor,
type AvatarRange,
type AvatarSpecies,
type PixelAvatarRecipe as IllustratedAvatarRecipe,
type PixelCell,
type PixelSymbol,
Expand Down
21 changes: 21 additions & 0 deletions packages/core/test/avatar-artwork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
seededAvatarRecipe,
type AvatarPart,
type IllustratedAvatarRecipe,
withAvatarSpecies,
} from '../src/bots/avatar-appearance.js';
import { deriveAvatarAppearance } from '../src/bots/avatar-snapshot.js';
import { MAX_PERSONA_BOT_AVATAR_BYTES } from '../src/bots/persona-bot.js';
Expand Down Expand Up @@ -212,4 +213,24 @@ describe('illustrated Avatar artwork', () => {
expect(bytes.byteLength).toBeLessThanOrEqual(MAX_PERSONA_BOT_AVATAR_BYTES);
}
});

it('derives a goblin with split, separately colored side hair as asset version 2', () => {
const goblin = {
...withAvatarSpecies({ ...DEFAULT_ILLUSTRATED_RECIPE, hair: 'bob' }, 'goblin'),
rightSideHair: 'none' as const,
leftSideHairColor: '#E2B04A',
};
const derived = deriveAvatarAppearance(goblin);
expect(derived?.appearance.recipe).toMatchObject({
assetVersion: 2,
species: 'goblin',
rightSideHair: 'none',
leftSideHairColor: '#e2b04a',
});
expect(deriveAvatarAppearance({ ...goblin, species: 'dragon' } as never)).toBeUndefined();
const human = withAvatarSpecies(DEFAULT_ILLUSTRATED_RECIPE, 'human');
expect(
illustratedAvatarSvg({ ...human, skinColor: DEFAULT_ILLUSTRATED_RECIPE.skinColor }),
).toBe(illustratedAvatarSvg(detailedAvatarRecipe(DEFAULT_ILLUSTRATED_RECIPE)));
});
});
Loading
Loading