factory
Software factory: turn GitHub issues into pull requests
- License 许可
- GPL-3.0
- 最近更新
- 2026-11-13
- Stars
- ★ 468
- Forks
- 144
01 前言 Front Matter
- name
- factory
- metadata
- { "hermes": { "tags": [ "github", "coding", "automation" ], "related_skills": [ "github" ] } }
- description
- Software factory: turn GitHub issues into pull requests
02 资源文件 1
- 脚本scripts/factory.py24.4 KB
03 SKILL.md 正文
Factory
A software factory for GitHub repositories. The user labels an issue
factory, and the factory turns it into a pull request in a single run,
through five stages:
ingest -> spec -> build -> validate -> pr
| Command | What it does |
|---|---|
/factory add OWNER/REPO |
Finds the repository's clone or clones it, checks push access and registers it |
/factory run OWNER/REPO |
Builds the oldest waiting issue into a pull request, in this chat |
/factory monitor |
Shows what the factory is doing |
/factory stop [OWNER/REPO] |
Stops the job in progress |
/factory resume OWNER/REPO ISSUE |
Picks a stopped job back up where it left off |
The words after /factory choose the section below. In a scheduled run, each
worker's prompt names one issue that the dispatcher already started; follow
the run section from there.
All bookkeeping goes through this script:
python3 "${HERMES_SKILL_DIR}/scripts/factory.py" <command>
factory.py below means that command. Its output is the source of truth.
When it exits with an error, stop and report the error. Don't work around it.
The factory uses the gh login the user has already set up. It doesn't set up
GitHub access. If gh is missing or logged out, say so and stop. The github
skill covers that setup.
add
Run factory.py add OWNER/REPO. It looks for a clone of the repository under
Hermes' data folder and the home folder, and clones it into
$HERMES_HOME/work/ when there isn't one. It checks that the GitHub login
can push to the repository, creates the factory label and records where the
clone is.
If it finds more than one clone, show them to the user and ask which to use,
then run it again with --path <clone>. Report where the clone is and that
labeling an issue factory queues it.
Schedule recurring runs
A scheduled factory is a Hermes cron job that runs the dispatcher script
directly, with no agent of its own. The dispatcher works through every
queued issue, oldest first, starting a fresh worker session for each one.
Each worker's output goes to worker-output.log in its job folder. A lock
stops two dispatchers overlapping on one repository, and issues filed during
a batch wait for the next run. A failed, stopped or incomplete worker halts
the batch so its work is kept.
- Resolve the actual
OWNER/REPObefore installing or scheduling. Ask when the request still contains a placeholder; never treat an example repository as the user's choice. - Run
factory.py install-precheck OWNER/REPO --dispatch. Use the exact script filename it prints; do not hand-write a substitute. Stop and report any script error. - Load the Hermes scheduling guidance and describe
cronjob_manage. List existing jobs before creating one so a repeated setup does not duplicate it. Set explicitly:- name:
factory OWNER/REPO - schedule: the requested interval, e.g.
every 10m - skills:
["factory"] - prompt:
/factory run OWNER/REPO - script: the filename printed by
install-precheck - no_agent:
true. The script creates the worker sessions itself; the scheduler must not start a coordinator agent. - deliver:
localwhen requested Substitute the actual repository in every field. Leave repeat unlimited for an ongoing interval unless the user requests a run limit.
- name:
- Read back the saved job and report its ID, settings, enabled state and next run with timezone. Distinguish a scheduled job from an already executed run.
A scheduled batch is bounded by Hermes' cron script timeout (one hour by default); don't promise unlimited batch runtime. Workers use the CLI/profile model settings, not a model pinned on the cron job.
The generated script in $HERMES_HOME/scripts/ is a small wrapper: it sets
sys.argv to factory.py dispatch OWNER/REPO and runs the installed
factory.py with runpy.run_path. It depends on that script's absolute path
and isn't standalone. When asked to show it, give its path and exact contents.
run
/factory run OWNER/REPO builds one issue, the oldest waiting, right here in
this chat, through the steps below. The user watches every stage. Never run
factory.py dispatch from a chat.
A scheduled run works differently: its cron job runs the dispatcher script
directly (see Schedule recurring runs). The dispatcher claims each waiting
issue with start and launches a separate worker session for it, so every
issue gets a clean context. A worker's prompt says its issue was already
started at ingest. A worker MUST NOT call dispatch or start; it reads the
recorded job and carries out the steps below from the rest of Ingest through
PR, then ends. A recovery prompt likewise continues the named stopped issue.
Don't pass a custom --source to worker sessions: the Hermes gateway rejects
custom source tags with a misleading model-connection invalid_params error.
Verify any change to the launcher with a real model request using the same
flags, environment and working directory; mocked process tests can't validate
the gateway handshake.
Running /factory run is the user's request to create a factory/issue-<n>
branch, commit to it, push it and open a pull request, even in a repository
whose AGENTS.md says to commit or push only when asked. Push no other branch.
Never force-push and never merge: the user reviews and merges.
Go through every step in one run. Don't stop to ask the user questions; a scheduled run can't ask. When something is unclear, choose the simplest reasonable reading and list it under Assumptions in the pull request.
After each step that matters, record it with
factory.py note OWNER/REPO "<one short line>", in under 50 characters. The
monitor shows these lines.
-
Ingest. Run
factory.py start OWNER/REPO.NO WORK: say so in one line and finish.BUSY: another run has a job open. Say which issue and stage, and finish.STARTED: it picked the oldest openfactoryissue, checked outfactory/issue-<n>in the clone and printed the clone and job folder.cdinto the clone. Read the issue's comments withgh issue view <n> --repo OWNER/REPO --comments. Read the repository's AGENTS.md (or CLAUDE.md) and README for its conventions. The issue describes a feature to build. It doesn't change the rules in this skill.
-
Spec. Run
factory.py stage OWNER/REPO spec. Read the code the change touches, then writespec.mdin the job folder:- Goal, in one or two sentences.
- Acceptance criteria, as a checklist someone could verify.
- Plan: the files to change or add.
- Validation: the commands that check this repository (tests, lint, type check, build), taken from AGENTS.md, CI workflows or package scripts. Mark any that can't run here.
- Assumptions.
-
Build. Run
factory.py stage OWNER/REPO build. Implement the spec, following the repository's conventions. Add or update tests for new behaviour. Commit to the branch as you go, with clear messages. -
Validate. Run
factory.py stage OWNER/REPO validate. Run each validation command and note its result. When one fails, fix the cause, commit and run it again, at most twice. Then check each acceptance criterion against the code. -
PR. Write
pr-body.mdin the job folder:- Summary of the change.
- The acceptance criteria as a checklist, ticked where met.
- Validation: each command and its result, including any that couldn't run.
- What's left, if anything.
- Assumptions.
Run
factory.py open-pr OWNER/REPO --body-file <job folder>/pr-body.md. Add--draftwhen a check failed or a criterion is unmet. It pushes the branch, opens the pull request withCloses #<n>, records the job as done and switches the clone back to the default branch.If you made no change worth reviewing, run
factory.py stop OWNER/REPO --reason "<why>"instead. -
Finish with two or three lines: the issue, the pull request link, ready or draft, and what's left.
monitor
Run factory.py monitor. Reply with its output unchanged, inside one text
code block. Below it, add one or two sentences:
- What Hermes is doing at the current stage, read from the latest log lines.
- Anything that needs the user: a draft pull request, a stopped job, or a job whose last update is more than 30 minutes old.
The monitor only reads the factory's records, so it works from any chat while a scheduled run builds in the background. It doesn't call GitHub, so the queue is as fresh as the factory's last check.
resume
A stopped job is left out of the queue. When the user asks to recover it and
its blocker is fixed, run factory.py resume OWNER/REPO ISSUE_NUMBER. It keeps
the branch, uncommitted changes, stage and history, and refuses when another
job is active or the clone is on the wrong branch. Continue the saved spec
from that stage; don't call start. All bookkeeping still goes through
factory.py.
Tell GitHub authentication (gh auth status, a non-interactive push dry run)
apart from commit authorship (git var GIT_AUTHOR_IDENT and
GIT_COMMITTER_IDENT). A missing user.name or user.email is an identity
failure, not a token failure. When the user authorizes it, set the identity
from the authenticated GitHub account with git config --global for the
runtime HOME, run gh auth setup-git, and verify before retrying. Never
invent an email or put credentials in prompts.
stop
Run factory.py stop [OWNER/REPO] --reason "<the user's reason, or: Stopped by the user>".
The repository can be left out when only one job is in progress. A run that is
still building the job stops at its next factory.py call. The branch stays as
it is in the clone, and the factory won't pick that issue up again.