chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.5.0 Latest 5 packages
0
0
Profiles have Follow, and knotless's page is another's profile
crates/hud-core/src/oauth/tests.rs+3−3
| @@ -1307,15 +1307,15 @@ async fn writes_held_to_the_scope_asked() { | ||
.await; | ||
assert!(made.unwrap().is_ok()); | ||
// A collection no view writes is refused before the PDS is asked. | ||
let follow = json!({ "collection": "app.bsky.graph.follow", "record": { | ||
let block = json!({ "collection": "app.bsky.graph.block", "record": { | ||
"subject": OTHER, "createdAt": "2026-11-14T12:00:00.000Z" } }); | ||
let writes = f.lock().unwrap().writes; | ||
let refused = h | ||
.call_tool("create_record", Some(&follow), Some(&account)) | ||
.call_tool("create_record", Some(&block), Some(&account)) | ||
.await; | ||
assert!(matches!( | ||
refused.unwrap(), | ||
Err(Refusal::Error(e)) if e.starts_with("HUD does not write app.bsky.graph.follow records") | ||
Err(Refusal::Error(e)) if e.starts_with("HUD does not write app.bsky.graph.block records") | ||
)); | ||
assert_eq!(f.lock().unwrap().writes, writes); | ||
// Granted less than asked: what the sign-in does not allow. | ||
crates/hud-core/src/scope.rs+2−1
| @@ -92,7 +92,8 @@ mod tests { | ||
"a Compose's writes" | ||
); | ||
assert!(writes(&s, "place.hud.theme")); | ||
assert!(!writes(&s, "app.bsky.graph.follow"), "no view writes it"); | ||
assert!(writes(&s, "app.bsky.graph.follow"), "a profile's Follow"); | ||
assert!(!writes(&s, "app.bsky.graph.block"), "no view writes it"); | ||
assert!(calls(&s, "did:web:api.bsky.chat#bsky_chat")); | ||
assert!(calls(&s, "did:web:knotless.dev#knotless_appview")); | ||
assert!(!calls(&s, "did:web:elsewhere.example#svc")); | ||
crates/hud-core/src/tools.rs+102−42
| @@ -1334,13 +1334,12 @@ impl Hud { | ||
Some(m) => std::slice::from_ref(m), | ||
None => v.page.as_ref().map_or(&[][..], |p| &p.queries[..]), | ||
}; | ||
// A join for one side alone (one's own page, or another's) | ||
// runs only there. | ||
let mine = scope["mine"] == true; | ||
let runs = queries.iter().filter(|q| q.mine.is_none_or(|m| m == mine)); | ||
let joined = self | ||
.query_joins( | ||
Some(queries.iter()), | ||
v.service.as_deref(), | ||
Some(&scope), | ||
account, | ||
) | ||
.query_joins(Some(runs), v.service.as_deref(), Some(&scope), account) | ||
.await | ||
.unwrap_or_default(); | ||
if let Some(m) = more | ||
| @@ -3102,11 +3101,12 @@ mod tests { | ||
assert_eq!(kept["_meta"]["ui"], page); | ||
} | ||
| ||
/// knotless's page is its own view's (`knotless-app`): My work with | ||
/// its counts, each row opening its query, Favorites from the stars and | ||
/// Recent, a tree the clients draw, signed in on one's own page or not; | ||
/// an app with no page view, or no account to draw one for, has the | ||
/// generic page. | ||
/// knotless's page is its own view's (`knotless-app`), a tree the | ||
/// clients draw. One's own is Home: My work with its counts, each row | ||
/// opening its query, Favorites from the stars and Recent. Another's, | ||
/// signed in or not, is their profile: who they are, Follow, their | ||
/// repositories and Recent. An app with no page view, or no account to | ||
/// draw one for, has the generic page. | ||
#[test] | ||
fn knotless_has_its_own_page() { | ||
let origin = "https://hud.example"; | ||
| @@ -3121,19 +3121,31 @@ mod tests { | ||
"author": { "did": did, "handle": "chadtmiller.com" }, "comments": 0 }, | ||
"repo": { "did": did, "handle": "chadtmiller.com", "name": "knotless" } }) | ||
}; | ||
let joins = json!({ | ||
let recent = json!({ "events": [{ "createdAt": "2026-11-16T10:00:00.000Z", | ||
"actor": { "did": did, "handle": "chadtmiller.com" }, | ||
"repo": { "did": did, "handle": "chadtmiller.com", "name": "knotless" }, | ||
"action": { "$type": "dev.knotless.getFeed#opened", | ||
"subject": format!("at://{did}/dev.knotless.issue/1"), | ||
"title": "Issue 1", "subjectState": "open" } }] }); | ||
let monolith = json!({ "uri": format!("at://{did}/dev.knotless.repo/monolith"), | ||
"owner": { "did": did, "handle": "chadtmiller.com" }, | ||
"name": "monolith", "description": "An atproto PDS", | ||
"language": { "name": "Rust" }, "starCount": 3, | ||
"createdAt": "2026-01-01T00:00:00.000Z" }); | ||
let home = json!({ | ||
"issues": { "items": (0..50).map(item).collect::<Vec<_>>(), "cursor": "50" }, | ||
"pulls": { "items": [] }, | ||
"stars": { "repos": [{ "uri": format!("at://{did}/dev.knotless.repo/monolith"), | ||
"owner": { "did": did, "handle": "chadtmiller.com" }, | ||
"name": "monolith", "description": "An atproto PDS", | ||
"createdAt": "2026-01-01T00:00:00.000Z" }] }, | ||
"recent": { "events": [{ "createdAt": "2026-11-16T10:00:00.000Z", | ||
"actor": { "did": did, "handle": "chadtmiller.com" }, | ||
"repo": { "did": did, "handle": "chadtmiller.com", "name": "knotless" }, | ||
"action": { "$type": "dev.knotless.getFeed#opened", | ||
"subject": format!("at://{did}/dev.knotless.issue/1"), | ||
"title": "Issue 1", "subjectState": "open" } }] } | ||
"stars": { "repos": [monolith] }, | ||
"recent": recent | ||
}); | ||
let profile = json!({ | ||
"profile": { "did": did, "handle": "chadtmiller.com", "displayName": "Chad", | ||
"description": "Makes knotless", "pronouns": "he/him", | ||
"followersCount": 12, "followsCount": 3, | ||
"links": [{ "url": "https://chadtmiller.com" }], | ||
"orgs": [{ "actor": { "did": "did:plc:knotless", "handle": "knotless.dev" } }] }, | ||
"repos": { "repos": [monolith] }, | ||
"recent": recent | ||
}); | ||
let me = Some((did, handle)); | ||
for (me, mine) in [(me, true), (None, false)] { | ||
| @@ -3144,35 +3156,64 @@ mod tests { | ||
scope["actor"], | ||
json!({ "did": did, "handle": "chadtmiller.com" }) | ||
); | ||
scope["joins"] = joins.clone(); | ||
let page = page_ui(v, &scope, None); | ||
scope["joins"] = if mine { home.clone() } else { profile.clone() }; | ||
let viewer = me.map(|(did, _)| did); | ||
let page = page_ui(v, &scope, viewer); | ||
assert_eq!(ui::check(&page), Ok(()), "{page:#}"); | ||
assert_eq!(page["title"], "knotless"); | ||
let drawn = page.to_string(); | ||
for words in [ | ||
"Issues", | ||
"Pull requests", | ||
"Review requests", | ||
"Starred", | ||
"Favorites", | ||
"monolith", | ||
"Recent", | ||
] { | ||
assert!(drawn.contains(&format!("\"{words}\"")), "{words}: {page:#}"); | ||
let (words, parts): (&[&str], &[&str]) = if mine { | ||
( | ||
&[ | ||
"My work", | ||
"Issues", | ||
"Pull requests", | ||
"Review requests", | ||
"Notifications", | ||
"Starred", | ||
"Favorites", | ||
], | ||
// Each row opens its query, for the page's account. | ||
&[ | ||
"\"method\":\"dev.knotless.listActorItems\"", | ||
"\"relation\":\"review\"", | ||
], | ||
) | ||
} else { | ||
( | ||
&[ | ||
"Chad", | ||
"he/him", | ||
"followers", | ||
"Follow", | ||
"Organizations", | ||
"knotless.dev", | ||
"Repositories", | ||
"Rust", | ||
"All repositories", | ||
"Stars", | ||
"Activity", | ||
], | ||
&[ | ||
"\"collection\":\"dev.knotless.follow\"", | ||
"\"method\":\"dev.knotless.getActorRepos\"", | ||
], | ||
) | ||
}; | ||
for w in words.iter().chain(&["monolith", "Recent"]) { | ||
assert!(drawn.contains(&format!("\"{w}\"")), "{w}: {page:#}"); | ||
} | ||
assert_eq!(drawn.contains("\"My work\""), mine); | ||
assert_eq!(drawn.contains("\"Notifications\""), mine); | ||
// Each row opens its query, for the page's account. | ||
for part in [ | ||
"\"method\":\"dev.knotless.listActorItems\"", | ||
"\"relation\":\"review\"", | ||
for part in parts.iter().chain(&[ | ||
"\"method\":\"dev.knotless.getActorStars\"", | ||
"\"actor\":\"did:plc:chad\"", | ||
] { | ||
]) { | ||
assert!(drawn.contains(part), "{part}: {page:#}"); | ||
} | ||
assert_eq!(drawn.contains("\"My work\""), mine); | ||
assert_eq!(drawn.contains("\"Follow\""), !mine); | ||
// A recorded answer is drawn as the tool drew it. | ||
let mut answer = json!({ "structuredContent": scope, "_meta": {} }); | ||
let meta = json!({ "viewer": me.map(|(did, h)| json!({ "did": did, "handle": h })) }); | ||
let mut answer = json!({ "structuredContent": scope, "_meta": meta }); | ||
resolve_answer(&mut answer, Some("describe_app"), None).unwrap(); | ||
assert_eq!(answer["_meta"]["ui"], page); | ||
} | ||
| @@ -4701,6 +4742,25 @@ mod tests { | ||
.unwrap(); | ||
assert_eq!(page.structured["actor"]["did"], ALICE); | ||
assert_eq!(page.structured["mine"], true); | ||
// knotless's page runs Home's joins on one's own page, and the | ||
// profile's on another's. | ||
let ran = |actor: &str| { | ||
let (hud, me) = (hud.clone(), &me); | ||
let args = json!({ "domain": "knotless.dev", "actor": actor }); | ||
async move { | ||
let page = call(&hud, "describe_app", args, Some(me)).await.unwrap(); | ||
let mut joins: Vec<String> = page.structured["joins"] | ||
.as_object() | ||
.unwrap() | ||
.keys() | ||
.cloned() | ||
.collect(); | ||
joins.sort(); | ||
joins | ||
} | ||
}; | ||
assert_eq!(ran("me").await, ["issues", "pulls", "recent", "stars"]); | ||
assert_eq!(ran("bob.test").await, ["profile", "recent", "repos"]); | ||
let blog = call( | ||
&hud, | ||
"describe_app", | ||
crates/hud-core/src/view.rs+131−23
| @@ -202,6 +202,9 @@ pub struct QueryJoin { | ||
pub params: Vec<(String, Param)>, | ||
/// What the tool's text says of its answer, if anything. | ||
pub say: Option<Say>, | ||
/// An app page's join that runs on one side alone: on one's own page | ||
/// (`true`) or on another's (`false`); none runs on both. | ||
pub mine: Option<bool>, | ||
} | ||
| ||
impl QueryJoin { | ||
| @@ -902,7 +905,14 @@ fn parse_app_page( | ||
let at = "page"; | ||
let po = p.object(v, at, &["join", "layout", "tag", "pages"])?; | ||
let queries = match po.get("join") { | ||
Some(j) => joins(p, j, "page.join", 1, Some((PAGE_SCOPE, false))).1, | ||
Some(j) => { | ||
let top = Top { | ||
keys: PAGE_SCOPE, | ||
records: false, | ||
page: true, | ||
}; | ||
joins(p, j, "page.join", 1, Some(top)).1 | ||
} | ||
None => Vec::new(), | ||
}; | ||
layout(p, po.get("layout"), at); | ||
| @@ -1414,7 +1424,14 @@ fn parse_query_mode(p: &mut Problems, v: &Value) -> Option<QueryMode> { | ||
); | ||
} | ||
let queries = match o.get("join") { | ||
Some(j) => joins(p, j, "query.join", 1, Some((QUERY_SCOPE, false))).1, | ||
Some(j) => { | ||
let top = Top { | ||
keys: QUERY_SCOPE, | ||
records: false, | ||
page: false, | ||
}; | ||
joins(p, j, "query.join", 1, Some(top)).1 | ||
} | ||
None => Vec::new(), | ||
}; | ||
let summary = o | ||
| @@ -1529,7 +1546,14 @@ fn parse_mode(p: &mut Problems, v: &Value, at: &str) -> Option<Mode> { | ||
RECORD_SCOPE | ||
}; | ||
let (join, queries) = match o.get("join") { | ||
Some(j) => joins(p, j, &format!("{at}.join"), 1, Some((keys, true))), | ||
Some(j) => { | ||
let top = Top { | ||
keys, | ||
records: true, | ||
page: false, | ||
}; | ||
joins(p, j, &format!("{at}.join"), 1, Some(top)) | ||
} | ||
None => (Vec::new(), Vec::new()), | ||
}; | ||
let summary = o | ||
| @@ -1543,15 +1567,25 @@ fn parse_mode(p: &mut Problems, v: &Value, at: &str) -> Option<Mode> { | ||
}) | ||
} | ||
| ||
/// A join array: record joins and, at a mode's top level (`top`: the keys | ||
/// of the main scope its query joins read, and whether record joins go | ||
/// there too, as in a records mode), query joins. | ||
/// Where a join array sits at a mode's top level: the keys of the main | ||
/// scope its query joins read, whether record joins go there too (as in a | ||
/// records mode), and whether it is an app page's, whose query joins may | ||
/// each run on one side alone (`mine`). | ||
#[derive(Clone, Copy)] | ||
struct Top<'a> { | ||
keys: &'a [&'a str], | ||
records: bool, | ||
page: bool, | ||
} | ||
| ||
/// A join array: record joins and, at a mode's top level (`top`), query | ||
/// joins. | ||
fn joins( | ||
p: &mut Problems, | ||
v: &Value, | ||
at: &str, | ||
depth: usize, | ||
top: Option<(&[&str], bool)>, | ||
top: Option<Top>, | ||
) -> (Vec<Join>, Vec<QueryJoin>) { | ||
let Some(a) = v.as_array() else { | ||
p.add(at, "must be an array of joins"); | ||
| @@ -1571,7 +1605,7 @@ fn joins( | ||
let at = format!("{at}[{i}]"); | ||
let is_query = j.as_object().is_some_and(|o| o.contains_key("query")); | ||
let name = match (is_query, top) { | ||
(true, Some((keys, records))) => query_join(p, j, &at, keys, records).map(|q| { | ||
(true, Some(top)) => query_join(p, j, &at, top).map(|q| { | ||
let name = q.name.clone(); | ||
queries.push(q); | ||
name | ||
| @@ -1583,7 +1617,7 @@ fn joins( | ||
); | ||
None | ||
} | ||
(false, Some((_, false))) => { | ||
(false, Some(Top { records: false, .. })) => { | ||
p.add( | ||
&at, | ||
"a query view's joins are query joins: { as, query, params?, service?, say? }", | ||
| @@ -1606,27 +1640,31 @@ fn joins( | ||
names.push(name); | ||
} | ||
} | ||
if queries.len() > MAX_QUERY_JOINS { | ||
// A page's joins for one's own page and for another's run apart: each | ||
// side holds to the cap. | ||
let side = |mine: bool| queries.iter().filter(|q| q.mine != Some(!mine)).count(); | ||
let most = side(true).max(side(false)); | ||
if most > MAX_QUERY_JOINS { | ||
p.add( | ||
at, | ||
format_args!("{} query joins, more than {MAX_QUERY_JOINS}", queries.len()), | ||
format_args!("{most} query joins, more than {MAX_QUERY_JOINS}"), | ||
); | ||
} | ||
(out, queries) | ||
} | ||
| ||
/// A query join: `{ as, query, params?, service?, say? }`, its params each | ||
/// literal JSON (a string, number or boolean, or an array of them), a | ||
/// binding or `{"$root": path}` into the main scope's `keys`, never a | ||
/// join's result. | ||
fn query_join( | ||
p: &mut Problems, | ||
v: &Value, | ||
at: &str, | ||
keys: &[&str], | ||
records: bool, | ||
) -> Option<QueryJoin> { | ||
let o = p.object(v, at, &["as", "query", "params", "service", "say"])?; | ||
/// A query join: `{ as, query, params?, service?, say? }`, and in an app | ||
/// page `mine?`, its params each literal JSON (a string, number or | ||
/// boolean, or an array of them), a binding or `{"$root": path}` into the | ||
/// main scope's keys, never a join's result. | ||
fn query_join(p: &mut Problems, v: &Value, at: &str, top: Top) -> Option<QueryJoin> { | ||
let Top { | ||
keys, | ||
records, | ||
page, | ||
} = top; | ||
let allowed: &[&str] = &["as", "query", "params", "service", "say", "mine"]; | ||
let o = p.object(v, at, &allowed[..if page { 6 } else { 5 }])?; | ||
let name = match o.get("as").and_then(Value::as_str) { | ||
Some(s) if Path::parse(s).is_some_and(|p| p.0.len() == 1) => Some(s.to_string()), | ||
_ => { | ||
| @@ -1686,6 +1724,17 @@ fn query_join( | ||
); | ||
} | ||
let say = o.get("say").and_then(|s| say(p, s, &format!("{at}.say"))); | ||
let mine = match o.get("mine") { | ||
None => None, | ||
Some(Value::Bool(b)) => Some(*b), | ||
Some(_) => { | ||
p.add( | ||
&format!("{at}.mine"), | ||
"true, to run on one's own page alone, or false, on another's alone", | ||
); | ||
None | ||
} | ||
}; | ||
Some(QueryJoin { | ||
name: name?, | ||
at: at.to_string(), | ||
| @@ -1693,6 +1742,7 @@ fn query_join( | ||
service, | ||
params, | ||
say, | ||
mine, | ||
}) | ||
} | ||
| ||
| @@ -5246,6 +5296,10 @@ mod tests { | ||
"knotless-app pulls", | ||
"knotless-app stars", | ||
"knotless-app recent", | ||
"knotless-app profile", | ||
"knotless-app repos", | ||
"knotless-profile repos", | ||
"knotless-profile recent", | ||
"knotless-repo readme", | ||
"knotless-repo release", | ||
"standard-document replies", | ||
| @@ -5403,6 +5457,60 @@ mod tests { | ||
assert!(for_domain("bsky.chat").is_none()); | ||
} | ||
| ||
/// A page's join may run on one side alone: one's own page (`mine` | ||
/// true) or another's (false). Each side holds to the cap, so a page | ||
/// may join more in all; `mine` is a page's alone, and a boolean. | ||
#[test] | ||
fn page_joins_run_on_a_side() { | ||
let join = |n: usize, mine: Option<bool>| { | ||
let mut j = json!({ "as": format!("q{n}"), "query": "dev.knotless.getFeed", | ||
"params": { "actor": { "$": "actor.did" } } }); | ||
if let Some(m) = mine { | ||
j["mine"] = json!(m); | ||
} | ||
j | ||
}; | ||
// Three for one's own page, two for another's, one for both: four | ||
// and three. | ||
let mut both: Vec<Value> = (0..3).map(|n| join(n, Some(true))).collect(); | ||
both.extend((3..5).map(|n| join(n, Some(false)))); | ||
both.push(join(5, None)); | ||
let v = parse(&app_page(json!(both)), true).unwrap(); | ||
let sides: Vec<Option<bool>> = v.query_joins().map(|q| q.mine).collect(); | ||
assert_eq!( | ||
sides, | ||
[ | ||
Some(true), | ||
Some(true), | ||
Some(true), | ||
Some(false), | ||
Some(false), | ||
None | ||
] | ||
); | ||
// Five on one side: over the cap. | ||
let mut over = both.clone(); | ||
over.push(join(6, Some(true))); | ||
assert_eq!( | ||
problems(&app_page(json!(over)), true), | ||
["page.join: 5 query joins, more than 4"] | ||
); | ||
let mut bad = join(0, None); | ||
bad["mine"] = json!("yes"); | ||
assert_eq!( | ||
problems(&app_page(json!([bad])), true), | ||
[ | ||
"page.join[0].mine: true, to run on one's own page alone, or false, on another's alone" | ||
] | ||
); | ||
let mut query = joining(json!([query_join(0)])); | ||
query["query"]["join"][0]["mine"] = json!(true); | ||
assert_eq!( | ||
problems(&query, false), | ||
["query.join[0]: unknown key \"mine\""] | ||
); | ||
} | ||
| ||
fn badge() -> Value { | ||
json!({ "component": "Badge", "props": { "value": "x" } }) | ||
} | ||
docs/app-pages.md+11−5
| @@ -26,6 +26,8 @@ The main scope is `{ domain, name, icon, actor, me, mine, entries, joins }`. It | ||
| ||
Its [query joins](views.md) read `domain`, `actor`, `me` and the rest of that scope, as any mode's do. HUD skips a join whose binding doesn't resolve. | ||
| ||
A page's join can also say `"mine": true` to run only on the person's own page, or `"mine": false` to run only on someone else's. Without `mine` it runs on both. Each side holds to the cap of 4 query joins, so a page can draw one thing for its owner and another for everyone else without asking for both. | ||
| ||
### Pages | ||
| ||
`pages` names one of the page's joins by its `as`. A `List`, `Covers`, `Gallery` or `Player` of that join's answer is the page's page list. Where the answer has a `cursor`, the tree's `next` is `describe_app` with that `cursor`. That call runs the join alone, from the cursor, and the clients add its items to the list. | ||
| @@ -40,26 +42,30 @@ Only a bundled view can be an app's page. HUD refuses an inline view that names | ||
| ||
### knotless | ||
| ||
knotless's page (`knotless-app`) is its Home. It has three parts: | ||
knotless's page (`knotless-app`) is Home on the person's own page and a profile on anyone else's, as knotless.dev has them. | ||
| ||
Home has three parts: | ||
| ||
- My work. This lists Issues and Pull requests opened (with their counts, `50+` where there's a page more), Review requests, Assigned, Notifications (on the person's own page alone), Repositories and Starred (with its count). Each row opens its query. | ||
- My work. This lists Issues and Pull requests opened (with their counts, `50+` where there's a page more), Review requests, Assigned, Notifications, Repositories and Starred (with its count). Each row opens its query. | ||
- Favorites, the repositories the account starred, each opening it. | ||
- Recent, the last 8 pulls and issues the account's doings touched, each once (`getFeed`). Each opens its thread. HUD leaves Recent out when there are none. | ||
| ||
The page has four joins, the most a mode makes. They're the open issues and pulls (`listActorItems`), the stars (`getActorStars`, for the Starred count and Favorites) and the recent activity. The other rows have no count. | ||
The profile shows the account's avatar, name, handle, bio, pronouns, followers and following, then Follow (`dev.knotless.follow`, starting as Following where `viewer.following` names one), their links and organizations (`getProfile`). Below that are 4 of their repositories as cards, each opening it (`getActorRepos`), links to all of them, their stars and their activity, and Recent as on Home. | ||
| ||
Home's joins are the open issues and pulls (`listActorItems`), the stars (`getActorStars`, for the Starred count and Favorites) and the recent activity. The profile's are `getProfile`, `getActorRepos` and the same recent activity. Each side runs only its own (`mine`). | ||
| ||
More on knotless's views is in [knotless](knotless.md). | ||
| ||
### Grain | ||
| ||
Grain's page (`grain-app`) is its profile. It shows the account's avatar large beside its galleries, followers and following, its name, handle and bio, and on one's own page where to go (For you, Following, Recent, Galleries, Notifications). It shows its galleries as 3:4 tiles, newest first, each opening the gallery, 18 a page (`pages`). The data comes from Grain's AppView (`getProfile` and the `actor` feed of `getFeed`). | ||
Grain's page (`grain-app`) is its profile. It shows the account's avatar large beside its galleries, followers and following, Follow on anyone else's page (`social.grain.graph.follow`), its name, handle and bio, and on one's own page where to go (For you, Following, Recent, Galleries, Notifications). It shows its galleries as 3:4 tiles, newest first, each opening the gallery, 18 a page (`pages`). The data comes from Grain's AppView (`getProfile` and the `actor` feed of `getFeed`). | ||
| ||
### Bluesky | ||
| ||
Bluesky's page (`bsky-app`) is a profile as Bluesky's app draws one: | ||
| ||
- banner, avatar, name, handle and bio | ||
- followers, following and posts | ||
- followers, following and posts, and Follow on anyone else's page (`app.bsky.graph.follow`) | ||
- where to go, on one's own page (Following, Discover, Saved feeds, Notifications) | ||
- their posts and their threads (`posts_and_author_threads`), with links to all of them, their replies, media and videos (the filters of `getAuthorFeed`) | ||
- the feeds they made | ||
docs/knotless.md+2−2
| @@ -21,13 +21,13 @@ Thirteen bundled views draw them. Each calls `did:web:knotless.dev#knotless_appv | ||
| `knotless-commits` | `listCommits` | a commit's pull | | ||
| `knotless-feed` | `getFeed` | actors, repositories, threads | | ||
| `knotless-notifications` | `listNotifications` | actors, repositories, threads | | ||
| `knotless-profile` | `getProfile` | Repositories (`getActorRepos`), Activity (`getFeed`) | | ||
| `knotless-profile` | `getProfile`, joining 4 of its repositories (`getActorRepos`) and its recent pulls and issues (`getFeed`), as the profile on knotless's page | Follow (`dev.knotless.follow`), each repository, All repositories, Stars, Activity, each recent thread | | ||
| `knotless-actor-repos` | `getActorRepos` | each repository | | ||
| `knotless-actor-items` | `listActorItems` | each row opens its thread · Open and Closed tabs | | ||
| `knotless-actor-stars` | `getActorStars` | each starred repository | | ||
| `knotless-file` | `getFile` | the repository | | ||
| ||
A knotless record opened by its at-uri draws as one of these views (their [`records`](views.md)), except a release. knotless's [app page](app-pages.md) (`knotless-app`) draws its Home. | ||
A knotless record opened by its at-uri draws as one of these views (their [`records`](views.md)), except a release. knotless's [app page](app-pages.md) (`knotless-app`) draws Home on one's own page and a profile on anyone else's. | ||
| ||
## Naming a repository | ||
| ||
docs/views.md+8−3
| @@ -79,7 +79,10 @@ record), `{"$root": "<path>"}` (the view's own scope) or `{"$first": [values]}` | ||
that resolves). | ||
| ||
The bundled Bluesky feeds and thread have Like and Repost on every card. Grain's galleries and | ||
comments have Favorite (`social.grain.favorite`, with `viewer.fav` the one made). | ||
comments have Favorite (`social.grain.favorite`, with `viewer.fav` the one made). Profiles of | ||
someone else have Follow: Bluesky's (`app.bsky.graph.follow`), Grain's (`social.grain.graph.follow`) | ||
and knotless's (`dev.knotless.follow`), each starting as Following where `viewer.following` names | ||
the follow already made. | ||
| ||
### Compose | ||
| ||
| @@ -181,8 +184,9 @@ view's error), and checks all of them before each call. | ||
### Service and limits | ||
| ||
A query join calls the query view's own service unless it names one. In a records mode it names one, | ||
unless its method has a bundled view. A mode has at most 4 query joins, and they join nothing | ||
further. An inline view's joins are held to the same limits. | ||
unless its method has a bundled view. A mode has at most 4 query joins (an | ||
[app page](app-pages.md), 4 on each side), and they join nothing further. An inline view's joins | ||
are held to the same limits. | ||
| ||
`say` adds a few words to the tool's text. It reports how many `count` finds in the answer, or the | ||
first line of `label` (`… README: knotless keeps a git…; latest release: 0.15.0.`). | ||
| @@ -199,6 +203,7 @@ Such a view's pages are no longer than its `pageSize`, so one call takes a page | ||
The bundled views use query joins for these: | ||
| ||
- a knotless repository's README (collapsed past about 20 lines) and latest release | ||
- a knotless profile's repositories and recent pulls and issues | ||
- a Bluesky profile's latest 5 posts, and its feeds | ||
- a standard.site post's replies on Bluesky, where it links a post (`bskyPostRef`) | ||
- the posts Bluesky notifications of likes and reposts are about | ||
harness/gallery/answers.json+2964−3116
A large diff, not shown.
harness/gallery/record.mjs+22−7
| @@ -11,6 +11,7 @@ | ||
// gallery-data` asks no server. | ||
// | ||
// node harness/gallery/record.mjs [<HUD url>] all of it (http://127.0.0.1:8797) | ||
// node harness/gallery/record.mjs --only=<id,…> [<HUD url>] those entries again, the rest as recorded | ||
// node harness/gallery/record.mjs --made the made-up answers again, from what is recorded | ||
| ||
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; | ||
| @@ -21,6 +22,7 @@ import { check, made } from './made.mjs'; | ||
| ||
const argv = process.argv.slice(2); | ||
const remake = argv.includes('--made'); | ||
const only = argv.find((a) => a.startsWith('--only='))?.slice('--only='.length).split(','); | ||
const base = argv.find((a) => !a.startsWith('--')) ?? 'http://127.0.0.1:8797'; | ||
const say = (line) => console.log(`==> ${line}`); | ||
const HUD = 'http://localhost:8787'; | ||
| @@ -51,16 +53,12 @@ const json = (file) => JSON.parse(readFileSync(file, 'utf8')); | ||
const domains = new Set(['bsky.app', 'bsky.chat']); | ||
const appOf = (nsid) => nsid?.split('.').slice(0, 2).reverse().join('.'); | ||
| ||
let book; | ||
if (remake) { | ||
if (!existsSync(answersFile)) throw new Error('nothing recorded yet: run record.mjs without --made first'); | ||
book = json(answersFile); | ||
} else { | ||
/** How an answer is recorded: as `hud resolve` reads one, the server's origin as HUD's default. */ | ||
async function keeper() { | ||
// The server's own origin, in its blob and icon URLs: an app's page names its icon by it. | ||
const app = await call('describe_app', { domain: 'bsky.app' }); | ||
const origin = new URL(app.structuredContent.icon).origin; | ||
/** A recorded answer as `hud resolve` reads one, the server's origin as HUD's default. */ | ||
const kept = (name, args, result) => { | ||
return (name, args, result) => { | ||
const { content, structuredContent, isError } = JSON.parse(JSON.stringify(result).replaceAll(origin, HUD)); | ||
const meta = {}; | ||
const doc = viewOf(name, args); | ||
| @@ -74,6 +72,23 @@ if (remake) { | ||
} | ||
return { content, structuredContent, isError, _meta: meta }; | ||
}; | ||
} | ||
| ||
let book; | ||
if (remake || only) { | ||
if (!existsSync(answersFile)) throw new Error('nothing recorded yet: run record.mjs without --made or --only first'); | ||
book = json(answersFile); | ||
} | ||
if (only) { | ||
const kept = await keeper(); | ||
for (const entryId of only) { | ||
const entry = entries.find((e) => e.id === entryId && !e.made) ?? (() => { throw new Error(`${entryId}: no public entry of that id`); })(); | ||
const args = filled(entry.call.args, book.picked); | ||
book.answers[entryId] = kept(entry.call.name, args, await call(entry.call.name, args)); | ||
console.log(`recorded ${entryId}`); | ||
} | ||
} else if (!remake) { | ||
const kept = await keeper(); | ||
| ||
const profiles = (await call('query', { method: 'app.bsky.actor.getProfiles', params: { actors: people }, service: 'did:web:api.bsky.app#bsky_appview' })).structuredContent.response.profiles; | ||
const did = (handle) => profiles.find((p) => p.handle === handle)?.did ?? (() => { throw new Error(`no profile for ${handle}`); })(); | ||
views/bsky-app.json+15−0
| @@ -180,6 +180,21 @@ | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"component": "Stack", | ||
"props": { "others": "actor.did" }, | ||
"children": [ | ||
{ | ||
"component": "Action", | ||
"props": { | ||
"label": "Follow", | ||
"done": "Following", | ||
"create": { "collection": "app.bsky.graph.follow", "record": { "subject": { "$": "actor.did" }, "createdAt": { "$now": true } } }, | ||
"existing": { "$": "joins.profile.viewer.following" } | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
views/bsky-profile.json+15−0
| @@ -67,6 +67,21 @@ | ||
{ "component": "Text", "props": { "value": { "$": "response.postsCount" }, "style": "strong" } }, | ||
{ "component": "Text", "props": { "value": "posts", "style": "muted" } } | ||
] | ||
}, | ||
{ | ||
"component": "Stack", | ||
"props": { "others": "response.did" }, | ||
"children": [ | ||
{ | ||
"component": "Action", | ||
"props": { | ||
"label": "Follow", | ||
"done": "Following", | ||
"create": { "collection": "app.bsky.graph.follow", "record": { "subject": { "$": "response.did" }, "createdAt": { "$now": true } } }, | ||
"existing": { "$": "response.viewer.following" } | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
views/grain-app.json+15−0
views/knotless-app.json+343−169
512 lines changed: not loaded until asked for.