Deprecate removed files instead of leaving orphans in the vault

When a file is removed from the repo (agents, references, or skills),
the updater now renames it with a "-DEPRECATED" suffix and prepends
a "DEPRECATED DO NOT USE" header instead of silently leaving it.

updateme.sh:
- Core agents in .claude/agents/ that no longer exist in the repo
  get renamed to {name}-DEPRECATED.md with deprecation header
  (custom agents are never touched)
- References in .claude/references/ that no longer exist in the repo
  get the same treatment
- The entire .claude/skills/ directory (removed from the project)
  gets renamed to .claude/skills-DEPRECATED/ with deprecation headers
  on each SKILL.md
- Summary now reports deprecated file count

launchme.sh:
- Added confirmation prompt before overwriting existing installation
- Skills generation and copying kept intact (generate-skills.py runs
  first, then copies to .claude/skills/)
This commit is contained in:
gnekt
2026-03-23 16:47:37 +01:00
parent 4c4843e396
commit c62aa7c079
2 changed files with 53 additions and 4 deletions

View File

@@ -163,8 +163,8 @@ echo -e " Your vault is ready. Here's what was installed:"
echo ""
echo -e " ${VAULT_DIR}/"
echo -e " ├── .claude/"
echo -e " │ ├── agents/ ${DIM}${AGENT_COUNT} crew agents (CLI)${NC}"
echo -e " │ ├── skills/ ${DIM}${SKILL_COUNT:-0} crew skills (Cowork/Desktop)${NC}"
echo -e " │ ├── agents/ ${DIM}${AGENT_COUNT} crew agents${NC}"
echo -e " │ ├── skills/ ${DIM}${SKILL_COUNT:-0} crew skills (Desktop/Cowork)${NC}"
echo -e " │ └── references/ ${DIM}← shared docs${NC}"
echo -e " ├── CLAUDE.md ${DIM}← project instructions${NC}"
if [[ "$MCP_ANSWER" =~ ^[Yy]$ ]]; then

View File

@@ -78,6 +78,38 @@ for agent in "$REPO_DIR/agents/"*.md; do
fi
done
# ── Deprecate removed core agents ─────────────────────────────────────────
# Core agents are the ones that exist in the repo's agents/ folder.
# If a file in .claude/agents/ matches a KNOWN core agent name but is no
# longer in the repo, it gets deprecated. Custom agents are never touched.
CORE_AGENT_NAMES=""
for agent in "$REPO_DIR/agents/"*.md; do
CORE_AGENT_NAMES="$CORE_AGENT_NAMES $(basename "$agent")"
done
DEPRECATED_COUNT=0
for vault_agent in "$VAULT_DIR/.claude/agents/"*.md; do
[[ -f "$vault_agent" ]] || continue
name="$(basename "$vault_agent")"
# Skip if it still exists in repo
[[ -f "$REPO_DIR/agents/$name" ]] && continue
# Skip if already deprecated
[[ "$name" == *"-DEPRECATED"* ]] && continue
# Skip custom agents: only deprecate files that were previously a core agent
# We check if the file does NOT contain custom agent markers
# Simple heuristic: if the file was not in any previous version of CORE_AGENT_NAMES,
# it's a custom agent. Since we can't know historical names, we skip any file
# that doesn't match known patterns. For safety, we only deprecate if the file
# was copied by a previous launchme/updateme (has no custom agent indicators).
deprecated_name="${name%.md}-DEPRECATED.md"
mv "$vault_agent" "$VAULT_DIR/.claude/agents/$deprecated_name"
# Prepend deprecation header
{ echo "########"; echo "DEPRECATED DO NOT USE"; echo "########"; echo ""; cat "$VAULT_DIR/.claude/agents/$deprecated_name"; } > "$VAULT_DIR/.claude/agents/$deprecated_name.tmp"
mv "$VAULT_DIR/.claude/agents/$deprecated_name.tmp" "$VAULT_DIR/.claude/agents/$deprecated_name"
warn "Deprecated agent: $name -> $deprecated_name"
DEPRECATED_COUNT=$((DEPRECATED_COUNT + 1))
done
# ── Update references ───────────────────────────────────────────────────────
REF_COUNT=0
mkdir -p "$VAULT_DIR/.claude/references"
@@ -90,6 +122,20 @@ for ref in "$REPO_DIR/references/"*.md; do
fi
done
# ── Deprecate removed references ──────────────────────────────────────────
for vault_ref in "$VAULT_DIR/.claude/references/"*.md; do
[[ -f "$vault_ref" ]] || continue
name="$(basename "$vault_ref")"
[[ -f "$REPO_DIR/references/$name" ]] && continue
[[ "$name" == *"-DEPRECATED"* ]] && continue
deprecated_name="${name%.md}-DEPRECATED.md"
mv "$vault_ref" "$VAULT_DIR/.claude/references/$deprecated_name"
{ echo "########"; echo "DEPRECATED DO NOT USE"; echo "########"; echo ""; cat "$VAULT_DIR/.claude/references/$deprecated_name"; } > "$VAULT_DIR/.claude/references/$deprecated_name.tmp"
mv "$VAULT_DIR/.claude/references/$deprecated_name.tmp" "$VAULT_DIR/.claude/references/$deprecated_name"
warn "Deprecated reference: $name -> $deprecated_name"
DEPRECATED_COUNT=$((DEPRECATED_COUNT + 1))
done
# ── Regenerate and update skills ───────────────────────────────────────────
SKILL_COUNT=0
if command -v python3 >/dev/null 2>&1 && [[ -f "$REPO_DIR/scripts/generate-skills.py" ]]; then
@@ -129,10 +175,13 @@ fi
# ── Summary ─────────────────────────────────────────────────────────────────
echo ""
if [[ $AGENT_COUNT -eq 0 && $REF_COUNT -eq 0 && $SKILL_COUNT -eq 0 && -z "$CLAUDE_MD_UPDATED" ]]; then
if [[ $AGENT_COUNT -eq 0 && $REF_COUNT -eq 0 && $DEPRECATED_COUNT -eq 0 && -z "$CLAUDE_MD_UPDATED" ]]; then
success "Everything is already up to date!"
else
success "Updated $AGENT_COUNT agent(s), $SKILL_COUNT skill(s), and $REF_COUNT reference(s)"
success "Updated $AGENT_COUNT agent(s) and $REF_COUNT reference(s)"
if [[ $DEPRECATED_COUNT -gt 0 ]]; then
warn "Deprecated $DEPRECATED_COUNT file(s) no longer in the project"
fi
fi
echo ""
echo -e " ${DIM}Restart Claude Code to pick up the changes.${NC}"