Write a generated client extension module into `path` as a managed block. * * The module is generated from the tool registry rather than shipped (see * src/cli/client_adapter.h), and it goes in as a MARKED BLOCK rather than a * whole-file write: the directory is auto-loaded by the client, so a user may * legitimately keep their own module there, and clobbering it would be the * install routi
| 9403 | * than a skip, because a silently absent extension is exactly the failure mode |
| 9404 | * that left #616 a no-op for six weeks. */ |
| 9405 | static void install_generated_client_extension(const char *label, const char *path, |
| 9406 | const char *binary_path, |
| 9407 | char *(*generate)(const char *), bool dry_run) { |
| 9408 | if (g_install_plan) { |
| 9409 | plan_record(label, "extension", path); |
| 9410 | return; |
| 9411 | } |
| 9412 | char *content = generate(binary_path); |
| 9413 | if (!content) { |
| 9414 | record_agent_config_error(false, label, "extension_generate", path); |
| 9415 | return; |
| 9416 | } |
| 9417 | bool installed = true; |
| 9418 | if (!dry_run && (!prepare_config_parent(path) || |
| 9419 | cbm_text_upsert_managed_block(path, CBM_ADAPTER_MARKER_START, |
| 9420 | CBM_ADAPTER_MARKER_END, content) != 0)) { |
| 9421 | installed = false; |
| 9422 | record_agent_config_error(false, label, "extension_install", path); |
| 9423 | } |
| 9424 | free(content); |
| 9425 | if (installed) { |
| 9426 | printf(" extension: %s\n", path); |
| 9427 | } |
| 9428 | } |
| 9429 | |
| 9430 | /* Remove only OUR marked block, never the file: a user's own module may share |
| 9431 | * it, and owned removal is the convention every other uninstall path here |
no test coverage detected