Keyrxng

Command-Ask: Context-aware GitHub AI Assistant

Ubiquity OS Marketplace · 2024 · Edge-deployed GitHub agent that recursively gathers linked context, filters noise, and answers with a multi-stage LLM pipeline—fast, citable, and CI-deployed.

So what?
branch-scoped workers deployability
Role
Product Engineer
Year
2024
Stack
Cloudflare Workers, TypeScript, Octokit, OpenRouter (Claude 3.5 Sonnet), Voyage embeddings, Supabase + pgvector, Jest, Wrangler
Read narrative
branch-scoped workers deployability

Problem

GitHub conversations span linked issues, PRs, code diffs, and cross-referenced discussion chains (“closes #12”, inline mentions) that ordinary chatbots historically ignored. Early (V1 kernel) attempts at AI replies either hallucinated due to shallow context or blew past token limits when naively concatenating whole threads. After the V2 kernel deployment the plugin had to be rewritten to match new webhook + execution boundaries, then stabilized again post-refactors. Repeated token limit failures and review debates over whether to bound recursion depth vs “grab everything” created friction and delayed adoption. The agent needed to (a) assemble just enough linked context deterministically, (b) stay under window + runtime limits, (c) answer directly in-thread via webhooks without elevated auth, and (d) avoid bot noise feedback loops.

Approach

System diagram

flowchart LR
  Webhook[GitHub Webhook] --> Action[GitHub Action]
  Action --> Context[Context Fetcher]
  Context --> LLM[LLM Processing]
  LLM --> Reply[Response Generation]
  Reply --> Callbacks[Proxy Callbacks]
  Callbacks --> Comment[GitHub Comment Reply]

Outcome

Constraints

Design choices

Proof

Code excerpt — recursive linked-context fetch (depth-limited)

// Recursive issue and PR context fetching with depth control
const fetchLinkedContext = async (issueUrl: string, depth: number = 0): Promise<Context[]> => {
  if (depth >= MAX_DEPTH) return [];
  const issue = await octokit.issues.get({
    owner: parseOwner(issueUrl),
    repo: parseRepo(issueUrl),
    issue_number: parseNumber(issueUrl)
  });
  const linkedUrls = extractGitHubUrls(issue.data.body);
  const contexts = await Promise.all(linkedUrls.map(url => fetchLinkedContext(url, depth + 1)));
  return [buildContext(issue.data), ...contexts.flat()];
};

Log/PR evidence — scope and CI status (trimmed)

PR #1 merged: 58 commits, +1,664 / −769; 2 checks passed. Worker deployed with branch-scoped name (RFC 1035 compliant). [#1 - "@ubiquityos gpt command"](https://github.com/ubiquity-os-marketplace/command-ask/pull/1 "@ubiquityos gpt command")

Test evidence — Jest suite exercising chat history + linked context (described in PR)

Chat history and linked context tests run under Jest with GitHub API mocks.

References