Write the initial global_settings.yml with comment hints and env examples. Only used by `ccc init` on first-time setup. Emits only the `embedding:` block from the input; the `envs:` section is a commented-out template. Subsequent programmatic writes use `save_user_settings` and do not
(
embedding: EmbeddingSettings,
defaults_applied: bool,
)
| 558 | |
| 559 | |
| 560 | def save_initial_user_settings( |
| 561 | embedding: EmbeddingSettings, |
| 562 | defaults_applied: bool, |
| 563 | ) -> Path: |
| 564 | """Write the initial global_settings.yml with comment hints and env examples. |
| 565 | |
| 566 | Only used by `ccc init` on first-time setup. Emits only the `embedding:` |
| 567 | block from the input; the `envs:` section is a commented-out template. |
| 568 | Subsequent programmatic writes use `save_user_settings` and do not |
| 569 | preserve comments. |
| 570 | |
| 571 | When ``defaults_applied`` is False, a provider-specific commented-out |
| 572 | template for ``indexing_params`` / ``query_params`` is inserted under the |
| 573 | ``embedding:`` block so the user sees the fields exist. |
| 574 | """ |
| 575 | emb_block = _yaml.safe_dump( |
| 576 | {"embedding": _embedding_settings_to_dict(embedding)}, |
| 577 | default_flow_style=False, |
| 578 | sort_keys=False, |
| 579 | ) |
| 580 | content = _INITIAL_HEADER + emb_block |
| 581 | if not defaults_applied: |
| 582 | hint = _PARAMS_COMMENT_BY_PROVIDER.get(embedding.provider) |
| 583 | if hint is not None: |
| 584 | content += hint |
| 585 | content += _INITIAL_ENVS_COMMENT |
| 586 | |
| 587 | path = user_settings_path() |
| 588 | path.parent.mkdir(parents=True, exist_ok=True) |
| 589 | path.write_text(content) |
| 590 | return path |
| 591 | |
| 592 | |
| 593 | def load_project_settings(project_root: Path) -> ProjectSettings: |