agents-work-repo.js · GitHub
/" data-turbo-transient="true" />
Skip to content
-->
Search Gists
Search Gists
Sign in
Sign up
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
Instantly share code, notes, and snippets.
atraining/gh-agent-watch.js
Last active<br>May 27, 2026 10:49
Show Gist options
Download ZIP
Star
(0)
You must be signed in to star a gist
Fork
(0)
You must be signed in to fork a gist
Embed
Select an option
Embed<br>Embed this gist in your website.
Share<br>Copy sharable link for this gist.
Clone via HTTPS<br>Clone using the web URL.
No results found
Learn more about clone URLs
Clone this repository at <script src="https://gist.github.com/atraining/d666e2d20e5abfdf92eb74a0d5f4918d.js"></script>
" readonly="readonly" data-autoselect="true" data-target="primer-text-field.inputElement " aria-describedby="validation-a0487437-2338-4d25-a310-e72e07a66b09" class="form-control FormControl-monospace FormControl-input FormControl-small rounded-left-0 rounded-right-0 border-right-0" type="text" name="gist-share-url-sized-down" />
Save atraining/d666e2d20e5abfdf92eb74a0d5f4918d to your computer and use it in GitHub Desktop.
Embed
Select an option
Embed<br>Embed this gist in your website.
Share<br>Copy sharable link for this gist.
Clone via HTTPS<br>Clone using the web URL.
No results found
Learn more about clone URLs
Clone this repository at <script src="https://gist.github.com/atraining/d666e2d20e5abfdf92eb74a0d5f4918d.js"></script>
" readonly="readonly" data-autoselect="true" data-target="primer-text-field.inputElement " aria-describedby="validation-4ba37e04-da15-4094-aea0-8b8024bb3a74" class="form-control FormControl-monospace FormControl-input FormControl-small rounded-left-0 rounded-right-0 border-right-0" type="text" name="gist-share-url-original" />
Save atraining/d666e2d20e5abfdf92eb74a0d5f4918d to your computer and use it in GitHub Desktop.
Download ZIP
agents-work-repo.js
Raw
gh-agent-watch.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.<br>Learn more about bidirectional Unicode characters
Show hidden characters
#!/usr/bin/env node
/**
* gh-agent-watch.js — GitHub-Issue poller for multi-agent coding teams
* WHAT THIS DOES (for AI agents reading this file)
* This script is your "inbox watcher". It polls a GitHub repo for issues
* labelled with your agent name (e.g. "agent:tester") and wakes you whenever
* something new arrives or an existing issue is updated.
* You run it once at startup inside a persistent Monitor process. Every line it
* prints to stdout is a signal for your orchestrator to wake you and let you
* act. Between wakes, you sleep. You do NOT need to poll manually.
* TEAM MODEL (generic, rename roles to fit your project)
* Any number of agents can participate. Each has a unique role name. Common
* example set:
* implementer — writes and commits code (the only agent with write access
* to source files; all others review, advise, or document)
* tester — writes test cases, user journeys, and acceptance criteria;
* reports failures as new issues to implementer
* reviewer — code review, architecture, and technical quality gating
* docs — user-facing documentation; touches no source code
* legal — compliance, licensing, regulatory gating before release
* market — competitive analysis, domain model, product direction
* You can use any names you like. The only contract: every agent's name must
* match exactly the label suffix used in GitHub, e.g. agent:tester.
* HOW ROUTING WORKS
* Issues are routed by label. An issue labelled "agent:tester" sits in the
* tester's queue. Routing rules (for AI agents):
* - To send an issue TO another agent:
* gh issue edit --add-label "agent:" \
* --remove-label "agent:"
* Add a one-line comment explaining WHY you are re-routing.
* - To create a new issue for another agent:
* gh issue create --repo \
* --title ": ()" \
* --label "agent:" --label "" \
* --body "..."
* - To respond to the current owner of an issue: comment on it.
* gh issue comment --body "..."
* - To close a resolved issue:
* gh issue close --comment "Done. "
* - FREI issues (no agent:* label) are visible to every agent's heartbeat.
* Any agent may claim them by adding their own label and a comment.
* QUEUE DISCIPLINE (rules for AI agents, non-negotiable)
* 1) idle != done.
* The heartbeat prints either "idle, queue empty" (genuinely done) or
* "idle, N open tickets" followed by PENDING lines (NOT done — those are
* your open assignments). When you see PENDING lines, your next action is
* to open the top ticket and...