Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

CLI: super-tab post reads its text from stdin when TEXT is '-' (#2355)

0xken15de8ed7c23fd2
diff --git a/cli/src/superTabs/command.spec.ts b/cli/src/superTabs/command.spec.ts
index b8e8b1fa5..c7b4b3c67 100644
--- a/cli/src/superTabs/command.spec.ts
+++ b/cli/src/superTabs/command.spec.ts
@@ -39,6 +39,67 @@ it('reads a command\'s JSON from stdin for -', () => {
expect(parseSuperTabArgs([...prefix, 'command', 'op-1', '-'], where, stdin).payload).toMatchObject({ operationId: 'op-1', command: { type: 'work.status', result: "it's '%h %s'" } })
expect(stdin).toHaveBeenCalledOnce()
})
+// 2026-10-30: three Reviewer verdicts posted with TEXT - arrived as a single dash, #2345's findings among them.
+it('reads a post\'s message from stdin for -, once, without its last line break', () => {
+ const stdin = vi.fn(() => "Ready: no\n- P1: it's '%h %s'\n"), terminal = vi.fn(() => false)
+ expect(parseSuperTabArgs([...prefix, 'post', 'lead', '-', 'op-1', '--reply-to', 'm1'], where, stdin, terminal).payload).toMatchObject({ action: 'command',
+ operationId: 'op-1', command: { type: 'message.send', conversationId: 'lead', text: "Ready: no\n- P1: it's '%h %s'", replyTo: 'm1' } })
+ expect(stdin).toHaveBeenCalledOnce()
+ // A message that is only a dash goes on stdin; a CRLF ending is a line break too.
+ expect(parseSuperTabArgs([...prefix, 'post', 'lead', '-', 'op-2'], where, () => '-\r\n', () => false).payload.command).toMatchObject({ text: '-' })
+ expect(parseSuperTabArgs([...prefix, 'post', 'lead', '-', 'op-3', '--attach', 'a.png'], where, () => 'with a file', () => false).payload)
+ .toMatchObject({ attach: [resolve('a.png')], command: { text: 'with a file' } })
+})
+it('refuses a post\'s - with an empty or a terminal stdin, naming the fix, and posts nothing', async () => {
+ for (const empty of ['', '\n', ' \n\n']) {
+ for (const tail of [[], ['--attach', 'a.png']]) {
+ expect(() => parseSuperTabArgs([...prefix, 'post', 'lead', '-', 'op-1', ...tail], where, () => empty, () => false))
+ .toThrow("post - read no message from stdin, so nothing was posted. Send the message on stdin: post GROUP - OPERATION_ID <<'MSG'")
+ }
+ }
+ // A terminal is never read: reading it would wait for input that never comes.
+ const stdin = vi.fn(() => 'never read')
+ expect(() => parseSuperTabArgs([...prefix, 'post', 'lead', '-', 'op-1'], where, stdin, () => true))
+ .toThrow('post - reads the message from stdin, but stdin is a terminal, so nothing was posted.')
+ expect(stdin).not.toHaveBeenCalled()
+ const print = vi.fn(), close = vi.fn(), request = vi.fn(async () => ({ ok: true }))
+ const deps = { where: () => where, pane: undefined, open: async () => ({ request, close, machineId: 'machine' }), print }
+ expect(await superTabCommand([...prefix, 'post', 'lead', '-', 'op'], { ...deps, stdin: () => '', terminal: () => false })).toBe(1)
+ expect(await superTabCommand([...prefix, 'post', 'lead', '-', 'op'], { ...deps, stdin, terminal: () => true })).toBe(1)
+ expect(print.mock.calls.map(([line]) => JSON.parse(line).error)).toEqual([expect.stringContaining('read no message from stdin'), expect.stringContaining('stdin is a terminal')])
+ expect(request).not.toHaveBeenCalled()
+})
+it('never reads stdin for a post whose TEXT is the message', () => {
+ const stdin = vi.fn(() => 'from stdin'), terminal = vi.fn(() => false)
+ for (const text of ['Ready', '--', '- ', ' -', '-x', '']) {
+ const tail = text ? [] : ['--attach', 'a.png']
+ expect(parseSuperTabArgs([...prefix, 'post', 'lead', text, 'op-1', ...tail], where, stdin, terminal).payload.command).toMatchObject({ text })
+ }
+ expect(stdin).not.toHaveBeenCalled()
+ expect(terminal).not.toHaveBeenCalled()
+})
+// An interrupted post is repeated with the same id and the same stdin; stdin is read before anything is sent, so the repeat
+// sends the same message under the same id, and the Swarm keeps one.
+it('repeats an interrupted stdin post with the same id and text, and it posts once', async () => {
+ const posted = new Map<string, unknown>(), print = vi.fn(), close = vi.fn()
+ let lose = true
+ const request = vi.fn(async (type: string, payload: Record<string, unknown> = {}) => {
+ if (type !== 'super_tabs') return { agents: [] }
+ posted.set(String(payload.operationId), (payload.command as { text?: string }).text)
+ if (lose) { lose = false; throw new Error('Connection lost') }
+ return { ok: true }
+ })
+ const deps = { where: () => where, pane: undefined, open: async () => ({ request, close, machineId: 'machine' }), print, terminal: () => false }
+ const stdin = vi.fn(() => "Verdict: it's fine\n")
+ expect(await superTabCommand([...prefix, 'post', 'lead', '-', 'op-verdict'], { ...deps, stdin })).toBe(1)
+ expect(JSON.parse(print.mock.calls.at(-1)![0])).toEqual({ error: 'Connection lost', operationId: 'op-verdict' })
+ expect(await superTabCommand([...prefix, 'post', 'lead', '-', 'op-verdict'], { ...deps, stdin })).toBe(0)
+ expect(stdin).toHaveBeenCalledTimes(2)
+ const sent = request.mock.calls.filter(([type]) => type === 'super_tabs').map(([, payload]) => payload)
+ expect(sent).toHaveLength(2)
+ expect(sent[1]).toEqual(sent[0])
+ expect([...posted]).toEqual([['op-verdict', "Verdict: it's fine"]])
+})
it('reacts to a message as people do, and --off takes the reaction back', () => {
expect(parseSuperTabArgs([...prefix, 'react', 'lead', 'msg-1', 'eyes', 'op-1'], where).payload).toEqual({ action: 'command', tabId: 'tab', agentId: 'agent',
operationId: 'op-1', command: { type: 'message.react', conversationId: 'lead', messageId: 'msg-1', emoji: 'eyes', on: true } })
diff --git a/cli/src/superTabs/command.ts b/cli/src/superTabs/command.ts
index f9c240c03..78fea165f 100644
--- a/cli/src/superTabs/command.ts
+++ b/cli/src/superTabs/command.ts
@@ -10,6 +10,7 @@ import { readInsideFolder, uploadAttachments, type UploadTarget } from './attach
import { keyName } from './terminal.js'
import { randomUUID } from 'node:crypto'
import { readFileSync } from 'node:fs'
+import { isatty } from 'node:tty'
import { inDaemonPane, NOT_IN_PANE, runningPane, type PaneProbe } from './callerPane.js'
// cli.ts's way to it: this file is its door to the Swarm's code (architecture.spec.ts SWARM_DOORS).
export { buddyRefusal } from './buddyPane.js'
@@ -27,7 +28,7 @@ function harnessIn(frames: PaneFrame[], pane: string, machineId: string): boolea
const ELSEWHERE = 'From a harness, Swarm commands go to this computer\'s own Harness only: leave out --machine and --port, or give this computer\'s own.'
-const USAGE = 'harness super-tab --tab ID [--agent ID] [--port N --machine ID] status [--archived [PAGE]] | messages GROUP [--before SEQUENCE MESSAGE_ID] | message GROUP MESSAGE_ID | decisions [--answered] | costs [--days N] | post GROUP TEXT OPERATION_ID [--reply-to MESSAGE_ID] [--attach PATH]... [--mention PERSON]... | react GROUP MESSAGE_ID EMOJI OPERATION_ID [--off] | command OPERATION_ID JSON | propose OPERATION_ID JSON [--attach PATH]... | start OPERATION_ID JSON | resume START_ID | capacity MACHINE_ID JSON | route GROUP JSON | plan [JSON] | remove-machine MACHINE_ID [--yes] | set-agents MACHINE_ID COUNT | screen AGENT [--scrollback N] | type AGENT [TEXT] [--key K]... | help'
+const USAGE = 'harness super-tab --tab ID [--agent ID] [--port N --machine ID] status [--archived [PAGE]] | messages GROUP [--before SEQUENCE MESSAGE_ID] | message GROUP MESSAGE_ID | decisions [--answered] | costs [--days N] | post GROUP TEXT|- OPERATION_ID [--reply-to MESSAGE_ID] [--attach PATH]... [--mention PERSON]... | react GROUP MESSAGE_ID EMOJI OPERATION_ID [--off] | command OPERATION_ID JSON | propose OPERATION_ID JSON [--attach PATH]... | start OPERATION_ID JSON | resume START_ID | capacity MACHINE_ID JSON | route GROUP JSON | plan [JSON] | remove-machine MACHINE_ID [--yes] | set-agents MACHINE_ID COUNT | screen AGENT [--scrollback N] | type AGENT [TEXT] [--key K]... | help'
/** The actions that take an id and then one JSON argument, and what that id names. */
const JSON_ACTIONS: Readonly<Record<string, string>> = { command: 'OPERATION_ID', propose: 'OPERATION_ID', start: 'OPERATION_ID', capacity: 'MACHINE_ID', route: 'GROUP' }
const stdinHint = (action: string) => `or send the JSON on stdin with - in its place: ${action} ${JSON_ACTIONS[action]} - <<'JSON' (the JSON on the next lines, then JSON alone on a line)`
@@ -62,9 +63,23 @@ function jsonShapeError(positional: readonly string[]): string | null {
return null
}
+/** A message on stdin, for post's TEXT `-`.
+ *
+ * `post GROUP - OPERATION_ID` posted a literal dash: three Reviewer verdicts on 2026-10-30, #2345's findings among them,
+ * arrived as "-". So `-` reads the message from stdin, once, before anything is sent, and an empty or a terminal stdin is
+ * refused: nothing is posted, and nothing waits on a terminal for input that never comes. */
+const POST_STDIN = "post GROUP - OPERATION_ID <<'MSG' (the message on the next lines, then MSG alone on a line)"
+function postStdin(stdin: () => string, terminal: () => boolean): string {
+ if (terminal()) throw new Error(`post - reads the message from stdin, but stdin is a terminal, so nothing was posted. Send the message on stdin: ${POST_STDIN}, or pass it as TEXT.`)
+ // A heredoc ends the message with one line break, which is not part of it.
+ const text = stdin().replace(/\r?\n$/, '')
+ if (!text.trim()) throw new Error(`post - read no message from stdin, so nothing was posted. Send the message on stdin: ${POST_STDIN}. A message that is only - goes on stdin too.`)
+ return text
+}
/** The files one proposal may carry (backend buddies.ts MAX_PROPOSAL_ATTACHMENTS). */
const MAX_PROPOSAL_FILES = 5
-export function parseSuperTabArgs(argv: readonly string[], where: Where, stdin: () => string = () => readFileSync(0, 'utf8')) {
+export function parseSuperTabArgs(argv: readonly string[], where: Where, stdin: () => string = () => readFileSync(0, 'utf8'),
+ terminal: () => boolean = () => isatty(0)) {
const positional: string[] = []
let tabId = '', agentId = ''
const target = { ...where }
@@ -111,10 +126,12 @@ export function parseSuperTabArgs(argv: readonly string[], where: Where, stdin:
else if (flag === '--mention' && value?.trim()) mentions.push(value.trim())
else throw new Error(USAGE)
}
+ // TEXT `-` is the message on stdin; any other TEXT is the message itself, and stdin is never read.
+ const text = second === '-' ? postStdin(stdin, terminal) : second
// A screenshot or a log may go without words.
- if (!second.trim() && !attach.length) throw new Error(USAGE)
+ if (!text.trim() && !attach.length) throw new Error(USAGE)
Object.assign(payload, { action: 'command', operationId: third, ...(attach.length ? { attach } : {}),
- command: { type: 'message.send', conversationId: first, text: second, replyTo, recipientIds: [], ...(mentions.length ? { mentions } : {}) } })
+ command: { type: 'message.send', conversationId: first, text, replyTo, recipientIds: [], ...(mentions.length ? { mentions } : {}) } })
} else if (action === 'react' && identifier(first) && identifier(second) && identifier(third) && identifier(positional[4])
&& (positional.length === 5 || positional.length === 6 && positional[5] === '--off')) {
// An acknowledgement without a post, as Slack bots do (swarm skills): the backend checks the emoji and who may react.
@@ -177,7 +194,7 @@ export function parseSuperTabArgs(argv: readonly string[], where: Where, stdin:
export async function superTabCommand(argv: readonly string[], deps: {
where?: () => Where; open?: typeof openDaemon; print?: (text: string) => void; pane?: string; probe?: PaneProbe; fetch?: typeof fetch; env?: NodeJS.ProcessEnv
- platform?: NodeJS.Platform
+ platform?: NodeJS.Platform; stdin?: () => string; terminal?: () => boolean
} = {}): Promise<number> {
let daemon: Daemon | null = null
let operationId: unknown
@@ -189,7 +206,7 @@ export async function superTabCommand(argv: readonly string[], deps: {
if (running.refused) throw new Error(running.refused)
const pane = running.pane
const local = (deps.where ?? (() => whereFor(pane)))()
- const request = parseSuperTabArgs(argv, local)
+ const request = parseSuperTabArgs(argv, local, deps.stdin, deps.terminal)
operationId = request.payload.operationId
// A harness reaches the Swarm through this computer's Harness alone (second review of #2087: a Buddy's --machine reached
// the owner's other Mac, which knew no pane there). The daemon refuses an agent's request from another computer as well.
diff --git a/cli/src/superTabs/service.spec.ts b/cli/src/superTabs/service.spec.ts
index 7ea9451ce..4405353bd 100644
--- a/cli/src/superTabs/service.spec.ts
+++ b/cli/src/superTabs/service.spec.ts
@@ -1158,7 +1158,9 @@ describe('mentions on a post', () => {
const t = setup()
swarm(t, t.agentId)
const lead = await help(t, { tabId: 'tab', agentId: t.agentId })
- expect(lead.post).toContain(`post GROUP TEXT OPERATION_ID [--reply-to MESSAGE_ID] [--attach PATH]... ${mention}:`)
+ expect(lead.post).toContain(`post GROUP TEXT|- OPERATION_ID [--reply-to MESSAGE_ID] [--attach PATH]... ${mention}:`)
+ // 2026-10-30: TEXT - posted a literal dash; help says - reads the message from stdin (command.ts postStdin).
+ expect(lead.post).toContain("when it holds quotes, or is only -, put - in its place and send the message on stdin (post GROUP - OPERATION_ID <<'MSG' … MSG); an empty stdin is refused and nothing is posted.")
expect(lead.post).toContain('--mention tags a person, by the id or email shown in status (up to 5), when you need them to act or decide; it shows in their notifications.')
// The server reads tags from the text too (backend mentions.ts).
expect(lead.post).toContain('An @username or @email in TEXT tags that person as well, outside code and links.')
diff --git a/cli/src/superTabs/service.ts b/cli/src/superTabs/service.ts
index 7e2dc20f5..abd30f383 100644
--- a/cli/src/superTabs/service.ts
+++ b/cli/src/superTabs/service.ts
@@ -37,7 +37,7 @@ import { createPullRequestsStatusReader } from '../lib/pullRequestsStatus.js'
import { buddyArchived, buddyStatus, isBuddyIn, type BuddyStatusDeps } from './buddyStatus.js'
import { startSubscriptionRelay } from '../lib/subscriptionRelay.js'
-const POST_HELP = 'reply in that conversation. Use a unique ID per message and reuse it after an interrupted request. Answer a message once, with --reply-to its ID. --attach sends a file (a screenshot, a log; up to 10 files of 10 MB each), and TEXT may then be empty.'
+const POST_HELP = 'reply in that conversation. Use a unique ID per message and reuse it after an interrupted request. Answer a message once, with --reply-to its ID. --attach sends a file (a screenshot, a log; up to 10 files of 10 MB each), and TEXT may then be empty. TEXT is one argument: when it holds quotes, or is only -, put - in its place and send the message on stdin (post GROUP - OPERATION_ID <<\'MSG\' … MSG); an empty stdin is refused and nothing is posted.'
/** Done or Stopped from an agent finishing its own work carries its session's token totals by model, read from its transcript
* now (core `usageFresh`): its attempt ends with every token it used, not a machine report up to a beat old (backend
* superTabs/costs/attempts.ts endRun; review of #2106). Counts only. No reading, and the status goes without them. */
@@ -56,7 +56,7 @@ const HELP = {
message: 'message GROUP MESSAGE_ID: read one exact message, including an earlier question or result referenced by a reply.',
decisions: 'decisions [--answered]: the decisions you asked of people, still open, or with --answered those answered (each with its choice and note). A Lead also sees those asked in its project. When your work needs a person to decide, ask through work.status needs_human with ask: the question as its result, 2 to 5 options, the one you recommend and what the answer unblocks. Keep working on your recommendation, marked provisional, until a notice in that conversation says it was answered; then read the answer here with --answered. The notice carries none of the answer. A decision is not a private channel: to tell one person something directly, a Lead sends person.tell; it lands in their Buddy chat, which the Lead cannot read. Project members watching the Lead\'s terminal see what it sends: put nothing there you would not say in the project chat.',
costs: 'costs [--days N]: what the attempts routed in the last N days (7 unless set, at most 90) cost and how they went, per engine, model, effort and kind of job: attempts, first-review pass rate, shipped, median minutes to ship, tokens, API-equivalent cost and actual per-token spend in US dollars, and cost per shipped change, with the prices and their sources; models has the same per engine and model alone (a grid model by its own name), and stepUps counts the attempts that stepped up from a cheaper model. Only attempts routed since cost records began, in the groups you may read.',
- post: `post GROUP TEXT OPERATION_ID [--reply-to MESSAGE_ID] [--attach PATH]...: ${POST_HELP}`,
+ post: `post GROUP TEXT|- OPERATION_ID [--reply-to MESSAGE_ID] [--attach PATH]...: ${POST_HELP}`,
// Acknowledgements as reactions, as Slack bots do (swarm skills); backend reactions.ts holds the emoji and the rules.
react: 'react GROUP MESSAGE_ID EMOJI OPERATION_ID [--off]: react to a message you can read in a conversation you take part in, as people do, instead of posting an acknowledgement: eyes (👀) when you start on a message addressed to you, check (✅) when you have done what it asked, rocket (🚀) when its work merged; also thumbs_up, tada, heart and laugh. --off takes yours back. A reaction wakes nobody.',
start: 'start OPERATION_ID JSON: create one agent in a conversation on a machine in this Swarm\'s Machines list; to use another machine, a person adds it to the Swarm first. Repeat exactly after an interruption; it follows the same native creation receipt. It does not assign work. With worktree true, the agent starts from the repository\'s default branch, fetched first, unless you set branchRef (refs/heads/BRANCH, or refs/remotes/origin/BRANCH to fetch it first) to start from another branch, such as the one this work builds on. Set role "reviewer" to start a Reviewer; leave role out for a Builder. The role is kept for the session. On Custom skills, add "roleId" to the start request to start the agent in that role of its kind (a builder or reviewer role from status); without it the agent takes the first role of its kind. A Reviewer runs on claude or codex and is assigned only review groups (conversation.create with reviewOf naming the group it reviews); a review group is assigned only to a Reviewer. Add the Reviewer to the reviewed group with conversation.agent so it is told when that work is ready for review and can pass its independent check. Start one with a routeDecisionId like any agent.',
@@ -115,7 +115,7 @@ const list = (value: unknown) => Array.isArray(value) ? value.map(object) : []
const answerOf = (read: SwarmRead) => ({ lastChangedAt: read.lastChangedAt, state: read.state, ...(read.githubApp ? { githubApp: true } : {}) })
const OFF_ROSTER = 'This agent is not on this machine\'s Swarm roster right now. That can mean this machine has no access to it, or its billing does not allow it. Check how this machine is shared.'
/** Only a project's Lead may tag people (spec 2026-10-24-lead-mentions), so only a Lead's help offers it. */
-const LEAD_HELP = { ...HELP, post: `post GROUP TEXT OPERATION_ID [--reply-to MESSAGE_ID] [--attach PATH]... [--mention PERSON]...: ${POST_HELP} --mention tags a person, by the id or email shown in status (up to 5), when you need them to act or decide; it shows in their notifications. An @username or @email in TEXT tags that person as well, outside code and links.`,
+const LEAD_HELP = { ...HELP, post: `post GROUP TEXT|- OPERATION_ID [--reply-to MESSAGE_ID] [--attach PATH]... [--mention PERSON]...: ${POST_HELP} --mention tags a person, by the id or email shown in status (up to 5), when you need them to act or decide; it shows in their notifications. An @username or @email in TEXT tags that person as well, outside code and links.`,
// Advisory (docs/plans/2026-10-27-swarm-scheduler.md): a plan for every open group at once, which the route still decides.
plan: 'plan [JSON]: the best plan for all your open groups at once, from the scheduler on this machine (Python 3 and OR-Tools; without them it says how to install, and routing works as before). Per group: the machine, engine, model and effort, start order and expected finish, with the finish time and cost against routing one group at a time. JSON (optional): {"groups":{"GROUP":{"difficulty":"low|medium|high","risk":"low|medium|high","size":"small|medium|large","kind":"optional word","after":["GROUP"]}}}; a group you do not assess is planned at medium and listed as an estimate. It keeps the owner\'s hard rules and a review\'s other model family, and records nothing: follow it in order by routing each group and starting the plan\'s pick with overrideReason "scheduler plan".',
// Only a project's Lead asks a batch: up to 10 questions for one person, in one of its project's conversations.