| 1023 | 1023 | | const TRAILER = "Add the trailer `G1t-Session: $G1T_SESSION` to the commits you make (git commit --trailer), so g1t ties them to this session. A commit pushed straight to the default branch that finishes an issue says `Closes #N` in its message: a bare `(#N)` only links it, and the issue stays open."; |
| 1024 | 1024 | | |
| 1025 | 1025 | | /** |
| 1026 | + | * How the agent keeps its session's title true: it starts as the first |
| 1027 | + | * prompt's intent, which often stops being what the session is about. |
| 1028 | + | */ |
| 1029 | + | export const RETITLE = 'Its title starts as your first prompt; once what you are actually doing is clear, and whenever it changes, retitle it in a few words with `g1t session attach --title "…"`.'; |
| 1030 | + | |
| 1031 | + | /** |
| 1032 | + | * At which prompts the agent is reminded to retitle: the second (what the |
| 1033 | + | * work is has usually shown by then) and every fifth after. |
| 1034 | + | */ |
| 1035 | + | export function retitleNudge(turn) { |
| 1036 | + | return turn === 2 || (turn > 2 && turn % 5 === 0) ? `g1t: if this session's title no longer says what it is doing, retitle it: \`g1t session attach --title "…"\`.` : null; |
| 1037 | + | } |
| 1038 | + | |
| 1039 | + | /** |
| 1026 | 1040 | | * SessionStart: marks the session as one in a g1t working copy, and |
| 1027 | 1041 | | * returns what to print: context for Claude, and a notice for you, once. |
| 1028 | 1042 | | * Null outside a g1t working copy, where nothing is recorded. |
| ⋯ |
| 1063 | 1077 | | context = `g1t: ${where} points at issue #${issue}. Load what is known about it with \`g1t work context ${issue}\`, and claim it with \`g1t work claim ${issue}\` before you start. ${TRAILER}`; |
| 1064 | 1078 | | } |
| 1065 | 1079 | | } else { |
| 1066 | | − | context = `g1t: this session is recorded on g1t and shows to the team, titled with what you are asked to do. Just work. If it turns into a change others should know about (a branch to push, a pull request), first look for its issue (\`g1t work list\`, \`g1t issue list\`) and claim it with \`g1t work claim N\`; if there is none, open and claim one with \`g1t work claim --title "…"\`. Never open issues for questions, exploration or trivial fixes. ${TRAILER}`; |
| 1080 | + | context = `g1t: this session is recorded on g1t and shows to the team, titled with what you are asked to do. Just work. If it turns into a change others should know about (a branch to push, a pull request), first look for its issue (\`g1t work list\`, \`g1t issue list\`) and claim it with \`g1t work claim N\`; if there is none, open and claim one with \`g1t work claim --title "…"\`. Never open issues for questions, exploration or trivial fixes. ${RETITLE} ${TRAILER}`; |
| 1067 | 1081 | | } |
| 1068 | 1082 | | if (context) output.hookSpecificOutput = { hookEventName: "SessionStart", additionalContext: context }; |
| 1069 | 1083 | | return output; |
| ⋯ |
| 1236 | 1250 | | return { output: { hookSpecificOutput: { hookEventName: "SubagentStart", additionalContext: subagentContext(issue) } }, job }; |
| 1237 | 1251 | | } |
| 1238 | 1252 | | const notice = late?.output.systemMessage ?? (name === "UserPromptSubmit" ? takeNotice(env) : null); |
| 1239 | | − | const context = [late?.output.hookSpecificOutput?.additionalContext, name === "UserPromptSubmit" ? updateContext(event, env) : null] |
| 1253 | + | const context = [ |
| 1254 | + | late?.output.hookSpecificOutput?.additionalContext, |
| 1255 | + | name === "UserPromptSubmit" ? updateContext(event, env) : null, |
| 1256 | + | // Only while it is being recorded: not with the CLI signed out or too old. |
| 1257 | + | name === "UserPromptSubmit" && !readJson(join(dataDir(env), "notice.json"), {}).problem ? retitleNudge(turn) : null, |
| 1258 | + | ] |
| 1240 | 1259 | | .filter(Boolean) |
| 1241 | 1260 | | .join("\n\n"); |
| 1242 | 1261 | | return { output: context || notice ? { |