Side B fixes a real production bug (empty /-/ external garden index due to bogus parent), refactors external_resolver into a resolvers/ module with typed GithubImportCard rendering, wires it through vote-compare and item pages, and adds integration/unit tests plus CSS. Side A adds a new URL-canonicalization graph engine with extensive tests but is a standalone/net-new feature not shown to fix any existing defect or integrate with the rest of the app in this diff, making B's change more clearly load-bearing and battle-tested.
constitution · epochs · watch · epoch 3
c_9bced108c8aa (tommy-mor) vs c_df12ba3b70a8 (tommy-mor)
download prompt · raw event · cmp_92d3b1115a7713
council reasoning
Side A introduces a full semantic URL graph (DFA traversal, builder validation, parse/canonicalize/breadcrumbs, generic fallback) with broad, lasting design and dense unit coverage for Reddit/YouTube equivalence. Side B fixes a real empty /-/ index bug via external_root_host_items and adds structured GitHub import cards plus render hooks, but much of the diff is a module move/refactor of existing resolver code plus CSS/layout polish.
Side A introduces a new URL parsing and semantic graph infrastructure with DFA-based traversal, canonicalization, generic fallback behavior, a validated graph builder, and extensive tests covering Reddit, YouTube, encoding, breadcrumbs, and parsing. Side B contains a real bug fix for the external garden index and adds GitHub resolver card rendering plus a module refactor, but much of its patch reorganizes existing resolver code while adding a narrower feature set.
sides
A — c_9bced108c8aa (tommy-mor)
message
[15e1037a] url stuff
diff preview
diff --git a/server/src/url_rules/graph.rs b/server/src/url_rules/graph.rs
new file mode 100644
index 0000000000000000000000000000000000000000..f7ac0f9a551a1727cb2f9294778c283b9885b147
--- /dev/null
+++ b/server/src/url_rules/graph.rs
@@ -0,0 +1,831 @@
+//! Semantic URL graph: DFA traversal on host + path, query in context, generic fallback.
+
+use std::collections::HashMap;
+use std::sync::OnceLock;
+
+use url::Url;
+
+use super::graph_builder::GraphBuilder;
+use super::parse::{normalize_match_host, strip_tracking_query, UrlParts};
+
+#[derive(Debug, Clone, Default)]
+pub struct Context {
+ pub vars: HashMap<String, String>,
+ pub query: HashMap<String, String>,
+}
+
+pub type CanonicalFn = fn(&Context) -> Option<String>;
+
+#[derive(Clone, Copy)]
+pub enum EdgePattern {
+ Literal(&'static str),
+ Variable(&'static str),
+ /// Absorb any trailing segment without leaving this node (e.g. post title slug).
+ AbsorbAny,
+ /// Absorb segment when `cond(seg)` (e.g. subreddit listing suffix).
+ AbsorbIf(fn(&str) -> bool),
+}
+
+pub struct Edge {
+ pub pattern: EdgePattern,
+ pub target: &'static str,
+}
+
+pub struct Node {
+ pub edges: Vec<Edge>,
+ pub canonical: CanonicalFn,
+ pub parent: Option<&'static str>,
+}
+
+impl Node {
+ pub(crate) fn empty() -> Self {
+ Self {
+ edges: Vec::new(),
+ canonical: |_| None,
+ parent: None,
+ }
+ }
+}
+
+pub struct Graph {
+ pub nodes: HashMap<&'static str, Node>,
+}
+
+static GRAPH: OnceLock<Graph> = OnceLock::new();
+
+pub fn graph() -> &'static Graph {
+ GRAPH.get_or_init(build_graph)
+}
+
+impl Graph {
+ pub fn resolve_canonical(&self, parts: &UrlParts) -> Option<String> {
+ let mut query = parts.query.clone();
+ strip_tracking_query(&mut query);
+ let mut ctx = Context {
+ vars: HashMap::new(),
+ query,
+ };
+
+ if let Some(node_id) = self.traverse(parts, &mut ctx) {
+ if let Some(canon) = (self.nodes.get(node_id)?.canonical)(&ctx) {
+ return Some(canon);
+ }
+ }
+ Some(generic_canonical(parts))
+ }
+
+ pub fn breadcrumbs(&self, parts: &UrlParts) -> Vec<String> {
+ let mut query = parts.query.clone();
+ strip_tracking_query(&mut query);
+ let mut ctx = Context {
+ vars: HashMap::new(),
+ query,
+ };
+
+ if let Some(mut node_id) = self.traverse(parts, &mut ctx) {
+ let mut paths = Vec::new();
+ loop {
+ let node = match self.nodes.get(node_id) {
+ Some(n) => n,
+ None => break,
+ };
+ if let Some(url) = (node.canonical)(&ctx) {
+ if paths.last() != Some(&url) {
+ paths.push(url);
+ }
+ }
+ match node.parent {
+ Some(p) => node_id = p,
+ None => break,
+ }
+ }
+ paths.reverse();
+ if !paths.is_empty() {
+ return paths;
+ }
+ }
+ generic_breadcrumbs(parts)
+ }
+
+ fn traverse(&self, parts: &UrlParts, ctx: &mut Context) -> Option<&'static str> {
+ let host = parts.match_host();
+ let mut node_id = match host.as_str() {
+ "reddit.com" => "reddit_root",
+ "youtube.com" => "youtube_root",
+ "youtu.be" => "youtu_be_entry",
+ _ => return None,
+ };
+
+ let segs: Vec<&str> = parts.path_segments.iter().map(String::as_str).collect();
+ let mut i = 0;
+ while i < segs.len() {
+ let seg = segs[i];
+ match self.follow_edge(node_id, seg, ctx) {
+ Ok(next) => {
+ node_id = next;
+ i += 1;
+ }
+ Err(()) => {
+ if self.try_absorb(node_id, seg) {
+ i += 1;
+ continue;
+ }
+ return None;
+ }
+ }
+ }
+ Some(node_id)
+ }
+
+ fn follow_edge(
+ &self,
+ node_id: &'static str,
+ seg: &str,
+ ctx: &mut Context,
+ ) -> Result<&'static str, ()> {
+ let node = self.nodes.get(node_id).ok_or(())?;
+ for edge in &node.edges {
+ match edge.pattern {
+ EdgePattern::Literal(lit) if lit == seg => return Ok(edge.target),
+ EdgePattern::Variable(name) => {
+ ctx.vars.insert(name.to_string(), seg.to_string());
+ return Ok(edge.target);
+ }
+ EdgePattern::AbsorbAny
+ | EdgePattern::AbsorbIf(_)
+ | EdgePattern::Literal(_)
+ | EdgePattern::Variable(_) => {}
+ }
+ }
+ Err(())
+ }
+
+ fn try_absorb(&self, node_id: &'static str, seg: &str) -> bool {
+ let node = match self.nodes.get(node_id) {
+ Some(n) => n,
+ None => return false,
+ };
+ for edge in &node.edges {
+ match edge.pattern {
+ EdgePattern::AbsorbAny => return true,
+ EdgePattern::AbsorbIf(cond) if cond(seg) => return true,
+ EdgePattern::AbsorbIf(_) | EdgePattern::Literal(_) | EdgePattern::Variable(_) => {}
+ }
+ }
+ false
+ }
+
+ /// Test hook: terminal graph node and captured context after traversal.
+ #[cfg(test)]
+ pub fn traverse_terminal(&self, parts: &UrlParts) -> Option<(&'static str, Context)> {
+ let mut query = parts.query.clone();
+ strip_tracking_query(&mut query);
+ let mut ctx = Context {
+ vars: HashMap::new(),
+ query,
+ };
+ let node = self.traverse(parts, &mut ctx)?;
+ Some((node, ctx))
+ }
+}
+
+fn is_reddit_listing_suffix(seg: &str) -> bool {
+ matches!(seg, "hot" | "top" | "new" | "rising" | "controversial")
+}
+
+/// Percent-encode a path or query fragment so `&`, `?`, etc. cannot break URL structure.
+fn enc(s: &str) -> String {
+ urlencoding::encode(s).into_owned()
+}
+
+// --- Canonical formatters ---
+
+fn canon_reddit_root(_: &Context) -> Option<String> {
+ Some("https://reddit.com".to_string())
+}
+
+fn canon_reddit_r_hub(_: &Context) -> Option<String> {
+ Some("https://reddit.com/r".to_string())
+}
+
+fn canon_reddit_subreddit(ctx: &Context) -> Option<String> {
+ let sub = ctx.vars.get("subreddit")?;
+ Some(format!(
+ "https://reddit.com/r/{}",
+ enc(&sub.to_ascii_lowercase())
+ ))
+}
+
+fn canon_reddit_post(ctx: &Context) -> Option<String> {
+ let sub = ctx.vars.get("subreddit")?.to_ascii_lowercase();
+ let id = ctx.vars.get("post_id")?;
+ Some(format!(
+ "https://reddit.com/r/{}/comments/{}",
+ enc(&sub),
+ enc(id)
+ ))
+}
+
+fn canon_youtube_root(_: &Context) -> Option<String> {
+ Some("https://youtube.com".to_string())
+}
+
+fn canon_youtube_watch(ctx: &Context) -> Option<String> {
+ let v = ctx
+ .query
+ .get("v")
+ .or_else(|| ctx.vars.get("video_id"))?;
+ Some(format!("https://youtube.com/watch?v={}", enc(v)))
+}
+
+fn canon_youtu_be(ctx: &Context) -> Option<String> {
+ let v = ctx.vars.get("vid_id")?;
+ Some(format!("https://youtube.com/watch?v={}", enc(v)))
+}
+
+pub fn build_graph() -> Graph {
+ GraphBuilder::new()
+ .node("reddit_root")
+ .canonical(canon_reddit_root)
+ .edge(EdgePattern::Literal("r"), "reddit_r_hub")
+ .node("reddit_r_hub")
+ .parent("reddit_root")
+ .canonical(canon_reddit_r_hub)
+ .edge(EdgePattern::Variable("subreddit"), "reddit_subreddit")
+ .node("reddit_subreddit")
+ .parent("reddit_r_hub")
+ .canonical(canon_reddit_subreddit)
+ .edge(
+ EdgePattern::AbsorbIf(is_reddit_listing_suffix),
+ "reddit_subreddit",
+ )
+ .edge(EdgePattern::Literal("comments"), "reddit_comments_gate")
+ .node("reddit_comments_gate")
+ .parent("reddit_subreddit")
+ .canonical(canon_reddit_subreddit)
+ .edge(EdgePattern::Variable("post_id"), "reddit_post")
+ .node("reddit_post")
+ .parent("reddit_subreddit")
+ .canonical(canon_reddit_post)
+ .edge(EdgePattern::AbsorbAny, "reddit_post")
+ .node("youtube_root")
+ .canonical(canon_youtube_root)
+ .edge(EdgePattern::Literal("watch"), "youtube_watch")
+ .edge(EdgePattern::Literal("shorts"), "youtube_shorts_gate")
+ .node("youtube_watch")
+ .parent("youtube_root")
+ .canonical(canon_youtube_watch)
+ .node("youtube_shorts_gate")
+ .parent("youtube_root")
+ .canonical(canon_youtube_root)
+ .edge(EdgePattern::Variable("video_id"), "youtube_watch")
+ .node("youtu_be_entry")
+ .canonical(canon_youtube_root)
+ .edge(EdgePattern::Variable("vid_id"), "youtu_be_video")
+ .node("youtu_be_video")
+ .parent("youtube_root")
+ .canonical(canon_youtu_be)
+ .build()
+}
+
+// --- Generic internet fallback ---
+
+pub fn generic_canonical(parts: &UrlParts) -> String {
+ let host = normalize_match_host(&parts.host);
+ let path_segments: Vec<String> = parts.path_segments.clone();
+ let mut query = parts.query.clone();
+ strip_tracking_query(&mut query);
+
+ let mut url = if path_segments.is_empty() {
+ Url::parse(&format!("https://{host}"))
+ .unwrap_or_else(|_| Url::parse("https://invalid").unwrap())
+ } else {
+ let path = format!("/{}", path_segments.join("/"));
+ Url::parse(&format!("https://{host}{path}"))
+ .unwrap_or_else(|_| Url::parse("https://invalid").unwrap())
+ };
+
+ if !query.is_empty() {
+ let mut pairs: Vec<_> = query.iter().collect();
+ pairs.sort_by(|a, b| a.0.cmp(b.0));
+ url.query_pairs_mut().clear();
+ for (k, v) in pairs {
+ url.query_pairs_mut().append_pair(k, v);
+ }
+ }
+
+ let mut s = url.to_string();
+ if path_segments.is_empty() {
+ s = s.trim_end_matches('/').to_string();
+ }
+ s
+}
+
+pub fn generic_breadcrumbs(parts: &UrlParts) -> Vec<String> {
+ let host = normalize_match_host(&parts.host);
+ let n = parts.path_segments.len();
+ let mut out = Vec::new();
+
+ let base = generic_canonical(&UrlParts {
+ scheme: "https".to_string(),
+ host: host.clone(),
+ path_segments: vec![],
+ query: HashMap::new(),
+ });
+ out.push(base);
+
+ for i in 0..n {
+ let segs: Vec<String> = parts.path_segments[..=i].to_vec();
+ let url = generic_canonical(&UrlParts {
+ scheme: "https".to_string(),
+ host: host.clone(),
+ path_segments: segs,
+ query: HashMap::new(),
+ });
+ if out.last() != Some(&url) {
+ out.push(url);
+ }
+ }
+ out
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::url_rules::parse::test_parts;
+
+ fn g() -> &'static Graph {
+ graph()
+ }
+
+ fn canon(parts: &UrlParts) -> String {
+ g().resolve_canonical(parts).unwrap()
+ }
+
+ fn crumbs(parts: &UrlParts) -> Vec<String> {
+ g().breadcrumbs(parts)
+ }
+
+ fn terminal(parts: &UrlParts) -> Option<&'static str> {
+ g().traverse_terminal(parts).map(|(n, _)| n)
+ }
+
+ fn vars(parts: &UrlParts) -> HashMap<String, String> {
+ g().traverse_terminal(parts)
+ .map(|(_, c)| c.vars)
+ .unwrap_or_default()
+ }
+
+ #[test]
+ fn youtu_be_malicious_segment_encoded_not_injected() {
+ let p = test_parts("youtu.be", &["abc&t=1"], &[]);
+ assert_eq!(canon(&p
… preview truncated; 29,502 characters omittedB — c_df12ba3b70a8 (tommy-mor)
message
[23c8134e] Fix /-/ external garden index; resolvers/ + GitHub import cards (#150) * Fix external garden root listing; add resolvers/ with GitHub cards The public and room external index pages queried children of a bogus https://./ parent, so /-/ always looked empty. Collect host-only https roots from all Web items and item_children edges so ghost parents from add_child_edge appear. Move GitHub resolver into server/src/resolvers/ with default_external.rs and a try_render_resolver_item_body hook. Resolver ingests now store slug-github-card fenced JSON; render_item_body_in_scope shows a small GitHub article card (with legacy support for schema-less json fences on github.com URLs). Styling in theme_default.css; agents.md updated. Co-authored-by: tommy <thmorriss@gmail.com> * Vote compare: GitHub cards in columns, layout CSS, tests Pass item_bodies into vote_compare_item_card for linkified tooltips on non-card bodies; clone item_bodies before dropping reducer read guard. Add layout rules so rich cards sit in the grid corners (default + retro). Unit test on vote_compare_item_card; integration GET /vote/compare with ingested slug-github-card bodies. agents.md clarifies compare columns. Co-authored-by: tommy <thmorriss@gmail.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
diff preview
diff --git a/agents.md b/agents.md
index 7508234d9b04223d0e64cfe69fedbebd06a256b5..d8b801e454fdf37e7ac6038b91a69f83b0746d59 100644
--- a/agents.md
+++ b/agents.md
@@ -42,7 +42,7 @@ Strict **CSP** that blocks `eval` would break the current app. Other projects ma
- **`VoteComparePost`:** On success returns **`text/javascript`** that **morphs** **`#vote-edge-history-region`** (recomputed **`<ul>`** — ratios match **`left`/`right`** query order, bullets, sorted by strength toward **`left`** then newer) and **`.vote-compare-nav`** (fresh next-pair link). The compare **`GET`** page uses **`layout_full_bleed_chromeless`** (no breadcrumbs, no **`#controls`**, no **`slug-pin-hud`**; **`view-vote-compare-fullscreen`** full-width **`body`**). **`__rpc__`** carries **`form_action: "/ui"`**; **`thread_tag`** and ratio fields come from the same form as **`$form`** holes.
-- **`ResolveExternal`:** GitHub resolver buttons are browser actions through **`POST /ui`**. Success responses morph **`#external-resolver-status`** then redirect to the sanitized shareable **`GET`** page so imported children render through the normal page path; errors morph the same status region. Resolver results are durable system ingests, while cooldown state is RAM-only.
+- **`ResolveExternal`:** GitHub resolver buttons are browser actions through **`POST /ui`**. Success responses morph **`#external-resolver-status`** then redirect to the sanitized shareable **`GET`** page so imported children render through the normal page path; errors morph the same status region. Resolver results are durable system ingests, while cooldown state is RAM-only. Implementation lives under **`server/src/resolvers/`** (GitHub resolver + import card JSON); ontology item pages and the **`GET /vote/compare`** left/right columns use **`render_item_body_in_scope`** in **`server/src/html/mod.rs`**, which calls **`server/src/resolvers/mod.rs::try_render_resolver_item_body`** before falling back to the usual **`<pre>`** linkified view.
- **Garden pin / compare voting:** Cookie **`slug_garden_pin`** via **`set_garden_pin`**. Pairwise UI: **`GET /vote/compare?…`** / **`GET /r/:room_key/vote/compare?…`** (fullscreen **`GET`** page: no HUD; other garden pages). HUD (**`#slug-pin-hud`**): only when **`layout`** passes garden metadata on **`body`**; the label is **`POST /ui`** **`set_garden_pin`** **`clear:true`** (**`slug_ui.js`**), not a permalink to the item.
diff --git a/server/src/api/ui_html.rs b/server/src/api/ui_html.rs
index 4b0214d18b173cd506d09176104f461dc4c4f208..c9eb8e242072e41fcf70da838bdf02dd4c838db8 100644
--- a/server/src/api/ui_html.rs
+++ b/server/src/api/ui_html.rs
@@ -18,7 +18,7 @@ use crate::{
rpc::{rpc_post_redact, rpc_post_with_bearer, rpc_room_delete},
},
canonical_path::canonicalize_tag,
- external_resolver::resolve_github_children,
+ resolvers::resolve_github_children,
html::vote_compare_post_success_js,
html::{
external_resolver_status_markup, fragment_new_thread_slot, login_to_post_hint_markup,
diff --git a/server/src/external_resolver.rs b/server/src/external_resolver.rs
deleted file mode 100644
index a5812250fed7613950b5417f396f886a55fafccf..0000000000000000000000000000000000000000
--- a/server/src/external_resolver.rs
+++ /dev/null
@@ -1,630 +0,0 @@
-use async_trait::async_trait;
-use serde_json::Value;
-use tokio::sync::oneshot;
-
-use crate::{path_types::ItemId, state::AppState, write_cmd::WriteCmd};
-
-const GITHUB_SYSTEM_PRINCIPAL: &str = "system:github-resolver";
-const GITHUB_RESOLVER_COOLDOWN_MS: i64 = 15_000;
-const GITHUB_MAX_PAGES: usize = 3;
-
-fn now_ms() -> i64 {
- use std::time::{SystemTime, UNIX_EPOCH};
- SystemTime::now()
- .duration_since(UNIX_EPOCH)
- .unwrap_or_default()
- .as_millis() as i64
-}
-
-#[derive(Debug, Clone, PartialEq, Eq)]
-pub struct ResolvedChild {
- pub url: String,
- pub title: String,
- pub body: Option<String>,
-}
-
-#[async_trait]
-pub trait ExternalResolver: Send + Sync {
- /// e.g. `"github.com"`
- fn domain_match(&self) -> &'static str;
-
- /// Normalizes URLs (e.g. stripping fragments); extend per-domain later.
- fn normalize(&self, path: &str) -> String;
-
- /// Fetches body when missing; GitHub hook lands here in a follow-up.
- async fn fetch_body(&self, item: &ItemId) -> Result<String, String>;
-}
-
-#[derive(Clone)]
-pub struct GitHubResolver {
- client: reqwest::Client,
- api_base_url: String,
- token: Option<String>,
-}
-
-impl GitHubResolver {
- pub fn from_env() -> Self {
- let api_base_url = std::env::var("SLUG_GITHUB_API_BASE_URL")
- .ok()
- .filter(|s| !s.trim().is_empty())
- .unwrap_or_else(|| "https://api.github.com".to_string());
- let token = std::env::var("SLUG_GITHUB_TOKEN")
- .ok()
- .filter(|s| !s.trim().is_empty());
- Self {
- client: reqwest::Client::new(),
- api_base_url: api_base_url.trim_end_matches('/').to_string(),
- token,
- }
- }
-
- pub fn can_resolve_children(&self, item: &ItemId) -> bool {
- github_segments(item).is_some()
- }
-
- pub async fn list_children(&self, item: &ItemId) -> Result<Vec<ResolvedChild>, String> {
- let segments = github_segments(item).ok_or_else(|| "not a GitHub URL".to_string())?;
- match segments.as_slice() {
- [] => Ok(vec![]),
- [owner] => self.list_repos(owner).await,
- [owner, repo] => Ok(github_repo_sections(owner, repo)),
- [owner, repo, section] if section == "issues" => self.list_issues(owner, repo).await,
- [owner, repo, section] if section == "pulls" => self.list_pulls(owner, repo).await,
- [owner, repo, section] if section == "commits" => self.list_commits(owner, repo).await,
- [owner, repo, section] if section == "releases" => {
- self.list_releases(owner, repo).await
- }
- _ => Ok(vec![]),
- }
- }
-
- async fn get_json(&self, path: &str) -> Result<Value, String> {
- let url = format!("{}/{}", self.api_base_url, path.trim_start_matches('/'));
- let mut req = self
- .client
- .get(url)
- .header(reqwest::header::USER_AGENT, "slugsocial-github-resolver");
- if let Some(token) = &self.token {
- req = req.bearer_auth(token);
- }
- let resp = req
- .send()
- .await
- .map_err(|e| format!("GitHub request failed: {e}"))?;
- let status = resp.status();
- if !status.is_success() {
- return Err(format!("GitHub request returned {status}"));
- }
- resp.json::<Value>()
- .await
- .map_err(|e| format!("GitHub response JSON failed: {e}"))
- }
-
- async fn get_json_array_pages(&self, path: &str) -> Result<Vec<Value>, String> {
- let sep = if path.contains('?') { '&' } else { '?' };
- let mut out = Vec::new();
- for page in 1..=GITHUB_MAX_PAGES {
- let value = self.get_json(&format!("{path}{sep}page={page}")).await?;
- let arr = value
- .as_array()
- .ok_or_else(|| "GitHub paged response was not an array".to_string())?;
- let n = arr.len();
- out.extend(arr.iter().cloned());
- if n < 100 {
- break;
- }
- }
- Ok(out)
- }
-
- async fn list_repos(&self, owner: &str) -> Result<Vec<ResolvedChild>, String> {
- let arr = self
- .get_json_array_pages(&format!(
- "/users/{owner}/repos?per_page=100&sort=updated&type=owner"
- ))
- .await?;
- let mut out = Vec::new();
- for repo in &arr {
- let name = repo
- .get("name")
- .and_then(|v| v.as_str())
- .unwrap_or_default();
- if name.is_empty() {
- continue;
- }
- let full_name = repo
- .get("full_name")
- .and_then(|v| v.as_str())
- .map(|s| s.to_ascii_lowercase())
- .unwrap_or_else(|| format!("{owner}/{name}").to_ascii_lowercase());
- out.push(ResolvedChild {
- url: format!("https://github.com/{full_name}"),
- title: full_name.clone(),
- body: Some(github_repo_body(repo)),
- });
- }
- out.sort_by(|a, b| a.url.cmp(&b.url));
- Ok(out)
- }
-
- async fn list_issues(&self, owner: &str, repo: &str) -> Result<Vec<ResolvedChild>, String> {
- let arr = self
- .get_json_array_pages(&format!(
- "/repos/{owner}/{repo}/issues?state=open&per_page=100"
- ))
- .await?;
- let mut out = Vec::new();
- for issue in &arr {
- if issue.get("pull_request").is_some() {
- continue;
- }
- let Some(number) = issue.get("number").and_then(|v| v.as_i64()) else {
- continue;
- };
- let title = issue
- .get("title")
- .and_then(|v| v.as_str())
- .unwrap_or("Untitled issue");
- out.push(ResolvedChild {
- url: format!("https://github.com/{owner}/{repo}/issues/{number}"),
- title: format!("#{number} {title}"),
- body: Some(github_issue_body(issue, "issue")),
- });
- }
- out.sort_by(|a, b| a.url.cmp(&b.url));
- Ok(out)
- }
-
- async fn list_pulls(&self, owner: &str, repo: &str) -> Result<Vec<ResolvedChild>, String> {
- let arr = self
- .get_json_array_pages(&format!(
- "/repos/{owner}/{repo}/pulls?state=open&per_page=100"
- ))
- .await?;
- let mut out = Vec::new();
- for pull in &arr {
- let Some(number) = pull.get("number").and_then(|v| v.as_i64()) else {
- continue;
- };
- let title = pull
- .get("title")
- .and_then(|v| v.as_str())
- .unwrap_or("Untitled pull request");
- out.push(ResolvedChild {
- url: format!("https://github.com/{owner}/{repo}/pulls/{number}"),
- title: format!("#{number} {title}"),
- body: Some(github_issue_body(pull, "pull request")),
- });
- }
- out.sort_by(|a, b| a.url.cmp(&b.url));
- Ok(out)
- }
-
- async fn list_commits(&self, owner: &str, repo: &str) -> Result<Vec<ResolvedChild>, String> {
- let arr = self
- .get_json_array_pages(&format!("/repos/{owner}/{repo}/commits?per_page=100"))
- .await?;
- let mut out = Vec::new();
- for commit in &arr {
- let Some(sha) = github_string(commit, "sha") else {
- continue;
- };
- let short = sha.chars().take(7).collect::<String>();
- let title = commit
- .get("commit")
- .and_then(|c| c.get("message"))
- .and_then(|v| v.as_str())
- .and_then(|m| m.lines().next())
- .filter(|s| !s.trim().is_empty())
- .unwrap_or("commit");
- let url = github_string(commit, "html_url")
- .map(|s| s.to_string())
- .unwrap_or_else(|| format!("https://github.com/{owner}/{repo}/commit/{sha}"));
- out.push(ResolvedChild {
- url,
- title: format!("{short} {title}"),
- body: Some(github_commit_body(commit)),
- });
- }
- out.sort_by(|a, b| a.url.cmp(&b.url));
- Ok(out)
- }
-
- async fn list_releases(&self, owner: &str, repo: &str) -> Result<Vec<ResolvedChild>, String> {
- let arr =
… preview truncated; 60,917 characters omittedHardlinks — judgments / attempts / prompt
judgments
attempts
Prompt text is loaded only by the download route.