mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
refactor(desktop): drop dead goose-set avatar refs
The goose avatar sets (fuzzies/gloopies/pollies) were removed from the project, so the filename-fallback support for them in gooseAppAvatarRefs is dead intent. Remove GOOSE_COLLECTION_ID_PATTERN, the allowFilenameFallback option, and the now-orphaned avatarRefFileFallback in resolveImportedPersonaAvatarUrl. The app-avatar: prefix parsing and runtime-avatar whitelist are untouched. Trim the fallback-dependent test and swap goose-set sample ids for neutral ones in remaining fixtures. Co-authored-by: Taylor Ho <taylorkmho@gmail.com> Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
This commit is contained in:
co-authored by
Taylor Ho
parent
67eb982b1f
commit
19f58a2603
@@ -375,7 +375,7 @@ mod tests {
|
||||
let md = br#"---
|
||||
name: fizz
|
||||
display_name: Fizz
|
||||
avatar: app-avatar:pollies-12
|
||||
avatar: app-avatar:persona-12
|
||||
runtime: goose
|
||||
---
|
||||
You are Fizz.
|
||||
@@ -388,7 +388,7 @@ You are Fizz.
|
||||
assert_eq!(result.personas[0].display_name, "Fizz");
|
||||
assert_eq!(
|
||||
result.personas[0].avatar_ref.as_deref(),
|
||||
Some("app-avatar:pollies-12")
|
||||
Some("app-avatar:persona-12")
|
||||
);
|
||||
assert_eq!(result.personas[0].source_file, "fizz.md");
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ fn parse_md_persona_preserves_app_avatar_ref() {
|
||||
name: goosey
|
||||
display_name: Goosey
|
||||
description: Goose internal agent.
|
||||
avatar: app-avatar:gloopies-19
|
||||
avatar: app-avatar:persona-19
|
||||
model: anthropic:claude-sonnet-4
|
||||
runtime: goose
|
||||
---
|
||||
@@ -418,7 +418,7 @@ You are Goosey.
|
||||
let result = parse_md_persona(md).unwrap();
|
||||
assert_eq!(result.display_name, "Goosey");
|
||||
assert_eq!(result.avatar_data_url, None);
|
||||
assert_eq!(result.avatar_ref.as_deref(), Some("app-avatar:gloopies-19"));
|
||||
assert_eq!(result.avatar_ref.as_deref(), Some("app-avatar:persona-19"));
|
||||
assert_eq!(result.model.as_deref(), Some("claude-sonnet-4"));
|
||||
assert_eq!(result.provider.as_deref(), Some("anthropic"));
|
||||
assert_eq!(result.runtime.as_deref(), Some("goose"));
|
||||
@@ -446,7 +446,7 @@ fn parse_md_persona_accepts_goose_internal_frontmatter() {
|
||||
let md = br#"---
|
||||
name: block.md
|
||||
description: Opinionated guide to Block's intelligence operating model.
|
||||
avatar: app-avatar:gloopies-19
|
||||
avatar: app-avatar:persona-19
|
||||
metadata:
|
||||
gooseInternalBundled: true
|
||||
---
|
||||
@@ -454,7 +454,7 @@ You are block.md.
|
||||
"#;
|
||||
let result = parse_md_persona(md).unwrap();
|
||||
assert_eq!(result.display_name, "block.md");
|
||||
assert_eq!(result.avatar_ref.as_deref(), Some("app-avatar:gloopies-19"));
|
||||
assert_eq!(result.avatar_ref.as_deref(), Some("app-avatar:persona-19"));
|
||||
assert_eq!(result.system_prompt, "You are block.md.\n");
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ fn parse_zip_with_plain_md_persona_preserves_avatar_ref() {
|
||||
name: fizz
|
||||
display_name: Fizz
|
||||
description: Engineering agent.
|
||||
avatar: app-avatar:pollies-12
|
||||
avatar: app-avatar:persona-12
|
||||
runtime: goose
|
||||
model: anthropic:claude-sonnet-4
|
||||
---
|
||||
@@ -508,7 +508,7 @@ You are Fizz.
|
||||
assert_eq!(result.personas[0].display_name, "Fizz");
|
||||
assert_eq!(
|
||||
result.personas[0].avatar_ref.as_deref(),
|
||||
Some("app-avatar:pollies-12")
|
||||
Some("app-avatar:persona-12")
|
||||
);
|
||||
assert_eq!(result.personas[0].source_file, "fizz.md");
|
||||
}
|
||||
|
||||
@@ -8,31 +8,22 @@ import {
|
||||
|
||||
test("toGooseAppAvatarRef canonicalizes app-avatar refs", () => {
|
||||
assert.equal(
|
||||
toGooseAppAvatarRef("app-avatar:gloopies-19"),
|
||||
"app-avatar:gloopies-19",
|
||||
toGooseAppAvatarRef("app-avatar:persona-19"),
|
||||
"app-avatar:persona-19",
|
||||
);
|
||||
});
|
||||
|
||||
test("toGooseAppAvatarRef ignores Goose-looking paths by default", () => {
|
||||
assert.equal(toGooseAppAvatarRef("./avatars/pollies_2.png"), null);
|
||||
});
|
||||
|
||||
test("toGooseAppAvatarRef detects Goose avatar ids in paths during import", () => {
|
||||
assert.equal(
|
||||
toGooseAppAvatarRef("./avatars/pollies_2.png", {
|
||||
allowFilenameFallback: true,
|
||||
}),
|
||||
"app-avatar:pollies-2",
|
||||
);
|
||||
test("toGooseAppAvatarRef ignores filesystem-looking paths", () => {
|
||||
assert.equal(toGooseAppAvatarRef("./avatars/persona_2.png"), null);
|
||||
});
|
||||
|
||||
test("resolveImportedPersonaAvatarUrl prefers app-avatar refs over data URLs", () => {
|
||||
assert.equal(
|
||||
resolveImportedPersonaAvatarUrl({
|
||||
avatarDataUrl: "https://example.com/avatar.png",
|
||||
avatarRef: "app-avatar:fuzzies-1",
|
||||
avatarRef: "app-avatar:persona-1",
|
||||
}),
|
||||
"app-avatar:fuzzies-1",
|
||||
"app-avatar:persona-1",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -46,13 +37,13 @@ test("resolveImportedPersonaAvatarUrl preserves ordinary image URLs", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveImportedPersonaAvatarUrl does not rewrite Goose-looking remote URLs", () => {
|
||||
test("resolveImportedPersonaAvatarUrl does not rewrite remote image URLs", () => {
|
||||
assert.equal(
|
||||
resolveImportedPersonaAvatarUrl({
|
||||
avatarDataUrl: "https://cdn.example.com/avatars/pollies_2.png",
|
||||
avatarDataUrl: "https://cdn.example.com/avatars/persona_2.png",
|
||||
avatarRef: null,
|
||||
}),
|
||||
"https://cdn.example.com/avatars/pollies_2.png",
|
||||
"https://cdn.example.com/avatars/persona_2.png",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -65,13 +56,3 @@ test("resolveImportedPersonaAvatarUrl preserves URL avatar refs", () => {
|
||||
"https://example.com/persona-avatar.png",
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveImportedPersonaAvatarUrl preserves Goose-looking URL avatar refs", () => {
|
||||
assert.equal(
|
||||
resolveImportedPersonaAvatarUrl({
|
||||
avatarDataUrl: null,
|
||||
avatarRef: " https://cdn.example.com/avatars/pollies_2.png ",
|
||||
}),
|
||||
"https://cdn.example.com/avatars/pollies_2.png",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
export const GOOSE_APP_AVATAR_REF_PREFIX = "app-avatar:" as const;
|
||||
|
||||
const APP_AVATAR_ID_PATTERN = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
||||
const GOOSE_COLLECTION_ID_PATTERN = /^(fuzzies|gloopies|pollies)[-_](\d+)$/;
|
||||
|
||||
type ParseGooseAppAvatarOptions = {
|
||||
allowFilenameFallback?: boolean;
|
||||
};
|
||||
|
||||
function cleanAvatarCandidate(value: string): string {
|
||||
const basename = value
|
||||
@@ -19,7 +14,6 @@ function cleanAvatarCandidate(value: string): string {
|
||||
|
||||
export function parseGooseAppAvatarId(
|
||||
value: string | null | undefined,
|
||||
options: ParseGooseAppAvatarOptions = {},
|
||||
): string | null {
|
||||
const trimmed = value?.trim();
|
||||
if (!trimmed) {
|
||||
@@ -33,22 +27,13 @@ export function parseGooseAppAvatarId(
|
||||
return APP_AVATAR_ID_PATTERN.test(id) ? id : null;
|
||||
}
|
||||
|
||||
if (options.allowFilenameFallback) {
|
||||
const candidate = cleanAvatarCandidate(trimmed);
|
||||
const collectionMatch = GOOSE_COLLECTION_ID_PATTERN.exec(candidate);
|
||||
if (collectionMatch) {
|
||||
return `${collectionMatch[1]}-${collectionMatch[2]}`;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function toGooseAppAvatarRef(
|
||||
value: string | null | undefined,
|
||||
options: ParseGooseAppAvatarOptions = {},
|
||||
): string | null {
|
||||
const id = parseGooseAppAvatarId(value, options);
|
||||
const id = parseGooseAppAvatarId(value);
|
||||
return id ? `${GOOSE_APP_AVATAR_REF_PREFIX}${id}` : null;
|
||||
}
|
||||
|
||||
@@ -67,15 +52,8 @@ export function resolveImportedPersonaAvatarUrl({
|
||||
avatarDataUrl?: string | null;
|
||||
avatarRef?: string | null;
|
||||
}): string | null {
|
||||
const trimmedAvatarRef = avatarRef?.trim();
|
||||
const avatarRefFileFallback =
|
||||
trimmedAvatarRef && !isPersistableAvatarUrl(trimmedAvatarRef)
|
||||
? toGooseAppAvatarRef(trimmedAvatarRef, { allowFilenameFallback: true })
|
||||
: null;
|
||||
const gooseRef =
|
||||
toGooseAppAvatarRef(avatarRef) ??
|
||||
avatarRefFileFallback ??
|
||||
toGooseAppAvatarRef(avatarDataUrl);
|
||||
toGooseAppAvatarRef(avatarRef) ?? toGooseAppAvatarRef(avatarDataUrl);
|
||||
if (gooseRef) {
|
||||
return gooseRef;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user