From 2554fb470caafa0c50d9b6b9740cab17cf3ec200 Mon Sep 17 00:00:00 2001 From: Florian Metz Date: Wed, 11 Nov 2026 19:49:31 +0100 Subject: [PATCH 1/3] feat: Pause the autopilot for a session or a project without touching the orders file: /orders pause|resume [parts] [project], a Pause card in Settings, /orders subagents, and effort auto comes back on resume --- CHANGELOG.md | 5 +++ README.md | 19 ++++++++- hooks/judges.ts | 8 +++- hooks/orders.ts | 30 ++++++++++++++- hooks/picks.ts | 14 ++++++- hooks/register.tsx | 89 ++++++++++++++++++++++++++++++++++++------ tests/pause.test.ts | 94 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 241 insertions(+), 18 deletions(-) create mode 100644 tests/pause.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b46828..aba2d6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased +- **Pause for a session or a project**, without touching your orders file: `/orders pause [replies|effort|model|subagents] [project]` and `/orders resume …`, plus a Pause card on the Settings tab. Before, every off switch for effort, model and subagents rewrote `~/.claude/standing-orders.md`, so it turned them off in every session and project until turned back on. A session pause ends with the session; a project pause is kept per folder in the plugin store. `/orders` lists what is paused, and paused parts say so on their Settings cards. +- `/orders subagents auto|off`: subagents had only a Settings button. +- Effort auto comes back when the orders turn it back on (an edited file, or a resume), unless you took effort over with `/effort`. Before, once off it stayed off until `/orders effort auto`. + ## 0.13.0 - Savings can now prove it. The table reads Saved, Cost, Bottom line, with a verdict that says "Proven" only when its whole 95% range is on one side of zero. - New **Savings audit** (`audit: on`, a button on the Savings tab; off by default): about one turn in five whose effort the mod would set runs at your own effort instead, chosen by a hash of the turn id. The difference in output tokens per request between the two groups is the effort effect, measured, with a 95% range. Without it effort stays an assumed estimate and the verdict says "Not proven". diff --git a/README.md b/README.md index 3f83234..8dfc5b0 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ Sections are bordered cards that light up under the pointer. Motion is calm: a s **Settings** (every click saves to your orders file; each card says which lines of the file it writes) +- **Pause**: turn everything off for this session or this project, and back on, without changing your orders file (see Pause below); - **Effort**: a button cycles auto, each level and off; with auto, buttons step the floor and ceiling or reset them; - **New chats** and **Subagents**: turn auto model and auto subagents on or off; choose which models a new chat may pick from; - **Replies**: how many answers auto mode sends in a row, and your always-ask words (click one to remove it, type to add); @@ -92,10 +93,13 @@ Commands, few on purpose: /orders help the whole mod in plain words /orders init have Claude write this repo's own orders /orders auto|draft send answers yourself, or leave them for your Enter -/orders on|off resume or pause +/orders on|off resume or pause the replies +/orders pause [parts] [project] turn the autopilot off for a while (see Pause) +/orders resume [parts] [project] turn it back on /orders effort auto|off|low|medium|high|xhigh|max auto, off, or a fixed level /orders effort min|max bound what auto may pick /orders model auto|off pick the model for a brand-new chat +/orders subagents auto|off pick a subagent's model and effort /orders setup open the Settings tab /orders savings open the Savings tab /autopilot the pane (/crew is its old name for now) @@ -124,6 +128,19 @@ band: mode, answered, effort, ctx, cache, hint, autopilot A repo's file can come from any clone, so it may only tighten things: its `always-ask` words add to yours, its `max-auto` can only lower yours, and it may set `effort: off` and `cache-ttl`. Every other setting is read from your own file alone. +## Pause + +Every setting in your orders file applies to every session and every project. To turn the autopilot off for a while without editing it: + +``` +/orders pause everything, this session only +/orders pause effort model only those parts (replies, effort, model, subagents) +/orders pause project everything, in this folder, for every session here +/orders resume [parts] [project] undo it +``` + +A session pause ends with the session (a `/clear` starts a new one). A project pause is kept in the plugin's store for that folder (not in any file of the repo) until you resume it. `/orders` lists what is paused, the Settings tab has a Pause card with a button for each, and the paused parts read "paused" on their cards. A pause only turns things off: resuming never undoes a `/effort` or `/model` you typed, and a chat that is already on its picked model stays on it. + ## Effort `effort:` takes `auto`, `off`, or a fixed level (`low`, `medium`, `high`, `xhigh`, `max`). diff --git a/hooks/judges.ts b/hooks/judges.ts index fee1ece..dd95ac9 100644 --- a/hooks/judges.ts +++ b/hooks/judges.ts @@ -231,6 +231,12 @@ When to use what: - At the keyboard ............ leave it on draft - Walking away from a long job /orders auto, then /orders draft when back - Exploring, want every question /orders off (or Pause), /orders on later +- Autopilot off for a while ... /orders pause (everything, this session only; + your orders file is not changed). Name parts to + pause only those: /orders pause effort model. + Add "project" to keep it paused in this folder + for every session: /orders pause project. + /orders resume [parts] [project] undoes it - First time in a repo ........ /orders init (Claude writes the repo's orders) - What is it doing? ........... /autopilot, Now tab (what needs you, what the orders did and picked, context and limits) @@ -275,7 +281,7 @@ Setting /effort yourself turns it off; /orders effort auto turns it back on. Subagents: with "subagents: auto", each helper subagent gets a model (Haiku allowed) and effort picked from its task. A model or effort you or Claude named -for it always wins. +for it always wins. /orders subagents auto|off. Files: - ~/.claude/standing-orders.md: your rules for every repo, plus the settings diff --git a/hooks/orders.ts b/hooks/orders.ts index 1f2f6ae..3b72400 100644 --- a/hooks/orders.ts +++ b/hooks/orders.ts @@ -175,6 +175,22 @@ export type SettingKey = | 'band' export type Settings = Partial> +/** What can be paused for a while without touching the file: the session's or this project's. */ +export const PARTS = ['replies', 'effort', 'model', 'subagents'] as const +export type Part = (typeof PARTS)[number] +export type Scope = 'session' | 'project' + +// A pause only turns things off, so it is laid over the merged orders like a repo's tightening. +export function withPaused(o: Orders, paused: ReadonlySet): Orders { + if (!paused.size) return o + return { + ...o, + ...(paused.has('effort') ? { isEffortAuto: false, effortFixed: null } : {}), + ...(paused.has('model') ? { isModelAuto: false } : {}), + ...(paused.has('subagents') ? { isSubagentsAuto: false } : {}), + } +} + const attempt = async (job: () => Promise): Promise => { try { return await job() @@ -197,6 +213,9 @@ export function createOrders() { let merged = parseOrders(DEFAULT_ORDERS) let own = parseOrders(DEFAULT_ORDERS) let isFirstRun = false + // Pauses: never written to a file. The session's live in memory, the project's in the plugin store (the caller's). + const paused = { session: new Set(), project: new Set() } + const pausedNow = () => new Set([...paused.session, ...paused.project]) // Reads each file once; reloads when asked to or when either differs from the last load. async function refresh(fs: FileStore, force = false) { @@ -220,8 +239,15 @@ export function createOrders() { } return { - /** What the mod obeys: the global file plus what the repo's file may tighten. */ - get: () => merged, + /** What the mod obeys: the global file, what the repo's file may tighten, and what is paused. */ + get: () => withPaused(merged, pausedNow()), + /** What is paused, per scope (replies are only listed here; the caller holds them back). */ + paused: (scope?: Scope) => (scope ? new Set(paused[scope]) : pausedNow()), + /** Pauses (`on`) or resumes parts in one scope. Returns that scope's parts after the change. */ + pause(scope: Scope, parts: readonly Part[], on: boolean) { + for (const p of parts) on ? paused[scope].add(p) : paused[scope].delete(p) + return [...paused[scope]] + }, /** The person's own file alone. */ mine: () => own, /** Whether the repo has an orders file. */ diff --git a/hooks/picks.ts b/hooks/picks.ts index 6cfe6b0..2b57064 100644 --- a/hooks/picks.ts +++ b/hooks/picks.ts @@ -123,6 +123,8 @@ export function createPicks(orders: () => Orders) { // The session's own level as last seen, and the one we last set: a request that matches neither was changed by the person. let lastBase: unknown let lastApplied: unknown + // The person set effort themselves (/effort): auto stays off until they turn it on again, whatever the orders say. + let isTakenOver = false // The effort judge's context: how the agent's last message ended. let lastAnswerTail = '' // model: chosen once, for a chat with no history @@ -196,13 +198,20 @@ export function createPicks(orders: () => Orders) { * isAuto changes in three places only: here, `followOrders` and a request the person changed. */ async setAuto(host: Host, isAuto: boolean) { + isTakenOver = !isAuto await host.show({ isAuto, why: isAuto ? 'auto' : 'yours' }) if (!isAuto) turnEffort = null }, - /** The orders were (re)loaded: if they turn effort off, auto is off. (This one leaves this turn's level standing.) */ + /** + * The orders were (re)loaded or a pause changed: off turns auto off; on turns it back on, + * unless the person took effort over. (Off leaves this turn's level standing.) + */ async followOrders(host: Host) { - if (!orders().isEffortAuto) await host.show({ isAuto: false }) + const isAuto = orders().isEffortAuto + const view = await host.view() + if (!isAuto && view.isAuto) await host.show({ isAuto: false }) + else if (isAuto && !view.isAuto && !isTakenOver) await host.show({ isAuto: true, why: 'auto' }) }, /** The agent's message ended: its tail is the next effort judge's context. */ @@ -271,6 +280,7 @@ export function createPicks(orders: () => Orders) { if (moved && view.isAuto) { turnEffort = null effortJob = null + isTakenOver = true view = await host.show({ isAuto: false, isJudging: false, why: 'yours' }) record.effortTakenOver(host) } diff --git a/hooks/register.tsx b/hooks/register.tsx index 53ed135..f7fc7cb 100644 --- a/hooks/register.tsx +++ b/hooks/register.tsx @@ -18,7 +18,7 @@ import { type Effort, } from './judges' import { checkAge, createChecks, type Host as ChecksHost } from './checks' -import { BAND_ITEMS, createOrders, type BandItem, type FileStore, type Settings } from './orders' +import { BAND_ITEMS, PARTS, createOrders, type BandItem, type FileStore, type Part, type Scope, type Settings } from './orders' import { createPicks, type Host } from './picks' import { IDLE, beforeJudging, decide, drafted, sent, waiting, whenTyped } from './run' import { @@ -68,6 +68,8 @@ const picks = createPicks(() => orders.get()) const needsYou = createChecks() const ctx = { + /** The session's folder: a project pause is kept per folder. */ + cwd: '', turnStartedAt: 0, composerAt: 0, isTicking: false, @@ -201,8 +203,21 @@ const EFFORT_CHOICES = ['auto', 'low', 'medium', 'high', 'xhigh', 'max', 'off'] const effortChoice = () => (!orders.mine().isEffortAuto ? 'off' : (orders.mine().effortFixed ?? 'auto')) async function chooseEffort($: EngineInterface, choice: string) { await writeSetting($, { effort: choice }) - await picks.setAuto(pickHost($), choice !== 'off') + // Off is the file's (followOrders), so editing it back to auto resumes; a choice here also ends a /effort takeover. + if (choice !== 'off') await picks.setAuto(pickHost($), true) } + +// A pause never touches the orders file: the session's is in memory, the project's in the plugin store. +const pausedKey = (cwd: string) => `paused:${cwd}` +async function pauseParts($: EngineInterface, scope: Scope, parts: readonly Part[], on: boolean) { + // Session replies are the mode's own pause (the band's "Replies paused"). + if (scope === 'session' && parts.includes('replies')) await setPaused($, on) + const left = orders.pause(scope, scope === 'session' ? parts.filter(p => p !== 'replies') : parts, on) + if (scope === 'project') await $.store.set(pausedKey(ctx.cwd), left) + await applyOrders($) +} +// Replies are held back by a session pause (the mode) or a project one. +const isRepliesPaused = async ($: EngineInterface) => (await read($, isPaused)) || orders.paused('project').has('replies') // A tab is named only to land on it; a plain open keeps the one the person left. const openPane = async ($: EngineInterface, t?: 'now' | 'settings' | 'savings') => { if (t) await update($, tab, () => t) @@ -215,7 +230,11 @@ const startInit = ($: EngineInterface) => $.clock.after(50, () => void $.prompt.submit({ text: INIT_PROMPT, asUser: true }).catch(() => {})) // Paused, then draft, then auto: one click walks the whole mode. const cycle = async ($: EngineInterface) => { - if (await read($, isPaused)) return setMode($, 'draft') + if (await isRepliesPaused($)) { + // The mode's click also ends a project pause of replies: the band would read paused otherwise. + if (orders.paused('project').has('replies')) await pauseParts($, 'project', ['replies'], false) + return setMode($, 'draft') + } if ((await read($, mode)) === 'draft') return setMode($, 'auto') return setPaused($, true) } @@ -247,7 +266,7 @@ async function wait($: EngineInterface, decision: string) { async function judge($: EngineInterface, answer: string, durationMs: number) { const judgedAt = await $.clock.now() - if (beforeJudging({ isPaused: await read($, isPaused), composerAt: ctx.composerAt, turnStartedAt: ctx.turnStartedAt })) return + if (beforeJudging({ isPaused: await isRepliesPaused($), composerAt: ctx.composerAt, turnStartedAt: ctx.turnStartedAt })) return const tail = answer.slice(-2500) const open = await read($, checks) @@ -339,11 +358,17 @@ export const register: Register = on => { // Commands first: whatever fails below, /orders and /autopilot still exist. await $.command.register({ name: 'orders', - description: 'Standing orders: status, help, setup, init, auto, draft, on, off, effort |model auto|off. Controls live in /autopilot', + description: 'Standing orders: status, help, setup, init, auto, draft, on, off, pause|resume [part] [project], effort |model|subagents auto|off. Controls live in /autopilot', }) await $.command.register({ name: 'autopilot', description: 'What needs you, what the orders did and picked, and the settings' }) await $.command.register({ name: 'crew', description: 'Old name of /autopilot' }) orders.locate({ cwd: e.cwd, globalPath: `${(await $.env.get('HOME')) ?? ''}/.claude/standing-orders.md` }) + ctx.cwd = e.cwd + // This project's pause, before the first prompt can pick anything. A new session's own pause starts empty. + const saved = await $.store.get(pausedKey(e.cwd)).catch(() => undefined) + orders.pause('session', PARTS, false) + orders.pause('project', PARTS, false) + orders.pause('project', Array.isArray(saved) ? saved.filter((p): p is Part => PARTS.includes(p)) : [], true) await reloadOrders($, true) const startedAt = await $.clock.now() await needsYou.load(checkHost($), { cwd: e.cwd, now: startedAt }) @@ -521,6 +546,27 @@ export const register: Register = on => { : 'Auto model off: /model stands.', } } + if (arg === 'subagents') { + if (sub !== 'auto' && sub !== 'off') return { text: 'Usage: /orders subagents auto|off' } + await writeSetting($, { subagents: sub }) + return { text: sub === 'auto' ? 'Auto subagents on: each helper gets a model and effort picked from its task.' : 'Auto subagents off: helpers run as the Agent call says.' } + } + if (arg === 'pause' || arg === 'resume') { + const words = [sub, ...rest].filter(Boolean) + const scope: Scope = words.includes('project') ? 'project' : 'session' + const named = words.filter((w): w is Part => PARTS.includes(w as Part)) + const bad = words.filter(w => !['project', 'session', 'all', ...PARTS].includes(w)) + if (bad.length) return { text: `Usage: /orders ${arg} [${PARTS.join('|')}|all] [project]` } + const parts = named.length ? named : PARTS + const isPause = arg === 'pause' + await pauseParts($, scope, parts, isPause) + const where = scope === 'project' ? `in ${ctx.cwd} (every session here, until /orders resume project)` : 'for this session' + const pinned = isPause && parts.includes('model') ? ' A chat already on its picked model stays on it.' : '' + const still = orders.paused() + return { + text: `${isPause ? 'Paused' : 'Resumed'} ${parts.join(', ')} ${where}. Your orders file is unchanged.${pinned}${!isPause && still.size ? ` Still paused: ${[...still].join(', ')}.` : ''}`, + } + } if (arg === 'auto' || arg === 'draft') { await setMode($, arg) return { @@ -548,13 +594,17 @@ export const register: Register = on => { const now = await $.clock.now() return { text: list.length ? list.map(c => `- ${c.text} (${checkAge(now - c.at)})`).join('\n') : 'No checks waiting.' } } - if (arg !== '') return { text: 'Usage: /orders [help | setup | savings | init | auto | draft | on | off | effort auto|off||min|max | model auto|off]. Details and controls: /autopilot' } + if (arg !== '') return { text: 'Usage: /orders [help | setup | savings | init | auto | draft | on | off | pause|resume [replies|effort|model|subagents|all] [project] | effort auto|off||min|max | model auto|off | subagents auto|off]. Details and controls: /autopilot' } const s = await read($, run) const ev = await read($, effort) return { text: [ - `Standing orders: ${(await read($, isPaused)) ? 'paused' : await read($, mode)}, answered ${s.autoCount} of up to ${orders.get().maxAuto} in a row.`, + `Standing orders: ${(await isRepliesPaused($)) ? 'paused' : await read($, mode)}, answered ${s.autoCount} of up to ${orders.get().maxAuto} in a row.`, `Effort: ${ev.isAuto ? 'auto' : 'yours'}${ev.level ? `, now ${ev.level}` : ''}${ev.isSaving ? ' (capped: usage past 85%)' : ''}.`, + ...(['session', 'project'] as const).flatMap(sc => { + const list = [...orders.paused(sc)] + return list.length ? [`Paused ${sc === 'session' ? 'this session' : 'in this project'}: ${list.join(', ')} (/orders resume${sc === 'project' ? ' project' : ''}).`] : [] + }), ...(s.pending ? [`Needs you: ${s.pending}`] : []), 'Details and controls: /autopilot', ].join('\n'), @@ -566,7 +616,7 @@ export const register: Register = on => { const [s, list, paused, m, ev, v] = await Promise.all([ read($, run), read($, checks), - read($, isPaused), + isRepliesPaused($), read($, mode), read($, effort), read($, vitals), @@ -648,7 +698,7 @@ export const register: Register = on => { const Client = clientOf(ui) const [t, v, s, list, paused, m, ev, entries, tl, isOpen, now, ledger, period] = await Promise.all([ read($, tab), read($, vitals), read($, run), read($, checks), - read($, isPaused), read($, mode), read($, effort), read($, log), read($, counts), read($, isChecksOpen), + isRepliesPaused($), read($, mode), read($, effort), read($, log), read($, counts), read($, isChecksOpen), $.clock.now(), read($, statsLedger), read($, statsPeriod), ]) // The pane body scrolls, so nothing here is squeezed to a height. @@ -894,6 +944,10 @@ export const register: Register = on => { // The person's own file, so a repo's orders are never written back into it. const mine = orders.mine() const choice = effortChoice() + const held = orders.paused() + const pausedIn = (sc: Scope) => [...orders.paused(sc), ...(sc === 'session' && paused && !orders.paused('project').has('replies') ? ['replies'] : [])] + const isAllPaused = (sc: Scope) => PARTS.every(p => pausedIn(sc).includes(p)) + const tag = (part: Part) => (held.has(part) ? ' · paused' : '') const control = (key: string, icon: string, name: string, color: string, value: string, hint: string, buttons: any, extra?: any, note?: string) => card( key, @@ -977,8 +1031,19 @@ export const register: Register = on => { {source('Saved as max-auto: and always-ask: in ~/.claude/standing-orders.md (starter list on first run). A repo file can add words or lower the cap.')} , )} + {control('pause', '❚❚', 'Pause', 'gray', + (['session', 'project'] as const).map(sc => pausedIn(sc).length ? `${sc === 'session' ? 'this session' : 'this project'}: ${pausedIn(sc).join(', ')}` : '').filter(Boolean).join(' · ') || 'nothing paused', + 'Turns replies, effort, model and subagents off for a while without changing your orders file. Per part: /orders pause effort model [project].', + ( + +