tk-studio-engage
The planner leg of an engagement — `reply` reads the engagement's memory (the record, the chat so far, the plan under `_bmad-output/planning-artifacts/`, `kb/` and `kb/confluence/`) and writes the planner's reply line, with optional proposals the owner can press, to the engagement's `chat.jsonl`; `questions` writes at most three multiple-choice clarifying questions, each with a default, for the owner's inbox; `scope` writes and publishes the scope of work; `quote` prices the scope as a seeded 50/85/95 band with a hard cap from the studio's own history and proposes `go`; `closeout` (run by the supervisor once the engagement's last run ends, never by the planner) writes and publishes the delivery report; `studio-reply` answers one line of the studio chat (`studiochat.py`) with proposals. Use when a supervisor `engagement-chat` or `studio-chat` payload names this skill, or the user says "reply in the engagement chat" or "tk engage reply".
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- tk-studio-engage
- description
- The planner leg of an engagement — `reply` reads the engagement's memory (the record, the chat so far, the plan under `_bmad-output/planning-artifacts/`, `kb/` and `kb/confluence/`) and writes the planner's reply line, with optional proposals the owner can press, to the engagement's `chat.jsonl`; `questions` writes at most three multiple-choice clarifying questions, each with a default, for the owner's inbox; `scope` writes and publishes the scope of work; `quote` prices the scope as a seeded 50/85/95 band with a hard cap from the studio's own history and proposes `go`; `closeout` (run by the supervisor once the engagement's last run ends, never by the planner) writes and publishes the delivery report; `studio-reply` answers one line of the studio chat (`studiochat.py`) with proposals. Use when a supervisor `engagement-chat` or `studio-chat` payload names this skill, or the user says "reply in the engagement chat" or "tk engage reply".
03 SKILL.md 正文
tk-studio-engage
The owner talks to the studio about one engagement through the supervisor's
own chat route (design spec §6.4, D2; user flow F2 step 1). Each owner line
queues one run of the shipped one-shot engagement-chat job: a claude -p
session of the planner leg, on the host, in the run's worktree, with this
plugin; it reads and writes the served project's root (the payload's
project_root, where chat.jsonl and the record live untracked). The session answers from the project's memory and writes its
reply through this surface. The planner moves nothing: it holds no
bearer and no CSRF token, it never sends a typed input, and nothing it
writes changes the engagement's state. A proposal is a button the owner
presses through the supervisor's POST /engagements/{id}/input.
Behavior (both modes)
-
Read the memory through the plugin root:
uv run "${CLAUDE_PLUGIN_ROOT}/lib/engage.py" reply --directory <project-root> \ --engagement <ENG-NNN>The result is
{ok, dry_run, engagement, mode: "memory", record, chat[], memory {plan, kb, confluence}, scope, notes[], written[]}with the status block last.scope(Story 32.4) is the engagement's currentscope.mdas{path, text}, ornullwhile none is written: read it before writing a new scope, since an owner edit in Confluence or arevisebody may have replaced it since your last turn.recordis the engagement record (engagement.yaml, JSON text);chat[]every chat line so far; eachmemoryentry an index{root, files: [{path, bytes, title}], truncated}of_bmad-output/planning-artifacts/,kb/(withoutkb/confluence/) andkb/confluence/(the synced Confluence pages), root-relative, sorted, capped. The index never carries a file's body: read the files the turn needs. Every indexedpathis relative to the served root (the payload'sproject_root, the same value passed as--directory), not to the session's cwd: read each file at<project_root>/<path>, never relative to the run's worktree (the untrackedkb/confluence/and any uncommitted plan edits exist only under the served root). -
Write the reply:
uv run "${CLAUDE_PLUGIN_ROOT}/lib/engage.py" reply --directory <project-root> \ --engagement <ENG-NNN> --body-file <path> [--proposals-file <path>] \ --run-id <run_id> [--dry-run]The body (at most 32 KiB UTF-8) comes from a file, never the command line. The proposals file is a JSON array of
{verb, payload, label}:verbone ofanswer,go,revise,question,approve,cancel;payloadthat verb's typed payload (answer {answers: {<question id>: <option>}},go {cap?},revise {body?},question {text},approve {autonomy: ask | steady | full, base_ref?},cancel {reason?}, no other field);labelthe button's text, at most 80 characters. The line{seq, at, author: "planner", body, run_id, proposals[]}is appended under the chat lock with the nextseq. The result is{ok, dry_run, engagement, mode: "write", line, notes[], written[]}with the status block last.Payload mapping (the
engagement-chatjob's payload is{verb: "reply", engagement, project, project_root, seq, run_id}):project_root(the served registry root, wherechat.jsonland the record live untracked) maps to--directory— neverdirectory, which is the run's worktree;engagementmaps to--engagement,run_id(the queue run id) to--run-id;seqis the owner line the turn answers.Session procedure for
payload.verb: reply: run mode 1; read the owner's lineseqand the chat before it; read the record (the state, the request, the questions, the scope page, the quote) and whichever plan, kb and Confluence files the question needs, each at<project_root>/<path>(the index'spathjoined to the payload'sproject_root, never to the cwd or the worktree); answer in plain language, naming the files you relied on. Story 32.8: when the record'sinputs[]holds an ownerquestionline (verbquestion,payload {text}, sourcebearerorcookie) newer than your last chat line (the newestauthor: "planner"line'sat), answer the newest such question in this reply — the owner'squestionmoves no state and mints no turn of its own; your next turn is its answer. When a typed input would move the engagement on (for examplegoinintake), offer it as a proposal rather than taking it. Write the body and the proposals to temp files and run mode 2 with the payload'srun_id. End on the status block; commit nothing. -
Ask clarifying questions (Story 32.3, user flow F2 step 2) — only in
intake, and only when the turn finds gaps that no default can cover: a choice the scope or the quote turns on and the memory does not settle. Ask at most three; each has options and exactly one default. When a sensible default covers a gap, do not ask: proceed on it and state it as an assumption in the reply. Write the questions to a temp file (a JSON array) and run:uv run "${CLAUDE_PLUGIN_ROOT}/lib/engage.py" questions --directory <project_root> \ --engagement <ENG-NNN> --run-id <run_id> --questions-file <path> [--dry-run]Each question is
{id, text, options: [{label, default?: true}], impact}:idmatching^[a-z0-9][a-z0-9-]{0,15}$and unique,textthe question,impactwhat the answer changes (the scope, the quote), 2 to 6 options with unique labels and exactly one"default": true.--directoryis the payload'sproject_root(never the worktree),--run-idthe payload'srun_id. It writes_bmad-output/engagements/<id>/questions.json; the planner still moves no state: when the run ends, the supervisor applies the file (intake → awaiting-answers, recorded with sourceplannerand the run id), puts the questions in the owner's inbox (one Jira issue per engagement) and reads the answers back. Then write the reply (mode 2) telling the owner what you asked and why. Its refusals (exit 2), each named:TooManyQuestions(a fourth),QuestionInvalid(naming the index),NotIntake,EngagementClosed,RunIdRequired, plus the record's (BadEngagement,UnknownEngagement,EngagementRecordUnreadable) and an unreadable--questions-file. A dry run writes nothing and endspartial. -
Write the scope of work (Story 32.4, user flow F2 step 3) — only in
scoping. Write_bmad-output/engagements/<id>/scope.md(or a temp file) with these##sections, in this order, each non-empty:## Goal## Deliverables— each deliverable a### <title>holding a line that startsAcceptance signal:(or**Acceptance signal:**/**Acceptance signal**:) followed by how the owner will know it is done. Keep the signal on its own paragraph (a blank line before it).## Exclusions## What the studio needs from you— a list; each item carries the date it is needed by,YYYY-MM-DD.## Milestones## Proposed epics and stories—### Epic <k>: <title>and#### Story <k>.<m>: <title>, each story inepics.md's shape (theAs a … / I want … / So that …lines and**Acceptance Criteria:**); the numbers are local (approval renumbers them); at least one story.## Assumptions(last; required when the record'sassumptions[]is non-empty) — name each assumption'squestionid.
A
#title before## Goalis fine; no other##section and no image. Then publish it:uv run "${CLAUDE_PLUGIN_ROOT}/lib/engage.py" scope --directory <project_root> \ --engagement <ENG-NNN> [--scope-file <path>] \ [--brief-file <path> --gdd-file <path>] [--dry-run]On a game project do step 4a first: this one
scopecall then carries--brief-fileand--gdd-file(a game project's call without them is refused); on any other project never pass them.--scope-filedefaults to the engagement's ownscope.md. It checks the shape, writesscope.md(underscope.lock), publishes it as the pageENG-NNN: Scope of Workin the Confluence folderEngagements/ENG-NNN(with the provenance footer; an unchanged scope on a page still at the recorded version isskipped, an owner's unmirrored edit is overwritten) and recordsscope_page {id, url, version}in the record. The result is{ok, dry_run, engagement, mode: "scope", source, scope, page {id, url, version, action: created | updated | skipped}, written[], notes[]}with the status block last. The proposed epics and stories are not plan entities: nothing is written underplan/,_bmad-output/planning-artifacts/or.tk-studio/until the owner approves (32.6). Whilescopingthe page is the owner's to edit (D9): an edit there (mirrored by the next sync-back) or arevisebody from the Chat screen replacesscope.mdwholesale, unchecked — readscopefrom the memory first and rewrite it into shape on your next turn. The supervisor runsengage.py scope --revise-at <at>itself for arevisebody; the planner never does. Its refusals (exit 2), each named:DeliverableWithoutSignal: <title>,ScopeInvalid: <what>(a section missing, empty, out of order or unknown; an undated dependency; no proposed story; an image),AssumptionUnstated: <question id>,NotScoping,EngagementClosed,ReviseNotFound,ConfluenceUnbound(noplanning.confluence.space_id),ConfluenceEnvMissing(an absent agent-seat variable, named),PublishRefused,ScopeUnwritable: <path>: <error>(scope.md, the record orscope.lockrefused by the OS;writtennames what had already landed), plus the record's; a heldscope.lock(ScopeBusy), a 429 or a 5xx endspartialwithretry: true(scope.mdkept,scope_pageunchanged): run it again. Then write the reply (mode 2) with the page's link.
4a. A game project's brief and GDD (Story 34.8, user flow F9) — only in
scoping, before step 4's scope call. A game project is one
whose tracked .tk-studio/config.yaml working_set has any role's list
holding gds or an entry starting gds-, and whose
_bmad/_config/manifest.yaml lists the gds module (Story 36.6; the
plugin-shipped gds-engine-godot-4 alone is not enough); engage.py
decides it (the
scope result's game), so never guess: a game project's scope
without both docs is refused GameDocsMissing: brief | gdd, and the
flags on any other project are refused NotAGameProject (exit 2). In
quick flow, in this order:
-
Run
gds-create-game-brief(create intent) on its Fast path: batch the gaps into one consolidated pass and draft the full brief with[ASSUMPTION]tags where you inferred, from the record, the chat and the answers. Unattended (thisclaude -psession), run it per the skill's## Headless Mode: never ask; haltblockedif the intent is ambiguous. -
Then run
gds-gdd(create intent) on its Express path, from that brief: resolve the critical gaps in one short batch, then draft the full GDD at once; unattended, per its## Headless Mode(references/headless.md). -
Write
scope.md(step 4's shape) and make step 4's onescopecall with the docs:engage.py scope … --brief-file <brief.md> --gdd-file <gdd.md>, never a call without them first. The docs land as_bmad-output/engagements/<id>/brief.mdandgdd.mdand are published beside the scope inEngagements/ENG-NNNasENG-NNN: Game BriefandENG-NNN: GDD; the record gainsbrief_page,gdd_page({id, url, version}, shaped likescope_page) andgame: true, which makes approval (32.6) mint the epics'run-epic-Njobs astype: run-vertical-slice. Arevisere-run (--revise-at, the supervisor's) of a scope already published keeps whatever doc pages the record holds. Put the three page links in the reply. -
Quote the scope (Story 32.5, user flow F2 step 4) — only in
scoping, on the turn after the scope is written (or by hand):uv run "${CLAUDE_PLUGIN_ROOT}/lib/engage.py" quote --directory <project_root> \ --engagement <ENG-NNN> [--seed N] [--dry-run]It counts the proposed stories of
scope.mdby their headings, reads the project's structured meter records from the store's ledgers, and resamples their per-story tokens and dollars over that count: a seeded bootstrap (10,000 resamples) givingband50,band85andband95, each{tokens, usd, share}(shareover the user config'splan.window_tokens, else"share unknown"), andcap = p95 + one story at p85in USD. Under eight metered stories the band says "thin history" (basis.thin) and is widened ×1.5 from the Opus 5.5 trial's per-story dollars; with none, the tokens arenulland the dollars carry. It mergesquote {band50, band85, band95, cap, basis, computed_at}into the record (basisnames the seed, the history, the route, the autonomy levels on offer,planning_usdandscoping_billable, andat_cap: the run pausespartial, the engagement's issue blocks with the figures, the owner decides) with each proposed epic's p85 dollars asbasis.epics[].usd_estimate;.tk-studio/budget-bands.yamlis neither read nor written (approve copies the figures onto the minted EP ids). The state does not move: write the reply (mode 2) stating the band, the cap and what happens at the cap, never a bare number (say "thin history" whenbasis.thin), with the proposal{"verb": "go", "payload": {}, "label": "Accept the quote"}; the owner'sgomovesscoping → quoted. Arevisevoids the quote (quote: null), and so does any replacedscope.mdwhilescoping(yourscope, arevisebody, or the owner's page edit mirrored by the sync-back voids a non-nullquotefirst, beforescope.mdis replaced; a void that fails leavesscope.mduntouched — yourscoperefusesScopeUnwritable, the sync-back retries on its next tick; a page save whose text equalsscope.mdkeeps the quote): quote again after the new scope.--seedis an integer0 <= N < 2**53(default the first 6 bytes ofsha256("<engagement>:<n>")). Its refusals (exit 2), each named:BadSeed(a--seedout of that range),NotScoping,EngagementClosed,NoScope(noscope.md, no proposed story, a repeated### Epic <k>number, or proposed epics not numbered 1..m in order),PricesUnreadable(an unreadableprices.jsonor an unpriced route model),QuoteUnwritable(the record refused by the OS, an unreadablemeasurements/, orscope.lock is held— the quote holds it from readingscope.mdthrough the merge;writtennames what had landed), plus the record's. A dry run writes nothing and endspartial. -
Close out (Story 32.8, user flow F2 steps 7 to 9) — the supervisor's verb, never the planner's: the supervisor's closeout pass runs it on the host once the engagement's last run ended (in
in-progressorpartial), with its own composition of the runs, the landed stories, their specs and PRs, the declared epics, the side exits, the spend and the quote written to a temp file:uv run "${CLAUDE_PLUGIN_ROOT}/lib/engage.py" closeout --directory <project_root> \ --engagement <ENG-NNN> --input-file <path> [--dry-run]It judges each
### <title>ofscope.md's## Deliverablesagainst its stories (donewhen each landed withspec_status: doneand its PR isMERGED; elsenot done —no acceptance signal,epic not run,story <key> not landedorPR <url> not merged), writes_bmad-output/engagements/<id>/closeout.md(Outcome,Deliverables,Pull requests,Cost per story,Spend,Quote against actual,Side exits), publishes it asENG-NNN: Closeoutbeside the scope page (page: nullwith a note when the project has no Confluence binding) and mergescloseout {path, page, outcome, done, not_done, run_id, at}into the record. The state does not move here: the supervisor then appliesrun-ended(delivered,partialorfailed), moves the engagement's issue toDoneand sends one notifier line. Its refusals (exit 2):NoScope,EngagementRecordUnreadable,CloseoutInputInvalid,NotInProgress,EngagementClosed, plus the record's; a 429, a 5xx or an OS refusal endspartialwithretry: true. A change afterdeliveredis a new engagement (POST /engagements {project, request, follows: ENG-NNN}) with its own scope and quote. -
Blocking conditions (exit 2), each named in
reason:BadEngagement(not likeENG-001),UnknownEngagement(no record),EngagementRecordUnreadable(not JSON, or not this engagement's record),EngagementClosed(delivered,failedorcancelled),BodyEmpty,BodyTooLarge,RunIdRequired,ProposalInvalid(naming the index),ChatBusy(the chat lock held past the wait),ChatUnwritable(the chat not UTF-8, or the lock or chat file refused by the OS), an unreadable--body-fileor--proposals-file. Nothing is appended on a refusal; a dry run appends nothing and endspartial. -
Report:
-
Attended: show the reply line and its proposals.
-
Headless: no prompts (AD-11). Relay the core's
status,reasonandartifactsas they are — never infer the status from the exit code (partialexits 0):{"status": "complete", "intent": "tk-studio-engage", "artifacts": [], "reason": null}
-
If the deterministic core is unrunnable — a tool call denied by permissions, uv/python unavailable — end blocked with the status block naming the unrunnable core as reason: never a question, never a headless run that ends without the block (AD-11).
The studio chat: studio-reply (Story 39.3)
The owner's chat at /app/chat is a conversation with the studio, not with
an engagement (design addendum 2026-11-07 §3.8, AD-11). Each owner line
queues one run of the shipped one-shot studio-chat job: a claude -p
session of the planner leg, on the host, with this plugin and the payload
{verb: "studio-reply", project, project_root, seq, run_id}. The session
runs the tk-studio-orchestrator core headless and answers one line. It
moves no state, holds no bearer and no CSRF token, and commits nothing: an
action is a proposal, a button the owner presses.
-
Read the context (read-only):
uv run "${CLAUDE_PLUGIN_ROOT}/lib/studiochat.py" context \ --directory <project_root> --seq <seq>The result is
{ok, dry_run, mode: "context", seq, line, chat[], reads, routing, voice, shell?, not_yet[], notes[], written[]}with the status block last:linethe owner's line,chat[]the last 40 lines of_bmad-output/tracking/studio-chat.jsonlup to it,readsthe supervisor's reads written at post time (studio-chat-reads/<seq>.json: the board, the office, the status and live runs, the project's last ten runs with their ledger cost, the inbox — whatGET /board,GET /office,GET /status,GET /runs/{id}andGET /inboxanswer), ornullwith a note;routingthe orchestrator core's own answer, exactly whatorchestrate.py resolve --directory <project_root>prints;voicecouncilwhen the line names the council, elseplain;shellthe council persona shell, present only for the council voice. Refusals:UnknownLine(no owner lineseq),ChatUnreadable. -
Handle the outcome.
routing.outcomeneeds-onboardingendsblockednamingrouting.gaps[](the orchestrator's headless rule; never invent a working set). Otherwise answer the line fromreadsand the routing's framing: "what is running" costs a read, never a plan. Use the plain studio voice; the council shell is presentation only, used whenvoiceiscouncil, and never changes the routing. -
Emit the reply once, between
<reply>and</reply>, before the record is written: the supervisor streams the text between the markers to the page as it is produced. The status block (step 4) is still the session's last output (AD-11). -
Write the record with the same text (UTF-8 files, never the command line):
uv run "${CLAUDE_PLUGIN_ROOT}/lib/studiochat.py" reply \ --directory <project_root> --seq <seq> --run-id <run_id> \ --body-file <path> [--proposals-file <path>] [--dry-run]It appends
{seq, at, author: "planner", body, run_id, reply_to, proposals[]}(reply_tothe owner line'sseq; one reply per line).proposals[]is at most 6 objects{kind, label (1–80)}plus the kind's fields and no other:queue {project, job},answer {id, letter, note, issue}(idthe question's id as its inbox item asks it,letterA–Z,notepossibly empty,issuethe inbox item's key),open {route}(a page under/app),engagement {title}.stop-after-storyandopen-studioare refused by name (ProposalNotYet: <kind> lands in Story 39.7): drop them and say in the body that the action arrives with Story 39.7. Its other refusals (exit 2):BodyEmpty,BodyTooLarge,RunIdRequired,UnknownLine,AlreadyAnswered,ProposalInvalid: <index>: <why>,ChatBusy,ChatUnwritable. Relay the status block as in step 8 above.
Rules
- The planner never moves state, never sends an input, and never holds a
bearer or a CSRF token; its session runs with a worker's environment
(every
TK_SUPERVISOR_*secret and the owner seat stripped). - The only files written are the engagement's
chat.jsonl, one line per reply, itsquestions.json(Story 32.3), and itsscope.mdwith the record'sscope_pageand the Confluence scope page (Story 32.4), and the record'squote(Story 32.5; itsbasis.epics[].usd_estimate, never.tk-studio/budget-bands.yaml); the supervisor'scloseout(Story 32.8) writescloseout.md, its Confluence page and the record'scloseout; the studio chat's reply (Story 39.3) is one line of_bmad-output/tracking/studio-chat.jsonl; nothing is committed, nothing is promoted. - All paths resolve through
${CLAUDE_PLUGIN_ROOT}.
04 同仓库更多 Skills
tk-studio-track
Tracking verbs on the bound Jira project — `block` moves a story the loop cannot progress, and each dependent story, to "Blocked - Awaiting User" with a comment that @mentions the owner (or, with `--engagement`, one engagement's questions issue, which `close` later moves to "Done"); `reply` posts the owner's answer (or "Done.") with the owner's host-only token and moves the issue to "Block Resolved"; `validate` checks that resolution and passes the issue back to work or re-blocks it with a follow-up. Use when the user says "block this story", "tk track block", "put it in the owner's inbox", "reply to the blocked issue", "validate the resolution", or a supervisor or engagement payload names this skill.
tk-studio-session
Session discipline as a surface — land a boundary handoff (optionally carrying knowledge deltas) and end the session, or resume a fresh session from a run workspace alone. Use when the user says "hand off this run", "tk session", "resume the run", or a boundary/budget trigger says the session must split.
tk-studio-research
Run a chartered research pass — survey the topics a charter scopes, grade every finding by evidence, land the findings in the run workspace, and emit observation events for recommendation-worthy ones. Use when the user says "run the ecosystem watch", "tk research", or a research job's invoke-skill directive names this skill.
tk-studio-report
One-verb human defect report — "the skill did the wrong thing" — recorded as a report event in the local measurement ledger. Use when the user says "tk report", "report a defect", "that skill misbehaved", or "log a studio issue".
tk-studio-playable-judge
The playable-verify leg's screenshot judge (Story 34.3) — reads only a playable run's report.json and its frames, answers the fixed rubric (scene loaded, player visible and framed, no magenta or error overlay, HUD reads, the named moments shown) with pass or fail and findings each naming a frame and a rubric line. Driven headless by the supervisor's host leg on the project's sandbox tier; use when the payload names a playable `media` folder, or the user says "judge the playable frames".
tk-studio-plan-sync
Planning adapter — canonicalize BMad-native planning artifacts (normalize pass, sole id authority) and sync them with the bound planning backend. Use when the user says "sync the plan", "normalize planning artifacts", "tk plan sync", or after stock BMad planning flows produce or change epics/stories.