thinkpool-pair 0.7.259 → 0.7.261
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 +2 -2
- package/claude-session.mjs +3 -3
- package/codex-session.mjs +1 -1
- package/package.json +3 -1
- package/thinkpool-capabilities.json +184 -0
- package/thinkpool-prompt-contracts.mjs +85 -0
- package/thinkpool-room-prompt.mjs +17 -56
package/bridge.mjs
CHANGED
|
@@ -122,7 +122,7 @@ import { planMeterLine } from './plan-meters.mjs'
|
|
|
122
122
|
import { priceForModel } from './model-prices.mjs'
|
|
123
123
|
import { makeThrottledTrack } from './presence.mjs'
|
|
124
124
|
import { resolveAnonKey, DEFAULT_SUPABASE_URL } from './supabase-key.mjs'
|
|
125
|
-
import { buildTerminalRolePrompt, HERMES_VISIBLE_WORKER_FALLBACK_RULE } from './thinkpool-room-prompt.mjs'
|
|
125
|
+
import { buildTerminalRolePrompt, HERMES_VISIBLE_WORKER_FALLBACK_RULE, THINKPOOL_PROMPT_BUNDLE } from './thinkpool-room-prompt.mjs'
|
|
126
126
|
|
|
127
127
|
// Public client creds (the same anon values the web app ships — safe to embed).
|
|
128
128
|
// Override with TP_SUPABASE_URL / TP_SUPABASE_ANON if you ever need to.
|
|
@@ -1061,7 +1061,7 @@ const announce = () => {
|
|
|
1061
1061
|
models: roomModels || undefined,
|
|
1062
1062
|
// cwd + version: the host's working dir + thinkpool-pair version, shown in
|
|
1063
1063
|
// the room's welcome banner. Re-sent per announce so late joiners get them.
|
|
1064
|
-
cwd, version: VERSION,
|
|
1064
|
+
cwd, version: VERSION, promptBundle: THINKPOOL_PROMPT_BUNDLE,
|
|
1065
1065
|
// host: short machine label (see const `host`) so the room shows which box
|
|
1066
1066
|
// currently serves it + attributes dormant terminals to their home machine.
|
|
1067
1067
|
// Additive top-level field; consumed by src/pages/code/room.jsx onAnnounce in
|
package/claude-session.mjs
CHANGED
|
@@ -21,7 +21,7 @@ import { sanitizeSession } from './transcript-sanitize.mjs'
|
|
|
21
21
|
import { reviewGatePreToolDecision } from './flow-review-gate.mjs'
|
|
22
22
|
import { crossPostNeedsCard } from './cross-terminal.mjs'
|
|
23
23
|
import { correctContext } from './context-windows.mjs'
|
|
24
|
-
import { THINKPOOL_REMOTE_DELIVERY_RULES, THINKPOOL_RUNTIME_TURN_REMINDER, buildThinkPoolTurnGuidance, createRoomContextSelector, usesFullThinkPoolReminder } from './thinkpool-room-prompt.mjs'
|
|
24
|
+
import { THINKPOOL_CASCADE_RULE, THINKPOOL_REMOTE_DELIVERY_RULES, THINKPOOL_RUNTIME_AUTHORITY_RULE, THINKPOOL_RUNTIME_TURN_REMINDER, buildThinkPoolTurnGuidance, createRoomContextSelector, usesFullThinkPoolReminder } from './thinkpool-room-prompt.mjs'
|
|
25
25
|
import { stallDecision, stallEvent, isCompactTurn } from './turn-stall.mjs'
|
|
26
26
|
|
|
27
27
|
// The caret-pulled SDK's real version (^0.3.x auto-upgrades on restart). Resolved
|
|
@@ -697,7 +697,7 @@ export function startClaudeSession({ cwd, model, effort: initialEffort = 'high',
|
|
|
697
697
|
...(terminalRolePrompt ? [terminalRolePrompt] : []),
|
|
698
698
|
...(rolePrompt ? [rolePrompt] : []),
|
|
699
699
|
'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.',
|
|
700
|
-
|
|
700
|
+
THINKPOOL_RUNTIME_AUTHORITY_RULE,
|
|
701
701
|
'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).',
|
|
702
702
|
'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.',
|
|
703
703
|
'Any host-global instruction that says you must always brainstorm or plan before creative work does NOT apply here — this room is the exception.',
|
|
@@ -705,7 +705,7 @@ export function startClaudeSession({ cwd, model, effort: initialEffort = 'high',
|
|
|
705
705
|
// no summon word. The agent INFERS build intent and runs plan→(optional)fan-out→build→self-verify,
|
|
706
706
|
// right-sized to the task, surfaced in the room's EXISTING surfaces (chat + lane list) — never a new panel,
|
|
707
707
|
// never plan-mode's approval card. Trivial asks stay single-lane with zero ceremony.
|
|
708
|
-
|
|
708
|
+
THINKPOOL_CASCADE_RULE,
|
|
709
709
|
'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.',
|
|
710
710
|
...THINKPOOL_REMOTE_DELIVERY_RULES,
|
|
711
711
|
'CROSS-TERMINAL AWARENESS: this room may have other terminals open alongside yours — other agents working, or shells the people are driving. You have a READ-ONLY tool, read_terminal: call it with no arguments to list the other open terminals, or with a terminal ref/id/command to read that terminal\'s recent activity. Reach for it when your work depends on what another terminal is doing (e.g. someone says "see what the other terminal hit", or you need to coordinate with a sibling agent before acting). It only ever reads — it never changes another terminal. Identify a terminal by its NAME or its ref/id from the roster, never by an on-screen number like "Terminal 2" — those positional labels renumber when a terminal is closed, so they do not reliably point at a lane.',
|
package/codex-session.mjs
CHANGED
|
@@ -211,7 +211,7 @@ export function codexPublishAccess({ cwd, env = process.env, tmpdir = os.tmpdir(
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
export const CODEX_ROOM_CASCADE_REMINDER = [
|
|
214
|
-
'THINKPOOL ROOM
|
|
214
|
+
'THINKPOOL ROOM ROLE ENFORCEMENT: obey the authoritative TERMINAL ROLE above. Conductors are independent main terminals; Ensemble lanes are workers only. An explicitly requested separate Cascade/conductor uses open_main_terminal — NEVER spawn_terminal. Use spawn_terminal only for bounded worker slices from a role permitted to delegate. If open_main_terminal is unavailable, say so; never substitute an Ensemble child. Leaf, worker, Side, and managed Flow lanes work directly and must not delegate. Never use hidden in-process subagents.',
|
|
215
215
|
].join(' ')
|
|
216
216
|
|
|
217
217
|
export function buildCodexPrompt({ text, terminalRolePrompt, rolePrompt, roomContext, firstTurn = false, promptIndex = 0, forceFullReminder = false }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "thinkpool-pair",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.261",
|
|
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": {
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
"claude-session.mjs",
|
|
18
18
|
"codex-session.mjs",
|
|
19
19
|
"thinkpool-room-prompt.mjs",
|
|
20
|
+
"thinkpool-prompt-contracts.mjs",
|
|
21
|
+
"thinkpool-capabilities.json",
|
|
20
22
|
"codex-app-server.mjs",
|
|
21
23
|
"codex-images.mjs",
|
|
22
24
|
"codex-mcp-http.mjs",
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"bundleVersion": 1,
|
|
4
|
+
"contracts": [
|
|
5
|
+
{
|
|
6
|
+
"id": "room-coordination",
|
|
7
|
+
"version": 1,
|
|
8
|
+
"routes": [
|
|
9
|
+
{
|
|
10
|
+
"id": "room-awareness",
|
|
11
|
+
"tools": ["read_terminal"],
|
|
12
|
+
"trigger": "\\b(other|another|sibling|peer)\\s+(lane|terminal)|\\bread_terminal\\b",
|
|
13
|
+
"prompt": "When the request depends on another lane, a sibling may overlap the work, or a person refers to another terminal, inspect it with read_terminal before acting."
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "cross-room-awareness",
|
|
17
|
+
"tools": ["list_sessions", "read_session"],
|
|
18
|
+
"trigger": "\\b(other|another|cross[- ]?room|cross[- ]?session)\\s+(room|session)|\\b(list_sessions|read_session)\\b",
|
|
19
|
+
"prompt": "When work depends on another ThinkPool room, use list_sessions then read_session instead of asking the people to relay host-side state."
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "visible-handoff",
|
|
23
|
+
"tools": ["post_to_terminal", "post_to_session"],
|
|
24
|
+
"trigger": "\\b(hand[ -]?off|tell|send|post)\\b.{0,40}\\b(lane|terminal|room|session|agent)\\b|\\b(post_to_terminal|post_to_session)\\b",
|
|
25
|
+
"prompt": "When the people want a handoff, read the target first, then use post_to_terminal or post_to_session; let the room approval contract handle consent."
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"impact": [
|
|
29
|
+
{"path": "bridge/cross-terminal.mjs"},
|
|
30
|
+
{"path": "bridge/bridge.mjs", "diffPattern": "read_terminal|list_sessions|read_session|post_to_terminal|post_to_session"}
|
|
31
|
+
],
|
|
32
|
+
"evidence": [
|
|
33
|
+
{"path": "bridge/cross-terminal.mjs", "pattern": "read_terminal"},
|
|
34
|
+
{"path": "bridge/cross-terminal.mjs", "pattern": "post_to_session"},
|
|
35
|
+
{"path": "bridge/bridge.mjs", "pattern": "'list_sessions'"}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "work-routing",
|
|
40
|
+
"version": 1,
|
|
41
|
+
"routes": [
|
|
42
|
+
{
|
|
43
|
+
"id": "work-routing",
|
|
44
|
+
"tools": ["spawn_terminal", "open_main_terminal", "close_terminal"],
|
|
45
|
+
"trigger": "\\b(parallel|delegate|worker|sub[- ]?terminal|conductor|cascade|spawn_terminal|open_main_terminal|close_terminal)\\b",
|
|
46
|
+
"prompt": "For genuinely decomposable work in a conductor-capable role, open visible worker slices with spawn_terminal, collect and verify them, then close_terminal. An explicitly requested separate Cascade/conductor uses open_main_terminal, never spawn_terminal."
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"expandedPrompt": "CASCADE WORKFLOW (default for non-trivial work that genuinely decomposes; mandatory when the people ask for Cascade, tiered lanes, one-shot flow, or unattended multi-slice execution): first investigate enough to name evidence-backed slices and their dependencies, then post a short plan in the room. The current top-level/conductor terminal keeps decomposition, integration, and final judgment; use spawn_terminal only for bounded worker slices, while an explicitly requested separate conductor uses open_main_terminal. Parallelize only disjoint slices and encode dependencies instead of holding them in your head. Choose sliceType=scaffold for mechanical/search work, feature or fix for implementation, and review with a balanced capable tier for adversarial verification. Every worker brief names the evidence/diagnosis, exact scope, observable acceptance proof, relevant repo gates, whether merge/publish is required, and a safe-skip escape hatch. After dispatch, remain responsible: use read_terminal to collect each owned lane, verify its claim, close_terminal immediately, and dispatch newly unblocked work; never declare the Cascade done or yield a final result while owned workers remain uncollected. Check origin/main CI before merge-bearing waves, coordinate shared fixtures/publishers, and treat sibling pushes as context rather than proof. Run an adversarial review after builders (or pipeline review behind completed phases), finish with production-condition evidence, verify every reported SHA/version, and close every worker you opened.",
|
|
50
|
+
"impact": [
|
|
51
|
+
{"path": "bridge/bridge.mjs", "diffPattern": "spawn_terminal|open_main_terminal|close_terminal|cascadeRole|spawnDepth"},
|
|
52
|
+
{"path": "bridge/lane-lifecycle.mjs"},
|
|
53
|
+
{"path": "bridge/lane-worktree.mjs"},
|
|
54
|
+
{"path": "bridge/flow-conductor.mjs"}
|
|
55
|
+
],
|
|
56
|
+
"evidence": [
|
|
57
|
+
{"path": "bridge/bridge.mjs", "pattern": "'spawn_terminal'"},
|
|
58
|
+
{"path": "bridge/bridge.mjs", "pattern": "'open_main_terminal'"},
|
|
59
|
+
{"path": "bridge/bridge.mjs", "pattern": "'close_terminal'"}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"id": "room-question",
|
|
64
|
+
"version": 1,
|
|
65
|
+
"routes": [
|
|
66
|
+
{
|
|
67
|
+
"id": "room-question",
|
|
68
|
+
"tools": ["request_user_input"],
|
|
69
|
+
"trigger": "\\b(request_user_input)\\b",
|
|
70
|
+
"prompt": "When a missing choice genuinely blocks useful progress, use request_user_input so the question is answerable in the room; otherwise make a safe in-scope assumption and continue."
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"impact": [
|
|
74
|
+
{"path": "bridge/bridge.mjs", "diffPattern": "request_user_input"},
|
|
75
|
+
{"path": "bridge/claude-session.mjs", "diffPattern": "AskUserQuestion|request_user_input"},
|
|
76
|
+
{"path": "bridge/codex-session.mjs", "diffPattern": "request_user_input"}
|
|
77
|
+
],
|
|
78
|
+
"evidence": [
|
|
79
|
+
{"path": "bridge/bridge.mjs", "pattern": "'request_user_input'"}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"id": "visual-proof",
|
|
84
|
+
"version": 1,
|
|
85
|
+
"routes": [
|
|
86
|
+
{
|
|
87
|
+
"id": "visual-proof",
|
|
88
|
+
"tools": ["preview_start", "preview_capture", "preview_inspect", "preview_stop"],
|
|
89
|
+
"trigger": "\\b(ui|ux|visual|design|frontend|html|css|page|route|mockup|screenshot|responsive|desktop|mobile|preview)\\b",
|
|
90
|
+
"prompt": "For built visual work, run the build, use preview_start, preview_capture at desktop and mobile, preview_inspect when rendered state matters, and preview_stop when finished. Surface PNG evidence only when no interactive source-backed Design card is displayed."
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"impact": [
|
|
94
|
+
{"path": "bridge/viewport.mjs"},
|
|
95
|
+
{"path": ".claude/skills/mockup-iterate/scripts/render.sh"}
|
|
96
|
+
],
|
|
97
|
+
"evidence": [
|
|
98
|
+
{"path": "bridge/viewport.mjs", "pattern": "preview_start"},
|
|
99
|
+
{"path": "bridge/viewport.mjs", "pattern": "preview_capture"},
|
|
100
|
+
{"path": "bridge/viewport.mjs", "pattern": "preview_inspect"},
|
|
101
|
+
{"path": "bridge/viewport.mjs", "pattern": "preview_stop"}
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "external-research",
|
|
106
|
+
"version": 1,
|
|
107
|
+
"routes": [
|
|
108
|
+
{
|
|
109
|
+
"id": "external-research",
|
|
110
|
+
"tools": ["research"],
|
|
111
|
+
"trigger": "\\b(research|latest|current|look up|browse|web search|online source|verify online)\\b",
|
|
112
|
+
"prompt": "For current external facts that materially benefit from multi-source verification, offer the metered research lane and call research only after the people agree."
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"impact": [
|
|
116
|
+
{"path": "bridge/bridge.mjs", "diffPattern": "research"},
|
|
117
|
+
{"path": "api/research-run.js"}
|
|
118
|
+
],
|
|
119
|
+
"evidence": [
|
|
120
|
+
{"path": "bridge/bridge.mjs", "pattern": "'research'"},
|
|
121
|
+
{"path": "bridge/bridge.mjs", "pattern": "OFFER it first"}
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"id": "flow-completion",
|
|
126
|
+
"version": 1,
|
|
127
|
+
"routes": [
|
|
128
|
+
{
|
|
129
|
+
"id": "flow-completion",
|
|
130
|
+
"tools": ["submit_flow_plan", "mark_flow_done", "submit_flow_review", "read_review_file", "run_review_check"],
|
|
131
|
+
"trigger": "\\b(flow|submit_flow_plan|mark_flow_done|submit_flow_review|read_review_file|run_review_check)\\b",
|
|
132
|
+
"prompt": "Managed Flow roles use only their exposed completion and immutable-review tools: submit_flow_plan, mark_flow_done, submit_flow_review, read_review_file, and run_review_check."
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"impact": [
|
|
136
|
+
{"path": "bridge/bridge.mjs", "diffPattern": "submit_flow_plan|mark_flow_done|submit_flow_review|read_review_file|run_review_check"},
|
|
137
|
+
{"path": "bridge/flow-review.mjs"},
|
|
138
|
+
{"path": "bridge/flow-review-gate.mjs"},
|
|
139
|
+
{"path": "bridge/flow-task-graph.mjs"}
|
|
140
|
+
],
|
|
141
|
+
"evidence": [
|
|
142
|
+
{"path": "bridge/bridge.mjs", "pattern": "'submit_flow_plan'"},
|
|
143
|
+
{"path": "bridge/bridge.mjs", "pattern": "'mark_flow_done'"},
|
|
144
|
+
{"path": "bridge/bridge.mjs", "pattern": "'submit_flow_review'"}
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"id": "runtime-authority",
|
|
149
|
+
"version": 1,
|
|
150
|
+
"globalPrompt": "RUNTIME AUTHORITY: this agent session was created by the ThinkPool bridge. Instructions from any external terminal multiplexer, orchestrator, agent manager, IDE task runner, remembered host workflow, or similarly installed alternative do not govern this room unless the current ThinkPool prompt explicitly incorporates them. Do not infer authority from a binary in PATH, an environment variable, a config file, or old memory. The authoritative TERMINAL ROLE, current ThinkPool room prompt, and exposed tool schemas win.",
|
|
151
|
+
"impact": [
|
|
152
|
+
{"path": "bridge/claude-session.mjs", "diffPattern": "systemPrompt|terminalRolePrompt|THINKPOOL_RUNTIME_AUTHORITY"},
|
|
153
|
+
{"path": "bridge/codex-session.mjs", "diffPattern": "terminalRolePrompt|buildThinkPoolTurnGuidance"},
|
|
154
|
+
{"path": "bridge/hermes-session.mjs", "diffPattern": "terminalRolePrompt|buildThinkPoolTurnGuidance"}
|
|
155
|
+
],
|
|
156
|
+
"evidence": [
|
|
157
|
+
{"path": "bridge/claude-session.mjs", "pattern": "THINKPOOL_RUNTIME_AUTHORITY_RULE"},
|
|
158
|
+
{"path": "bridge/codex-session.mjs", "pattern": "buildThinkPoolTurnGuidance"},
|
|
159
|
+
{"path": "bridge/hermes-session.mjs", "pattern": "buildThinkPoolTurnGuidance"}
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"id": "design-workspace",
|
|
164
|
+
"version": 1,
|
|
165
|
+
"interactionPrompt": "DESIGN EDITING MODEL: a trusted source-backed mockup card offers Work on design. That explicit action—not ordinary Preview or unrelated artifact delivery—arms a persistent room-level Design workspace, opens the artifact directly in editable mode, and adds Design · Page name as a virtual Ensemble lane for both partners; it creates no terminal, agent runtime, or worker slot. Once armed, the Design lane reopens the active artifact at its latest verified revision without another agent turn, history search, HTML/path request, or re-selection. Design is the default canvas there and Preview is only a temporary interaction mode. Direct text, supported movement, and selected-image changes auto-stage as optimistic drafts in the bounded changes queue. Apply changes sends the ordered batch once to the producing lane, that lane edits the canonical authored HTML, and a successful desktop+mobile render advances the verified revision for the room. Never call a staged draft saved or live. A preview_capture card is visual evidence, not an editable Design artifact.",
|
|
166
|
+
"turnReminder": "DESIGN ROUTE: authored HTML must produce a source-backed Thinkpool Design card with verified desktop and mobile renders. Work on design explicitly arms the persistent Design workspace and adds its virtual Design · Page Ensemble lane; Preview alone does not arm it. Do not duplicate the card renders as inline PNGs. Use inline PNG evidence only when no interactive Design artifact is available.",
|
|
167
|
+
"impact": [
|
|
168
|
+
{"path": "src/pages/code/design/"},
|
|
169
|
+
{"path": "src/pages/code/structured.jsx", "diffPattern": "Work on design|openMockup|tp-mockup-view|sourceKnown"},
|
|
170
|
+
{"path": "src/pages/code/room.jsx", "diffPattern": "designWorkspace|designLane|activeDesign|DesignViewer"},
|
|
171
|
+
{"path": "bridge/design-edit.mjs"}
|
|
172
|
+
],
|
|
173
|
+
"evidence": [
|
|
174
|
+
{"path": "src/pages/code/structured.jsx", "pattern": "Work on design"},
|
|
175
|
+
{"path": "src/pages/code/design/workspace.js", "pattern": "armed: true"},
|
|
176
|
+
{"path": "src/pages/code/room.jsx", "pattern": "designLaneSelected"},
|
|
177
|
+
{"path": "src/pages/code/design/DesignViewer.jsx", "pattern": "createPortal\\(surface, laneHost\\)"},
|
|
178
|
+
{"path": "src/pages/code/design/DesignViewer.jsx", "pattern": "Apply \\${pendingEditCount}"},
|
|
179
|
+
{"path": "src/pages/code/design/queue.js", "pattern": "designBatchPayload"},
|
|
180
|
+
{"path": "bridge/design-edit.mjs", "pattern": "validateDesignBatchRequest"}
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
2
|
+
import { readFileSync } from 'node:fs'
|
|
3
|
+
|
|
4
|
+
const REGISTRY_URL = new URL('./thinkpool-capabilities.json', import.meta.url)
|
|
5
|
+
|
|
6
|
+
function deepFreeze(value) {
|
|
7
|
+
if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value
|
|
8
|
+
Object.freeze(value)
|
|
9
|
+
for (const child of Object.values(value)) deepFreeze(child)
|
|
10
|
+
return value
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function stableValue(value) {
|
|
14
|
+
if (Array.isArray(value)) return value.map(stableValue)
|
|
15
|
+
if (!value || typeof value !== 'object') return value
|
|
16
|
+
return Object.fromEntries(Object.keys(value).sort().map((key) => [key, stableValue(value[key])]))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function computePromptBundleHash(registry) {
|
|
20
|
+
return createHash('sha256').update(JSON.stringify(stableValue(registry))).digest('hex')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function validatePromptRegistry(registry) {
|
|
24
|
+
const errors = []
|
|
25
|
+
if (!Number.isInteger(registry?.schemaVersion) || registry.schemaVersion < 1) errors.push('schemaVersion must be a positive integer')
|
|
26
|
+
if (!Number.isInteger(registry?.bundleVersion) || registry.bundleVersion < 1) errors.push('bundleVersion must be a positive integer')
|
|
27
|
+
if (!Array.isArray(registry?.contracts) || registry.contracts.length === 0) errors.push('contracts must be a non-empty array')
|
|
28
|
+
const ids = new Set()
|
|
29
|
+
const routeIds = new Set()
|
|
30
|
+
for (const contract of registry?.contracts || []) {
|
|
31
|
+
if (!contract?.id || !/^[a-z0-9-]+$/.test(contract.id)) errors.push(`invalid contract id: ${contract?.id || '<missing>'}`)
|
|
32
|
+
else if (ids.has(contract.id)) errors.push(`duplicate contract id: ${contract.id}`)
|
|
33
|
+
else ids.add(contract.id)
|
|
34
|
+
if (!Number.isInteger(contract?.version) || contract.version < 1) errors.push(`${contract?.id || '<missing>'}: version must be a positive integer`)
|
|
35
|
+
if (!Array.isArray(contract?.impact)) errors.push(`${contract?.id || '<missing>'}: impact must be an array`)
|
|
36
|
+
if (!Array.isArray(contract?.evidence) || contract.evidence.length === 0) errors.push(`${contract?.id || '<missing>'}: evidence must be a non-empty array`)
|
|
37
|
+
if (!(contract?.routes?.length || contract?.globalPrompt || contract?.expandedPrompt || contract?.interactionPrompt)) {
|
|
38
|
+
errors.push(`${contract?.id || '<missing>'}: at least one compiled prompt surface is required`)
|
|
39
|
+
}
|
|
40
|
+
for (const impact of contract?.impact || []) {
|
|
41
|
+
if (!impact?.path || typeof impact.path !== 'string') errors.push(`${contract.id}: every impact entry needs a path`)
|
|
42
|
+
if (impact?.diffPattern) {
|
|
43
|
+
try { new RegExp(impact.diffPattern, 'i') } catch { errors.push(`${contract.id}: invalid impact regex for ${impact.path}`) }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for (const evidence of contract?.evidence || []) {
|
|
47
|
+
if (!evidence?.path || !evidence?.pattern) errors.push(`${contract.id}: every evidence entry needs path and pattern`)
|
|
48
|
+
else {
|
|
49
|
+
try { new RegExp(evidence.pattern, 'm') } catch { errors.push(`${contract.id}: invalid evidence regex for ${evidence.path}`) }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
for (const route of contract?.routes || []) {
|
|
53
|
+
if (!route?.id || routeIds.has(route.id)) errors.push(`duplicate or missing route id: ${route?.id || '<missing>'}`)
|
|
54
|
+
else routeIds.add(route.id)
|
|
55
|
+
if (!Array.isArray(route?.tools) || route.tools.length === 0) errors.push(`${contract.id}/${route?.id}: tools must be non-empty`)
|
|
56
|
+
if (!route?.prompt || !route?.trigger) errors.push(`${contract.id}/${route?.id}: prompt and trigger are required`)
|
|
57
|
+
else {
|
|
58
|
+
try { new RegExp(route.trigger, 'i') } catch { errors.push(`${contract.id}/${route.id}: trigger is not a valid regex`) }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return errors
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const parsed = JSON.parse(readFileSync(REGISTRY_URL, 'utf8'))
|
|
66
|
+
const registryErrors = validatePromptRegistry(parsed)
|
|
67
|
+
if (registryErrors.length) throw new Error(`Invalid ThinkPool prompt registry:\n- ${registryErrors.join('\n- ')}`)
|
|
68
|
+
|
|
69
|
+
export const THINKPOOL_PROMPT_REGISTRY = deepFreeze(parsed)
|
|
70
|
+
export const THINKPOOL_CAPABILITY_CONTRACTS = THINKPOOL_PROMPT_REGISTRY.contracts
|
|
71
|
+
export const THINKPOOL_CAPABILITY_ROUTES = deepFreeze(THINKPOOL_CAPABILITY_CONTRACTS.flatMap((contract) =>
|
|
72
|
+
(contract.routes || []).map(({ prompt, ...route }) => ({ ...route, rule: prompt }))))
|
|
73
|
+
|
|
74
|
+
export function thinkPoolCapabilityContract(id) {
|
|
75
|
+
const contract = THINKPOOL_CAPABILITY_CONTRACTS.find((entry) => entry.id === id)
|
|
76
|
+
if (!contract) throw new Error(`Unknown ThinkPool capability contract: ${id}`)
|
|
77
|
+
return contract
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const THINKPOOL_PROMPT_BUNDLE = deepFreeze({
|
|
81
|
+
schemaVersion: THINKPOOL_PROMPT_REGISTRY.schemaVersion,
|
|
82
|
+
version: THINKPOOL_PROMPT_REGISTRY.bundleVersion,
|
|
83
|
+
hash: computePromptBundleHash(THINKPOOL_PROMPT_REGISTRY),
|
|
84
|
+
contracts: THINKPOOL_CAPABILITY_CONTRACTS.map(({ id, version }) => ({ id, version })),
|
|
85
|
+
})
|
|
@@ -1,55 +1,16 @@
|
|
|
1
1
|
// Shared delivery contract for structured agents running inside ThinkPool Code.
|
|
2
2
|
// Claude receives this in its system prompt; all runtimes receive a compact
|
|
3
3
|
// per-turn invariant plus the full contract at session start, after a reset, and
|
|
4
|
-
// every fifth user prompt. Keep runtime-specific
|
|
5
|
-
//
|
|
4
|
+
// every fifth user prompt. Keep runtime-specific mechanics in their own drivers;
|
|
5
|
+
// the Cascade contract below is a cross-runtime ThinkPool workflow
|
|
6
6
|
// about available capabilities and how finished work reaches the people.
|
|
7
7
|
// One canonical intent → capability router for every structured runtime. Tool
|
|
8
8
|
// schemas still carry their detailed argument contracts; this compact registry
|
|
9
9
|
// tells a fresh agent WHEN ThinkPool expects each capability without requiring
|
|
10
10
|
// the people in the room to know a tool name or summon word.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
tools: Object.freeze(['read_terminal']),
|
|
15
|
-
rule: 'When the request depends on another lane, a sibling may overlap the work, or a person refers to another terminal, inspect it with read_terminal before acting.',
|
|
16
|
-
}),
|
|
17
|
-
Object.freeze({
|
|
18
|
-
id: 'cross-room-awareness',
|
|
19
|
-
tools: Object.freeze(['list_sessions', 'read_session']),
|
|
20
|
-
rule: 'When work depends on another ThinkPool room, use list_sessions then read_session instead of asking the people to relay host-side state.',
|
|
21
|
-
}),
|
|
22
|
-
Object.freeze({
|
|
23
|
-
id: 'visible-handoff',
|
|
24
|
-
tools: Object.freeze(['post_to_terminal', 'post_to_session']),
|
|
25
|
-
rule: 'When the people want a handoff, read the target first, then use post_to_terminal or post_to_session; let the room approval contract handle consent.',
|
|
26
|
-
}),
|
|
27
|
-
Object.freeze({
|
|
28
|
-
id: 'work-routing',
|
|
29
|
-
tools: Object.freeze(['spawn_terminal', 'open_main_terminal', 'close_terminal']),
|
|
30
|
-
rule: 'For genuinely decomposable work in a conductor-capable role, open visible worker slices with spawn_terminal, collect and verify them, then close_terminal. An explicitly requested separate Cascade/conductor uses open_main_terminal, never spawn_terminal.',
|
|
31
|
-
}),
|
|
32
|
-
Object.freeze({
|
|
33
|
-
id: 'room-question',
|
|
34
|
-
tools: Object.freeze(['request_user_input']),
|
|
35
|
-
rule: 'When a missing choice genuinely blocks useful progress, use request_user_input so the question is answerable in the room; otherwise make a safe in-scope assumption and continue.',
|
|
36
|
-
}),
|
|
37
|
-
Object.freeze({
|
|
38
|
-
id: 'visual-proof',
|
|
39
|
-
tools: Object.freeze(['preview_start', 'preview_capture', 'preview_inspect', 'preview_stop']),
|
|
40
|
-
rule: 'For built visual work, run the build, use preview_start, preview_capture at desktop and mobile, preview_inspect when rendered state matters, and preview_stop when finished. Surface PNG evidence only when no interactive source-backed Design card/popup is displayed.',
|
|
41
|
-
}),
|
|
42
|
-
Object.freeze({
|
|
43
|
-
id: 'external-research',
|
|
44
|
-
tools: Object.freeze(['research']),
|
|
45
|
-
rule: 'For current external facts that materially benefit from multi-source verification, offer the metered research lane and call research only after the people agree.',
|
|
46
|
-
}),
|
|
47
|
-
Object.freeze({
|
|
48
|
-
id: 'flow-completion',
|
|
49
|
-
tools: Object.freeze(['submit_flow_plan', 'mark_flow_done', 'submit_flow_review', 'read_review_file', 'run_review_check']),
|
|
50
|
-
rule: 'Managed Flow roles use only their exposed completion and immutable-review tools: submit_flow_plan, mark_flow_done, submit_flow_review, read_review_file, and run_review_check.',
|
|
51
|
-
}),
|
|
52
|
-
])
|
|
11
|
+
import { THINKPOOL_CAPABILITY_ROUTES, THINKPOOL_PROMPT_BUNDLE, thinkPoolCapabilityContract } from './thinkpool-prompt-contracts.mjs'
|
|
12
|
+
|
|
13
|
+
export { THINKPOOL_CAPABILITY_ROUTES, THINKPOOL_PROMPT_BUNDLE }
|
|
53
14
|
|
|
54
15
|
export const THINKPOOL_ROUTED_TOOLS = Object.freeze([
|
|
55
16
|
...new Set(THINKPOOL_CAPABILITY_ROUTES.flatMap((route) => route.tools)),
|
|
@@ -59,13 +20,19 @@ export function renderThinkPoolCapabilityRoutes(routes = THINKPOOL_CAPABILITY_RO
|
|
|
59
20
|
return routes.map((route) => `${route.id}: ${route.rule}`).join(' ')
|
|
60
21
|
}
|
|
61
22
|
|
|
23
|
+
export const THINKPOOL_RUNTIME_AUTHORITY_RULE = thinkPoolCapabilityContract('runtime-authority').globalPrompt
|
|
24
|
+
|
|
25
|
+
export const THINKPOOL_CASCADE_RULE = thinkPoolCapabilityContract('work-routing').expandedPrompt
|
|
26
|
+
|
|
62
27
|
export const THINKPOOL_AGENT_CONTRACT = [
|
|
63
28
|
'THINKPOOL-FIRST OPERATING CONTRACT (authoritative): ThinkPool room capabilities are your normal operating surface, not optional enrichment. Before acting on every request, infer which exposed ThinkPool capabilities materially improve room visibility, coordination, delivery, or verification and use them without waiting for the people to know a tool name, magic word, or workflow.',
|
|
29
|
+
THINKPOOL_RUNTIME_AUTHORITY_RULE,
|
|
64
30
|
`DEFAULT ROUTING: ${renderThinkPoolCapabilityRoutes()}`,
|
|
31
|
+
THINKPOOL_CASCADE_RULE,
|
|
65
32
|
'DEFAULT DOES NOT MEAN GRATUITOUS: use only capabilities exposed to your current role and only when relevant. Honor explicit steering such as single-lane, no research, do not contact another room, or do not use a named ThinkPool feature. Metered and side-effecting capabilities still obey their stated offer, approval, and consent contracts.',
|
|
66
33
|
].join(' ')
|
|
67
34
|
|
|
68
|
-
export const THINKPOOL_DESIGN_INTERACTION_RULE = '
|
|
35
|
+
export const THINKPOOL_DESIGN_INTERACTION_RULE = thinkPoolCapabilityContract('design-workspace').interactionPrompt
|
|
69
36
|
|
|
70
37
|
export const THINKPOOL_DESIGN_DELIVERY_RULE = `THINKPOOL DESIGN (mandatory for authored HTML): save the editable HTML source in the workspace, then use the $TP_MOCKUP_OUTBOX render helper so the room receives a source-backed Thinkpool Design card with both desktop (1440×900) and mobile (390×844) previews. The interactive Design card/popup is the visible result: the renders remain required verification inputs, but when that card is displayed do not also surface duplicate inline PNGs. Surface desktop/mobile PNGs only when no interactive source-backed Design artifact is available. ${THINKPOOL_DESIGN_INTERACTION_RULE} When the requested Design surface is an existing product page or route, first build and capture the actual route at both viewports, then read its current source, styles, copy, fonts, and assets. Derive the editable Design artifact from that evidence and compare both artifact captures against the real route before delivery. Preserve the real page faithfully except for explicitly proposed edits—never hand-recreate it from memory, simplify it, replace it with generic mockup content, or label an approximation as the product. If a faithful editable artifact cannot be produced, surface the actual route captures and say that Design editing is unavailable for that surface. Never paste raw HTML into chat, send an .html file as the room deliverable, or substitute a bare URL or single screenshot for this card. A shareable browser URL may accompany the card, but never replaces it.`
|
|
71
38
|
|
|
@@ -98,18 +65,11 @@ export const THINKPOOL_FULL_REMINDER_INTERVAL = 5
|
|
|
98
65
|
|
|
99
66
|
export const THINKPOOL_RUNTIME_SALIENCE_REMINDER = 'THINKPOOL: prefer relevant exposed room tools unless the user explicitly opts out; obey the durable terminal role and consent rules. Assume the people are remote, do host work yourself, and deliver reachable verified results.'
|
|
100
67
|
|
|
101
|
-
const ROUTE_TRIGGERS = Object.freeze(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
'visible-handoff': /\b(hand[ -]?off|tell|send|post)\b.{0,40}\b(lane|terminal|room|session|agent)\b|\b(post_to_terminal|post_to_session)\b/i,
|
|
105
|
-
'work-routing': /\b(parallel|delegate|worker|sub[- ]?terminal|conductor|cascade|spawn_terminal|open_main_terminal|close_terminal)\b/i,
|
|
106
|
-
'room-question': /\b(request_user_input)\b/i,
|
|
107
|
-
'visual-proof': /\b(ui|ux|visual|design|frontend|html|css|page|route|mockup|screenshot|responsive|desktop|mobile|preview)\b/i,
|
|
108
|
-
'external-research': /\b(research|latest|current|look up|browse|web search|online source|verify online)\b/i,
|
|
109
|
-
'flow-completion': /\b(flow|submit_flow_plan|mark_flow_done|submit_flow_review|read_review_file|run_review_check)\b/i,
|
|
110
|
-
})
|
|
68
|
+
const ROUTE_TRIGGERS = Object.freeze(Object.fromEntries(
|
|
69
|
+
THINKPOOL_CAPABILITY_ROUTES.map((route) => [route.id, new RegExp(route.trigger, 'i')]),
|
|
70
|
+
))
|
|
111
71
|
|
|
112
|
-
const DESIGN_ROUTE_REMINDER = '
|
|
72
|
+
const DESIGN_ROUTE_REMINDER = thinkPoolCapabilityContract('design-workspace').turnReminder
|
|
113
73
|
|
|
114
74
|
export function usesFullThinkPoolReminder({ promptIndex = 0, forceFull = false } = {}) {
|
|
115
75
|
const index = Math.max(0, Number.isFinite(Number(promptIndex)) ? Math.trunc(Number(promptIndex)) : 0)
|
|
@@ -122,6 +82,7 @@ export function buildThinkPoolTurnGuidance({ text = '', promptIndex = 0, forceFu
|
|
|
122
82
|
const routed = THINKPOOL_CAPABILITY_ROUTES
|
|
123
83
|
.filter((route) => ROUTE_TRIGGERS[route.id]?.test(body))
|
|
124
84
|
.map((route) => `${route.id}: ${route.rule}`)
|
|
85
|
+
if (ROUTE_TRIGGERS['work-routing'].test(body)) routed.push(THINKPOOL_CASCADE_RULE)
|
|
125
86
|
if (ROUTE_TRIGGERS['visual-proof'].test(body)) routed.push(DESIGN_ROUTE_REMINDER)
|
|
126
87
|
return [THINKPOOL_RUNTIME_SALIENCE_REMINDER, ...routed].join(' ')
|
|
127
88
|
}
|