feat: dynamic environment scaffolding and human-readable config parsing#56
Merged
JacksonFergusonDev merged 9 commits intomainfrom Feb 25, 2026
Merged
feat: dynamic environment scaffolding and human-readable config parsing#56JacksonFergusonDev merged 9 commits intomainfrom
JacksonFergusonDev merged 9 commits intomainfrom
Conversation
Extends the global configuration model to support customizable parameters for the `--env` bootstrap command. Introduces the `EnvConfig` dataclass to handle Python version targeting, virtual environment directory naming, and boolean flags for opting out of VS Code and direnv generation. This ensures the environment scaffolding is decoupled from hardcoded strings and can participate in the cascading TOML configuration hierarchy.
Updates `bootstrap_env` to load the active `Config` instance and utilize the new `EnvConfig` parameters. - Dynamically injects `config.env.python_version` into the `uv init` call. - Dynamically injects `config.env.venv_dir` into the `.envrc` and VS Code settings generation templates. - Wraps the direnv and VS Code generation blocks in conditionals based on the respective boolean flags in `EnvConfig`.
Injects a dynamic call to `add_ignore()` in the `--env` bootstrap sequence to automatically untrack the configured virtual environment directory (`config.env.venv_dir`). Additionally appends `".venv/"` to `DEFAULT_IGNORES` in `constants.py` as a fallback safety measure for standard repository initialization.
Refactors `test_bootstrap_env_scaffolds_files` to mock the active `Config` state rather than relying on hardcoded defaults. - Asserts that the dynamically assigned `venv_dir` is correctly injected into the generated `.envrc` and VS Code settings files. - Verifies that `add_ignore` is successfully called with the custom virtual environment directory path to prevent index bloat.
Introduces the `manage_gitignore` boolean flag in `FilesConfig` to allow users to opt out of automated `.gitignore` modifications. - Wraps the default ignore scaffolding in `cli.py`'s `setup_repo()` behind the flag constraint. - Conditionally bypasses the file write step in `ops.py`'s `add_ignore()` while preserving the index tracking checks. This ensures Git Pulsar operates non-destructively for power users who prefer strict, manual control over their repository ignore state.
Introduces `git pulsar config --list` to provide a zero-friction way to view the configuration schema directly in the terminal. - Renders a rich table containing all sections, keys, types, defaults, and descriptions. - Keeps the primary `git pulsar help` output clean by isolating the verbose configuration matrix to a specific subcommand flag.
Introduces flexible string parsing for configuration values, allowing users to define intervals (e.g., "10 min", "1 hr") and file limits (e.g., "100mb", "1.5gb") intuitively. - Adds `parse_size` and `parse_time` regex-based helper functions. - Refactors `_update_dataclass` to intercept updates, warn on unknown keys, and safely fall back to defaults if parsing fails. - Modifies the `.gitignore` parsing logic in `_merge_from_file` to cleanly separate list extension from dataclass field updates.
Introduces unit tests for the new `parse_time` and `parse_size` helpers to ensure human-readable formats and whitespace variations are correctly converted to operational integers. - Verifies conversion logic for bytes (KB, MB, GB) and seconds (s, m, h). - Implements strict `pytest.raises` matching to satisfy Ruff's PT011 rule and prevent false positives on generic ValueErrors. - Adds `test_config_invalid_keys_and_values` to verify the configuration engine successfully intercepts garbage data, logs targeted warnings, and preserves safe defaults without crashing.
Updates the `git pulsar config --list` output to accurately reflect the new parsing capabilities introduced in the configuration engine. - Changes type hints for interval and threshold settings to `int | str`. - Updates the displayed defaults to their human-readable equivalents (e.g., `"10m"`, `"100mb"`). - Expands descriptions to include syntax examples for the time and size parsers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR overhauls the configuration engine to provide a more flexible, user-friendly, and secure experience. It abstracts hardcoded environment variables into the configuration hierarchy, introduces human-readable string parsing for intervals/limits, and gives power users strict control over their
.gitignorefiles.Key Changes
1. Dynamic Environment Scaffolding (
--env)EnvConfigDataclass: Added toconfig.pyto exposepython_version,venv_dir,generate_vscode_settings, andgenerate_direnv.bootstrap_env: Replaced hardcoded strings ("3.12",".venv") with dynamic injections from the activeConfigpayload.2. Safety & Index Bloat Prevention
bootstrap_envnow dynamically injects the configuredvenv_dirinto.gitignoreupon creation to prevent the daemon from staging thousands of Python binaries into the shadow index.".venv/"toDEFAULT_IGNORESinconstants.pyfor standard repository initialization..gitignoreManagement: Added amanage_gitignoreboolean toFilesConfig. If set tofalse, the daemon will completely bypass writing to.gitignoreduringsetup_repoandadd_ignore, respecting user boundaries.3. Human-Readable Configuration & Validation
parse_time(e.g.,"10m","1 hr") andparse_size(e.g.,"100mb","1.5gb") toconfig.py.4. CLI Observability
--list(-l) flag to thegit pulsar configcommand. This renders a comprehensive Rich table outlining all configuration sections, keys, accepted types, defaults, and descriptions.Testing
test_ops.pyto mockConfigand assert dynamic directory injections.pytest.raises(ValueError, match=...)) totest_config.pyto validate byte/second conversions and ensure Ruff (PT011) compliance.