From 1eeb0891e3abed837fd31b503ef00152f60e4aab Mon Sep 17 00:00:00 2001 From: Benjamin Carrasco Date: Sat, 5 Dec 2026 18:24:20 +0100 Subject: [PATCH 1/5] feat(orchestrator): one goal from brief to merged through lanes (#323) --- README.md | 9 ++ plugins/bstack/scripts/lane.mjs | 91 +++++++++++++++++++ plugins/bstack/skills/mode/SKILL.md | 3 +- .../skills/mode/playbooks/autonomous-run.md | 2 +- plugins/bstack/skills/orchestrator/SKILL.md | 52 +++++++++++ .../orchestrator/lane-result.schema.json | 24 +++++ tests/lane.test.mjs | 78 ++++++++++++++++ 7 files changed, 257 insertions(+), 2 deletions(-) create mode 100644 plugins/bstack/scripts/lane.mjs create mode 100644 plugins/bstack/skills/orchestrator/SKILL.md create mode 100644 plugins/bstack/skills/orchestrator/lane-result.schema.json create mode 100644 tests/lane.test.mjs diff --git a/README.md b/README.md index 0c749c1..b2f46fe 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Requirements: Node 18+ on `PATH` (the hooks are Node scripts), git, and the GitH | Session rules (`rules/`) | Injected at every session and subagent start by a hook, so they hold without anyone loading a skill. | | `bstack:mode` | Router: goal, smallest change, playbook and risk tier. Playbooks: investigate, bug-fix, feature, refactor, migration, ticket, ship, autonomous-run. | | `bstack:plan` | Sizes the work, grills you where intent is unclear, and writes a spec with ticket sub-issues, or a map of decision tickets for foggy work. Keeps `GLOSSARY.md` and ADRs. | +| `bstack:orchestrator` | One T3 Code thread for all repos: takes a goal, starts one lane (a child thread in its own worktree) per ticket on the model `scripts/model.mjs lane` names, answers the lanes' technical questions and asks you only what is yours to decide. See [Orchestrator](#orchestrator). | | `bstack:triage` | Sorts incoming issues: checks the claim, finds duplicates and work already done, writes acceptance criteria, labels the state. | | `bstack:audit` | Review and clean up a whole repo: map, find, prove, present once, fix through small gated PRs. | | `bstack:vibecoding` | Prototype an idea fast when you ask for it: no plan, tests, PR or review before it runs. Then discard it, or harden it into a ticket that ships through the full gate. | @@ -53,6 +54,14 @@ idea or bug report -> bstack:triage or bstack:plan -> tickets (issues) -> ticket - Issues are kept by the agent, never by hand. Specs are temporary: once merged, the code and tests are the truth. - `scripts/tracker.mjs labels` creates the labels a repo lacks and changes nothing else. It needs `gh` 2.94 or newer. +## Orchestrator + +Start a new thread in T3 Code, in any project, on your usual model at medium effort, and write `/bstack:orchestrator` followed by the goal, for example `/bstack:orchestrator byg #42 i owner/repo`. Leave the thread open; T3 wakes it when a lane finishes or asks. + +- Each ticket becomes a lane: a child thread started with `delegate_task` in a worktree from the default branch, with a brief of Goal, Done when, Constraints and Result form (`scripts/lane.mjs brief`). The lane is a full bstack session: it builds, starts its own judge and merges. +- A lane answers with JSON that matches `skills/orchestrator/lane-result.schema.json` (`scripts/lane.mjs result` checks it). The orchestrator reads no diff, log or transcript. +- It answers technical questions itself and records them on the ticket. Questions on the stop list, and about goal, scope or priority, come to you together, each with a recommended answer, while the other lanes go on. + ## What the hooks enforce The guard runs before every `Bash` and `PowerShell` command (Windows routes shell commands through PowerShell, so a Bash-only hook would never fire there), every file write and every MCP tool call. It fails closed. diff --git a/plugins/bstack/scripts/lane.mjs b/plugins/bstack/scripts/lane.mjs new file mode 100644 index 0000000..073ce7d --- /dev/null +++ b/plugins/bstack/scripts/lane.mjs @@ -0,0 +1,91 @@ +#!/usr/bin/env node +// The two ends of a lane the orchestrator starts (#323): the brief it sends, and the result it reads back. +// lane.mjs brief < {"goal", "done", "constraints": [...]} or {"goal", "done", "open": true} +// lane.mjs result < the lane's last message +// `result` prints the lane result as compact JSON when it matches lane-result.schema.json, else exits 1 +// with what did not fit. +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { isMain } from './lib/is-main.mjs'; + +const USAGE = 'usage: lane.mjs brief|result < input'; +export const SCHEMA_FILE = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'skills', 'orchestrator', 'lane-result.schema.json'); +export const SCHEMA = JSON.parse(fs.readFileSync(SCHEMA_FILE, 'utf8')); + +const STEP_LINE = /^\s*(\d+[.)]|step\b)/im; + +export function brief({ goal, done, constraints = [], open = false }) { + const parts = { Goal: goal, 'Done when': done }; + const missing = Object.entries(parts).filter(([, v]) => typeof v !== 'string' || !v.trim()).map(([k]) => k); + if (missing.length) throw new Error(`brief needs ${missing.join(' and ')}`); + if (!Array.isArray(constraints) || constraints.some(c => typeof c !== 'string')) throw new Error('constraints must be a list of strings'); + const texts = [goal, done, ...constraints]; + if (texts.some(t => STEP_LINE.test(t))) throw new Error('a brief says what, never how: no numbered steps'); + const lines = [`Goal: ${goal.trim()}`, '', `Done when: ${done.trim()}`]; + if (open) return `${lines.join('\n')}\n`; + if (constraints.length) lines.push('', 'Constraints:', ...constraints.map(c => `- ${c.trim()}`)); + lines.push('', 'Result form: your last message is only one JSON object that matches this schema, nothing around it.', + JSON.stringify(SCHEMA.properties), `Required: ${SCHEMA.required.join(', ')}.`); + return `${lines.join('\n')}\n`; +} + +const typeOf = v => (v === null ? 'null' : Array.isArray(v) ? 'array' : Number.isInteger(v) ? 'integer' : typeof v); + +export function check(value, schema = SCHEMA, at = 'result') { + const errors = []; + const types = [schema.type ?? []].flat(); + if (types.length && !types.includes(typeOf(value))) return [`${at}: is ${typeOf(value)}, wants ${types.join(' or ')}`]; + if (schema.enum && !schema.enum.includes(value)) errors.push(`${at}: ${JSON.stringify(value)} is not one of ${schema.enum.join(', ')}`); + if (typeOf(value) === 'object') { + for (const key of schema.required ?? []) if (!(key in value)) errors.push(`${at}: missing ${key}`); + for (const [key, v] of Object.entries(value)) { + const sub = schema.properties?.[key]; + if (sub) errors.push(...check(v, sub, `${at}.${key}`)); + else if (schema.additionalProperties === false) errors.push(`${at}: unknown field ${key}`); + } + } + if (typeOf(value) === 'array' && schema.items) value.forEach((v, i) => errors.push(...check(v, schema.items, `${at}[${i}]`))); + return errors; +} + +function lastObject(text) { + const trimmed = text.trim(); + const fenced = [...trimmed.matchAll(/```(?:json)?\s*\n([\s\S]*?)\n```/g)].map(m => m[1]); + const candidates = [trimmed, ...fenced.reverse()]; + for (let i = trimmed.length; i > 0;) { + i = trimmed.lastIndexOf('{', i - 1); + if (i < 0) break; + candidates.push(trimmed.slice(i)); + } + for (const c of candidates) { + try { return JSON.parse(c); } catch {} + } + throw new Error('no JSON object in the lane message'); +} + +export function result(text) { + const value = lastObject(text); + const errors = check(value); + if (errors.length) throw new Error(errors.join('\n')); + return JSON.stringify(value); +} + +const MODES = { + brief: input => brief(JSON.parse(input)), + result: input => `${result(input)}\n`, +}; + +if (isMain(import.meta.url)) { + const mode = MODES[process.argv[2]]; + if (!mode) { + process.stderr.write(`${USAGE}\n`); + process.exit(2); + } + try { + process.stdout.write(mode(fs.readFileSync(0, 'utf8'))); + } catch (e) { + process.stderr.write(`${e.message}\n`); + process.exit(1); + } +} diff --git a/plugins/bstack/skills/mode/SKILL.md b/plugins/bstack/skills/mode/SKILL.md index 21e81a4..c8f933d 100644 --- a/plugins/bstack/skills/mode/SKILL.md +++ b/plugins/bstack/skills/mode/SKILL.md @@ -25,7 +25,8 @@ Three lines, then start: | An issue to build, or "the next ticket" | [ticket](playbooks/ticket.md) | | A prototype or POC the user asked for | the `bstack:vibecoding` skill | | A branch exists and must land | [ship](playbooks/ship.md) | -| "Keep going until X", or a run without the user | [autonomous-run](playbooks/autonomous-run.md) | +| A goal to run without the user in T3 Code (its delegate tools are loaded), or work across repos | the `bstack:orchestrator` skill; a lane it started (a brief with a Result form) is a ticket | +| "Keep going until X", or a run without the user outside T3 Code | [autonomous-run](playbooks/autonomous-run.md) | | Review or clean up a whole repo | the `bstack:audit` skill | | Incoming issues to sort | the `bstack:triage` skill | diff --git a/plugins/bstack/skills/mode/playbooks/autonomous-run.md b/plugins/bstack/skills/mode/playbooks/autonomous-run.md index 73d934d..5dc7e50 100644 --- a/plugins/bstack/skills/mode/playbooks/autonomous-run.md +++ b/plugins/bstack/skills/mode/playbooks/autonomous-run.md @@ -1,6 +1,6 @@ # Autonomous run -For "keep going until X", background sessions and runs nobody watches. +For "keep going until X", background sessions and runs nobody watches. In T3 Code, where the delegate tools are loaded, a goal runs through the `bstack:orchestrator` skill instead. **Goal:** a stop condition written as a checkable predicate, not a duration, and stated in the first reply: "every finding in the audit list has a merged PR or a stated reason", "every ticket under the spec is closed, or handed to the user as `ready-for-human`". **Done when** it holds on main. diff --git a/plugins/bstack/skills/orchestrator/SKILL.md b/plugins/bstack/skills/orchestrator/SKILL.md new file mode 100644 index 0000000..7271d3b --- /dev/null +++ b/plugins/bstack/skills/orchestrator/SKILL.md @@ -0,0 +1,52 @@ +--- +name: orchestrator +description: Run a goal from brief to merged through lanes, child threads in T3 Code, one per ticket, across any repo, and come back to the owner only for strategic questions. Holds ticket and PR numbers and states, never code. Use for "orkestrér", "kør det her", "run this across repos", "orchestrate", or a run without the user in T3 Code. +--- + +# Orchestrator + +**Goal:** the owner gives a goal; every ticket under it ends merged, capped or with a question for the owner, and the owner is asked only what is theirs to decide. Any thread that loads this skill is the orchestrator. It keeps no memory: GitHub and the T3 thread list hold the state, so its context can be thrown away at any time. + +**Done when** every lane's ticket reads back closed and its PR merged (`gh issue view -R --json state`, `gh pr view -R --json state,mergedAt`), or the owner has the open questions. + +Reading code, diffs, logs or a lane's transcript, and fixing anything, is the lane's work. Read a lane's thread only when it is stuck: it failed without a result, or its result does not parse. + +## Size the goal + +As `bstack:plan` sizes it: one ticket; a spec with tickets; or questions to the owner when the intent is unclear. Planning is a lane of its own (`bstack:plan` in that repo) when it needs a grilling or research; the orchestrator does not write specs itself. A ticket labelled `ready-for-human` or `plan:*` is not a build lane. + +## Start a lane + +One lane per ticket, in the ticket's repo, in its own worktree. +1. Model: `node "${CLAUDE_PLUGIN_ROOT}/scripts/model.mjs" lane build -R ` prints `{ model, effort }` (`research` or `mechanical` for those kinds; `--failed ` after failed lanes). Map the family to the provider's model id from `orchestrator_capabilities`; `session` means the orchestrator's own model. +2. Brief: `node "${CLAUDE_PLUGIN_ROOT}/scripts/lane.mjs" brief` with `{ "goal", "done", "constraints": [...] }` on stdin. It prints Goal, Done when, Constraints and Result form, in English; it refuses numbered steps, because a brief says what, never how. An open task (research, a question) gets `{ "goal", "done", "open": true }`: a goal and a done-when only. +3. `delegate_task` with that brief as `task`, `isolation: "worktree"`, `mode: "async"`, a `title` of `# `, and `target`: the repo's `projectId` (from `t3_project_list`), a Claude `providerInstanceId` that `canRunChildTask` and is not at its limit, `model`, and `options: { "effort": ... }`. + +Constraints every build brief carries: +- Build issue in through the bstack ticket and ship playbooks; a `bstack:judge` you start judges. +- Done means the PR that says `Closes #` is squash-merged with green checks and a verdict for its head, read back as merged, the issue is closed, and the branch and worktree are removed. +- Start from the default branch on origin. +- No deploys. A question on the stop list of the session rules: do not ask anyone; stop and report it in `questions` with state `needs_owner`. +- Three rounds with blocking findings: stop with state `capped`. +- Plus whatever the owner or the spec fixed for this ticket. + +Then end the turn. T3 wakes the orchestrator when a lane finishes or asks; never poll (`task_status` on a running lane, sleeps, watchers). + +## When a lane wakes it + +Pipe the lane's last message to `node "${CLAUDE_PLUGIN_ROOT}/scripts/lane.mjs" result`. It prints the result as JSON matching [lane-result.schema.json](lane-result.schema.json), or what did not fit. A result that does not fit goes back to the lane with `t3_thread_send` and `outputSchema` set to the schema file; that is not reading its work. + +- `merged`: read the issue and PR states back from GitHub, then report. +- `needs_owner` or `blocked` with `questions`, or a pending question in the lane (`t3_pending_request list` on its thread): sort each question. + - **Technical** (how to build, which tool, a test approach, a reversible choice): answer it yourself, send the answer to the lane's thread with `t3_thread_send`, and record it on the ticket in one comment (`gh issue comment`: the question, the answer, why). + - **The owner's**: on the stop list of the session rules, or about goal, scope, priority or a product choice no experiment can settle. Collect it; the other lanes go on. +- `capped`: report it with its open findings; what to do at the cap is the owner's until its own ticket says otherwise. +- A lane that failed on the account limit (`Claude API rate limit reached`): start it again on another account from its pushed branch, or report it. + +Before ending a turn with owner questions, ask them all at once, each with your recommended answer. Send the answers to the lanes that asked, and record each on its ticket. + +## To the owner + +Danish, at the `ultra` level of `bstack:style`: per lane, the ticket, the state and the PR, as links. Warnings and questions to the owner are full sentences: what is at stake, the options, your pick and why. + +The orchestrator itself runs on the owner's model at medium effort. diff --git a/plugins/bstack/skills/orchestrator/lane-result.schema.json b/plugins/bstack/skills/orchestrator/lane-result.schema.json new file mode 100644 index 0000000..a7330de --- /dev/null +++ b/plugins/bstack/skills/orchestrator/lane-result.schema.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "bstack lane result", + "type": "object", + "additionalProperties": false, + "required": ["ticket", "pr", "state", "head", "open_findings", "questions", "decisions"], + "properties": { + "ticket": { "type": "integer" }, + "pr": { "type": ["integer", "null"] }, + "state": { "enum": ["merged", "capped", "blocked", "needs_owner"] }, + "head": { "type": ["string", "null"] }, + "open_findings": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "required": ["id", "title"], + "properties": { "id": { "type": "string" }, "title": { "type": "string" } } + } + }, + "questions": { "type": "array", "items": { "type": "string" } }, + "decisions": { "type": "array", "items": { "type": "string" } } + } +} diff --git a/tests/lane.test.mjs b/tests/lane.test.mjs new file mode 100644 index 0000000..b43cb41 --- /dev/null +++ b/tests/lane.test.mjs @@ -0,0 +1,78 @@ +// #323: the orchestrator sends a lane a brief of four parts and reads its result back as data that +// matches one schema file in the plugin. +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { spawnSync } from 'node:child_process'; +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { SCHEMA, SCHEMA_FILE, brief, check, result } from '../plugins/bstack/scripts/lane.mjs'; + +const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const SCRIPT = path.join(ROOT, 'plugins', 'bstack', 'scripts', 'lane.mjs'); +const run = (mode, input) => spawnSync(process.execPath, [SCRIPT, mode], { input, encoding: 'utf8' }); + +const MERGED = { ticket: 7, pr: 9, state: 'merged', head: 'a'.repeat(40), open_findings: [], questions: [], decisions: ['kept the old flag: callers read it'] }; +const BUILD = { goal: 'Build issue #7 in o/r.', done: 'The PR that says Closes #7 is merged.', constraints: ['No deploys.', 'Three rounds with blocking findings: stop with state capped.'] }; + +test('the schema file holds the lane result contract of the spec', () => { + assert.deepEqual(SCHEMA.required, ['ticket', 'pr', 'state', 'head', 'open_findings', 'questions', 'decisions']); + assert.deepEqual(SCHEMA.properties.state.enum, ['merged', 'capped', 'blocked', 'needs_owner']); + assert.deepEqual(SCHEMA.properties.open_findings.items.required, ['id', 'title']); + assert.equal(SCHEMA_FILE, path.join(ROOT, 'plugins', 'bstack', 'skills', 'orchestrator', 'lane-result.schema.json')); +}); + +test('a build brief has Goal, Done when, Constraints and Result form, in that order', () => { + const text = brief(BUILD); + const heads = text.split('\n').map(l => /^(Goal|Done when|Constraints|Result form):/.exec(l)?.[1]).filter(Boolean); + assert.deepEqual(heads, ['Goal', 'Done when', 'Constraints', 'Result form']); + assert.match(text, /- No deploys\./); + for (const key of SCHEMA.required) assert.ok(text.includes(`"${key}"`), key); +}); + +test('an open task gets a goal and a done-when only', () => { + const text = brief({ goal: 'Find out whether X can be read from a script.', done: 'An answer per source is a comment on #8.', open: true, constraints: ['ignored'] }); + assert.equal(text, 'Goal: Find out whether X can be read from a script.\n\nDone when: An answer per source is a comment on #8.\n'); +}); + +test('a brief refuses steps and missing parts', () => { + assert.throws(() => brief({ ...BUILD, goal: 'Fix it:\n1. open the file\n2. edit' }), /no numbered steps/); + assert.throws(() => brief({ ...BUILD, constraints: ['Step one: run the tests'] }), /no numbered steps/); + assert.throws(() => brief({ goal: 'x' }), /Done when/); + assert.throws(() => brief({ ...BUILD, constraints: 'No deploys.' }), /list of strings/); +}); + +test('a result is read from the last message, bare or fenced', () => { + assert.equal(result(JSON.stringify(MERGED)), JSON.stringify(MERGED)); + assert.equal(result(`Merged.\n\n\`\`\`json\n${JSON.stringify(MERGED, null, 2)}\n\`\`\``), JSON.stringify(MERGED)); + assert.equal(result(`Done, here it is: ${JSON.stringify(MERGED)}`), JSON.stringify(MERGED)); + const asking = { ...MERGED, pr: null, head: null, state: 'needs_owner', questions: ['Deploy now? Recommended: no.'] }; + assert.equal(result(JSON.stringify(asking)), JSON.stringify(asking)); +}); + +test('a result that does not fit the schema says what is wrong', () => { + assert.deepEqual(check({ ...MERGED, state: 'done' }), ['result.state: "done" is not one of merged, capped, blocked, needs_owner']); + assert.deepEqual(check({ ...MERGED, ticket: '7' }), ['result.ticket: is string, wants integer']); + assert.deepEqual(check({ ...MERGED, open_findings: [{ id: 'F1' }] }), ['result.open_findings[0]: missing title']); + assert.deepEqual(check({ ...MERGED, diff: '...' }), ['result: unknown field diff']); + const { questions, ...noQuestions } = MERGED; + assert.deepEqual(check(noQuestions), ['result: missing questions']); + assert.throws(() => result('I merged it.'), /no JSON object/); +}); + +test('the command prints the result or exits 1 with the reason', () => { + const ok = run('result', JSON.stringify(MERGED)); + assert.equal(ok.status, 0); + assert.deepEqual(JSON.parse(ok.stdout), MERGED); + const bad = run('result', JSON.stringify({ ...MERGED, state: 'done' })); + assert.equal(bad.status, 1); + assert.match(bad.stderr, /result\.state/); + assert.match(run('brief', JSON.stringify(BUILD)).stdout, /^Goal: Build issue #7/); + assert.equal(run('nope', '').status, 2); +}); + +test('the skill points at the schema file and the commands it runs', () => { + const skill = fs.readFileSync(path.join(ROOT, 'plugins', 'bstack', 'skills', 'orchestrator', 'SKILL.md'), 'utf8'); + assert.match(skill, /\]\(lane-result\.schema\.json\)/); + for (const cmd of ['scripts/model.mjs" lane', 'scripts/lane.mjs" brief', 'scripts/lane.mjs" result']) assert.ok(skill.includes(cmd), cmd); +}); From 445bcb6eae3a2029f0b16f807dbaa2c03b507da0 Mon Sep 17 00:00:00 2001 From: Benjamin Carrasco Date: Sat, 5 Dec 2026 18:25:48 +0100 Subject: [PATCH 2/5] docs(orchestrator): find or register the repo's T3 project before a lane starts --- plugins/bstack/skills/orchestrator/SKILL.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/bstack/skills/orchestrator/SKILL.md b/plugins/bstack/skills/orchestrator/SKILL.md index 7271d3b..4493282 100644 --- a/plugins/bstack/skills/orchestrator/SKILL.md +++ b/plugins/bstack/skills/orchestrator/SKILL.md @@ -20,7 +20,8 @@ As `bstack:plan` sizes it: one ticket; a spec with tickets; or questions to the One lane per ticket, in the ticket's repo, in its own worktree. 1. Model: `node "${CLAUDE_PLUGIN_ROOT}/scripts/model.mjs" lane build -R ` prints `{ model, effort }` (`research` or `mechanical` for those kinds; `--failed ` after failed lanes). Map the family to the provider's model id from `orchestrator_capabilities`; `session` means the orchestrator's own model. 2. Brief: `node "${CLAUDE_PLUGIN_ROOT}/scripts/lane.mjs" brief` with `{ "goal", "done", "constraints": [...] }` on stdin. It prints Goal, Done when, Constraints and Result form, in English; it refuses numbered steps, because a brief says what, never how. An open task (research, a question) gets `{ "goal", "done", "open": true }`: a goal and a done-when only. -3. `delegate_task` with that brief as `task`, `isolation: "worktree"`, `mode: "async"`, a `title` of `# `, and `target`: the repo's `projectId` (from `t3_project_list`), a Claude `providerInstanceId` that `canRunChildTask` and is not at its limit, `model`, and `options: { "effort": ... }`. +3. Project: the `t3_project_list` entry whose `repositoryIdentity` names the repo. A repo that moved keeps its old owner there, so compare `gh repo view --json nameWithOwner`. No entry: `t3_project_clone` into a folder next to the other projects, then `t3_project_create` on it. +4. `delegate_task` with that brief as `task`, `isolation: "worktree"`, `mode: "async"`, a `title` of `# `, and `target`: that `projectId`, a Claude `providerInstanceId` that `canRunChildTask` and is not at its limit, `model`, and `options: { "effort": ... }`. Constraints every build brief carries: - Build issue in through the bstack ticket and ship playbooks; a `bstack:judge` you start judges. From ec76c58ea203ffca5109ec3fb59ad5a99b86e76e Mon Sep 17 00:00:00 2001 From: Benjamin Carrasco Date: Sat, 5 Dec 2026 18:30:48 +0100 Subject: [PATCH 3/5] fix(orchestrator): read briefs piped from PowerShell, and start a lane where T3 refuses another project --- plugins/bstack/scripts/lane.mjs | 2 +- plugins/bstack/skills/orchestrator/SKILL.md | 4 ++-- tests/lane.test.mjs | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/bstack/scripts/lane.mjs b/plugins/bstack/scripts/lane.mjs index 073ce7d..98a40f7 100644 --- a/plugins/bstack/scripts/lane.mjs +++ b/plugins/bstack/scripts/lane.mjs @@ -83,7 +83,7 @@ if (isMain(import.meta.url)) { process.exit(2); } try { - process.stdout.write(mode(fs.readFileSync(0, 'utf8'))); + process.stdout.write(mode(fs.readFileSync(0, 'utf8').replace(/^/, ''))); } catch (e) { process.stderr.write(`${e.message}\n`); process.exit(1); diff --git a/plugins/bstack/skills/orchestrator/SKILL.md b/plugins/bstack/skills/orchestrator/SKILL.md index 4493282..f33d76b 100644 --- a/plugins/bstack/skills/orchestrator/SKILL.md +++ b/plugins/bstack/skills/orchestrator/SKILL.md @@ -20,8 +20,8 @@ As `bstack:plan` sizes it: one ticket; a spec with tickets; or questions to the One lane per ticket, in the ticket's repo, in its own worktree. 1. Model: `node "${CLAUDE_PLUGIN_ROOT}/scripts/model.mjs" lane build -R ` prints `{ model, effort }` (`research` or `mechanical` for those kinds; `--failed ` after failed lanes). Map the family to the provider's model id from `orchestrator_capabilities`; `session` means the orchestrator's own model. 2. Brief: `node "${CLAUDE_PLUGIN_ROOT}/scripts/lane.mjs" brief` with `{ "goal", "done", "constraints": [...] }` on stdin. It prints Goal, Done when, Constraints and Result form, in English; it refuses numbered steps, because a brief says what, never how. An open task (research, a question) gets `{ "goal", "done", "open": true }`: a goal and a done-when only. -3. Project: the `t3_project_list` entry whose `repositoryIdentity` names the repo. A repo that moved keeps its old owner there, so compare `gh repo view --json nameWithOwner`. No entry: `t3_project_clone` into a folder next to the other projects, then `t3_project_create` on it. -4. `delegate_task` with that brief as `task`, `isolation: "worktree"`, `mode: "async"`, a `title` of `# `, and `target`: that `projectId`, a Claude `providerInstanceId` that `canRunChildTask` and is not at its limit, `model`, and `options: { "effort": ... }`. +3. Project: the `t3_project_list` entry whose `repositoryIdentity` names the repo. A repo that moved keeps its old owner there, so compare `gh repo view --json nameWithOwner`. No entry: `t3_project_clone` into a folder next to the other projects, then `t3_project_create` on it. Both need a full-access thread; when T3 refuses them (`capability_denied`), registering the repo is an owner question (access), recommended answer: the owner adds the folder as a project in T3. +4. `delegate_task` with that brief as `task`, `isolation: "worktree"`, `mode: "async"`, a `title` of `# `, and `target`: that `projectId`, a Claude `providerInstanceId` that `canRunChildTask` and is not at its limit, `model`, and `options: { "effort": ... }`. When T3 refuses the `projectId` ("A local task runs in this thread's project"), start the lane without it and add the constraint "Work in your own git worktree of , made from origin's default branch; remove it when done." Constraints every build brief carries: - Build issue in through the bstack ticket and ship playbooks; a `bstack:judge` you start judges. diff --git a/tests/lane.test.mjs b/tests/lane.test.mjs index b43cb41..4c841ab 100644 --- a/tests/lane.test.mjs +++ b/tests/lane.test.mjs @@ -68,6 +68,7 @@ test('the command prints the result or exits 1 with the reason', () => { assert.equal(bad.status, 1); assert.match(bad.stderr, /result\.state/); assert.match(run('brief', JSON.stringify(BUILD)).stdout, /^Goal: Build issue #7/); + assert.equal(run('brief', `${JSON.stringify(BUILD)}`).status, 0, 'PowerShell pipes start with a byte order mark'); assert.equal(run('nope', '').status, 2); }); From dad857c88944a305b764b8b7e6931f11a44ac2d3 Mon Sep 17 00:00:00 2001 From: Benjamin Carrasco Date: Sat, 5 Dec 2026 18:35:35 +0100 Subject: [PATCH 4/5] fix(lane): a goal that starts with a decimal is not a numbered step --- plugins/bstack/scripts/lane.mjs | 2 +- tests/lane.test.mjs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/bstack/scripts/lane.mjs b/plugins/bstack/scripts/lane.mjs index 98a40f7..f9274d9 100644 --- a/plugins/bstack/scripts/lane.mjs +++ b/plugins/bstack/scripts/lane.mjs @@ -13,7 +13,7 @@ const USAGE = 'usage: lane.mjs brief|result < input'; export const SCHEMA_FILE = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'skills', 'orchestrator', 'lane-result.schema.json'); export const SCHEMA = JSON.parse(fs.readFileSync(SCHEMA_FILE, 'utf8')); -const STEP_LINE = /^\s*(\d+[.)]|step\b)/im; +const STEP_LINE = /^\s*(\d+[.)](\s|$)|step\b)/im; export function brief({ goal, done, constraints = [], open = false }) { const parts = { Goal: goal, 'Done when': done }; diff --git a/tests/lane.test.mjs b/tests/lane.test.mjs index 4c841ab..1474da2 100644 --- a/tests/lane.test.mjs +++ b/tests/lane.test.mjs @@ -38,6 +38,7 @@ test('an open task gets a goal and a done-when only', () => { test('a brief refuses steps and missing parts', () => { assert.throws(() => brief({ ...BUILD, goal: 'Fix it:\n1. open the file\n2. edit' }), /no numbered steps/); assert.throws(() => brief({ ...BUILD, constraints: ['Step one: run the tests'] }), /no numbered steps/); + assert.match(brief({ ...BUILD, goal: '1.5x faster export.' }), /^Goal: 1\.5x faster export\./); assert.throws(() => brief({ goal: 'x' }), /Done when/); assert.throws(() => brief({ ...BUILD, constraints: 'No deploys.' }), /list of strings/); }); From d030925a2acc94bd1e84ecd63ec009fb06e62cc0 Mon Sep 17 00:00:00 2001 From: Benjamin Carrasco Date: Sat, 5 Dec 2026 18:40:52 +0100 Subject: [PATCH 5/5] docs(orchestrator): a reversible choice inside the ticket is the orchestrator's to answer --- plugins/bstack/skills/orchestrator/SKILL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bstack/skills/orchestrator/SKILL.md b/plugins/bstack/skills/orchestrator/SKILL.md index f33d76b..992431c 100644 --- a/plugins/bstack/skills/orchestrator/SKILL.md +++ b/plugins/bstack/skills/orchestrator/SKILL.md @@ -39,7 +39,7 @@ Pipe the lane's last message to `node "${CLAUDE_PLUGIN_ROOT}/scripts/lane.mjs" r - `merged`: read the issue and PR states back from GitHub, then report. - `needs_owner` or `blocked` with `questions`, or a pending question in the lane (`t3_pending_request list` on its thread): sort each question. - - **Technical** (how to build, which tool, a test approach, a reversible choice): answer it yourself, send the answer to the lane's thread with `t3_thread_send`, and record it on the ticket in one comment (`gh issue comment`: the question, the answer, why). + - **Technical** (how to build, which tool, a test approach, and any reversible choice inside the ticket's scope, even one that shapes behaviour): answer it yourself, send the answer to the lane's thread with `t3_thread_send`, and record it on the ticket in one comment (`gh issue comment`: the question, the answer, why). - **The owner's**: on the stop list of the session rules, or about goal, scope, priority or a product choice no experiment can settle. Collect it; the other lanes go on. - `capped`: report it with its open findings; what to do at the cap is the owner's until its own ticket says otherwise. - A lane that failed on the account limit (`Claude API rate limit reached`): start it again on another account from its pushed branch, or report it.