MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / getPlanModeExitAttachment

Function getPlanModeExitAttachment

src/utils/attachments.ts:1302–1327  ·  view source on GitHub ↗

* Returns a plan_mode_exit attachment if we just exited plan mode. * This is a one-time notification to tell the model it's no longer in plan mode.

(
  toolUseContext: ToolUseContext,
)

Source from the content-addressed store, hash-verified

1300 * This is a one-time notification to tell the model it's no longer in plan mode.
1301 */
1302async function getPlanModeExitAttachment(
1303 toolUseContext: ToolUseContext,
1304): Promise<Attachment[]> {
1305 // Only trigger if the flag is set (we just exited plan mode)
1306 if (!needsPlanModeExitAttachment()) {
1307 return []
1308 }
1309
1310 const appState = toolUseContext.getAppState()
1311 if (appState.toolPermissionContext.mode === 'plan') {
1312 setNeedsPlanModeExitAttachment(false)
1313 return []
1314 }
1315
1316 // Clear the flag - this is a one-time notification
1317 setNeedsPlanModeExitAttachment(false)
1318
1319 const planFilePath = getPlanFilePath(toolUseContext.agentId)
1320 const planExists = getPlan(toolUseContext.agentId) !== null
1321
1322 // Note: skill discovery does NOT fire on plan exit. By the time the plan is
1323 // written, it's too late — the model should have had relevant skills WHILE
1324 // planning. The user_message signal already fires on the request that
1325 // triggers planning ("plan how to deploy this"), which is the right moment.
1326 return [{ type: 'plan_mode_exit', planFilePath, planExists }]
1327}
1328
1329function getAutoModeAttachmentTurnCount(messages: Message[]): {
1330 turnCount: number

Callers 1

getAttachmentsFunction · 0.85

Calls 4

getPlanFilePathFunction · 0.85
getPlanFunction · 0.85

Tested by

no test coverage detected