AGENT SKILL

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)

  1. 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 current scope.md as {path, text}, or null while none is written: read it before writing a new scope, since an owner edit in Confluence or a revise body may have replaced it since your last turn. record is the engagement record (engagement.yaml, JSON text); chat[] every chat line so far; each memory entry an index {root, files: [{path, bytes, title}], truncated} of _bmad-output/planning-artifacts/, kb/ (without kb/confluence/) and kb/confluence/ (the synced Confluence pages), root-relative, sorted, capped. The index never carries a file's body: read the files the turn needs. Every indexed path is relative to the served root (the payload's project_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 untracked kb/confluence/ and any uncommitted plan edits exist only under the served root).

  2. 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}: verb one of answer, go, revise, question, approve, cancel; payload that 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); label the 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 next seq. The result is {ok, dry_run, engagement, mode: "write", line, notes[], written[]} with the status block last.

    Payload mapping (the engagement-chat job's payload is {verb: "reply", engagement, project, project_root, seq, run_id}): project_root (the served registry root, where chat.jsonl and the record live untracked) maps to --directory — never directory, which is the run's worktree; engagement maps to --engagement, run_id (the queue run id) to --run-id; seq is the owner line the turn answers.

    Session procedure for payload.verb: reply: run mode 1; read the owner's line seq and 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's path joined to the payload's project_root, never to the cwd or the worktree); answer in plain language, naming the files you relied on. Story 32.8: when the record's inputs[] holds an owner question line (verb question, payload {text}, source bearer or cookie) newer than your last chat line (the newest author: "planner" line's at), answer the newest such question in this reply — the owner's question moves 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 example go in intake), 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's run_id. End on the status block; commit nothing.

  3. 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}: id matching ^[a-z0-9][a-z0-9-]{0,15}$ and unique, text the question, impact what the answer changes (the scope, the quote), 2 to 6 options with unique labels and exactly one "default": true. --directory is the payload's project_root (never the worktree), --run-id the payload's run_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 source planner and 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 ends partial.

  4. 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:

    1. ## Goal
    2. ## Deliverables — each deliverable a ### <title> holding a line that starts Acceptance 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).
    3. ## Exclusions
    4. ## What the studio needs from you — a list; each item carries the date it is needed by, YYYY-MM-DD.
    5. ## Milestones
    6. ## Proposed epics and stories — ### Epic <k>: <title> and #### Story <k>.<m>: <title>, each story in epics.md's shape (the As a … / I want … / So that … lines and **Acceptance Criteria:**); the numbers are local (approval renumbers them); at least one story.
    7. ## Assumptions (last; required when the record's assumptions[] is non-empty) — name each assumption's question id.

    A # title before ## Goal is 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 scope call then carries --brief-file and --gdd-file (a game project's call without them is refused); on any other project never pass them.

    --scope-file defaults to the engagement's own scope.md. It checks the shape, writes scope.md (under scope.lock), publishes it as the page ENG-NNN: Scope of Work in the Confluence folder Engagements/ENG-NNN (with the provenance footer; an unchanged scope on a page still at the recorded version is skipped, an owner's unmirrored edit is overwritten) and records scope_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 under plan/, _bmad-output/planning-artifacts/ or .tk-studio/ until the owner approves (32.6). While scoping the page is the owner's to edit (D9): an edit there (mirrored by the next sync-back) or a revise body from the Chat screen replaces scope.md wholesale, unchecked — read scope from the memory first and rewrite it into shape on your next turn. The supervisor runs engage.py scope --revise-at <at> itself for a revise body; 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 (no planning.confluence.space_id), ConfluenceEnvMissing (an absent agent-seat variable, named), PublishRefused, ScopeUnwritable: <path>: <error> (scope.md, the record or scope.lock refused by the OS; written names what had already landed), plus the record's; a held scope.lock (ScopeBusy), a 429 or a 5xx ends partial with retry: true (scope.md kept, scope_page unchanged): 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:

  1. 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 (this claude -p session), run it per the skill's ## Headless Mode: never ask; halt blocked if the intent is ambiguous.

  2. 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).

  3. Write scope.md (step 4's shape) and make step 4's one scope call 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.md and gdd.md and are published beside the scope in Engagements/ENG-NNN as ENG-NNN: Game Brief and ENG-NNN: GDD; the record gains brief_page, gdd_page ({id, url, version}, shaped like scope_page) and game: true, which makes approval (32.6) mint the epics' run-epic-N jobs as type: run-vertical-slice. A revise re-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.

  4. 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.md by 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) giving band50, band85 and band95, each {tokens, usd, share} (share over the user config's plan.window_tokens, else "share unknown"), and cap = p95 + one story at p85 in 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 are null and the dollars carry. It merges quote {band50, band85, band95, cap, basis, computed_at} into the record (basis names the seed, the history, the route, the autonomy levels on offer, planning_usd and scoping_billable, and at_cap: the run pauses partial, the engagement's issue blocks with the figures, the owner decides) with each proposed epic's p85 dollars as basis.epics[].usd_estimate; .tk-studio/budget-bands.yaml is 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" when basis.thin), with the proposal {"verb": "go", "payload": {}, "label": "Accept the quote"}; the owner's go moves scoping → quoted. A revise voids the quote (quote: null), and so does any replaced scope.md while scoping (your scope, a revise body, or the owner's page edit mirrored by the sync-back voids a non-null quote first, before scope.md is replaced; a void that fails leaves scope.md untouched — your scope refuses ScopeUnwritable, the sync-back retries on its next tick; a page save whose text equals scope.md keeps the quote): quote again after the new scope. --seed is an integer 0 <= N < 2**53 (default the first 6 bytes of sha256("<engagement>:<n>")). Its refusals (exit 2), each named: BadSeed (a --seed out of that range), NotScoping, EngagementClosed, NoScope (no scope.md, no proposed story, a repeated ### Epic <k> number, or proposed epics not numbered 1..m in order), PricesUnreadable (an unreadable prices.json or an unpriced route model), QuoteUnwritable (the record refused by the OS, an unreadable measurements/, or scope.lock is held — the quote holds it from reading scope.md through the merge; written names what had landed), plus the record's. A dry run writes nothing and ends partial.

  5. 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-progress or partial), 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> of scope.md's ## Deliverables against its stories (done when each landed with spec_status: done and its PR is MERGED; else not done — no acceptance signal, epic not run, story <key> not landed or PR <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 as ENG-NNN: Closeout beside the scope page (page: null with a note when the project has no Confluence binding) and merges closeout {path, page, outcome, done, not_done, run_id, at} into the record. The state does not move here: the supervisor then applies run-ended (delivered, partial or failed), moves the engagement's issue to Done and 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 ends partial with retry: true. A change after delivered is a new engagement (POST /engagements {project, request, follows: ENG-NNN}) with its own scope and quote.

  6. Blocking conditions (exit 2), each named in reason: BadEngagement (not like ENG-001), UnknownEngagement (no record), EngagementRecordUnreadable (not JSON, or not this engagement's record), EngagementClosed (delivered, failed or cancelled), 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-file or --proposals-file. Nothing is appended on a refusal; a dry run appends nothing and ends partial.

  7. Report:

    • Attended: show the reply line and its proposals.

    • Headless: no prompts (AD-11). Relay the core's status, reason and artifacts as they are — never infer the status from the exit code (partial exits 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.

  1. 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: line the owner's line, chat[] the last 40 lines of _bmad-output/tracking/studio-chat.jsonl up to it, reads the 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 — what GET /board, GET /office, GET /status, GET /runs/{id} and GET /inbox answer), or null with a note; routing the orchestrator core's own answer, exactly what orchestrate.py resolve --directory <project_root> prints; voice council when the line names the council, else plain; shell the council persona shell, present only for the council voice. Refusals: UnknownLine (no owner line seq), ChatUnreadable.

  2. Handle the outcome. routing.outcome needs-onboarding ends blocked naming routing.gaps[] (the orchestrator's headless rule; never invent a working set). Otherwise answer the line from reads and 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 when voice is council, and never changes the routing.

  3. 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).

  4. 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_to the owner line's seq; 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} (id the question's id as its inbox item asks it, letter A–Z, note possibly empty, issue the inbox item's key), open {route} (a page under /app), engagement {title}. stop-after-story and open-studio are 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, its questions.json (Story 32.3), and its scope.md with the record's scope_page and the Confluence scope page (Story 32.4), and the record's quote (Story 32.5; its basis.epics[].usd_estimate, never .tk-studio/budget-bands.yaml); the supervisor's closeout (Story 32.8) writes closeout.md, its Confluence page and the record's closeout; 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

thkennedy
thkennedy/tk-studio

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.

★ 0
thkennedy
thkennedy/tk-studio

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.

★ 0
thkennedy
thkennedy/tk-studio

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.

★ 0
thkennedy
thkennedy/tk-studio

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".

★ 0
thkennedy
thkennedy/tk-studio

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".

★ 0
thkennedy
thkennedy/tk-studio

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.

★ 0