0
0
Fork 0

fix(add_library): wrapper message reflects dedup vs add branch

The wrapper at server.ts:1896 always rendered "Library 'X' added" even
when the script's dedup pre-check no-op'd because the same library was
already referenced. The script itself emits distinct markers
("Library Already Present:" vs "Library Added:"); the wrapper now
inspects result.output to pick wording instead of hardcoding "added".
This commit is contained in:
Karstein Phobic Nyvold Kvistad 2026-04-29 08:23:57 +02:00
parent 065bce5b3d
commit e94892233f

View file

@ -1970,12 +1970,14 @@ export async function startMcpServer(config: ServerConfig): Promise<void> {
['ensure_project_open']
);
const result = await executor.executeScript(script);
return await formatModifyingResponse(
result,
`Library '${args.libraryName}' added to ${args.projectFilePath}. Project saved.`,
escaped,
mirrorCtx
);
// Pick wording from the script's branch (dedup vs add) instead of
// always saying "added" -- script emits "Library Already Present"
// on the dedup no-op path and "Library Added" on actual add.
const dedupHit = result.output.includes('Library Already Present:');
const successMessage = dedupHit
? `Library '${args.libraryName}' already referenced in ${args.projectFilePath}. No-op (use force=true to add a duplicate).`
: `Library '${args.libraryName}' added to ${args.projectFilePath}. Project saved.`;
return await formatModifyingResponse(result, successMessage, escaped, mirrorCtx);
}
);