chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.3.1 Latest 5 packages
0
0
// The call the playground starts each bundled view with: the tool that
// draws it and its arguments, as harness/gallery/entries.mjs makes them
// for the gallery, its `$picked.*` filled from harness/gallery/answers.json's
// `picked`. A collection's view is drawn as its list (`list_records`), with
// one record of it (`get_record`) for when the tool is switched to that.
// Those `signIn` read only as the signed-in account (the gallery's `made`
// entries): signed out, the preview shows the tool's own error. An app's
// page (a view with `page`) is drawn by describe_app, not one of these
// tools, so it has none.
/** The tools that draw a view given inline. */
export const TOOLS = ['list_records', 'get_record', 'query'] as const;
export type Tool = (typeof TOOLS)[number];
export const isTool = (name: unknown): name is Tool => TOOLS.includes(name as Tool);
/** One bundled view's call, and the gallery's title for what it draws. */
export type Example = {
title: string;
tool: Tool;
arguments: Record<string, unknown>;
/** One record of the collection, for a collection's view, as `get_record` reads it. */
record?: Record<string, unknown>;
signIn?: true;
};
const repo = 'at://chadtmiller.com/dev.knotless.repo/knotless';
const pull = 'at://did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.pull/3n2hkefgu7ieu';
const gallery = 'at://did:plc:kqd2csf4wvgvqioz374r5r2y/social.grain.gallery/3mzzwhvdshf7d';
const me = 'did:plc:bcgltzqazw5tb6k2g3ttenbj';
const dan = 'did:plc:fpruhuo22xkm5o7ttr2ktxdo';
const post = 'at://did:plc:fpruhuo22xkm5o7ttr2ktxdo/app.bsky.feed.post/3n2icn7szlk2n';
const q = (title: string, method: string, params: Record<string, unknown>, signIn?: true): Example => ({ title, tool: 'query', arguments: { method, params }, ...(signIn && { signIn }) });
const records = (title: string, actor: string, collection: string, uri: string): Example => ({ title, tool: 'list_records', arguments: { actor, collection, limit: 4 }, record: { uri } });
/** Each bundled view's call, by its id. */
export const EXAMPLES: Record<string, Example> = {
'bsky-timeline': q('Timeline', 'app.bsky.feed.getTimeline', { limit: 6 }, true),
'bsky-feed': q('Feed', 'app.bsky.feed.getFeed', { feed: 'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot', limit: 6 }),
'bsky-author-feed': q('An account’s posts', 'app.bsky.feed.getAuthorFeed', { actor: 'danabra.mov', filter: 'posts_no_replies', limit: 6 }),
'bsky-thread': { ...q('Thread', 'app.bsky.feed.getPostThread', { uri: post, depth: 2 }), record: { uri: post } },
'bsky-profile': q('Profile', 'app.bsky.actor.getProfile', { actor: 'danabra.mov' }),
'bsky-notifications': q('Notifications', 'app.bsky.notification.listNotifications', { limit: 25 }, true),
'bsky-search': q('Search', 'app.bsky.feed.searchPosts', { q: 'atproto', limit: 6 }, true),
'bsky-feed-generators': q('Feeds’ cards', 'app.bsky.feed.getFeedGenerators', {
feeds: [
'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot',
'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/with-friends',
'at://did:plc:wqowuobffl66jv3kpsvo7ak4/app.bsky.feed.generator/the-science-feed'
]
}),
'bsky-chats': q('Chats', 'chat.bsky.convo.listConvos', {}, true),
'bsky-chat': q('Chat', 'chat.bsky.convo.getMessages', { convoId: '3n2group0chat' }, true),
'bsky-chat-with': q('Chat with an account', 'chat.bsky.convo.getConvoForMembers', { members: [dan] }, true),
'bsky-chat-availability': q('Message button', 'chat.bsky.convo.getConvoAvailability', { members: [dan] }, true),
'grain-feed': q('Feed', 'social.grain.feed.getFeed', { feed: 'at://did:web:grain.social/social.grain.feed.generator/recent', limit: 4 }),
'grain-gallery-view': q('Gallery', 'social.grain.gallery.getGallery', { gallery }),
'grain-notifications': q('Notifications', 'social.grain.notification.listNotifications', {}, true),
'knotless-feed': q('Activity', 'dev.knotless.getFeed', { actor: me, limit: 8 }),
'knotless-notifications': q('Notifications', 'dev.knotless.listNotifications', {}, true),
'knotless-profile': q('Profile', 'dev.knotless.getProfile', { actor: 'chadtmiller.com' }),
'knotless-actor-repos': q('Repositories', 'dev.knotless.getActorRepos', { actor: 'chadtmiller.com' }),
'knotless-actor-stars': q('Stars', 'dev.knotless.getActorStars', { actor: 'chadtmiller.com' }),
'knotless-actor-items': q('An account’s pulls and issues', 'dev.knotless.listActorItems', { actor: 'chadtmiller.com', kind: 'pull', relation: 'created', state: 'closed', limit: 6 }),
'knotless-repo': q('Repository', 'dev.knotless.getRepo', { repo }),
'knotless-items': q('Pulls and issues', 'dev.knotless.listItems', { repo, kind: 'issue', state: 'open', limit: 6 }),
'knotless-thread': q('Pull or issue', 'dev.knotless.getThread', { repo, uri: pull }),
'knotless-diff': q('Pull’s changes', 'dev.knotless.getPullDiff', { repo, uri: pull, paths: ['Dockerfile'] }),
'knotless-commits': q('Commits', 'dev.knotless.listCommits', { repo, limit: 6 }),
'knotless-checks': q('Checks', 'dev.knotless.listChecks', { repo, key: '3myg5zr2qubsd', limit: 6 }),
'knotless-file': q('File', 'dev.knotless.getFile', { repo, path: 'README.md' }),
'plyr-likes': records('Liked tracks', 'chadtmiller.com', 'fm.plyr.like', 'at://did:plc:bcgltzqazw5tb6k2g3ttenbj/fm.plyr.like/3myqbfsdcm2u2'),
'plyr-list': records('Playlists', 'zzstoatzz.io', 'fm.plyr.list', 'at://did:plc:xbtmt2zjwlrfegqvch7fboei/fm.plyr.list/3mzrbtvnopr22'),
'plyr-tracks': records('An artist’s tracks', 'zzstoatzz.io', 'fm.plyr.track', 'at://did:plc:xbtmt2zjwlrfegqvch7fboei/fm.plyr.track/3n2rehscmuk2h'),
'plyr-latest-tracks': q('Latest tracks', 'fm.plyr.unspecced.getLatestTracks', { limit: 10 }),
'plyr-top-tracks': q('Top tracks', 'fm.plyr.unspecced.getTopTracks', { period: 'week', limit: 10 }),
'standard-document': records('Blog posts', 'danabra.mov', 'site.standard.document', 'at://did:plc:fpruhuo22xkm5o7ttr2ktxdo/site.standard.document/3mncmabgnmc2x'),
'standard-publication': records('Blogs', 'danabra.mov', 'site.standard.publication', 'at://did:plc:fpruhuo22xkm5o7ttr2ktxdo/site.standard.publication/3m23dstduds2v')
};
/** The view the playground opens with, when nothing was kept or shared. */
export const FIRST = 'bsky-profile';
/** A start of one's own: a minimal list view of a collection, and its call. */
export const BLANK: { view: Record<string, unknown>; example: Example } = {
view: {
$type: 'place.hud.view',
collection: 'app.bsky.feed.post',
description: 'Posts, as their text and when each was written',
list: {
summary: { noun: ['post', 'posts'], label: { $: 'value.text' } },
layout: {
component: 'List',
props: { items: { $: 'records' }, style: 'rows', empty: 'No posts' },
children: [
{ component: 'Text', props: { value: { $: 'value.text' }, clamp: 4 } },
{ component: 'Time', props: { value: { $: 'value.createdAt' } } }
]
}
}
},
example: { title: 'Blank', tool: 'list_records', arguments: { actor: 'danabra.mov', collection: 'app.bsky.feed.post', limit: 5 } }
};
/** A view's call when it has no example: a query view's method with no params, or a collection's records of no one in particular. */
export function exampleOf(id: string, view: Record<string, unknown>): Example {
const known = EXAMPLES[id];
if (known) return known;
if (typeof view.method === 'string') return { title: id, tool: 'query', arguments: { method: view.method, params: {} } };
return { title: id, tool: 'list_records', arguments: { actor: 'danabra.mov', collection: typeof view.collection === 'string' ? view.collection : '', limit: 4 } };
}