Keyrxng

Daemon Responder: guide contributors in no-reply repos

Ubiquity OS · 2024 · Auto-reply to common mistakes in designated repositories using pattern-based config and Worker-deployed plugin with tests and CI.

So what?
pattern-based repos response coverage
Role
Engineer
Year
2024
Stack
TypeScript, Cloudflare Workers, @ubiquity-os/plugin-sdk, TypeBox, Jest, GitHub Actions
Read narrative
pattern-based repos response coverage

Problem

Contributors occasionally tried to self-assign or ask questions in no-reply repositories. Maintainers needed an automated way to redirect them to the correct flow.

Approach

System diagram

flowchart LR
  IssueComment[GitHub Issue Comment] --> Router[Kernel Event Router]
  Router --> Plugin[Daemon-Responder Plugin]
  Plugin --> Matcher[Config Pattern Matcher]
  Matcher --> Handler[Auto-Response Handler]
  Handler --> API[Comment API]
  API --> Posted[Response Posted]

Outcome

Constraints

Design choices

Proof

Code excerpt — auto-response handler

export async function handleAutoResponse(context: Context) {
  const { logger, payload: { repository }, config: { automatedResponses }, commentHandler } = context;
  const repo = repository.name;
  const owner = repository.owner.login;
  const autoResponse = automatedResponses[`${owner}/${repo}`] || automatedResponses[owner] || automatedResponses[repo];
  if (autoResponse) {
    await commentHandler.postComment(context, logger.warn(autoResponse, { owner, repo }));
  }
}

Code excerpt — settings schema default

export const pluginSettingsSchema = T.Object({
  /** key → message; supports `owner/repo`, `repo`, `owner` */
  automatedResponses: T.Record(T.String(), T.String(), {
    default: {
      "devpool-directory": "This is a no-reply repository, please visit the task using the link in the description.",
    },
  }),
});

CI evidence — deploy + tests (trimmed)

- name: Deploy with Wrangler
  uses: cloudflare/wrangler-action@v3
  with:
    wranglerVersion: "3.79.0"
    apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
    accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

References