MCPcopy Create free account
hub / github.com/Noumena-Network/code / getPlanModeExitAttachment

Function getPlanModeExitAttachment

src/utils/attachments.ts:1250–1279  ·  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

1248 * This is a one-time notification to tell the model it's no longer in plan mode.
1249 */
1250async function getPlanModeExitAttachment(
1251 toolUseContext: ToolUseContext,
1252): Promise<Attachment[]> {
1253 // Only trigger if the flag is set (we just exited plan mode)
1254 if (!needsPlanModeExitAttachment()) {
1255 return []
1256 }
1257
1258 const appState = toolUseContext.getAppState()
1259 if (appState.toolPermissionContext.mode === 'plan') {
1260 setNeedsPlanModeExitAttachment(false)
1261 return []
1262 }
1263
1264 // Clear the flag - this is a one-time notification
1265 setNeedsPlanModeExitAttachment(false)
1266
1267 const planFilePath = getPlanFilePath(toolUseContext.agentId)
1268 const planExists = getPlan(toolUseContext.agentId) !== null
1269
1270 const verificationInstruction = isEnvTruthy(process.env.CLAUDE_CODE_VERIFY_PLAN)
1271 ? '\n\nWhen you have finished implementing the plan, you MUST call the "VerifyPlanExecution" tool directly to trigger background verification.'
1272 : undefined
1273
1274 // Note: skill discovery does NOT fire on plan exit. By the time the plan is
1275 // written, it's too late — the model should have had relevant skills WHILE
1276 // planning. The user_message signal already fires on the request that
1277 // triggers planning ("plan how to deploy this"), which is the right moment.
1278 return [{ type: 'plan_mode_exit', planFilePath, planExists, verificationInstruction }]
1279}
1280
1281function getAutoModeAttachmentTurnCount(messages: Message[]): {
1282 turnCount: number

Callers 1

getAttachmentsFunction · 0.85

Calls 5

isEnvTruthyFunction · 0.90
getPlanFilePathFunction · 0.85
getPlanFunction · 0.85

Tested by

no test coverage detected