Submits the prompts regin's agent bridge delivers to this session, in place of tmux keystrokes, and aborts the running turn on regin's send-now

A workbench for building software with AI coding agents. Plan the feature, run the agents, see what they did, count what they got wrong.
🌐 regin.ccday.top — the official project site.
⚠️ Early beta. regin is under active development and breaking changes are expected at any time. Database schemas, settings keys, hook contracts, skill bundles, and CLI flags may all change without backward-compatible shims. Pin a commit if you need stability.
regin runs one loop around the coding agent you already use:
Spec → Run → Watch → Count
│ │ │ └─ defects declared against the done-claim; rounds-to-done per feature
│ │ └─ every session traced: tools, edits, tokens, time, grades
│ └─ task runs launched on Claude or Kimi, steered and stopped from /live
└─ a feature row carries the spec, its acceptance tests, and the slices cut from it
It is organized in four layers. The first two are where you spend the day; the last two make the runs inspectable and keep the agent on-spec.
| Layer | What it covers | Dashboard |
|---|---|---|
| Workbench | feature → spec → acceptance tests → tasks → done-claim; the defect ledger | /overview (Pipeline), /inbox |
| Runs | launching task runs, steering live sessions, the agent's messages back to you | /live, /inbox |
| Observability | session traces, time and cost analytics, post-hoc grades, audit | /trace, /audit |
| Guidance | patterns & skills, rule engines in hooks, cross-session memory, topic wikis | /patterns, /rules, /memory, /repos/:name/topics |
A feature is a row. Its spec lives on that row (or on its tracker issue when the feature is tracked remotely), and its acceptance items are named tests in the repo — red before the build, green at ship. The spec is cut into slices; each slice becomes a task with its dependencies, and tasks run in dependency order. When the work is called done, that is a done-claim, and anything found wrong afterwards is a defect declared against the feature.
The number the pipeline is held to is rounds-to-done: one build plus each time a done-claim was walked back. Only declarations feed it — nothing is inferred from prose, branch names or timing.
/overview is the Pipeline — Overview, Features and Tasks behind one tab strip; defects are reached from the Overview and the Features triage rail. /features/:id is a feature's ledger./projects/:id holds a project's step stages, each stage's prompt, and the language its task runs write in.regin feature (where a feature stands and what it cost), regin task (capture, inspect, check a slice table, arm a run; runs are launched from the dashboard), regin defects (what a feature got wrong, and what escaped), regin workspace (add, list, remove).A task is armed with a provider, a model and a launch mode, then started from the dashboard. Claude runs go through the Python Claude Agent SDK, so regin owns the process and keeps a typed channel to it — an AskUserQuestion is answered from the browser rather than by typing into a terminal. Kimi Code and CodeBuddy Code runs go over ACP or into a tmux pane on regin's own tmux server.
/live follows a running session: its current state, recent steps, any question it is blocked on, with steer and Stop.send_to_user tool; messages land in /inbox and can fan out to a webhook, Telegram or Lark. CLI: regin messages, regin bridge.regin MCP server — carries send_to_user and the pipeline's tools (features, tasks, defects), so any MCP-speaking agent can read and write the pipeline. regin mcp register wires it, with the memory server, into each provider's config./live renders a phone-sized card that can answer permission prompts while you are away from the desk. Rough edges and breaking changes are expected; see docs/agent-bridge-design.md.Internals: Agent SDK tier, Provider launch capabilities, Agent Messages.
Hooks and transcripts produce a stream of events: tool calls, model thoughts, file edits, hook decisions, token usage. regin ingests that stream into a session trace you can filter by tool, agent and phase, replay, and roll up (tokens by tool, skill reads, MCP calls).
/trace/sessions lists sessions; each opens into a timeline and a conversation view.regin stats time shows where build time goes (attended vs. agent vs. human); regin stats session <trace-id> ranks why one session was slow; regin stats sessions exports per-session rows.regin grade scores finished sessions against a rubric; its aspects and judge are configured under Settings → Grading. /audit is the ops history of regin itself.Internals: Turn & Token Tracing, Session Grader.
The supporting layer: what the agent is told before it acts, and what pushes back when it drifts.
regin pattern promote packages a proven pattern as a versioned skill. Dashboard: /patterns, /skills.PostToolUse hooks, so a violation is reported to the agent in the same turn as the edit. Dashboard: /rules; CLI: regin rules, regin hooks./memory; CLI: regin memory./repos/:name/topics; CLI: regin topics, regin wiki.Internals: Patterns, Rule engines, Agent Memory, docs/topics/proposals.md.
git clone https://github.com/caiuswang/regin && cd regin
./scripts/setup.sh # needs Python ≥ 3.11 and Node; asks to wire the Claude Code hooks
.venv/bin/python cli/regin.py serve # dashboard on http://localhost:8321
.\scripts\setup.cmd instead (PowerShell or cmd; ./scripts/setup.sh there only opens the file in an editor), then regin serve in a new terminal. Same steps, except the live-session terminal and agent bridge, which need tmux. See docs/setup.md.regin hooks install --provider claude. Without them no session is recorded.git pull && ./scripts/setup.sh; it keeps your database, settings and users and runs regin migrate.regin uninstall (--dry-run to preview, --purge-data to drop data too), then delete the checkout.Manual setup, settings, server mode and the CLI reference: docs/setup.md.
| Agent | Status |
|---|---|
| Claude Code | Full: hooks, rule engines, trace, memory, and task runs through the Agent SDK. |
| Kimi Code | Task runs only (ACP or tmux), with known limits — runs are unattended and a steer is cancel-then-re-prompt. See Run a task with Kimi. |
| CodeBuddy Code | Hooks, skills, MCP servers and transcript capture, plus task runs over ACP or tmux with a model and permission mode. |
| WorkBuddy | Hooks, skills, MCP servers and transcript capture; cannot be armed for task runs, and its sessions are not offered Resume. |
| Codex, generic | Provider adapters exist; cannot be armed for task runs. See Agent provider architecture. |
Not a chat UI, not a model, not a hosted service. It assumes you already have a coding agent and a codebase, and runs locally beside them.
hooks/register.ts 157 lines1import type { EngineInterface, Register } from 'claude-code'
2
3let listening = false
4
5const TURN = { plugin: 'regin-bridge', key: 'turn' } as const
6
7export type BridgePrompt = { text: string; id: string; session_id: string }
8export type BridgeControl = { op: 'abort'; id: string; session_id: string }
9
10// A spawned child's pieces end wherever its writes did, so a line can span
11// two pieces: the unterminated tail is carried into the next call.
12export function splitLines(carry: string, text: string): [string[], string] {
13 const parts = (carry + text).split('\n')
14 const tail = parts.pop() ?? ''
15 return [parts.filter(line => line.trim() !== ''), tail]
16}
17
18// Same resolution as regin-agents/bin/regin-mcp.sh: $REGIN_HOME, else ~/regin.
19async function reginHome($: EngineInterface): Promise<string> {
20 return (await $.env.get('REGIN_HOME')) || `${await $.env.get('HOME')}/regin`
21}
22
23async function listen($: EngineInterface) {
24 const session = await $.session.id()
25 const home = await reginHome($)
26 const child = $.process.spawn({
27 argv: [`${home}/.venv/bin/python`, `${home}/cli/regin.py`, 'bridge', 'listen', '--session', session],
28 cwd: home,
29 })
30 let carry = ''
31 for await (const { stream, text } of child) {
32 if (stream !== 'stdout') continue
33 const [lines, tail] = splitLines(carry, text)
34 carry = tail
35 for (const line of lines) {
36 const frame = JSON.parse(line) as BridgePrompt | BridgeControl
37 if ('op' in frame) await abortRunning($)
38 else await $.prompt.submit({ text: frame.text })
39 }
40 }
41}
42
43// regin's "send now": end the running turn and Claude Code runs the prompts
44// queued behind it. Submitting one instead would only queue it behind them.
45async function abortRunning($: EngineInterface) {
46 const { value: turnId } = await $.state.get(TURN)
47 if (!turnId) return
48 try {
49 await $.turn.abort({ turnId })
50 } catch (err) {
51 // The turn ended between the frame and the call; the queue runs anyway.
52 $.ui.log(`regin-bridge: abort skipped: ${String(err)}`, { to: 'debug' })
53 }
54}
55
56export type PhaseEvent = {
57 event: 'turn.start' | 'turn.step' | 'tool.call' | 'turn.complete'
58 turn_id?: string
59 reason?: string
60}
61
62// Only the newest event matters to regin's phase machine, so reports are
63// coalesced: one `regin bridge phase` in flight, and whatever arrived meanwhile
64// collapses into the latest. That keeps them in order without holding the turn
65// on a CLI start per model request.
66let pendingPhase: PhaseEvent | null = null
67// Kept beside the TURN state so tool.call can tag its report without an
68// awaited read that could land after the turn's completion was queued.
69let mainTurn: string | null = null
70let sendingPhase = false
71
72export function reportPhase($: EngineInterface, ev: PhaseEvent) {
73 pendingPhase = ev
74 if (!sendingPhase) void drainPhase($)
75}
76
77async function drainPhase($: EngineInterface) {
78 sendingPhase = true
79 try {
80 while (pendingPhase) {
81 const ev = pendingPhase
82 pendingPhase = null
83 // One more attempt for a lost report, unless a newer event replaced it:
84 // a lost turn.complete would otherwise hold the session at working
85 // until the next turn starts.
86 if (!(await sendPhase($, ev)) && !pendingPhase) await sendPhase($, ev)
87 }
88 } finally {
89 sendingPhase = false
90 }
91}
92
93async function sendPhase($: EngineInterface, ev: PhaseEvent): Promise<boolean> {
94 try {
95 const home = await reginHome($)
96 const session = await $.session.id()
97 const { exitCode, stderr } = await $.process.run(
98 [`${home}/.venv/bin/python`, `${home}/cli/regin.py`, 'bridge', 'phase', '--session', session],
99 { cwd: home, stdin: JSON.stringify(ev) },
100 )
101 if (exitCode === 0) return true
102 $.ui.log(`regin-bridge: phase exited ${exitCode}: ${stderr}`, { to: 'debug' })
103 } catch (err) {
104 $.ui.log(`regin-bridge: phase failed: ${String(err)}`, { to: 'debug' })
105 }
106 return false
107}
108
109// Without the child the bridge falls back to tmux on its own, so a listener
110// that fails is a debug line, never an error in the person's session.
111function ended($: EngineInterface, err: unknown) {
112 try {
113 $.ui.log(`regin-bridge: listener ended: ${String(err)}`, { to: 'debug' })
114 } catch {
115 // the module is unloading; there is nowhere left to log to
116 }
117}
118
119// One listener per loaded module: the bridge registers the session for as long
120// as this child's stream is open, and a second child would submit every prompt
121// twice. A reload ends the old loop (and its child) along with the module.
122export const register: Register = on => {
123 on('session.start', async ($, e, next) => {
124 const started = await next(e)
125 if (!listening) {
126 listening = true
127 void listen($)
128 .catch(err => ended($, err))
129 .finally(() => { listening = false })
130 }
131 return started
132 })
133 on('turn.start', async ($, e, next) => {
134 mainTurn = e.turnId
135 reportPhase($, { event: 'turn.start', turn_id: e.turnId })
136 await $.state.set(TURN, e.turnId)
137 return next(e)
138 })
139 on('turn.step', async function* ($, e, next) {
140 if (!e.agentId) reportPhase($, { event: 'turn.step', turn_id: e.turnId })
141 return yield* next(e)
142 })
143 on('tool.call', async ($, e, next) => {
144 if (!e.agentId) reportPhase($, { event: 'tool.call', ...(mainTurn ? { turn_id: mainTurn } : {}) })
145 return next(e)
146 })
147 on('turn.complete', async ($, e, next) => {
148 if (!e.agentId) {
149 if (mainTurn === e.turnId) mainTurn = null
150 reportPhase($, { event: 'turn.complete', turn_id: e.turnId, reason: e.reason })
151 const { value } = await $.state.get(TURN)
152 if (value === e.turnId) await $.state.set(TURN, null)
153 }
154 return next(e)
155 })
156}
157types/index.d.ts 8 lines1export type RunningTurn = string | null
2
3declare module 'claude-code' {
4 interface PluginState {
5 'regin-bridge': { turn: RunningTurn }
6 }
7}
8