( metadata: WorkspaceMetadata, runtime: Runtime, workspacePath: string, modelString: string, agentInstructions?: readonly string[] )
| 289 | * @returns Map of tool names to their additional instructions |
| 290 | */ |
| 291 | export async function readToolInstructions( |
| 292 | metadata: WorkspaceMetadata, |
| 293 | runtime: Runtime, |
| 294 | workspacePath: string, |
| 295 | modelString: string, |
| 296 | agentInstructions?: readonly string[] |
| 297 | ): Promise<Record<string, string>> { |
| 298 | // Tool instructions read the same `AGENTS.md` files as the system prompt; |
| 299 | // anchor at the workspace root so sub-project workspaces still see parent |
| 300 | // project tool sections (see `loadInstructionSources` doc). |
| 301 | const workspaceRootPath = subProjectAwareWorkspaceRoot(metadata, runtime, workspacePath); |
| 302 | const sources = await loadInstructionSources(metadata, runtime, workspaceRootPath); |
| 303 | const globalContents = collectInstructionContents([sources.global]); |
| 304 | const contextContents = collectInstructionContents(sources.context); |
| 305 | |
| 306 | return extractToolInstructions(globalContents, contextContents, modelString, { |
| 307 | ...getToolAvailabilityOptions({ |
| 308 | workspaceId: metadata.id, |
| 309 | parentWorkspaceId: metadata.parentWorkspaceId, |
| 310 | }), |
| 311 | agentInstructions, |
| 312 | }); |
| 313 | } |
| 314 | |
| 315 | /** |
| 316 | * For sub-project workspaces, callers typically pass the execution path |
no test coverage detected