Long mode

Start a long job before you sleep. It runs step by step on your Mac until it is done, fails or hits a deadline, and every step is a comment on a GitHub issue

Long mode

Give it a goal and go. A loop plans the goal as a checklist, runs one step at a time on an agent, and writes every step on a GitHub issue. The issue is the single source of truth. Long mode is built on Dispatch.

Start one

long "Add the missing Arabic strings to the timetable block and push" --repo hogwarts --hours 6

long is the same command as kun-long. It files the issue, starts the loop on this Mac, and prints the issue URL and the log path. Then you can close the lid on the conversation, not on the Mac.

FlagMeaningDefault
--repo RWork folder: a name under ~, ~/oss, ~/Documents, or an absolute path. A known databayt repo name also files the issue in that repothe kun checkout
--in databayt/RFile the issue in this repo (and run in its folder unless --repo says otherwise)databayt/kun
--to Afcc, opencode, claude, codex or agyfcc (the free Pool, class long)
--hours HDeadline from the start8
--steps-max NMost steps the plan may have15
--step-timeout MINTime limit for one step30
--privatePrivate data. Files in the private repo (wins over --in) and runs only on claudeoff
--queueFile the issue only. A runner picks it upoff
--machine LRun on the machine of GitHub login L, or anyyou

A long run for an issue

long "Do the work in this sprint issue" --in databayt/hogwarts --parent databayt/hogwarts#77

--parent <owner>/<repo>#<n> files a new long issue for an issue that already exists. The existing issue is the parent. It is never converted: the loop does not label it, edit it or close it. The reason is the points. A sprint issue carries its points (rate:<n>) and counts only when a named person closes it. The ledger skips every issue labelled long, and the loop closes its own issue, so a converted issue would lose its points.

The long issue says Parent: <owner>/<repo>#<n> on its own line at the top of the body. The parent gets two comments: one when the loop starts, with a link to the long issue and a line saying its steps run there, and one when the loop ends (done, failed or paused), with the outcome and the same link. They follow the same public-output rule as every other comment, so a private run tells the parent only that it ended and that its output is withheld. If a comment on the parent cannot be posted, the loop goes on and the failure is written to the journal. The reference must look like databayt/<repo>#<number>, or the command refuses and creates nothing.

From the app

The Kun app reads long runs through two read-only forms. Both print one line of JSON and exit.

CommandPrints
long status --jsonAn array with one object per open long issue: n, repo, title, url, labels, running, paused, last, parent, agent, private, steps (text and done), done and total
long log <n> --json [--tail N]The last N entries (40 by default) of the run's journal, ~/.kun/dispatch/long-<n>.jsonl. Any long text is cut to 2,000 characters. It does not follow the file

With no gh or no network, status --json prints [] and exits 0. Plain long status and long log <n> are unchanged.

The evidence trail

Everything is on the issue.

WhenWhat you see
Startlong started: host, agent, deadline, step timeout, power state (informational)
PlanA comment with the planning run, then a ## Steps checklist added to the issue body
Each steplong step k/N done or failed (attempt a), with the agent, seconds and the tail of the output
Each successThe step's box is ticked in the body (matched by text, so your edits survive)
Endlong done: steps with durations, total time, the commits made since the start. Labels done, issue closed

Each comment is also appended to a local journal, ~/.kun/dispatch/long-<n>.jsonl. If the network drops, the loop retries with backoff (10 seconds up to 5 minutes). A comment that still cannot be posted waits in a backlog and is posted, marked "posted late", after the next call that works. A step result is never lost.

Every door

DoorHow
Terminallong "…"
Any agent CLI (o, opencode, codex, agy)Ask it to run kun-long "<goal>"
Claude Code and the Machine chat, by text or voiceSay "long mode: …", "night shift: …", "شغل طويل …". The long skill runs the command and answers with the URL
Hermes in Slack or WhatsApp"long …", "night shift …", "شغل طويل …". Hermes runs kun-long and answers with the URL
A GitHub issue from your phoneOpen an issue with labels dispatch and long (and to:<agent>). Write the goal in the body. The runner starts it within about 2 minutes

The runner is the launchd job that wakes every 2 minutes. When it sees a long issue for this machine and no long loop running, it starts one. It never runs a long issue as a one-shot task.

Status, stop, resume

long status         # open long issues: step k/N, running here or not, time of the last step
long stop 12        # finish the current step, then pause (or: long stop all)
long resume 12      # continue a paused or failed issue
long log 12         # tail ~/.kun/dispatch/long-12.log

A pause adds the label paused and a comment that says why: you stopped it, the deadline passed, or the process was interrupted (SIGTERM or Ctrl-C). When one issue finishes, the loop looks for the next open long issue for this machine, oldest first, and goes on. One long loop runs per machine.

The data rule and the private repo

Work repos can be public. Free agents never get private data, and nothing private reaches a public issue. So:

  • --private files the issue in the private repo named by engine.json dispatch.private_repo (now databayt/ops). If that key is empty, the command refuses.
  • Private work runs only on claude. The loop refuses a data:private issue for any other agent.
  • A data:private issue may live in a work repo. There no agent output is ever posted: every comment carries the status, agent, host and seconds, plus "Output withheld: this run read private data. It is in the local journal on <host>." The output is in ~/.kun/dispatch/long-<n>.jsonl. The loop does not plan such an issue: write its ## Steps checklist yourself, because a plan is agent output.
  • On any other issue outside the private repo, the output tail goes through the public guard first. If it objects, that comment is withheld the same way, with the reason.
  • Before a goal is filed anywhere but the private repo, the guard reads it. A phone number, a private email, a key, a quoted chat or commission terms refuse the command and nothing is created. Name a client by CRM record id only.
  • Only an author with write access to the repo may start or resume a run. Otherwise the loop adds failed, posts one skip comment and never claims the issue (Dispatch).
  • Use --private for leads, the CRM, email replies, WhatsApp and the users of schools.

Keeping the Mac awake

While the loop runs it starts caffeinate -i -m -s tied to its own process, so the Mac does not sleep. There is no power or Wi-Fi check: it starts when you say, and if it fails, it fails. The start comment records the battery and disablesleep state for reference only.

When things fail

The ladder

A step that fails twice on a free agent gets one more try on claude, when claude is installed on this machine. It runs on the build lane, on the subscription: never Fable, never an API key. If it passes, the run goes on with its own agent for the next steps. If it fails, the run stops as described below. The step comment names the agent that ran it, so the issue shows the hand-over, and the journal records it. A run that is already on claude, which includes every private run, never leaves it and keeps its two attempts.

FailureWhat happens
A step failsOne retry. A second failure on the same step: a run on a free agent gets one try on claude (see below). Any other run stops: label failed, a final comment, the issue stays open
A step times outCounts as a failure
The agent prints no STEP: line but exits 0Counts as done, with the note "no STEP line"
Fable, Mythos or escalateRefused up front (subscription only)
The author has no write accessSkipped: label failed, one comment, never claimed
Repo not found, agent not installedfailed with the reason
gh or the network is downRetries, journal, backlog (above). The loop does not crash
The Mac restartsThe issue stays claimed by this machine. The runner restarts the loop on its next pass, or run long resume <n>

See also Pool: long sessions.