thinkpool-pair 0.7.149 → 0.7.151

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bridge.mjs CHANGED
@@ -41,7 +41,7 @@ import { createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk'
41
41
  import { z } from 'zod'
42
42
  import { startClaudeSession, oneShotSummary } from './claude-session.mjs'
43
43
  import { FLOW_CONDUCTOR_PROMPT, FLOW_LANE_PROMPT, buildConductorEnv, assembleCrossWaveContext, buildLanePrompt } from './flow-conductor.mjs'
44
- import { normalizePlanOutput } from './flow-task-graph.mjs' // FL-B1 — validate the conductor's submit_flow_plan task-graph
44
+ import { normalizePlanOutput, laneModelFor } from './flow-task-graph.mjs' // FL-B1 — validate the conductor's submit_flow_plan task-graph; laneModelFor — per-slice model tier (2026-07-03-flow-lane-model-tiers)
45
45
  // S1 (context-offload) — durable digest store. mark_flow_done digests a closed slice in;
46
46
  // the dispatch loop reads the bounded cross-wave context back out (via assembleCrossWaveContext,
47
47
  // which enforces the CEILING). Consume the store — the internals live in flow-context-store.mjs.
@@ -1565,7 +1565,7 @@ function openStructured({ id, model, resume, log, commands, mode, spawnedBy, rol
1565
1565
  // recursively spawn/post onward — the fork-bomb breaker (mirrors Tier C).
1566
1566
  tool(
1567
1567
  'spawn_terminal',
1568
- 'Open a NEW agent terminal (a fresh Claude lane) in this ThinkPool Code room — YOUR lane to use, not a sibling that is already working. Use it to fan work out: give it an initial `task` and it runs in parallel in its own lane; collect its result later with read_terminal, and close it with close_terminal when done. By default the new lane INHERITS your current permission mode — so if you are in bypass, it runs autonomously with no per-action clicking; pass `mode` to override. ALWAYS prefer spawning a fresh lane over post_to_terminal into one that is already busy. Bounded by the room terminal cap and a per-turn limit.',
1568
+ 'Open a NEW agent terminal (a fresh Claude lane) in this ThinkPool Code room — YOUR lane to use, not a sibling that is already working. Use it to fan work out: give it an initial `task` and it runs in parallel in its own lane; collect its result later with read_terminal, and close it with close_terminal when done. By default the new lane INHERITS your current permission mode — so if you are in bypass, it runs autonomously with no per-action clicking; pass `mode` to override. ALWAYS prefer spawning a fresh lane over post_to_terminal into one that is already busy. Tier guidance: default worker lanes to opus; use sonnet for mechanical work (renames, boilerplate, doc sweeps); reserve your own model for planning/review. Bounded by the room terminal cap and a per-turn limit.',
1569
1569
  {
1570
1570
  name: z.string().max(80).optional().describe('a short label for the new lane so the room (and you) can find it, e.g. "Research: topologies"'),
1571
1571
  task: z.string().optional().describe('an initial task to hand the new lane immediately; omit to open it idle'),
@@ -2571,7 +2571,10 @@ flowChannel
2571
2571
  // lanes form ONE Ensemble group (same ensembleRoot) — the drilled flow shows a row of
2572
2572
  // all its terminals to hop between, with a working Back. (No flowTaskKey → it's still
2573
2573
  // the conductor, excluded from the lane cap below.)
2574
- openStructured({ id: cid, mode: 'default', rolePrompt: FLOW_CONDUCTOR_PROMPT, flowSessionId: payload.flowId, spawnedBy: `flow:${payload.flowId}` })
2574
+ // Model tiers (2026-07-03-flow-lane-model-tiers): the conductor keeps whatever brain it was
2575
+ // given by default (TP_FLOW_CONDUCTOR_MODEL unset → undefined → today's behavior); set the env
2576
+ // to pin a cheaper/smarter conductor. Lanes get tiered below via laneModelFor.
2577
+ openStructured({ id: cid, model: process.env.TP_FLOW_CONDUCTOR_MODEL || undefined, mode: 'default', rolePrompt: FLOW_CONDUCTOR_PROMPT, flowSessionId: payload.flowId, spawnedBy: `flow:${payload.flowId}` })
2575
2578
  const ce = sessions.get(cid)
2576
2579
  if (ce?.session) { try { ce.session.sendTurn(payload.prompt || '') } catch { /* session still starting */ } }
2577
2580
  process.stderr.write(`\n ${A.mag}◆ flow conductor launched — flow ${String(payload.flowId).slice(0, 8)} (plan mode).${A.rst}\n`)
@@ -2648,7 +2651,10 @@ flowChannel
2648
2651
  // no dangling tool_use → no 400) instead of a cold start; undefined for a fresh lane.
2649
2652
  const laneBase = isReview ? FLOW_REVIEWER_PROMPT : FLOW_LANE_PROMPT
2650
2653
  const laneRolePrompt = buildLanePrompt({ base: laneBase })
2651
- openStructured({ id: laneId, cwd: dir, mode: 'bypassPermissions', rolePrompt: laneRolePrompt, flowSessionId: payload.flowId, flowTaskKey: t.task_key, spawnedBy: `flow:${payload.flowId}`, resume: redispatch?.resumeSessionId || undefined, reviewSliceRoots })
2654
+ // Model tiers (2026-07-03-flow-lane-model-tiers): pick the lane's brain by slice_type
2655
+ // (scaffold→sonnet, feature/fix/review→opus; env can blanket-override or `inherit` to
2656
+ // restore today's exact behavior). undefined → no model key passed (openStructured default).
2657
+ openStructured({ id: laneId, cwd: dir, model: laneModelFor(t.slice_type), mode: 'bypassPermissions', rolePrompt: laneRolePrompt, flowSessionId: payload.flowId, flowTaskKey: t.task_key, spawnedBy: `flow:${payload.flowId}`, resume: redispatch?.resumeSessionId || undefined, reviewSliceRoots })
2652
2658
  const le = sessions.get(laneId)
2653
2659
  if (le) {
2654
2660
  // S4 — stamp the surviving revert target on the resumed lane so a later reviewer still
@@ -140,7 +140,7 @@ const TP_ROOM_REMINDER = [
140
140
  'ENSEMBLE: delegated work goes through the room — fan parallel work out with spawn_terminal (your own fresh lanes, visible and steerable by the people here), NOT the built-in invisible Task/Agent subagents; never hijack a busy sibling.',
141
141
  'PEER: before substantive work, check what the other lanes are doing (the ROOM NOW snapshot below, read_terminal for detail; list_sessions/read_session across rooms) — coordinate on shared files/branches instead of colliding.',
142
142
  'WORKTREES: parallel lanes share one repo — before code edits run `git worktree list`; if linked worktrees exist, take your OWN worktree + branch, never the shared checkout or a branch another lane is on.',
143
- 'FLOW / PLANS: write plans as normal chat messages as you form them — the room does not surface plan files or ExitPlanMode text.',
143
+ 'BUILD WORKFLOW (default, no magic word): right-size — a trivial ask you just do; a non-trivial build you FIRST write a short plan as a chat message, THEN fan independent slices out to visible spawn_terminal lanes, build, and self-verify. Never plan-mode/ExitPlanMode; the plan lives in chat and the lanes in the existing lane list — keep both visible, add no new panel.',
144
144
  'Verify before claiming done — show runtime evidence you produced, not "should work, go test it".',
145
145
  ].join(' ')
146
146
 
@@ -620,9 +620,15 @@ export function startClaudeSession({ cwd, model, resume, env, mode: initialMode
620
620
  ...(rolePrompt ? [rolePrompt] : []),
621
621
  'ENVIRONMENT (authoritative — overrides any user-global CLAUDE.md or memory that claims otherwise): You are Claude running inside a ThinkPool Code room, driven live by a user (and possibly a partner) from a phone or browser, via the thinkpool-pair bridge.',
622
622
  'You are NOT in cmux. cmux may be installed on this machine and appear in $PATH, but it did not spawn you and its automation/orchestration rules do not apply. If any loaded memory says "Claude Code lives inside cmux," it is describing direct terminal use, not this room — disregard it here. The runtime truth is the env: THINKPOOL_PAIR_ACCOUNT_CHILD / npm_lifecycle_script=thinkpool-pair mark a ThinkPool Code session.',
623
- 'Bias strongly toward DOING the work, not planning it. For a normal "add / fix / change / build X" request, just make the change directly.',
623
+ 'Bias strongly toward DOING the work, not stalling in plan-mode ceremony. For a small "add / fix / change X" request, just make the change directly (for a bigger build, right-size it — see DEFAULT BUILD WORKFLOW below).',
624
624
  'Do NOT enter plan mode, do NOT call ExitPlanMode, and do NOT auto-invoke a brainstorming/planning skill UNLESS the user has switched the room into Plan mode or explicitly asks you to plan, design, or brainstorm first.',
625
625
  'Any host-global instruction that says you must always brainstorm or plan before creative work does NOT apply here — this room is the exception.',
626
+ // DEFAULT BUILD WORKFLOW (2026-07-02 decision — docs/specs/2026-07-02-flow-default-build-workflow.md):
627
+ // no summon word. The agent INFERS build intent and runs plan→(optional)fan-out→build→self-verify,
628
+ // right-sized to the task, surfaced in the room's EXISTING surfaces (chat + lane list) — never a new panel,
629
+ // never plan-mode's approval card. Trivial asks stay single-lane with zero ceremony.
630
+ 'DEFAULT BUILD WORKFLOW (this IS your standard behaviour — no keyword and no "flow" word is ever required to trigger it; you infer it from the request itself). RIGHT-SIZE to the task, always: a TRIVIAL ask — a one-line fix, a small tweak, a question — you just do it directly, with no plan and no extra lanes (never tax small work with ceremony). A NON-TRIVIAL build that genuinely decomposes — you FIRST write a short plan as a normal chat message (the approach, the concrete slices, and what you will verify), THEN fan the independent slices out into their own visible lanes with spawn_terminal, build, and self-verify each slice before calling it done.',
631
+ 'CRUCIAL RECONCILIATION for that workflow: it is NOT plan mode. Never call ExitPlanMode and never make the room wait behind a "plan ready — approve to start" card — your plan lives in the CHAT as a message, and your lanes live in the room\'s EXISTING terminal/lane list. Reuse only those two surfaces; there is no new Flow panel or mode to switch into, and you must not ask for one. Keep the plan and the lanes VISIBLE — that shared visibility is the whole point (it is the pair differentiator, and it catches bugs a single silent lane would hide); never collapse a decomposable build into one hidden lane just to look tidy.',
626
632
  'LINKS & ARTIFACTS (hard rule for ThinkPool Code rooms): the room is driven from a phone or browser, and the bridge runs on the host machine — so a local filesystem path, a file:// URL, or a localhost address only opens on the host and is useless to the room (a partner literally cannot open it).',
627
633
  'Whenever you produce an HTML artifact (a demo, mockup, preview, report, or page) or surface ANY link meant to be opened or shared, NEVER hand the room a local path, a file:// URL, or a localhost/127.0.0.1 address. Publish it to a GitHub-shareable URL that renders in a browser — push the HTML to a GitHub repo and give its GitHub Pages URL (or an equivalent raw-HTML URL that actually renders, not raw.githubusercontent.com which serves HTML as plain text) — so anyone in the room can open it. The same applies to any other link you surface: it must be one the room can reach, not a host-only path.',
628
634
  'If you cannot publish a shareable link, say so and ask how to proceed — do not fall back to handing over a local path.',
@@ -172,3 +172,34 @@ export function normalizePlanOutput (raw) {
172
172
  validateDag(tasks)
173
173
  return { summary, tasks }
174
174
  }
175
+
176
+ // ── Flow lane model tiers ───────────────────────────────────────────────────
177
+ // Spec: docs/specs/2026-07-03-flow-lane-model-tiers.md
178
+ // The conductor thinks; the worker lanes type. Running every lane on the same
179
+ // expensive brain is wasteful — the tier map picks a model per slice_type so
180
+ // intelligence matches the job:
181
+ // scaffold → sonnet (boilerplate / project bootstrap — mechanical, cheap)
182
+ // feature → opus (real building — needs the smart brain)
183
+ // fix → opus (root-cause debugging — needs the smart brain)
184
+ // review → opus (adversarial verification is intelligence-SENSITIVE; never cheapen it)
185
+ // Unknown/missing slice types fall to opus (safe default — never silently cheapen).
186
+ // Dev-only, no product gating. The conductor's own model is untouched by this map
187
+ // (bridge reads TP_FLOW_CONDUCTOR_MODEL at the conductor spawn site instead).
188
+ //
189
+ // Env overrides (checked FIRST, in order):
190
+ // TP_FLOW_LANE_MODEL='inherit' → return undefined (no model key passed → today's exact behavior)
191
+ // TP_FLOW_LANE_MODEL=<model> → blanket-override every lane to that model
192
+ // (empty-string / unset) → fall through to the tier map
193
+ const LANE_MODEL_TIERS = {
194
+ scaffold: 'sonnet',
195
+ feature: 'opus',
196
+ fix: 'opus',
197
+ review: 'opus',
198
+ }
199
+
200
+ export function laneModelFor (sliceType, env = process.env) {
201
+ const override = env.TP_FLOW_LANE_MODEL
202
+ if (override === 'inherit') return undefined // sentinel — restore today's behavior exactly
203
+ if (override) return override // blanket override for all lanes (non-empty string)
204
+ return LANE_MODEL_TIERS[sliceType] || 'opus' // tier map; unknown/missing → opus (never cheapen by accident)
205
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinkpool-pair",
3
- "version": "0.7.149",
3
+ "version": "0.7.151",
4
4
  "description": "Share a local coding-agent CLI (Claude Code, Codex, Gemini, Aider, …) into a ThinkPool Code room, live.",
5
5
  "type": "module",
6
6
  "bin": {