dev_prune/constants.rs
1// Copyright 2026 VKrishna04
2// SPDX-License-Identifier: Apache-2.0
3
4// Centralized application constants and default configurations.
5//
6// Serves as the single source of truth for app metadata, versioning,
7// default thresholds, and file paths.
8
9/// Application crate version derived dynamically from `Cargo.toml`.
10pub const VERSION: &str = env!("CARGO_PKG_VERSION");
11
12/// Application name.
13pub const APP_NAME: &str = "dev-prune";
14
15/// Default idle threshold in days before a repository is eligible for pruning.
16pub const DEFAULT_IDLE_DAYS: u64 = 15;
17
18/// Default interval in days between background daemon prune runs.
19pub const DEFAULT_CHECK_INTERVAL_DAYS: u64 = 2;
20
21/// Whether the setup pass installs the OS scheduler.
22///
23/// On. A pruner that has to be remembered is a pruner that never runs; the scheduled
24/// pass is the product, not an extra. It is still bounded by everything an interactive
25/// run is bounded by — idle threshold, lockfile verification, per-repo opt-outs — and
26/// `devp daemon uninstall` (or `devp config set auto_daemon false`) removes it.
27pub const DEFAULT_AUTO_DAEMON: bool = true;
28
29/// Whether the setup pass installs the global Git auto-registration hooks.
30///
31/// On, but conditionally: installation is skipped, not forced, when `core.hooksPath`
32/// already belongs to husky, pre-commit or lefthook.
33pub const DEFAULT_AUTO_HOOKS: bool = true;
34
35/// Whether dev-prune installs its missing integrations by itself.
36///
37/// On. The pass runs once per installed version — on first run, and again after an
38/// upgrade — and only creates what is absent. Set to `false`, or export
39/// `DEV_PRUNE_NO_AUTO_SETUP`, to manage the integrations entirely by hand.
40pub const DEFAULT_AUTO_SETUP: bool = true;
41
42/// Default setting for requiring interactive confirmation before pruning.
43pub const DEFAULT_REQUIRE_CONFIRMATION: bool = true;
44
45/// Default size floor, in MiB, below which a bloat directory is left alone.
46///
47/// Zero — every recognised directory is a candidate. Raising it trades a little disk
48/// space for fewer reinstalls: deleting a 3 MiB `node_modules` costs a full `npm ci`
49/// and reclaims almost nothing.
50pub const DEFAULT_MIN_SIZE_MB: u64 = 0;
51
52/// How far below a repository root project discovery descends, by default.
53///
54/// Six covers `packages/scope/name/…` monorepo layouts with room to spare while keeping
55/// the walk bounded on repositories with deep source trees. Configurable with
56/// `devp config set scan_depth`, and per repository with `"scan_depth"` in
57/// `.devprune.json`, because "deep enough" is a property of the layout, not of the tool.
58pub const DEFAULT_SCAN_DEPTH: usize = 6;
59
60/// Upper bound accepted for `scan_depth`.
61///
62/// Not a matter of taste. The walk is breadth-first over every directory that is not
63/// excluded, so cost grows with the tree, and a repository with a deep generated tree
64/// (a Bazel `bazel-out`, a `.terraform` provider cache) can turn an unbounded walk into
65/// a multi-minute stall on a background pass nobody is watching.
66pub const MAX_SCAN_DEPTH_LIMIT: usize = 32;
67
68/// Whether an adapter whose sync command edits tracked manifests may run it.
69///
70/// Off. `cargo generate-lockfile` re-resolves every dependency and rewrites
71/// `Cargo.lock`; `go mod tidy` edits `go.mod` and `go.sum` and can drop requirements.
72/// A cleanup tool that silently changes files Git tracks has done something the user
73/// did not ask for, so these run read-only and this switch is the informed opt-in.
74pub const DEFAULT_ALLOW_MANIFEST_REWRITE: bool = false;
75
76/// Whether the setup pass installs the Git hooks in front of another tool's.
77///
78/// Off. Chaining is behaviour-preserving — every hook is forwarded on and
79/// `devp hook uninstall` restores the original `core.hooksPath` — but it still rewires
80/// somebody else's Git configuration, which is not a thing to do unasked. Turn it on
81/// with `devp config set auto_hooks_chain true`, or do it once with
82/// `devp hook install --chain`.
83pub const DEFAULT_AUTO_HOOKS_CHAIN: bool = false;
84
85/// GitHub releases page, shown whenever an upgrade is relevant.
86pub const RELEASES_URL: &str = "https://github.com/Life-Experimentalist/dev-prune/releases";
87
88/// GitHub API endpoint for the latest published release.
89///
90/// Contacted only by `devp update --check`, never on any other code path. See the
91/// network policy in `docs/PRIVACY.md`.
92pub const LATEST_RELEASE_API_URL: &str =
93 "https://api.github.com/repos/Life-Experimentalist/dev-prune/releases/latest";
94
95/// Whether the periodic release check runs. On by default — see `Settings::update_check`.
96pub const DEFAULT_UPDATE_CHECK: bool = true;
97
98/// Default interval, in days, between automatic release checks.
99///
100/// A week. Frequent enough that a security fix is not missed for long, rare enough that
101/// it is invisible in day-to-day use. Override with
102/// `devp config set update_check_interval_days`.
103pub const UPDATE_CHECK_INTERVAL_DAYS: i64 = 7;
104
105/// Default timeout for the release check. Short on purpose — this is a convenience,
106/// and a user waiting on a hung socket is worse than not knowing. Override with
107/// `devp config set update_check_timeout_secs` when a proxy needs longer.
108pub const UPDATE_CHECK_TIMEOUT_SECS: u64 = 5;
109
110/// Name of the registry JSON file.
111pub const REGISTRY_FILENAME: &str = "registry.json";
112
113/// Config directory name under user config root.
114pub const CONFIG_DIR_NAME: &str = "dev-prune";
115
116/// Global environment variable name to override config directory location.
117pub const ENV_CONFIG_DIR_OVERRIDE: &str = "DEV_PRUNE_CONFIG_DIR";
118
119/// Filename that, when present in a repo root, causes dev-prune to skip that repo entirely.
120///
121/// Create this file with: `touch ignore.devprune.json`
122pub const DEVPRUNE_IGNORE_FILE: &str = "ignore.devprune.json";
123
124/// Default timeout in seconds for lockfile enforcement / CLI commands (10 minutes).
125pub const DEFAULT_COMMAND_TIMEOUT_SECS: u64 = 600;
126
127/// Timeout for the "where does your cache live?" queries `devp caches` makes.
128///
129/// Deliberately not `command_timeout_secs`. That ceiling is sized for `npm ci` and
130/// `cargo metadata`; `npm config get cache` prints one line and returns. A query that
131/// has not answered in five seconds is a broken installation, and the report is better
132/// off falling back to the conventional path than waiting ten minutes for it.
133pub const CACHE_QUERY_TIMEOUT_SECS: u64 = 5;
134
135/// Documentation URL for troubleshooting lockfile and pruning failures.
136pub const TROUBLESHOOTING_URL: &str = "https://devprune.vkrishna04.me/docs/troubleshooting";
137/// Name of the structured per-repository configuration file stored inside repo roots.
138pub const PER_REPO_CONFIG_FILE: &str = ".devprune.json";
139
140/// Public URL for the JSON Schema used by IDEs for .devprune.json IntelliSense.
141pub const JSON_SCHEMA_URL: &str = "https://devprune.vkrishna04.me/schemas/v1/devprune.schema.json";