File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -176,4 +176,21 @@ describe("resolveAgentPluginProfiles", () => {
176176 ) ,
177177 ) . toBe ( true ) ;
178178 } ) ;
179+
180+ test ( "warns once when a prompt file is missing and still loads the profile" , async ( ) => {
181+ const { mod, config } = agentModule ( "p1" , [
182+ { id : "scout" , systemPromptPath : "prompts/does-not-exist.md" } ,
183+ ] ) ;
184+ mod . dir = "/tmp/wt-cl-6724-missing-prompt-dir" ;
185+ const warnings : string [ ] = [ ] ;
186+ const profiles = await resolveAgentPluginProfiles ( [ mod ] , config , ( msg ) =>
187+ warnings . push ( msg ) ,
188+ ) ;
189+ expect ( profiles . length ) . toBe ( 1 ) ;
190+ expect ( defined ( profiles [ 0 ] ) . systemPromptRole ) . toBeUndefined ( ) ;
191+ expect ( warnings . length ) . toBe ( 1 ) ;
192+ expect ( warnings [ 0 ] ) . toContain ( '"p1"' ) ;
193+ expect ( warnings [ 0 ] ) . toContain ( '"scout"' ) ;
194+ expect ( warnings [ 0 ] ) . toContain ( "prompts/does-not-exist.md" ) ;
195+ } ) ;
179196} ) ;
Original file line number Diff line number Diff line change @@ -90,14 +90,18 @@ export async function resolveAgentPluginProfiles(
9090 profile . systemPromptRole === undefined &&
9191 mod . dir !== undefined
9292 ) {
93+ const promptPath = join ( mod . dir , profile . systemPromptPath ) ;
9394 try {
94- const promptRaw = await readFile (
95- join ( mod . dir , profile . systemPromptPath ) ,
96- "utf8" ,
97- ) ;
95+ const promptRaw = await readFile ( promptPath , "utf8" ) ;
9896 profile . systemPromptRole = promptRaw . trim ( ) ;
99- } catch {
100- // Missing prompt file is non-fatal — the profile loads without a role.
97+ } catch ( err ) {
98+ const reason =
99+ ( err instanceof Error ? err . message : String ( err ) )
100+ . split ( "\n" ) [ 0 ]
101+ ?. trim ( ) || "unknown error" ;
102+ onWarning (
103+ `plugin "${ mod . manifest . id } " agent "${ profile . id } " systemPromptPath "${ profile . systemPromptPath } " unreadable (${ promptPath } ): ${ reason } ` ,
104+ ) ;
101105 }
102106 }
103107 // Provenance for search_agents: Claude marketplace installs stamp
You can’t perform that action at this time.
0 commit comments