refactor(tui): remove skill digest/setup leftovers (dead-code audit 2026-08-03, P1)

package_is_path_safe, bundled_skill_body_sha256, and
uninstall_system_skills had no callers. compute_package_digest and
install_system_skills remain part of the current install/audit flow; the
two uninstall-only tests are removed with the dead API.
This commit is contained in:
Hmbown
2026-08-03 09:47:02 -07:00
parent a6f4c05d1a
commit 849010b034
4 changed files with 3 additions and 66 deletions
+2 -2
View File
@@ -24,11 +24,11 @@ pub use roots::{
CompatibleHarness, SkillRootAccess, SkillRootCatalog, SkillRootDescriptor, SkillRootId,
SkillRootKind, SkillScope, classify_configured_skills_dir, safe_display_path,
};
#[allow(unused_imports)]
pub use system::is_exact_bundled_skill;
pub use system::{
BundledSkillTier, bundled_skill_tier, install_system_skills, is_bundled_skill_name,
};
#[allow(unused_imports)]
pub use system::{bundled_skill_body_sha256, is_exact_bundled_skill};
use std::fs;
use std::path::{Path, PathBuf};
-6
View File
@@ -71,12 +71,6 @@ pub fn compute_package_digest(package_dir: &Path) -> Result<String, PackageDiges
Ok(hex_digest(hasher.finalize()))
}
/// Whether the package tree is safe (no symlink / escape / cycle) under limits.
#[allow(dead_code)] // used by future import/validation paths
pub fn package_is_path_safe(package_dir: &Path) -> bool {
compute_package_digest(package_dir).is_ok()
}
fn walk(
dir: &Path,
package_root: &Path,
-35
View File
@@ -345,22 +345,6 @@ pub fn is_exact_bundled_skill(name: &str, skill_md_content: &str) -> bool {
.any(|s| s.name == name && s.body == skill_md_content)
}
/// SHA-256 (hex) of the shipped `SKILL.md` body for a bundled skill, if any.
#[must_use]
#[allow(dead_code)] // available for managers / docs that prefer digest over body compare
pub fn bundled_skill_body_sha256(name: &str) -> Option<String> {
use sha2::{Digest, Sha256};
BUNDLED_SKILLS.iter().find(|s| s.name == name).map(|s| {
let digest = Sha256::digest(s.body.as_bytes());
let mut out = String::with_capacity(digest.len() * 2);
for byte in digest {
use std::fmt::Write as _;
let _ = write!(&mut out, "{byte:02x}");
}
out
})
}
/// Attempt to install a single bundled skill into `skills_dir`.
///
/// Returns `true` if installation occurred (fresh install or version bump).
@@ -492,24 +476,5 @@ fn write_marker_atomically(marker: &Path, version: &str) -> std::io::Result<()>
fs::rename(temporary.path(), marker)
}
/// Remove all system skills and the version marker.
///
/// Intended for tests and `deepseek setup --clean`. Ignores missing files.
#[allow(dead_code)]
pub fn uninstall_system_skills(skills_dir: &Path) -> std::io::Result<()> {
let marker = skills_dir.join(".system-installed-version");
for skill in BUNDLED_SKILLS {
let dir = skills_dir.join(skill.name);
if dir.exists() {
fs::remove_dir_all(&dir)?;
}
}
if marker.exists() {
fs::remove_file(&marker)?;
}
Ok(())
}
#[cfg(test)]
mod tests;
+1 -23
View File
@@ -394,30 +394,8 @@ fn version_bump_respects_deleted_existing_skill_while_adding_new_skill() {
assert_eq!(ver.trim(), BUNDLED_SKILL_VERSION);
}
// ── uninstall ─────────────────────────────────────────────────────────────
// ── upgrade ───────────────────────────────────────────────────────────────
#[test]
fn uninstall_removes_bundled_skills_and_marker() {
let tmp = TempDir::new().unwrap();
install_system_skills(tmp.path()).unwrap();
uninstall_system_skills(tmp.path()).unwrap();
for skill in BUNDLED_SKILLS {
assert!(
!skill_file(&tmp, skill.name).exists(),
"{} should be removed",
skill.name
);
}
assert!(!marker_file(&tmp).exists(), "marker should be removed");
}
#[test]
fn uninstall_on_clean_dir_is_a_noop() {
let tmp = TempDir::new().unwrap();
// Must not panic or error.
uninstall_system_skills(tmp.path()).unwrap();
}
#[test]
fn upgrade_from_v4_installs_pack_and_retires_unchanged_v4_best_practices() {
let tmp = TempDir::new().unwrap();