The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | /** Session-invariant; harnesses with a native system-prompt append can carry it once per session. */ |
| 2 | export const PULL_REQUEST_LINKING_INSTRUCTIONS = `<pull_request_linking> |
| 3 | Link each PR you create, take over, or push to: link_pull_request, or link_pull_requests for several, full URL, every stack layer, as your next call. Host tools don't link for you. If linking fails, say so. Skip PRs you only read or review and PRs named only as background. Call watch_pull_request when asked to monitor or babysit, or when work you were asked to do, such as a merge, still waits on checks or reviews, even after an earlier unwatch. Finish any needed branch update and push first, then watch and end your turn. Otherwise act now or hand back. Delegated children never watch, even if the brief says babysit. After PR work, a child's last line is: PR <full URL>, head <SHA>, checks and reviews <state>. Links and watches persist across pushes. For PR waits, no sleep, loops, gh --watch, Monitor or ScheduleWakeup. Before handback, call unwatch_pull_request on any PR you watch. When pull_request_* tools are listed, use them, not gh or cafe, to read, list, open, edit, review, reply on, close, or merge PRs, and ci_logs and ci_rerun for their checks. pull_request_create links for you. |
| 4 | If available, call link_issue for each issue you take on or file, even via CLI; skip issues you only read. |
| 5 | </pull_request_linking>`; |
| 6 | |
| 7 | /** Omit model and effort when the harness manages them dynamically. */ |
| 8 | export function buildRuntimeInstructions(runtime: { |
| 9 | readonly harness: string; |
| 10 | readonly model?: string | undefined; |
| 11 | readonly modelName?: string | undefined; |
| 12 | readonly reasoningEffort?: string | undefined; |
| 13 | /** False when the session's system prompt already carries the linking instructions. */ |
| 14 | readonly pullRequestLinking?: boolean; |
| 15 | }): string { |
| 16 | const harness = toSingleLine(runtime.harness); |
| 17 | const model = toSingleLine(runtime.model ?? ""); |
| 18 | const modelName = toSingleLine(runtime.modelName ?? ""); |
| 19 | const effort = toSingleLine(runtime.reasoningEffort ?? ""); |
| 20 | const modelLabel = |
| 21 | modelName && modelName !== model ? `${modelName} (model slug: ${model})` : model; |
| 22 | const modelInfo = model && model !== "auto" && model !== "default" ? `, as ${modelLabel}` : ""; |
| 23 | const effortInfo = effort ? ` with ${effort} reasoning effort` : ""; |
| 24 | const runtimeInfo = `<runtime_info>In case you're asked: you are running in T3 Code through the ${harness} harness${modelInfo}${effortInfo}. No need to mention this otherwise. You can embed images, video, and audio using Markdown image syntax with absolute file paths. Link every other file you cite or produce by its absolute path, as in [http.ts:42](/abs/path/http.ts:42), so the user can open it in T3 Code's files viewer.</runtime_info>`; |
| 25 | return runtime.pullRequestLinking === false |
| 26 | ? runtimeInfo |
| 27 | : `${runtimeInfo}\n\n${PULL_REQUEST_LINKING_INSTRUCTIONS}`; |
| 28 | } |
| 29 | |
| 30 | function toSingleLine(value: string): string { |
| 31 | return value.replaceAll(/\s+/g, " ").trim(); |
| 32 | } |