SLOPSHOPPER

devcycle

Opinionated pipeline from a feature, bug, or refactor description to a verified, publish-ready implementation: scoped interview, wave-based plan, parallelized…

bandguardstatusprocesstimeragents
★ 5v0.28.0MITupdated 2026-10-25KonstantinRoehrl/devcycle
A shopper browsing a rack in a slop shop
Preview could not run: TypeError: Invalid URL: null/home/runner/work/slopshopper/slopshopper/.cache/src/konstantinroehrl-devcycle/hooks/./mod-sink.mjs at new URLShim (inner.js:204:26) at anonymous (file:///inner.js:
README

devcycle

A Claude Code plugin that turns a one-line feature, bug, or refactor description into a verified, reviewed implementation on its own git branch. You type one command; devcycle asks clarifying questions to scope and brainstorm the work, designs a spec with you (an independent reviewer checks its claims against your code before you approve it), plans it as parallel tasks, and implements them test-first with subagents running in parallel. It reviews the finished branch against the spec and — when the change is visible on screen — launches the app and drives it through claude-in-chrome first: what a browser can confirm structurally is checked off, what it can only observe comes back as proposed verdicts you confirm in one answer, and only how it looks and feels is asked item by item, since that verdict is yours, not a script's. A branch with nothing on screen skips that stage.

Beyond building the change, devcycle closes the loop around a pull request: it reads a PR's review comments and reconciles them into the right fixes and consented replies. And it benchmarks its own runs and learns from past sessions, its learning report carrying a per-period ledger that nets win savings against culprit cost, and a routing advisory that measures what each model actually cost per accepted task — so the pipeline gets better the more you use it.

Policy — what it may do with git, which models it runs, how deep reviews go — is configuration, not something you re-explain each session, and a single profile preset sets the cost-versus-rigor level for all of it at once. devcycle is built entirely on the [superpowers] plugin (a required dependency): superpowers is the toolkit, devcycle is the guide for using it as a repeatable pipeline. Brainstorming and debugging are upstream's, unmodified; devcycle adds the stages, gates, and mechanics around them, and ships compact native planning and execution engines that overlay their upstream counterparts only at the thorough profile.

Where to start

---
title: devcycle — where to start
accDescr: Command-level map of devcycle's nine slash commands. /devcycle:onboard scaffolds a new repo before the first cycle; /devcycle:cycle runs the guided pipeline through Scope/Design, Plan, Build, Review, and Ship; /devcycle:continue resumes a stopped cycle; and /devcycle:review, /devcycle:doctor, /devcycle:verify, /devcycle:learn, /devcycle:maintain, and /devcycle:reconcile each run standalone at any time.
---
flowchart LR
    CYCLE(["/devcycle:cycle"]):::tool
    CONT(["/devcycle:continue"]):::tool
    ONBOARD(["/devcycle:onboard"]):::tool
    REVIEWCMD(["/devcycle:review"]):::tool
    DOCTOR(["/devcycle:doctor"]):::tool
    VERIFY(["/devcycle:verify"]):::tool
    LEARN(["/devcycle:learn"]):::tool
    MAINTAIN(["/devcycle:maintain"]):::tool
    RECONCILE(["/devcycle:reconcile"]):::tool

    ONBOARD -. "first, in a new repo" .-> CYCLE
    CYCLE --> SCOPE["Scope / Design"]:::stage
    SCOPE --> PLAN["Plan"]:::stage
    PLAN --> BUILD["Build"]:::stage
    BUILD --> REVIEW["Review"]:::stage
    REVIEW --> SHIP["Ship"]:::stage

    CONT -. "resumes wherever the cycle stopped" .-> PLAN

    REVIEWCMD -. "standalone, anytime" .-> SHIP
    DOCTOR -. "standalone, anytime" .-> SHIP
    VERIFY -. "standalone, anytime" .-> SHIP
    LEARN -. "standalone, anytime" .-> SHIP
    MAINTAIN -. "standalone, anytime" .-> SHIP
    RECONCILE -. "standalone, anytime" .-> SHIP

    classDef stage fill:#EEEDFE,stroke:#534AB7,color:#3C3489;
    classDef tool fill:#E1F5EE,stroke:#0F6E56,color:#085041,stroke-dasharray:5 5;
    classDef structural fill:#F1EFE8,stroke:#5F5E5A,color:#444441;

Command-level only — for stage internals, see docs/pipeline/.

Those nine commands are devcycle's entire surface — everything else it ships is machinery they load. The full stage-level pipeline is in docs/pipeline/.

Two of the standalone commands form a review write-back path around a pull request: /devcycle:review produces a ranked findings document and can file those findings back onto an open PR, and /devcycle:reconcile responds to a PR's own review comments — triaging them into fixes and consent-gated replies. Both post through one shared comment-body shape, so what Claude files and what it replies look the same on the PR.

Install

claude plugin marketplace add KonstantinRoehrl/devcycle
claude plugin install devcycle@devcycle

devcycle depends on the [superpowers] plugin. Installing devcycle installs it automatically from the official Claude Code plugin directory; afterwards claude plugin list shows both devcycle and superpowers as enabled.

Requires Claude Code 2.1.287 or later — earlier releases reject the manifest's userConfig pick-lists (before 2.1.271) or run an earlier hooks-module API, under which devcycle's hooks module stays off.

What the hooks module can see. Besides its settings hooks, devcycle ships a hooks module (hooks/devcycle-mod.mjs) that Claude Code runs in-process: it sees your sessions' prompts, tool calls and tool results, it is not sandboxed, and claude plugin validate <plugin directory> lists every hook it registers and every engine call it makes. In every session it looks for a .devcycle/state.md in the working directory or a parent; where that file names an active run, it runs a short Node check (node hooks/mod-sink.mjs check-joined) to learn whether this session joined the run. Beyond that it acts only in a session that joined an active devcycle run, where what it writes are run-record rows of ids, counts and enum values. In any session it also relays the terminal notification scripts/handoff-mark.mjs asks for (handoffNotification), and, where it finds a .devcycle/state.md, checks the one file .devcycle/drive-progress.json beside it about every 300 ms (reading it only when it changed) to draw the drive band above the prompt while an unattended run's driver is running or an ended run awaits /devcycle:continue; that file is written by the unattended-run driver, and the band spends no model turn.

For the on-device verification stage's agent pass, also install the claude-in-chrome plugin — Claude Code's integration with your own Chrome (without it, the stage still launches the app, but every checklist item falls to you).

Use

Start a cycle with a description of any maturity — a one-liner is fine:

/devcycle:cycle add CSV export to the report page

What to expect: devcycle first judges how developed your description is (a rough idea starts with a scope interview; a detailed ticket skips ahead). Questions come in small batches with concrete options to pick from, never one-at-a-time trickles. You approve the spec, then the plan; implementation, testing, and review then run without you; at the end you get a branch (and, for UI work, a short walkthrough of the running app: one batch of proposed verdicts to confirm, then the items only your eyes can judge).

The pipeline saves its position to files under .devcycle/ at every stage boundary, so it survives /clear, compaction, and new sessions — resume any time with /devcycle:continue. How the stages hand off and how the state file is verified is covered in docs/pipeline/.

The pipeline pauses between stages by design: it stops at most stage boundaries and asks you to run /clear and then /devcycle:continue, so a cycle plays out as several short sessions rather than one long one.

Execution can also walk its waves without you: when /devcycle:continue resumes at execution it asks whether to run them unattended (the executionMode setting only decides which answer comes first), then starts a driver that gives each wave a fresh session, watches it, and stops at the first thing that needs you — see running execution unattended. A band above the prompt shows the run's progress without spending a model turn.

Every handoff records when it is safe to /clear; resuming before it warns you, and the handoffNotification setting can ring your terminal or push a notification when it is.

Add .devcycle/ to the target repo's .gitignore — none of it belongs in git history. What devcycle attempts to commit outside that directory is docTrackingPolicy's call.

profile is the one knob most people need — it sets the cost-versus-rigor level for the whole run at once. The full configuration surface is in docs/configuration/.

Troubleshooting

  • devcycle shows "failed to load" in claude plugin list — the [superpowers] dependency is missing or disabled. It normally installs automatically from the official plugin directory (claude plugin install superpowers@claude-plugins-official re-resolves it); once present and enabled, both plugins load.
  • Two copies of superpowers listed — you had superpowers installed from its own marketplace before installing devcycle, and the dependency pulled in the official-directory copy as well. Both work; keep one, e.g. claude plugin uninstall superpowers@superpowers-marketplace.
  • A literal ${user_config.KEY} string appears in output — you are looking at the resolver invocation of an entry command with that option unset; this is expected, and scripts/resolve-knobs.mjs resolves it per docs/configuration/. Set the option in /plugin configure to make the value substitute. Configured and still literal under claude --plugin-dir? That load never sees configured values — docs/platform-notes.md § (h).
  • A command fails on a path that starts with /scripts/ — a plugin script was named with ${CLAUDE_PLUGIN_ROOT} in text that reached a shell, where that token is empty: it is substituted when a playbook is rendered into a prompt, not by the shell. devcycle names plugin scripts "$(devcycle-root)/scripts/<name>.mjs" instead, quotes included — bin/devcycle-root prints the installed plugin root, and Claude Code puts <plugin>/bin on PATH, so it resolves from any shell, a dispatched subagent's included. The quotes are load-bearing: command substitution is word-split, so an unquoted form tears a plugin root containing a space and fails as a module-not-found on the truncated path.
  • Source edits don't show up after reinstalling — the plugin cache is keyed by version, and reinstalling the same version does not refresh it. Bump the version or uninstall and reinstall.

Go deeper

docs/ is the documentation hub — the design, the full pipeline, every playbook, the configuration surface, the decision log, and the full inventory of what the plugin ships. Start there.

  • Design rationale and architecture: docs/design/
  • Decision log: docs/decisions/
  • How the coordinator delegates and keeps its own context small: references/delegation.md
  • Open defects: docs/known-issues.md
  • Release history: CHANGELOG.md
  • Contributing, including the golden-path fixture that holds the pipeline's wiring together: CONTRIBUTING.md. scripts/doctor.mjs re-measures devcycle's own token profile from a local Claude Code session corpus, which is how the cost claims are kept honest rather than assumed; it reads each run's workload from records the hooks/workload-sensor.mjs commit-sensor writes on every commit, not from a single finish-stage step, and reports agent depth per stage from the per-subagent depth rows hooks/dispatch-sensor.mjs writes whenever a cycle's own session sees a subagent finish. The hooks module (hooks/devcycle-mod.mjs) adds an agent-trace row per finished subagent turn, which doctor cross-checks against those depth rows. The depth gate runs scripts/depth-probe.mjs, which measures one transcript without loading doctor. Every /devcycle:doctor cost-analysis reply carries a per-version and per-stage overview, rendered by scripts/doctor-overview.mjs from the same tables as the full report. A step that needs one section of a shared reference loads only that section, through scripts/read-section.mjs.
  • Developing devcycle itself: scripts/self-dev-check.mjs guards the case where the repo under work is this plugin's own source, so the pipeline runs from the installed copy while the deliverable belongs in the repo. /devcycle:cycle records what the installed copy holds when the run starts — by content hash, via scripts/tree-hash.mjs — and the finish stage fails when an expected deliverable is absent from the branch or the installed copy was written to during the run. It is inert in every other repo.
  • The evidence-and-verification contract's gates: planning runs scripts/plan-check.mjs in its self-review — one fail-closed gate over seven legs, including the budget-fixture and authored-claims checks — and /devcycle:cycle runs scripts/contract-staleness-check.mjs as an advisory preflight that warns when a cached plugin's contract predates the target repo's. A host repo can declare its whole-gate checks in the required-checks manifest tests/fixtures/required-gate-checks.json — a committed JSON array of substrings every convention whole-gate command must contain, enforced by plan-check against the plan's gate commands and by scripts/evidence-completeness-check.mjs against each capture's cmd:, and a no-op when absent, keeping the plugin repo-agnostic. Every capture is written by scripts/capture-evidence.mjs, which runs the task's gate command, so a capture's header, the report's cmd: and the gate cannot drift apart. The contract itself lives in references/evidence.md.

[superpowers]: https://github.com/obra/superpowers

Source 6 files
hooks/devcycle-mod.mjs 499 lines
1// devcycle's hooks module, loaded in-process from hooks/hooks.json's `modules`. In a session that
2// joined the active devcycle run it observes each subagent and writes one agent-trace run-record row
3// per finished subagent turn, under the agentId hooks/dispatch-sensor.mjs keys its agent-depth row by;
4// it bounds a subagent's context by the subagentBudget tier, and shows the coordinator's stage budget
5// on the status line. In any session it raises the terminal notifications scripts/handoff-mark.mjs
6// prints and, in an interactive one, draws the execution driver's progress band above the prompt. The
7// engine's own forks (compaction, memory) are neither traced nor bounded.
8// It runs without Node — nothing it imports may import a node: module, call require or import
9// dynamically — so the state file's run, the joined-run check and the run-record write go through
10// hooks/mod-sink.mjs, which it spawns. Settings hooks sit beneath it in one chain, so every hook that
11// is not answering for itself returns next's result; every non-streaming hook passes the call through
12// when it fails. Claude Code's loader refuses the module unless `$` reaches only functions declared
13// at the top of this file and each event is registered once, so every helper below takes the
14// per-load state, `st`, as an argument, and one tool.call hook serves every behaviour.
15import { HARD_STOP, OVER_BUDGET, STAGE_FILES_READ, STAGE_TOOL_CALLS, budgetBand, contextDepth, windowFor } from "../scripts/depth-bands.mjs";
16import { activeRun } from "./lib/run-scope.mjs";
17
18// The first Claude Code whose hooks-module API this module is written against; below it the
19// early-access API differs, so the module stays inert (docs/platform-notes.md § (j)).
20const MIN_CLAUDE_CODE = [2, 1, 287];
21// A module's environment has no CLAUDE_PLUGIN_ROOT; its own file URL is the anchor.
22const SINK = decodeURIComponent(new URL("./mod-sink.mjs", import.meta.url).pathname);
23const STATE_REL = ".devcycle/state.md";
24const MAX_WALK = 64;
25// The drive band's file, beside the state file. scripts/drive-progress.mjs owns its shape and writes it
26// through Node, which this module cannot import, so the path is restated here.
27const PROGRESS_REL = ".devcycle/drive-progress.json";
28const INERT = Object.freeze({ active: false, stateFile: null });
29// The limiter's tiers, the reads `enforce` refuses at the hard stop (never Write, Edit or Bash), and
30// how often the over-budget note repeats after its first crossing.
31const TIERS = ["off", "warn", "enforce"];
32const BOUNDED_READS = new Set(["Read", "Grep", "Glob", "WebFetch", "WebSearch"]);
33const NOTE_EVERY = 5;
34const percent = (fraction) => Math.round(fraction * 100);
35const HARD_STOP_DENY =
36  `devcycle budget: hard stop at ${percent(HARD_STOP)}% of the context window. Do not read further; ` +
37  "return what you have and name what you did not explore.";
38const budgetNote = (fraction) =>
39  `devcycle budget: this subagent is at ≈${percent(fraction)}% of its context window (over budget at ` +
40  `${percent(OVER_BUDGET)}%, hard stop at ${percent(HARD_STOP)}%). Finish with what you have; name what you did not explore.`;
41
42function atLeast(base, version) {
43  const parts = String(base ?? "").match(/^(\d+)\.(\d+)\.(\d+)/)?.slice(1).map(Number);
44  if (!parts) return false;
45  for (let i = 0; i < 3; i++) if (parts[i] !== version[i]) return parts[i] > version[i];
46  return true;
47}
48
49const stateFileIn = (dir) => `${dir === "/" ? "" : dir}/${STATE_REL}`;
50// A worktree's `.git` is a file, so only its existence is asked.
51const gitIn = (dir) => `${dir === "/" ? "" : dir}/.git`;
52const parentOf = (dir) => dir.slice(0, dir.lastIndexOf("/")) || "/";
53// A session joins a run by appending its session row from a main-loop Bash call (commands/cycle.md,
54// commands/continue.md), which leaves the state file untouched.
55const appendsSessionRow = (e) => e.tool === "Bash" && typeof e.command === "string" && e.command.includes("--kind session");
56
57// A subagent's per-turn counters. Its identity survives a reset, because a continued agent
58// (SendMessage, a resume) keeps its agentId.
59const turnCounters = () => ({ steps: 0, peakDepth: 0, lastDepth: null, model: null, toolResultChars: 0, warned: 0, refused: 0, overResults: 0 });
60
61// Everything one load of the module knows. `joinedKey` is "<session id> <run id>" once the sink
62// answered joined; a negative answer is never cached. `scope` is the promise active() answers from.
63// `tier` is the subagentBudget value Claude Code hands register; anything else reads as warn.
64// `meter` is the stage meter's counters for the stage it last displayed; `band` is the drive band's
65// timer and the progress file it last read.
66function newState(options) {
67  return { version: null, notNested: null, joinedKey: null, scope: null, agents: new Map(),
68    tier: TIERS.includes(options?.subagentBudget) ? options.subagentBudget : "warn",
69    meter: { stage: null, calls: 0, files: new Set(), percent: null, shown: false },
70    band: { timer: null, busy: false, stamp: null, progress: null, frame: 0, moving: false } };
71}
72
73const versionOf = (st, $) => (st.version ??= $.session.version().then((v) => v?.base ?? null, () => null));
74
75async function resolveScope(st, $) {
76  st.notNested ??= $.env.get("DEVCYCLE_NESTED_RUN").then((v) => !v, () => false);
77  if (!atLeast(await versionOf(st, $), MIN_CLAUDE_CODE) || !(await st.notNested)) return INERT;
78  const cwd = await $.session.cwd();
79  let stateFile = null;
80  let root = null;
81  for (let dir = cwd, i = 0; i < MAX_WALK && !stateFile; i++) {
82    if (await $.fs.exists(stateFileIn(dir))) stateFile = stateFileIn(dir);
83    else {
84      if (root === null && (await $.fs.exists(gitIn(dir)))) root = dir;
85      if (parentOf(dir) === dir) break;
86      dir = parentOf(dir);
87    }
88  }
89  // A cycle writes its state file at the repo root (references/resume.md § The state file), so with
90  // none found yet that is where one appears; the cwd's own candidate covers a directory outside git.
91  if (!stateFile) return { active: false, stateFile: null, candidates: [...new Set([root ?? cwd, cwd])].map(stateFileIn) };
92  const { mtimeMs } = await $.fs.stat(stateFile);
93  const run = activeRun(await $.fs.read(stateFile));
94  if (!run) return { active: false, stateFile, mtimeMs };
95  const sessionId = await $.session.id();
96  const key = `${sessionId} ${run.run}`;
97  if (st.joinedKey !== key) {
98    const answer = await $.process.run(["node", SINK, "check-joined", "--run", run.run, "--session", sessionId, "--cwd", cwd]);
99    if (answer.exitCode !== 0 || answer.stdout.trim() !== "joined") return { active: false, stateFile, mtimeMs };
100    st.joinedKey = key;
101  }
102  return { active: true, stateFile, mtimeMs, run: run.run, stage: run.stage, sessionId, cwd };
103}
104
105function current(st, $) {
106  return (st.scope ??= resolveScope(st, $).catch(() => INERT));
107}
108
109function refresh(st, $) {
110  st.scope = resolveScope(st, $).catch(() => INERT);
111}
112
113async function active(st, $) {
114  return (await current(st, $)).active;
115}
116
117function entry(st, agentId) {
118  let a = st.agents.get(agentId);
119  if (!a) {
120    a = { tracked: false, engineFork: false, agentType: null, requestedModel: null, resolvedModel: null,
121      parentAgentId: null, background: false, fork: false, isTeammate: false, ...turnCounters() };
122    st.agents.set(agentId, a);
123  }
124  return a;
125}
126
127// One stat per main-loop tool call: a cycle's start, a stage advance or a finished cycle writes the
128// state file. A session-row append while inactive asks the joined question again, once, right then.
129async function afterMainLoopCall(st, $, e) {
130  const seen = await current(st, $);
131  if ((appendsSessionRow(e) && !seen.active) || (await stateFileChanged($, seen))) refresh(st, $);
132  await updateMeter(st, $, e);
133}
134
135// A state file that appeared or disappeared changed as much as a rewritten one. With none known, only
136// the repo root's and the cwd's candidates are checked, so outside a devcycle run each call costs at
137// most two exists.
138async function stateFileChanged($, seen) {
139  if (seen.stateFile) return (await $.fs.stat(seen.stateFile).then((s) => s.mtimeMs, () => null)) !== seen.mtimeMs;
140  for (const candidate of seen.candidates ?? []) if (await $.fs.exists(candidate)) return true;
141  return false;
142}
143
144// A section read is a file read the meter must see too. The agent's command carries the expanded
145// plugin root, so this matches the script name rather than the ${CLAUDE_PLUGIN_ROOT} citation form.
146const SECTION_READ_CALL = /([^\s"']*)read-section\.mjs["']?\s+(["']?)(references\/[A-Za-z0-9._-]+\.md)\2/g;
147
148// Keyed like a Read's file_path, so one file read both ways counts once: an absolute script path
149// (<root>/scripts/read-section.mjs) names the plugin root; without one the relative path stands.
150function sectionReadKey([, scriptDir, , reference]) {
151  return scriptDir.startsWith("/") ? scriptDir.replace(/[^/]+\/$/, "") + reference : reference;
152}
153
154// The stage meter: in an interactive session, the coordinator's stage budget on the status line
155// (references/delegation.md § The stage budget). It only displays; it never refuses a call.
156async function updateMeter(st, $, e) {
157  const meter = st.meter;
158  const now = await current(st, $);
159  if (!now.active || (await $.session.surfaces()).length === 0) {
160    if (meter.shown) {
161      meter.shown = false;
162      await $.ui.status(undefined);
163    }
164    return;
165  }
166  if (now.stage !== meter.stage) Object.assign(meter, { stage: now.stage, calls: 0, files: new Set() });
167  meter.calls += 1;
168  if (e.tool === "Read" && typeof e.file_path === "string") meter.files.add(e.file_path);
169  if (e.tool === "Bash" && typeof e.command === "string")
170    for (const m of e.command.matchAll(SECTION_READ_CALL)) meter.files.add(sectionReadKey(m));
171  meter.shown = true;
172  // Claude Code labels a plugin's status entry with the plugin's name, so the text leaves it out.
173  await $.ui.status(`${meter.stage} · calls ${meter.calls}/~${STAGE_TOOL_CALLS} · ` +
174    `files ${meter.files.size}/~${STAGE_FILES_READ} · ctx ${meter.percent ?? "–"}%`);
175}
176
177// scripts/handoff-mark.mjs prints one `notify: terminal <message>` line per handoff notification the
178// handoffNotification knob asks for. A Bash child has no terminal of its own, so the module raises it
179// through the person's notification channel; a Claude Code without $.ui.notify throws on the call, which
180// the catch below absorbs.
181const HANDOFF_MARK_CALL = /handoff-mark\.mjs/;
182const TERMINAL_NOTICE = /^notify: terminal (.+)$/gm;
183
184function relayNotifications($, e, result) {
185  try {
186    if (e.tool !== "Bash" || typeof e.command !== "string" || !HANDOFF_MARK_CALL.test(e.command)) return;
187    const stdout = result?.result?.stdout;
188    if (typeof stdout !== "string") return;
189    for (const [, message] of stdout.matchAll(TERMINAL_NOTICE)) $.ui.notify(message, { title: "devcycle" }).catch(() => {});
190  } catch { /* a notification never fails the call it rode on */ }
191}
192
193async function mainLoopToolCall(st, $, e, next) {
194  const result = await next(e);
195  relayNotifications($, e, result);
196  await afterMainLoopCall(st, $, e);
197  return result;
198}
199
200// Where a bounded subagent stands, or null: untracked, a fork (it inherits its parent's context, so
201// it would meet the hard stop on its first step) or a teammate (a session of its own), no measured
202// step yet, or a window no model table knows. An assumed window counts.
203function standing(st, agentId) {
204  const a = st.agents.get(agentId);
205  if (!a?.tracked || a.fork || a.isTeammate || a.lastDepth === null || !a.model) return null;
206  const w = windowFor(a.model);
207  return w ? { a, band: budgetBand(a.lastDepth, w.window), fraction: a.lastDepth / w.window } : null;
208}
209
210// The observer's character count and the limiter: past the over-budget band a bounded subagent's
211// result carries the note on the first crossing and every NOTE_EVERY-th result after it; under
212// enforce a bounded read at the hard stop is refused before it runs. A refused call carries no
213// result to attach a note to.
214async function subagentToolCall(st, $, e, next) {
215  const at = st.tier === "off" ? null : standing(st, e.agentId);
216  const bounded = at !== null && at.band !== "ok" && (await active(st, $));
217  if (bounded && st.tier === "enforce" && at.band === "hard-stop" && BOUNDED_READS.has(e.tool)) {
218    at.a.refused += 1;
219    return { deny: HARD_STOP_DENY };
220  }
221  const result = await next(e);
222  const a = st.agents.get(e.agentId);
223  // A character count of the result text, named as such: not tokens.
224  if (a?.tracked) a.toolResultChars += result.text?.length ?? 0;
225  if (!bounded || result.deny !== undefined) return result;
226  at.a.overResults += 1;
227  if ((at.a.overResults - 1) % NOTE_EVERY !== 0) return result;
228  at.a.warned += 1;
229  return { ...result, context: [...(result.context ?? []), budgetNote(at.fraction)] };
230}
231
232// Whether a loop is a subagent's or a teammate's. One with no spawn on record counts only when
233// `$.agent.list()` names it, as it does an agent whose spawn a module reload lost and never the
234// engine's own forks; the list is asked once per such loop.
235async function subagentLoop(st, $, agentId) {
236  const known = st.agents.get(agentId);
237  if (known) return !known.engineFork;
238  const listed = (await $.agent.list()).some((agent) => agent.id === agentId);
239  entry(st, agentId).engineFork = !listed;
240  return listed;
241}
242
243function flush($, seen, agentId, a, e) {
244  const w = a.model ? windowFor(a.model) : null;
245  const record = {
246    agentId, agentType: a.agentType, requestedModel: a.requestedModel, resolvedModel: a.resolvedModel,
247    parentAgentId: a.parentAgentId, background: a.background, fork: a.fork, steps: a.steps, peakDepth: a.peakDepth,
248    window: w?.window ?? null, windowAssumed: w?.windowAssumed === true, peakBand: w ? budgetBand(a.peakDepth, w.window) : null,
249    toolResultChars: a.toolResultChars, warned: a.warned, refused: a.refused, reason: e.reason, isAborted: e.isAborted === true,
250  };
251  // Started, never awaited: a subagent's hand-back must not wait on a Node startup. A lost flush is
252  // not retried; doctor's mod-inactive and COLLECTION GAP checks surface it.
253  $.process.run(["node", SINK, "append"], { stdin: JSON.stringify({ run: seen.run, session: seen.sessionId, cwd: seen.cwd, record }) })
254    .catch(() => {});
255}
256
257// The drive band: a running execution driver's progress above the prompt, read from the file the
258// driver keeps (PROGRESS_REL), so watching a run costs no model turn. A timer stats the file each tick,
259// reads it only when its size or mtime moved, and writes what the drawing needs into BAND; the
260// drawing reads only BAND. Interactive sessions only: a `claude -p` run has nothing to draw on.
261const BAND = { plugin: "devcycle", key: "band" };
262const BAND_TICK_MS = 300;
263const SILENT_AFTER_MS = 120_000;
264const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
265const RUN_STATES = new Set(["running", "waiting", "stopped", "ended"]);
266const LIVE_STATES = new Set(["running", "waiting"]);
267// Below this Claude Code, AbovePrompt's bodyColumns still counts the five cells of the band's own
268// [-] mark (seen on 2.1.287; 2.1.292 reports them left out).
269const BODY_COLUMNS_LEAVE_MARK = [2, 1, 292];
270const MARK_COLUMNS = 5;
271
272const cells = (text) => [...text].length;
273const pad2 = (n) => String(n).padStart(2, "0");
274const clockTime = (iso) => {
275  const at = new Date(iso);
276  return Number.isNaN(at.getTime()) ? "--:--" : `${pad2(at.getHours())}:${pad2(at.getMinutes())}`;
277};
278function elapsedText(ms) {
279  const minutes = Math.floor(Math.max(0, ms) / 60_000);
280  if (minutes < 1) return `${Math.floor(Math.max(0, ms) / 1000)}s`;
281  return minutes < 60 ? `${minutes}m` : `${Math.floor(minutes / 60)}h${pad2(minutes % 60)}m`;
282}
283
284function parseProgress(text) {
285  try {
286    const p = JSON.parse(text);
287    return p?.v === 1 && RUN_STATES.has(p.state) && Array.isArray(p.waves) ? p : null;
288  } catch {
289    return null;
290  }
291}
292
293// A live run whose driver has not rewritten the file for SILENT_AFTER_MS; its heartbeat is 30 s.
294const silent = (p, now) => LIVE_STATES.has(p.state) && now - Date.parse(p.updatedAt) > SILENT_AFTER_MS;
295const moving = (p, now) => p !== null && LIVE_STATES.has(p.state) && !silent(p, now);
296
297async function startBand(st, $) {
298  if (st.band.timer || (await $.session.surfaces()).length === 0) return;
299  st.band.timer = $.clock.every(BAND_TICK_MS, () => bandTick(st, $));
300}
301
302// A slow host call never stacks ticks. BAND is written only when the file changed, while the spinner
303// turns, and once more on the tick it stops, so an idle band costs one stat per tick.
304async function bandTick(st, $) {
305  const band = st.band;
306  if (band.busy) return;
307  band.busy = true;
308  try {
309    const { stateFile } = await current(st, $);
310    const path = stateFile ? stateFile.slice(0, -STATE_REL.length) + PROGRESS_REL : null;
311    const stat = path ? await $.fs.stat(path).catch(() => null) : null;
312    const stamp = stat ? `${stat.mtimeMs} ${stat.size}` : null;
313    const changed = stamp !== band.stamp;
314    if (changed) {
315      band.stamp = stamp;
316      band.progress = stamp === null ? null : parseProgress(await $.fs.read(path).catch(() => ""));
317    }
318    const now = await $.clock.now();
319    const turning = moving(band.progress, now);
320    if (!changed && !turning && !band.moving) return;
321    if (turning) band.frame += 1;
322    band.moving = turning;
323    await $.state.set(BAND, { progress: band.progress, frame: band.frame, now });
324  } finally {
325    band.busy = false;
326  }
327}
328
329function waveMark(wave, currentWave) {
330  const count = `${wave.wave} ${wave.committed}/${wave.tasks.length}`;
331  if (wave.tasks.length > 0 && wave.committed >= wave.tasks.length) return { text: `✓${count}`, color: "success" };
332  return wave.wave === currentWave ? { text: `●${count}`, color: "claude" } : { text: `○${count}`, color: "subtle" };
333}
334
335const joined = (marks, separator) => marks.flatMap((m, i) => (i === 0 ? [m] : [{ text: separator }, m]));
336const width = (segments) => segments.reduce((sum, s) => sum + cells(s.text), 0);
337
338// Separators go first, then the strip is windowed around the current wave; it never wraps.
339function fitStrip(marks, at, room) {
340  for (const separator of [" · ", " "]) {
341    const strip = joined(marks, separator);
342    if (width(strip) <= room) return strip;
343  }
344  let lo = at;
345  let hi = at;
346  const windowed = (a, b) => [
347    ...(a > 0 ? [{ text: "… " }] : []), ...joined(marks.slice(a, b + 1), " "), ...(b < marks.length - 1 ? [{ text: " …" }] : []),
348  ];
349  for (let grew = true; grew; ) {
350    grew = false;
351    if (hi < marks.length - 1 && width(windowed(lo, hi + 1)) <= room) (hi += 1), (grew = true);
352    if (lo > 0 && width(windowed(lo - 1, hi)) <= room) (lo -= 1), (grew = true);
353  }
354  return windowed(lo, hi);
355}
356
357function stripLine(p, columns) {
358  const lead = "  waves  ";
359  const total = `${p.committed}/${p.total} committed`;
360  const marks = p.waves.map((w) => waveMark(w, p.currentWave));
361  const at = p.waves.findIndex((w) => w.wave === p.currentWave);
362  const strip = fitStrip(marks, at === -1 ? marks.length - 1 : at, columns - cells(lead) - cells(total) - 2);
363  const gap = Math.max(2, columns - cells(lead) - width(strip) - cells(total));
364  return [{ text: lead }, ...strip, { text: " ".repeat(gap) }, { text: total }];
365}
366
367function headerLine(p, spin, now) {
368  const run = `session ${p.session} · ${p.model} · ${p.effort}`;
369  if (silent(p, now)) return [{ text: `? driver silent since ${clockTime(p.updatedAt)} · devcycle drive · ${run}`, color: "warning" }];
370  if (LIVE_STATES.has(p.state)) return [{ text: `${spin} devcycle drive · ${run} · ${elapsedText(now - Date.parse(p.startedAt))}` }];
371  return [{ text: `devcycle drive · ${run} · ${elapsedText(Date.parse(p.updatedAt) - Date.parse(p.startedAt))}` }];
372}
373
374function taskRow(t, spin) {
375  if (t.step === "committed") return [{ text: `✓ task ${t.task}  committed`, color: "success" }];
376  if (t.step === "pending") return [{ text: `○ task ${t.task}  pending`, color: "subtle" }];
377  const round = (t.step === "reviewing" || t.step === "fixing") && t.round > 0 ? ` · round ${t.round}` : "";
378  const row = [{ text: `${spin} task ${t.task}  ` }, { text: `${t.step}${round}`, color: t.step === "needs-user" ? "warning" : undefined }];
379  if (t.rejections > 0) row.push({ text: ` (${t.rejections} rejection${t.rejections === 1 ? "" : "s"})`, color: "warning" });
380  return row;
381}
382
383function bodyLines(p, spin) {
384  if (p.state === "waiting") return [[{ text: `  ⏸ ${p.waitWhat} — resumes ${clockTime(p.waitUntil)}`, color: "warning" }]];
385  if (p.state === "stopped") return [[{ text: `  ✖ stopped for you — ${p.stopDetail}`, color: "error" }]];
386  if (p.state === "ended" && p.outcome === "complete") return [[{ text: "  ✓ run complete — run /devcycle:continue", color: "success" }]];
387  if (p.state === "ended") return [[{ text: `  ✖ run ended: ${p.outcome} — run /devcycle:continue`, color: "error" }]];
388  const wave = p.waves.find((w) => w.wave === p.currentWave);
389  if (!wave) return [];
390  const lead = `  wave ${wave.wave}  `;
391  return wave.tasks.map((t, i) => [{ text: i === 0 ? lead : " ".repeat(cells(lead)) }, ...taskRow(t, spin)]);
392}
393
394// Each line a list of { text, color } segments; color a theme key.
395function bandLines({ progress: p, frame, now }, columns) {
396  const spin = silent(p, now) ? "?" : SPINNER[frame % SPINNER.length];
397  return [headerLine(p, spin, now), stripLine(p, columns), ...bodyLines(p, spin)];
398}
399
400async function drawBand(st, $, e, next) {
401  if (e.props.hasSurvey) return next(e);
402  const value = (await $.state.get(BAND))?.value;
403  if (!value?.progress) return next(e);
404  const leavesMark = atLeast(await versionOf(st, $), BODY_COLUMNS_LEAVE_MARK);
405  const lines = bandLines(value, e.props.bodyColumns - (leavesMark ? 0 : MARK_COLUMNS));
406  const { Box, Text } = $.ui.resolve(e);
407  return h(Box, { flexDirection: "column" }, ...lines.map((line) =>
408    h(Text, { wrap: "truncate" }, ...line.map((s) => (s.color ? h(Text, { color: s.color }, s.text) : s.text)))));
409}
410
411export function register(on, options) {
412  const st = newState(options);
413
414  // Every main-loop turn re-derives the run and the joined answer; the version and the child marker
415  // are read once per load.
416  on("turn.start", async ($, e, next) => {
417    refresh(st, $);
418    return next(e);
419  }).catch(($, e, next) => next(e));
420
421  // /clear starts a conversation under a new session id, which has not joined anything yet.
422  on("session.end", async ($, e, next) => {
423    const result = await next(e);
424    if (e.reason === "clear") {
425      st.joinedKey = null;
426      st.scope = null;
427    }
428    return result;
429  }).catch(($, e, next) => next(e));
430
431  // /devcycle:continue appends this session's row mid-turn, after turn.start asked and was told
432  // not-joined, so a spawn while inactive re-derives the scope before the agent runs: one sink check
433  // per spawn, and only until the session has joined (spec §4.3 amendment, 2026-10-07).
434  on("agent.spawn", async ($, e, next) => {
435    if (!(await active(st, $))) refresh(st, $);
436    const result = await next(e);
437    if (result.agentId && (await active(st, $)))
438      Object.assign(entry(st, result.agentId), {
439        agentType: e.subagentType, requestedModel: e.model ?? null, resolvedModel: result.model ?? null,
440        parentAgentId: e.parentAgentId ?? null, background: e.background === true, fork: e.fork === true,
441        isTeammate: e.isTeammate === true,
442      });
443    return result;
444  }).catch(($, e, next) => next(e));
445
446  // Tracking starts at an agent's first step, not its spawn, so state lost to a module reload costs
447  // the spawn's fields, never the record. A streaming hook: its bookkeeping catches its own errors
448  // once the stream has been relayed.
449  on("turn.step", async function* ($, e, next) {
450    const stepping = next(e);
451    for await (const chunk of stepping) yield chunk;
452    const result = await stepping.result;
453    try {
454      if (e.agentId !== undefined && (await active(st, $)) && (await subagentLoop(st, $, e.agentId))) {
455        const a = entry(st, e.agentId);
456        a.tracked = true;
457        const depth = contextDepth(result.usage);
458        if (depth !== null) {
459          a.steps += 1;
460          a.lastDepth = depth;
461          a.peakDepth = Math.max(a.peakDepth, depth);
462          a.model = result.usage.model ?? e.model;
463        }
464      }
465    } catch { /* observation only: a failed count never touches the step */ }
466    return result;
467  });
468
469  // The module's one tool.call hook: the loader refuses a second unmatched registration.
470  on("tool.call", async ($, e, next) =>
471    (e.agentId === undefined ? mainLoopToolCall(st, $, e, next) : subagentToolCall(st, $, e, next)))
472    .catch(($, e, next) => next(e));
473
474  on("turn.complete", async ($, e, next) => {
475    const result = await next(e);
476    const a = e.agentId === undefined ? undefined : st.agents.get(e.agentId);
477    if (a?.tracked) {
478      const seen = await current(st, $);
479      if (seen.active) flush($, seen, e.agentId, a, e);
480      Object.assign(a, turnCounters());
481    }
482    return result;
483  }).catch(($, e, next) => next(e));
484
485  on("session.start", async ($, e, next) => {
486    const result = await next(e);
487    await startBand(st, $);
488    return result;
489  }).catch(($, e, next) => next(e));
490
491  on("ui.render", { component: "AbovePrompt" }, ($, e, next) => drawBand(st, $, e, next)).catch(($, e, next) => next(e));
492
493  on("session.measure", async ($, e, next) => {
494    const result = await next(e);
495    if (typeof e.context?.percent === "number") st.meter.percent = Math.round(e.context.percent);
496    return result;
497  }).catch(($, e, next) => next(e));
498}
499
scripts/depth-bands.mjs 70 lines
1// The context-depth arithmetic, with no Node import, so the hooks module (hooks/devcycle-mod.mjs) — which runs without Node — measures a subagent with the same functions depth-probe.mjs and doctor.mjs use. It imports only pricing.mjs.
2import { PRICING, parseModelId, priceFor, provisionalPriceFor } from "./pricing.mjs";
3
4// An unpriced model with no priced family is most likely a newer one, and every current Claude 5
5// model runs a 1M window; the label, not the number, is what tells the reader to fix pricing.mjs.
6export const ASSUMED_WINDOW = 1_000_000;
7
8// A step the engine reports with no usage block has no depth to measure — never zero.
9export function contextDepth(usage) {
10  if (!usage) return null;
11  return (usage.input_tokens ?? 0) + (usage.cache_creation_input_tokens ?? 0) + (usage.cache_read_input_tokens ?? 0);
12}
13
14// Fractions of the running model's context window. The underlying measurement is absolute —
15// cost per 1k output tokens bottoms at 15.1k in the 100-150k band and climbs to 40.7k past
16// 300k — taken on 1M-window sessions, so these fractions are those absolutes divided by 1M.
17// Expressing them as fractions is a deliberate approximation that lets them adapt to smaller
18// windows; cache-read cost actually scales with absolute tokens, not with the fraction used.
19// Doctor's own per-model band data is what should confirm or correct them once smaller-window
20// sessions have been measured.
21export const OVER_BUDGET = 0.15;
22export const HARD_STOP = 0.2;
23
24export function budgetBand(depth, window) {
25  const f = depth / window;
26  if (f >= HARD_STOP) return "hard-stop";
27  if (f >= OVER_BUDGET) return "over-budget";
28  return "ok";
29}
30
31// The id pricing.mjs would key the model under: strips the wrappers a host reports around it
32// (Claude Code's `[1m]`, Bedrock's `<region>.anthropic.` prefix and `-v<n>:<n>` suffix, Vertex's
33// `@<date>`) and reorders the older `claude-3-5-sonnet-...` naming to family-first.
34function canonicalModelId(model) {
35  return model
36    .replace(/\[1m\]$/i, "")
37    .replace(/^(?:[a-z]+\.)?anthropic\./, "")
38    .replace(/-v\d+:\d+$/, "")
39    .replace(/@\d{8}$/, "")
40    .replace(/^claude-(\d+(?:-\d+)*)-(opus|sonnet|haiku)(-\d{8})?$/, "claude-$2-$1$3");
41}
42
43const PRICED_VERSIONS = Object.keys(PRICING.models).map((id) => ({ id, ...parseModelId(id) })).filter((p) => p.family);
44const sameVersion = (a, b) => a.family === b.family && a.version.join("-") === b.version.join("-");
45
46// Null when no window is knowable: an unpriced version older than its family's newest priced one
47// (Sonnet 4.5, Opus 4.1) may have run a smaller window than that sibling, so the assumed 1M would
48// read its depth several times too shallow. An id that does not parse is assumed, not unknown.
49export function windowFor(model) {
50  const id = typeof model === "string" ? canonicalModelId(model) : model;
51  const exact = priceFor(id);
52  if (exact) return { window: exact.window };
53  const provisional = provisionalPriceFor(id);
54  if (provisional) return { window: provisional.price.window, windowProvisionalAs: provisional.basedOn };
55  const parsed = typeof id === "string" ? parseModelId(id) : null;
56  if (parsed) {
57    // A dated snapshot of a priced version is that version.
58    const snapshotOf = PRICED_VERSIONS.find((p) => sameVersion(p, parsed));
59    if (snapshotOf) return { window: PRICING.models[snapshotOf.id].window, windowProvisionalAs: snapshotOf.id };
60    // provisionalPriceFor declines a parsed id of a priced family only when it is older.
61    if (PRICED_VERSIONS.some((p) => p.family === parsed.family)) return null;
62  }
63  return { window: ASSUMED_WINDOW, windowAssumed: true };
64}
65
66// The coordinator's per-stage counters, references/delegation.md § The stage budget; the stage meter
67// displays them and golden-path holds them equal to that section.
68export const STAGE_TOOL_CALLS = 30;
69export const STAGE_FILES_READ = 15;
70
hooks/lib/run-scope.mjs 15 lines
1// Which state file names an active devcycle run: a 16-hex `run:` and a stage from the run record's
2// stage enum. Node-free, so the hooks module applies the same rule in-process that
3// hooks/dispatch-sensor.mjs and hooks/mod-sink.mjs apply on disk.
4import { field } from "../../scripts/md-field-core.mjs";
5
6export const STAGES = new Set(["scoping", "audit", "diagnosis", "brainstorm", "planning", "execution",
7  "branch-review", "on-device", "fast-path", "sweep", "finish", "maintain"]);
8export const RUN_ID = /^[0-9a-f]{16}$/;
9
10export function activeRun(stateText) {
11  const run = field(stateText, "run");
12  const stage = field(stateText, "stage");
13  return RUN_ID.test(run ?? "") && STAGES.has(stage) ? { run, stage } : null;
14}
15
scripts/pricing.mjs 84 lines
1// The one place model prices and context windows live. Both ride together because the
2// context-depth gate needs the window and a second table would be a second thing to let drift.
3// Prices are US dollars per million tokens.
4//
5// A row may carry `cacheRead`, the listed cache-read price. A row without it is "unlisted,
6// assumed": it reads at CACHE_READ_DEFAULT_MULTIPLIER x its input price, the rate doctor applied
7// to every model before cache reads were priced per model. `claude-fable-5` and the rows whose
8// reference entry names no cache-read price are in that state until one is listed.
9
10export const CACHE_READ_DEFAULT_MULTIPLIER = 0.1;
11
12export const PRICING = Object.freeze({
13  // The date the claude-api reference these prices came from was cached.
14  asOf: "2026-09-25",
15  models: Object.freeze({
16    "claude-opus-5-5": Object.freeze({ in: 4, out: 20, cacheRead: 0.2, window: 1_000_000 }),
17    "claude-opus-5": Object.freeze({ in: 5, out: 25, window: 1_000_000 }),
18    "claude-opus-4-8": Object.freeze({ in: 5, out: 25, window: 1_000_000 }),
19    "claude-fable-5": Object.freeze({ in: 10, out: 50, window: 1_000_000 }),
20    "claude-fable-5-1": Object.freeze({ in: 10, out: 50, cacheRead: 0.25, window: 1_000_000 }),
21    "claude-sonnet-5-5": Object.freeze({ in: 2, out: 10, cacheRead: 0.2, window: 1_000_000 }),
22    // List price per the claude-api reference as of asOf.
23    "claude-sonnet-5": Object.freeze({ in: 2, out: 10, window: 1_000_000 }),
24    "claude-haiku-4-5-20251001": Object.freeze({ in: 1, out: 5, window: 200_000 }),
25  }),
26});
27
28// The exact id, or null. Strict on purpose: the routing advisories, the impact ledger and
29// dispatch-cost present what they compute as measured, so none of them may receive a price
30// that was inferred for a model the table has never heard of.
31export function priceFor(model) {
32  if (typeof model !== "string" || model === "") return null;
33  return PRICING.models[model] ?? null;
34}
35
36// Cache-read cost for `tokens`, in per-million-weighted units (doctor divides by 1e6). The
37// unlisted branch keeps the operation order the flat rate used, so every figure for a row with
38// no listed cache-read price is bit-identical to what it was before.
39export function cacheReadDollars(tokens, price) {
40  return price.cacheRead !== undefined
41    ? tokens * price.cacheRead
42    : tokens * price.in * CACHE_READ_DEFAULT_MULTIPLIER;
43}
44
45// `claude-<family>-<n>[-<n>...][-<8-digit date>]`. Anything else (a family after the version, a
46// non-numeric suffix, a family the table does not price) does not parse and gets no fallback.
47const MODEL_ID = /^claude-(opus|sonnet|haiku|fable)-(\d+(?:-\d+)*?)(?:-\d{8})?$/;
48
49export function parseModelId(id) {
50  const m = MODEL_ID.exec(id);
51  if (!m) return null;
52  const version = m[2].split("-").map(Number);
53  // A lone date stamp is not a version: no real model line has a segment this large.
54  if (version.some((n) => n > 99)) return null;
55  return { family: m[1], version };
56}
57
58function compareSegments(a, b) {
59  for (let i = 0; i < Math.max(a.length, b.length); i++) {
60    const x = a[i] ?? 0, y = b[i] ?? 0;
61    if (x !== y) return x - y;
62  }
63  return 0;
64}
65
66// A provisional price for a model the table has no row for — only when the model is NEWER than
67// every priced model of its family, so a future `claude-opus-5-6` prices as Opus 5.5. An older
68// model is deliberately not covered: its price may differ from the newest sibling's (Sonnet 4.6
69// is $3/$15 against Sonnet 5.5's $2/$10), and a plausible wrong figure is worse than an exclusion.
70// Doctor reports what this returns on its own line and never folds it into a measured figure.
71export function provisionalPriceFor(model) {
72  if (typeof model !== "string" || priceFor(model)) return null;
73  const parsed = parseModelId(model);
74  if (!parsed) return null;
75  let best = null;
76  for (const [id, price] of Object.entries(PRICING.models)) {
77    const known = parseModelId(id);
78    if (!known || known.family !== parsed.family) continue;
79    if (!best || compareSegments(known.version, best.version) > 0) best = { id, price, version: known.version };
80  }
81  if (!best || compareSegments(parsed.version, best.version) < 0) return null;
82  return { price: best.price, basedOn: best.id };
83}
84
scripts/md-field-core.mjs 11 lines
1// The "- key: value" markdown-field-line parser, with no import at all, so the hooks module
2// (hooks/devcycle-mod.mjs), which runs without Node, reads the state file by the rule every script
3// uses; scripts/md-field.mjs re-exports it beside the readers that need the filesystem.
4// `[ \t]*` — never `\s*` — stops the capture at the field's own newline, so a field left blank on
5// its own line cannot read the following "- key:" line back as its value. A miss returns null, the
6// honest sentinel: "" is a legitimate present-but-blank value.
7export function field(text, key) {
8  const m = String(text).match(new RegExp(`^- ${key}:[ \\t]*(.*)$`, "m"));
9  return m ? m[1].trim() : null;
10}
11
types/index.d.ts 32 lines
1// The hooks module's `$.state` contract (hooks/devcycle-mod.mjs), named by plugin.json's `types`.
2// DriveProgress mirrors the file scripts/drive-progress.mjs writes, schema v 1.
3export type DriveStep = 'pending' | 'implementing' | 'reviewing' | 'fixing' | 'committing' | 'committed' | 'needs-user';
4export type DriveTask = { task: string; step: DriveStep; round: number; rejections: number };
5export type DriveWave = { wave: number; committed: number; tasks: DriveTask[] };
6export type DriveProgress = {
7  v: 1;
8  state: 'running' | 'waiting' | 'stopped' | 'ended';
9  session: number;
10  model: string;
11  effort: string;
12  startedAt: string;
13  updatedAt: string;
14  waitUntil: string | null;
15  waitWhat: string | null;
16  stopDetail: string | null;
17  outcome: string | null;
18  currentWave: number | null;
19  committed: number;
20  total: number;
21  waves: DriveWave[];
22};
23// What the band draws from: the parsed file (null when absent or unreadable), the spinner frame and
24// the time the timer last ticked, in `$.clock.now()` milliseconds.
25export type DriveBand = { progress: DriveProgress | null; frame: number; now: number };
26
27declare module 'claude-code' {
28  interface PluginState {
29    devcycle: { band: DriveBand };
30  }
31}
32