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/// Minimum supported Rust version, derived dynamically from `rust-version` in
13/// `Cargo.toml` — which is the single source of truth for the MSRV. Only `cargo
14/// install` users ever meet it; every other channel ships a prebuilt binary.
15pub const MSRV: &str = env!("CARGO_PKG_RUST_VERSION");
16
17/// Application name.
18pub const APP_NAME: &str = "dev-prune";
19
20/// Author of dev-prune.
21pub const AUTHOR: &str = "VKrishna04";
22
23/// Canonical source repository.
24///
25/// The one in `Cargo.toml` is only visible to people who already found the crate. This
26/// one is compiled into the binary, so a copy of the executable still says where it came
27/// from.
28pub const REPO_URL: &str = "https://github.com/Life-Experimentalist/dev-prune";
29
30/// Project homepage.
31pub const HOMEPAGE_URL: &str = "https://devprune.vkrishna04.me";
32
33/// The one-line credit printed under interactive output.
34///
35/// Deliberately plain text in plain sight: it is not obfuscated, not assembled at
36/// runtime, and not checked anywhere. Anyone may fork this project and change this line
37/// — the Apache-2.0 licence says so, and nothing in the code argues. It exists so that
38/// the common case, someone running the published binary, shows where it came from.
39pub const ATTRIBUTION_LINE: &str =
40 "dev-prune · made with ♥ by VKrishna04 · github.com/Life-Experimentalist/dev-prune";
41
42/// The body of `devp --version`.
43///
44/// Built at runtime rather than with `concat!`, which only takes literals and would mean
45/// spelling the author and the URL a second time. Two copies of a string are two things
46/// that can disagree, and this one exists precisely so that a stray copy of the binary
47/// can still be traced back.
48pub static LONG_VERSION: std::sync::LazyLock<String> = std::sync::LazyLock::new(|| {
49 format!(
50 "{VERSION}\n\
51 author: {AUTHOR}\n\
52 repository: {REPO_URL}\n\
53 homepage: {HOMEPAGE_URL}\n\
54 license: Apache-2.0"
55 )
56});
57
58/// How many prune passes `devp stats` keeps a summary of.
59///
60/// The registry is rewritten in full on every save, so this list is a file-size decision
61/// as much as a display one. Fifty passes is roughly a year of a fortnightly schedule.
62pub const PRUNE_HISTORY_LIMIT: usize = 50;
63
64/// The release that started recording per-repository totals and the pass history.
65///
66/// A machine that pruned for months on 1.0.0 has a large lifetime total and no history at
67/// all, and reading that as "nothing was ever pruned here" would be wrong. Both `devp
68/// stats` and its `--json` document quote this version so the gap is explained rather than
69/// looking like data loss. It is deliberately not [`VERSION`]: it names the release the
70/// format changed in, and does not move again.
71pub const HISTORY_STARTS_AT: &str = "1.1.0";
72
73/// Default idle threshold in days before a repository is eligible for pruning.
74pub const DEFAULT_IDLE_DAYS: u64 = 15;
75
76/// Default idle threshold for *build-tool* directories (gradle, maven), in days.
77///
78/// Deliberately much longer than [`DEFAULT_IDLE_DAYS`]: those directories come back
79/// by recompiling the whole project, not by re-downloading a dependency tree, so the
80/// bar for "nobody will miss this" sits higher. The engine applies
81/// `max(build_idle_days, idle_days)`.
82pub const DEFAULT_BUILD_IDLE_DAYS: u64 = 60;
83
84/// Default interval in days between background daemon prune runs.
85pub const DEFAULT_CHECK_INTERVAL_DAYS: u64 = 2;
86
87/// Whether the setup pass installs the OS scheduler.
88///
89/// On. A pruner that has to be remembered is a pruner that never runs; the scheduled
90/// pass is the product, not an extra. It is still bounded by everything an interactive
91/// run is bounded by — idle threshold, lockfile verification, per-repo opt-outs — and
92/// `devp daemon uninstall` (or `devp config set auto_daemon false`) removes it.
93pub const DEFAULT_AUTO_DAEMON: bool = true;
94
95/// Whether the setup pass installs the global Git auto-registration hooks.
96///
97/// On, but conditionally: installation is skipped, not forced, when `core.hooksPath`
98/// already belongs to husky, pre-commit or lefthook.
99pub const DEFAULT_AUTO_HOOKS: bool = true;
100
101/// Whether dev-prune installs its missing integrations by itself.
102///
103/// On. The pass runs once per installed version — on first run, and again after an
104/// upgrade — and only creates what is absent. Set to `false`, or export
105/// `DEV_PRUNE_NO_AUTO_SETUP`, to manage the integrations entirely by hand.
106///
107/// The environment variable is symmetric: with it set, `devp uninstall` leaves those
108/// same hand-managed integrations — the scheduler, the agent skills, the install
109/// directories guessed from the home folder — alone too, and says so. "Entirely by
110/// hand" has to include the removal, or the variable's promise only holds until the
111/// day you uninstall.
112pub const DEFAULT_AUTO_SETUP: bool = true;
113
114/// Default for whether `link` and `init` write a `.devprune.json` into repositories
115/// they register.
116///
117/// Off: most repositories are fine on the defaults, and a config file dropped into
118/// every repo is litter. The setting exists for people who tune repositories
119/// individually often enough that creating the file by hand every time is the chore.
120pub const DEFAULT_AUTO_CONFIG: bool = false;
121
122/// Default setting for requiring interactive confirmation before pruning.
123pub const DEFAULT_REQUIRE_CONFIRMATION: bool = true;
124
125/// Default size floor, in MiB, below which a bloat directory is left alone.
126///
127/// Zero — every recognised directory is a candidate. Raising it trades a little disk
128/// space for fewer reinstalls: deleting a 3 MiB `node_modules` costs a full `npm ci`
129/// and reclaims almost nothing.
130pub const DEFAULT_MIN_SIZE_MB: u64 = 0;
131
132/// How far below a repository root project discovery descends, by default.
133///
134/// Six covers `packages/scope/name/…` monorepo layouts with room to spare while keeping
135/// the walk bounded on repositories with deep source trees. Configurable with
136/// `devp config set scan_depth`, and per repository with `"scan_depth"` in
137/// `.devprune.json`, because "deep enough" is a property of the layout, not of the tool.
138pub const DEFAULT_SCAN_DEPTH: usize = 6;
139
140/// Upper bound accepted for `scan_depth`.
141///
142/// Not a matter of taste. The walk is breadth-first over every directory that is not
143/// excluded, so cost grows with the tree, and a repository with a deep generated tree
144/// (a Bazel `bazel-out`, a `.terraform` provider cache) can turn an unbounded walk into
145/// a multi-minute stall on a background pass nobody is watching.
146pub const MAX_SCAN_DEPTH_LIMIT: usize = 32;
147
148/// Whether an adapter whose sync command edits tracked manifests may run it.
149///
150/// Off. `cargo generate-lockfile` re-resolves every dependency and rewrites
151/// `Cargo.lock`; `go mod tidy` edits `go.mod` and `go.sum` and can drop requirements.
152/// A cleanup tool that silently changes files Git tracks has done something the user
153/// did not ask for, so these run read-only and this switch is the informed opt-in.
154pub const DEFAULT_ALLOW_MANIFEST_REWRITE: bool = false;
155
156/// Whether the setup pass installs the Git hooks in front of another tool's.
157///
158/// Off. Chaining is behaviour-preserving — every hook is forwarded on and
159/// `devp hook uninstall` restores the original `core.hooksPath` — but it still rewires
160/// somebody else's Git configuration, which is not a thing to do unasked. Turn it on
161/// with `devp config set auto_hooks_chain true`, or do it once with
162/// `devp hook install --chain`.
163pub const DEFAULT_AUTO_HOOKS_CHAIN: bool = false;
164
165/// GitHub releases page, shown whenever an upgrade is relevant.
166pub const RELEASES_URL: &str = "https://github.com/Life-Experimentalist/dev-prune/releases";
167
168/// The shell installer, printed as an upgrade command and re-run by `devp update
169/// --install` when the running binary came from it.
170pub const INSTALL_SH_URL: &str = "https://devprune.vkrishna04.me/install.sh";
171
172/// The PowerShell installer — same two callers as [`INSTALL_SH_URL`].
173pub const INSTALL_PS1_URL: &str = "https://devprune.vkrishna04.me/install.ps1";
174
175/// GitHub API endpoint for the latest published release.
176///
177/// Contacted by `devp update`, by the interval-gated check behind `run`/`status`/`init`
178/// (off via `update_check false` or `DEV_PRUNE_OFFLINE`), and by the one-time
179/// extension-install offer's `.vsix` fallback. See the network policy in
180/// `docs/PRIVACY.md`.
181pub const LATEST_RELEASE_API_URL: &str =
182 "https://api.github.com/repos/Life-Experimentalist/dev-prune/releases/latest";
183
184/// Whether the periodic release check runs. On by default — see `Settings::update_check`.
185pub const DEFAULT_UPDATE_CHECK: bool = true;
186
187/// Default interval, in days, between automatic release checks.
188///
189/// A week. Frequent enough that a security fix is not missed for long, rare enough that
190/// it is invisible in day-to-day use. Override with
191/// `devp config set update_check_interval_days`.
192pub const UPDATE_CHECK_INTERVAL_DAYS: i64 = 7;
193
194/// Default timeout for the release check. Short on purpose — this is a convenience,
195/// and a user waiting on a hung socket is worse than not knowing. Override with
196/// `devp config set update_check_timeout_secs` when a proxy needs longer.
197pub const UPDATE_CHECK_TIMEOUT_SECS: u64 = 5;
198
199/// Name of the registry JSON file.
200pub const REGISTRY_FILENAME: &str = "registry.json";
201
202/// Config directory name under user config root.
203pub const CONFIG_DIR_NAME: &str = "dev-prune";
204
205/// Global environment variable name to override config directory location.
206pub const ENV_CONFIG_DIR_OVERRIDE: &str = "DEV_PRUNE_CONFIG_DIR";
207
208/// Environment variable that suppresses the automatic setup pass entirely.
209///
210/// For images, CI and anyone who wants the binary and nothing else. `devp setup` still
211/// works when it is set — this only governs the unattended pass.
212pub const ENV_NO_AUTO_SETUP: &str = "DEV_PRUNE_NO_AUTO_SETUP";
213
214/// Environment variable that keeps the process off the network entirely — the release
215/// check and the extension-download fallback alike. Set by the test suites, useful on
216/// air-gapped machines; the durable per-user switch is
217/// `devp config set update_check false`.
218pub const ENV_OFFLINE: &str = "DEV_PRUNE_OFFLINE";
219
220/// Filename that, when present in a repo root, causes dev-prune to skip that repo entirely.
221///
222/// Create this file with: `touch ignore.devprune.json`
223pub const DEVPRUNE_IGNORE_FILE: &str = "ignore.devprune.json";
224
225/// Default timeout in seconds for lockfile enforcement / CLI commands (10 minutes).
226pub const DEFAULT_COMMAND_TIMEOUT_SECS: u64 = 600;
227
228/// Timeout for the "where does your cache live?" queries `devp caches` makes.
229///
230/// Deliberately not `command_timeout_secs`. That ceiling is sized for `npm ci` and
231/// `cargo metadata`; `npm config get cache` prints one line and returns. A query that
232/// has not answered in five seconds is a broken installation, and the report is better
233/// off falling back to the conventional path than waiting ten minutes for it.
234pub const CACHE_QUERY_TIMEOUT_SECS: u64 = 5;
235
236/// Documentation URL for troubleshooting lockfile and pruning failures.
237pub const TROUBLESHOOTING_URL: &str = "https://devprune.vkrishna04.me/docs/troubleshooting";
238/// Name of the structured per-repository configuration file stored inside repo roots.
239pub const PER_REPO_CONFIG_FILE: &str = ".devprune.json";
240
241/// Public URL for the JSON Schema used by IDEs for .devprune.json IntelliSense.
242pub const JSON_SCHEMA_URL: &str = "https://devprune.vkrishna04.me/schemas/v1/devprune.schema.json";
243
244/// Directory under the user's home that marks a Claude Code installation.
245///
246/// Its presence is how the setup pass decides the machine has an agent to install the
247/// skill for; the directory itself is only ever created by Claude Code.
248pub const CLAUDE_HOME_DIR: &str = ".claude";
249
250/// Subdirectory of an agent's home where Agent Skills live, one directory per skill.
251pub const AGENT_SKILLS_SUBDIR: &str = "skills";
252
253/// Marketplace identifier (`publisher.name`) of the VS Code extension, as understood
254/// by `code --install-extension`.
255pub const VSCODE_EXTENSION_ID: &str = "VKrishna04.dev-prune";
256
257/// Where a person can read about the extension before installing it.
258///
259/// The offer prints all three. The two registries carry the same build — the release
260/// `.vsix` — but a machine that trusts one may not have the other, and someone who
261/// wants to read the source before letting anything into their editor needs neither.
262pub const VSCODE_MARKETPLACE_URL: &str =
263 "https://marketplace.visualstudio.com/items?itemName=VKrishna04.dev-prune";
264/// The Open VSX listing, which is what VSCodium, Cursor and Windsurf resolve against.
265pub const OPENVSX_URL: &str = "https://open-vsx.org/extension/VKrishna04/dev-prune";
266
267/// Name of the Windows Task Scheduler task the daemon registers.
268pub const WINDOWS_TASK_NAME: &str = "DevPrune";
269/// File name of the windowless scheduler binary — `dev-prune.exe` with its PE subsystem
270/// set to GUI, the same relationship `pythonw.exe` has to `python.exe`. Generated
271/// locally beside the managed binary; never shipped in any archive.
272pub const WINDOWS_HIDDEN_BIN: &str = "devpw.exe";
273/// Marker file (in the config directory) recording that this machine's Task Scheduler
274/// refused the hidden (S4U) task registration, so setup keeps the visible task instead
275/// of retrying the upgrade on every pass.
276pub const SCHEDULER_HIDDEN_REFUSED_MARKER: &str = "scheduler-hidden-refused";
277
278/// Label of the macOS LaunchAgent the daemon registers (also names its plist file).
279pub const MACOS_LAUNCHD_LABEL: &str = "com.devprune.daemon";
280
281/// Where `devp skill --agent cursor` writes the per-repository rules.
282pub const CURSOR_RULES_FILE: &str = ".cursor/rules/dev-prune.mdc";
283
284/// Where `devp skill --agent windsurf` writes the per-repository rules.
285pub const WINDSURF_RULES_FILE: &str = ".windsurf/rules/dev-prune.md";
286
287/// Where `devp skill --agent antigravity` writes the per-repository rules —
288/// Antigravity (Google) reads workspace rules from `.agent/rules/`.
289pub const ANTIGRAVITY_RULES_FILE: &str = ".agent/rules/dev-prune.md";
290
291/// Where `devp skill --agent cline` writes its rules (Cline reads every file in the
292/// `.clinerules/` directory).
293pub const CLINE_RULES_FILE: &str = ".clinerules/dev-prune.md";
294
295/// Where `devp skill --agent agents-md` writes its marked block — the cross-tool
296/// convention read by Codex, Jules, Amp, Antigravity and others.
297pub const AGENTS_MD_FILE: &str = "AGENTS.md";
298
299/// The shared file `devp skill --agent copilot` owns a marked block inside.
300pub const COPILOT_INSTRUCTIONS_FILE: &str = ".github/copilot-instructions.md";
301
302/// Markers around the block in [`COPILOT_INSTRUCTIONS_FILE`] that dev-prune manages.
303/// Everything outside them belongs to the user and is never touched.
304pub const RULES_BLOCK_START: &str = "<!-- dev-prune:rules:start -->";
305pub const RULES_BLOCK_END: &str = "<!-- dev-prune:rules:end -->";