youmd 0.13.14 → 0.13.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +1 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +21 -1
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/runtime.d.ts +5 -0
- package/dist/commands/runtime.d.ts.map +1 -0
- package/dist/commands/runtime.js +63 -0
- package/dist/commands/runtime.js.map +1 -0
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +29 -17
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/stack.d.ts +0 -2
- package/dist/commands/stack.d.ts.map +1 -1
- package/dist/commands/stack.js +0 -30
- package/dist/commands/stack.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +26 -8
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/worktree.d.ts +51 -0
- package/dist/commands/worktree.d.ts.map +1 -0
- package/dist/commands/worktree.js +303 -0
- package/dist/commands/worktree.js.map +1 -0
- package/dist/generated/capability-registry.d.ts +245 -101
- package/dist/generated/capability-registry.d.ts.map +1 -1
- package/dist/generated/capability-registry.js +258 -101
- package/dist/generated/capability-registry.js.map +1 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/api.d.ts +75 -1
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +44 -1
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/remote-command.js +12 -11
- package/dist/lib/remote-command.js.map +1 -1
- package/dist/lib/remote-executor.d.ts +12 -0
- package/dist/lib/remote-executor.d.ts.map +1 -1
- package/dist/lib/remote-executor.js +65 -7
- package/dist/lib/remote-executor.js.map +1 -1
- package/dist/lib/runtime/event-journal.d.ts +77 -0
- package/dist/lib/runtime/event-journal.d.ts.map +1 -0
- package/dist/lib/runtime/event-journal.js +254 -0
- package/dist/lib/runtime/event-journal.js.map +1 -0
- package/dist/lib/worktreeRegistry.d.ts +40 -0
- package/dist/lib/worktreeRegistry.d.ts.map +1 -0
- package/dist/lib/worktreeRegistry.js +329 -0
- package/dist/lib/worktreeRegistry.js.map +1 -0
- package/dist/mcp/registry.d.ts.map +1 -1
- package/dist/mcp/registry.js +237 -1
- package/dist/mcp/registry.js.map +1 -1
- package/native/prebuilds/darwin-universal/youmd_safe_open.node +0 -0
- package/package.json +1 -1
- package/scripts/skillstack-sync/README.md +1 -1
- package/scripts/skillstack-sync/capture-agent-config.sh +26 -13
- package/scripts/skillstack-sync/context-sync.sh +82 -6
- package/scripts/skillstack-sync/deletion-guard.sh +75 -0
- package/scripts/skillstack-sync/sync.sh +118 -37
- package/scripts/skillstack-sync/tests/deletion-guard.test.sh +50 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# deletion-guard.sh — sourced by sync.sh. Runs AFTER `git add -A`, BEFORE commit.
|
|
3
|
+
#
|
|
4
|
+
# Auto-sync must never propagate one machine's *absence* of files as deletions
|
|
5
|
+
# (incident b4889ae7, 2026-10-05: a MacBook Pro without ~/.codex, ~/.warp and
|
|
6
|
+
# ~/.agents committed 53 agent-config deletions to agent-shared).
|
|
7
|
+
#
|
|
8
|
+
# 1. agent-config/ is an additive snapshot: staged deletions there are always
|
|
9
|
+
# unstaged AND restored. This covers machine-specific config
|
|
10
|
+
# (codex/config.toml, claude/settings*.json) unconditionally.
|
|
11
|
+
# 2. claude-skills/: if staged deletions exceed DELETION_GUARD_MAX_FILES files
|
|
12
|
+
# or DELETION_GUARD_MAX_LINES lines, they are unstaged (left in the working
|
|
13
|
+
# tree for a human) and a warning row is appended to the ledger.
|
|
14
|
+
#
|
|
15
|
+
# bash 3.2 / BSD safe.
|
|
16
|
+
|
|
17
|
+
DELETION_GUARD_MAX_FILES="${DELETION_GUARD_MAX_FILES:-5}"
|
|
18
|
+
DELETION_GUARD_MAX_LINES="${DELETION_GUARD_MAX_LINES:-200}"
|
|
19
|
+
DELETION_GUARD_LEDGER="${DELETION_GUARD_LEDGER:-${YOU_HOME:-${YOUMD_HOME:-${HOME}/.you}}/logs/skillstack-deletion-guard.jsonl}"
|
|
20
|
+
|
|
21
|
+
_dg_log() { if command -v log_warn >/dev/null 2>&1; then log_warn "$*"; else echo "WARN $*" >&2; fi; }
|
|
22
|
+
|
|
23
|
+
_dg_ledger() {
|
|
24
|
+
# _dg_ledger <repo> <action> <scope> <files> <lines> <paths...newline list>
|
|
25
|
+
local repo="$1" action="$2" scope="$3" files="$4" lines="$5" paths="$6" host ts sample
|
|
26
|
+
mkdir -p "$(dirname "${DELETION_GUARD_LEDGER}")"
|
|
27
|
+
host="$(hostname | cut -d. -f1)"
|
|
28
|
+
ts="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
|
29
|
+
sample="$(printf '%s\n' "${paths}" | head -10 | sed 's/\\/\\\\/g; s/"/\\"/g' | awk 'NF{printf "%s\"%s\"", (n++?",":""), $0}')"
|
|
30
|
+
printf '{"ts":"%s","host":"%s","repo":"%s","action":"%s","scope":"%s","files":%s,"lines":%s,"sample":[%s]}\n' \
|
|
31
|
+
"${ts}" "${host}" "${repo}" "${action}" "${scope}" "${files}" "${lines}" "${sample}" >> "${DELETION_GUARD_LEDGER}"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_dg_deleted_lines() {
|
|
35
|
+
git -C "$1" diff --cached --diff-filter=D --numstat -- "$2" 2>/dev/null | awk '$2 ~ /^[0-9]+$/ {s+=$2} END {print s+0}'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# deletion_guard <repo> — returns 0 always; mutates the index only.
|
|
39
|
+
deletion_guard() {
|
|
40
|
+
local repo="$1" dropped count lines line
|
|
41
|
+
|
|
42
|
+
# 1) agent-config: additive, always restore.
|
|
43
|
+
dropped="$(git -C "${repo}" diff --cached --diff-filter=D --name-only -- agent-config 2>/dev/null || true)"
|
|
44
|
+
if [ -n "${dropped}" ]; then
|
|
45
|
+
count="$(printf '%s\n' "${dropped}" | grep -c .)"
|
|
46
|
+
lines="$(_dg_deleted_lines "${repo}" agent-config)"
|
|
47
|
+
_dg_log "deletion-guard: refusing ${count} agent-config deletion(s) (${lines} lines) in ${repo}; restoring (snapshot is additive)."
|
|
48
|
+
while IFS= read -r line; do
|
|
49
|
+
[ -n "${line}" ] || continue
|
|
50
|
+
git -C "${repo}" reset -q HEAD -- "${line}" 2>/dev/null || true
|
|
51
|
+
git -C "${repo}" checkout -- "${line}" 2>/dev/null || true
|
|
52
|
+
done <<EOF_DG1
|
|
53
|
+
${dropped}
|
|
54
|
+
EOF_DG1
|
|
55
|
+
_dg_ledger "${repo}" "restored" "agent-config" "${count}" "${lines}" "${dropped}"
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
# 2) claude-skills: bulk deletions need a human.
|
|
59
|
+
dropped="$(git -C "${repo}" diff --cached --diff-filter=D --name-only -- claude-skills 2>/dev/null || true)"
|
|
60
|
+
if [ -n "${dropped}" ]; then
|
|
61
|
+
count="$(printf '%s\n' "${dropped}" | grep -c .)"
|
|
62
|
+
lines="$(_dg_deleted_lines "${repo}" claude-skills)"
|
|
63
|
+
if [ "${count}" -gt "${DELETION_GUARD_MAX_FILES}" ] || [ "${lines}" -gt "${DELETION_GUARD_MAX_LINES}" ]; then
|
|
64
|
+
_dg_log "deletion-guard: ${count} claude-skills deletion(s) (${lines} lines) exceed limits (${DELETION_GUARD_MAX_FILES} files / ${DELETION_GUARD_MAX_LINES} lines) in ${repo}; left UNSTAGED for human review. Ledger: ${DELETION_GUARD_LEDGER}"
|
|
65
|
+
while IFS= read -r line; do
|
|
66
|
+
[ -n "${line}" ] || continue
|
|
67
|
+
git -C "${repo}" reset -q HEAD -- "${line}" 2>/dev/null || true
|
|
68
|
+
done <<EOF_DG2
|
|
69
|
+
${dropped}
|
|
70
|
+
EOF_DG2
|
|
71
|
+
_dg_ledger "${repo}" "held-unstaged" "claude-skills" "${count}" "${lines}" "${dropped}"
|
|
72
|
+
fi
|
|
73
|
+
fi
|
|
74
|
+
return 0
|
|
75
|
+
}
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
#
|
|
9
9
|
# Env overrides:
|
|
10
10
|
# SKILLSTACK_REPOS space-separated list of absolute repo paths (default: ~/.agent-shared ~/.claude/scistack)
|
|
11
|
-
# GIT_USER_NAME commit author name
|
|
12
|
-
# GIT_USER_EMAIL commit author email (default:
|
|
11
|
+
# GIT_USER_NAME explicit commit author name (default: resolved per repo)
|
|
12
|
+
# GIT_USER_EMAIL explicit commit author email (default: resolved per repo)
|
|
13
13
|
|
|
14
14
|
set -euo pipefail
|
|
15
15
|
|
|
@@ -20,8 +20,12 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
20
20
|
LOG_DIR="${YOU_HOME:-${YOUMD_HOME:-${HOME}/.you}}/logs"
|
|
21
21
|
LOG_FILE="${LOG_DIR}/skillstack-sync.log"
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
# Identity is resolved per repository unless explicitly overridden.
|
|
24
|
+
GIT_USER_NAME="${GIT_USER_NAME:-}"
|
|
25
|
+
# An explicit GIT_USER_EMAIL always wins. Otherwise commit identity is resolved
|
|
26
|
+
# per repository so a machine cannot accidentally attribute commits to a stale
|
|
27
|
+
# or unrelated account.
|
|
28
|
+
GIT_USER_EMAIL="${GIT_USER_EMAIL:-}"
|
|
25
29
|
|
|
26
30
|
AGENT_SHARED="${HOME}/.agent-shared"
|
|
27
31
|
SCISTACK="${HOME}/.claude/scistack"
|
|
@@ -88,6 +92,9 @@ log_dry() {
|
|
|
88
92
|
log "DRY $*"
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
# shellcheck source=deletion-guard.sh
|
|
96
|
+
. "${SCRIPT_DIR}/deletion-guard.sh"
|
|
97
|
+
|
|
91
98
|
# ---------------------------------------------------------------------------
|
|
92
99
|
# Helpers
|
|
93
100
|
# ---------------------------------------------------------------------------
|
|
@@ -101,6 +108,69 @@ is_dry() {
|
|
|
101
108
|
[ "${DRY_RUN}" -eq 1 ]
|
|
102
109
|
}
|
|
103
110
|
|
|
111
|
+
commit_email() {
|
|
112
|
+
local repo="$1" email login id
|
|
113
|
+
if [ -n "${GIT_USER_EMAIL}" ]; then
|
|
114
|
+
printf '%s' "${GIT_USER_EMAIL}"
|
|
115
|
+
return 0
|
|
116
|
+
fi
|
|
117
|
+
email="$(git -C "${repo}" config --local --get user.email 2>/dev/null || true)"
|
|
118
|
+
if [ -n "${email}" ]; then
|
|
119
|
+
printf '%s' "${email}"
|
|
120
|
+
return 0
|
|
121
|
+
fi
|
|
122
|
+
if command -v gh >/dev/null 2>&1; then
|
|
123
|
+
email="$(gh api user --jq '.email // empty' 2>/dev/null || true)"
|
|
124
|
+
if [ -n "${email}" ]; then
|
|
125
|
+
printf '%s' "${email}"
|
|
126
|
+
return 0
|
|
127
|
+
fi
|
|
128
|
+
login="$(gh api user --jq '.login // empty' 2>/dev/null || true)"
|
|
129
|
+
id="$(gh api user --jq '.id // empty' 2>/dev/null || true)"
|
|
130
|
+
if [ -n "${login}" ] && [ -n "${id}" ]; then
|
|
131
|
+
printf '%s+%s@users.noreply.github.com' "${id}" "${login}"
|
|
132
|
+
return 0
|
|
133
|
+
fi
|
|
134
|
+
fi
|
|
135
|
+
email="$(git config --global --get user.email 2>/dev/null || true)"
|
|
136
|
+
if [ -n "${email}" ]; then
|
|
137
|
+
printf '%s' "${email}"
|
|
138
|
+
else
|
|
139
|
+
return 1
|
|
140
|
+
fi
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
commit_name() {
|
|
144
|
+
local repo="$1" name login
|
|
145
|
+
if [ -n "${GIT_USER_NAME}" ]; then
|
|
146
|
+
printf '%s' "${GIT_USER_NAME}"
|
|
147
|
+
return 0
|
|
148
|
+
fi
|
|
149
|
+
name="$(git -C "${repo}" config --local --get user.name 2>/dev/null || true)"
|
|
150
|
+
if [ -n "${name}" ]; then
|
|
151
|
+
printf '%s' "${name}"
|
|
152
|
+
return 0
|
|
153
|
+
fi
|
|
154
|
+
if command -v gh >/dev/null 2>&1; then
|
|
155
|
+
name="$(gh api user --jq '.name // empty' 2>/dev/null || true)"
|
|
156
|
+
if [ -n "${name}" ]; then
|
|
157
|
+
printf '%s' "${name}"
|
|
158
|
+
return 0
|
|
159
|
+
fi
|
|
160
|
+
login="$(gh api user --jq '.login // empty' 2>/dev/null || true)"
|
|
161
|
+
if [ -n "${login}" ]; then
|
|
162
|
+
printf '%s' "${login}"
|
|
163
|
+
return 0
|
|
164
|
+
fi
|
|
165
|
+
fi
|
|
166
|
+
name="$(git config --global --get user.name 2>/dev/null || true)"
|
|
167
|
+
if [ -n "${name}" ]; then
|
|
168
|
+
printf '%s' "${name}"
|
|
169
|
+
else
|
|
170
|
+
return 1
|
|
171
|
+
fi
|
|
172
|
+
}
|
|
173
|
+
|
|
104
174
|
# Check if repo is in a mid-merge/rebase state
|
|
105
175
|
repo_is_in_progress() {
|
|
106
176
|
local repo="$1"
|
|
@@ -276,6 +346,32 @@ sync_repo() {
|
|
|
276
346
|
return 1
|
|
277
347
|
fi
|
|
278
348
|
|
|
349
|
+
# Pull FIRST (rebase, autostash so local edits survive), then commit. Committing
|
|
350
|
+
# before pulling is what produced merge commits and stuck merges across Macs.
|
|
351
|
+
if is_dry; then
|
|
352
|
+
log_dry "Would git pull --rebase --autostash in ${repo}"
|
|
353
|
+
else
|
|
354
|
+
local pull_log
|
|
355
|
+
pull_log="$(mktemp -t skillstack_pull)"
|
|
356
|
+
local pull_ok=0
|
|
357
|
+
git -C "${repo}" pull --rebase --autostash --no-edit >"${pull_log}" 2>&1 || pull_ok=$?
|
|
358
|
+
while IFS= read -r line; do
|
|
359
|
+
log "pull|${repo_name}: ${line}"
|
|
360
|
+
done < "${pull_log}"
|
|
361
|
+
rm -f "${pull_log}"
|
|
362
|
+
|
|
363
|
+
if [ "${pull_ok}" -ne 0 ]; then
|
|
364
|
+
log_error "CONFLICT in ${repo_name} — pull --rebase failed."
|
|
365
|
+
log_error "Aborting rebase and skipping commit/push."
|
|
366
|
+
log_error "Manual resolution needed: cd ${repo} && git status"
|
|
367
|
+
git -C "${repo}" rebase --abort 2>/dev/null || true
|
|
368
|
+
git -C "${repo}" merge --abort 2>/dev/null || true
|
|
369
|
+
git -C "${repo}" stash pop >/dev/null 2>&1 || true
|
|
370
|
+
return 1
|
|
371
|
+
fi
|
|
372
|
+
log "Pull (rebase) succeeded for ${repo_name}."
|
|
373
|
+
fi
|
|
374
|
+
|
|
279
375
|
# Stage and commit local changes if any
|
|
280
376
|
local status_out
|
|
281
377
|
status_out="$(git -C "${repo}" status --porcelain 2>&1)"
|
|
@@ -289,45 +385,30 @@ sync_repo() {
|
|
|
289
385
|
log_dry "Would commit in ${repo}: '${commit_msg}'"
|
|
290
386
|
log_dry "Changed files:\n${status_out}"
|
|
291
387
|
else
|
|
388
|
+
local author_name author_email
|
|
389
|
+
author_name="$(commit_name "${repo}")" || author_name=""
|
|
390
|
+
author_email="$(commit_email "${repo}")" || author_email=""
|
|
391
|
+
if [ -z "${author_name}" ] || [ -z "${author_email}" ]; then
|
|
392
|
+
log_warn "Skipping ${repo_name}: no safe Git author identity resolved (set GIT_USER_NAME/GIT_USER_EMAIL or configure GitHub/Git)."
|
|
393
|
+
return 0
|
|
394
|
+
fi
|
|
292
395
|
git -C "${repo}" add -A
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
commit
|
|
297
|
-
|
|
396
|
+
# Deletion guard: additive agent-config + bulk claude-skills hold (deletion-guard.sh).
|
|
397
|
+
deletion_guard "${repo}"
|
|
398
|
+
if git -C "${repo}" diff --cached --quiet; then
|
|
399
|
+
log "Nothing to commit in ${repo_name} after deletion guard."
|
|
400
|
+
else
|
|
401
|
+
git -C "${repo}" \
|
|
402
|
+
-c "user.name=${author_name}" \
|
|
403
|
+
-c "user.email=${author_email}" \
|
|
404
|
+
commit -m "${commit_msg}"
|
|
405
|
+
log "Committed local changes in ${repo_name}: '${commit_msg}'"
|
|
406
|
+
fi
|
|
298
407
|
fi
|
|
299
408
|
else
|
|
300
409
|
log "No local changes in ${repo_name}."
|
|
301
410
|
fi
|
|
302
411
|
|
|
303
|
-
# Pull (merge, no rebase)
|
|
304
|
-
if is_dry; then
|
|
305
|
-
log_dry "Would git pull --no-rebase --no-edit in ${repo}"
|
|
306
|
-
else
|
|
307
|
-
local pull_log
|
|
308
|
-
pull_log="$(mktemp -t skillstack_pull)"
|
|
309
|
-
local pull_ok=0
|
|
310
|
-
git -C "${repo}" pull --no-rebase --no-edit >"${pull_log}" 2>&1 || pull_ok=$?
|
|
311
|
-
# Echo pull output line by line into the log
|
|
312
|
-
while IFS= read -r line; do
|
|
313
|
-
log "pull|${repo_name}: ${line}"
|
|
314
|
-
done < "${pull_log}"
|
|
315
|
-
rm -f "${pull_log}"
|
|
316
|
-
|
|
317
|
-
if [ "${pull_ok}" -ne 0 ]; then
|
|
318
|
-
log_error "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
319
|
-
log_error "CONFLICT in ${repo_name} — pull failed."
|
|
320
|
-
log_error "Aborting merge/rebase and skipping push."
|
|
321
|
-
log_error "Manual resolution needed: cd ${repo} && git status"
|
|
322
|
-
log_error "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
323
|
-
# Abort any in-progress merge or rebase, leave working tree clean
|
|
324
|
-
git -C "${repo}" merge --abort 2>/dev/null || true
|
|
325
|
-
git -C "${repo}" rebase --abort 2>/dev/null || true
|
|
326
|
-
return 1
|
|
327
|
-
fi
|
|
328
|
-
log "Pull succeeded for ${repo_name}."
|
|
329
|
-
fi
|
|
330
|
-
|
|
331
412
|
# Push
|
|
332
413
|
if is_dry; then
|
|
333
414
|
log_dry "Would git push in ${repo}"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Proves: a machine missing agent-config sources produces NO deletions in the
|
|
3
|
+
# shared repo, machine-specific config is never deleted, and bulk claude-skills
|
|
4
|
+
# deletions are held unstaged + ledgered. Runs the real sync.sh in a sandbox HOME.
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
HERE="$(cd "$(dirname "$0")/.." && pwd)"
|
|
7
|
+
T="$(mktemp -d -t dg_test)"; trap 'rm -rf "$T"' EXIT
|
|
8
|
+
fail() { echo "FAIL: $*"; exit 1; }
|
|
9
|
+
export HOME="$T/home" YOU_HOME="$T/home/.you" GIT_USER_NAME=t GIT_USER_EMAIL=t@t GIT_CONFIG_GLOBAL=/dev/null
|
|
10
|
+
mkdir -p "$HOME"
|
|
11
|
+
|
|
12
|
+
# Remote seeded the way the Mac Mini publishes it.
|
|
13
|
+
git init -q --bare -b main "$T/remote.git"
|
|
14
|
+
git clone -q "$T/remote.git" "$T/seed" 2>/dev/null
|
|
15
|
+
cd "$T/seed"
|
|
16
|
+
mkdir -p agent-config/codex agent-config/claude agent-config/warp agent-config/agents-skills/find-skills claude-skills/big/data
|
|
17
|
+
echo 'model="x"' > agent-config/codex/config.toml
|
|
18
|
+
echo '{}' > agent-config/claude/settings.local.json
|
|
19
|
+
echo '{}' > agent-config/claude/settings.json
|
|
20
|
+
echo 'a=1' > agent-config/warp/settings.toml
|
|
21
|
+
echo 'skill' > agent-config/agents-skills/find-skills/SKILL.md
|
|
22
|
+
for i in 1 2 3 4 5 6 7; do seq 1 50 > "claude-skills/big/data/f$i.csv"; done
|
|
23
|
+
echo small > claude-skills/small.md
|
|
24
|
+
git add -A && git -c user.name=t -c user.email=t@t commit -qm seed && git push -q origin main 2>/dev/null
|
|
25
|
+
|
|
26
|
+
# "MacBook Pro": clone, no ~/.codex ~/.warp ~/.agents ~/.claude/settings.local.json.
|
|
27
|
+
git clone -q "$T/remote.git" "$HOME/.agent-shared" 2>/dev/null
|
|
28
|
+
R="$HOME/.agent-shared"
|
|
29
|
+
# Simulate the old failure mode: working tree lost the machine-absent files...
|
|
30
|
+
rm -rf "$R/agent-config/codex" "$R/agent-config/warp" "$R/agent-config/agents-skills" "$R/agent-config/claude/settings.local.json"
|
|
31
|
+
# ...plus a bulk skill-tree loss and one legit small deletion.
|
|
32
|
+
rm -rf "$R/claude-skills/big"
|
|
33
|
+
|
|
34
|
+
SKILLSTACK_REPOS="$R" bash "$HERE/sync.sh" >/dev/null 2>&1 || fail "sync.sh exited non-zero"
|
|
35
|
+
|
|
36
|
+
[ -z "$(git -C "$R" log origin/main --diff-filter=D --name-only --format= | grep . || true)" ] || fail "remote recorded deletions: $(git -C "$R" log origin/main --diff-filter=D --name-only --format=)"
|
|
37
|
+
for f in agent-config/codex/config.toml agent-config/claude/settings.local.json agent-config/warp/settings.toml agent-config/agents-skills/find-skills/SKILL.md; do
|
|
38
|
+
[ -f "$R/$f" ] || fail "$f not restored in working tree"
|
|
39
|
+
done
|
|
40
|
+
[ -n "$(git -C "$R" status --porcelain -- claude-skills/big | grep '^ D' || true)" ] || fail "bulk claude-skills deletion not left unstaged"
|
|
41
|
+
grep -q '"action":"held-unstaged"' "$YOU_HOME/logs/skillstack-deletion-guard.jsonl" || fail "no held-unstaged ledger row"
|
|
42
|
+
grep -q '"action":"restored"' "$YOU_HOME/logs/skillstack-deletion-guard.jsonl" || fail "no restored ledger row"
|
|
43
|
+
|
|
44
|
+
# Human restores the held files; a small deletion under the limit then goes through.
|
|
45
|
+
git -C "$R" checkout -- claude-skills/big
|
|
46
|
+
rm "$R/claude-skills/small.md"
|
|
47
|
+
SKILLSTACK_REPOS="$R" bash "$HERE/sync.sh" >/dev/null 2>&1 || true
|
|
48
|
+
git -C "$R" log origin/main --diff-filter=D --name-only --format= | grep -qx claude-skills/small.md || fail "small legit deletion was blocked"
|
|
49
|
+
git -C "$R" log origin/main --diff-filter=D --name-only --format= | grep -q 'big/' && fail "bulk deletion leaked on second run"
|
|
50
|
+
echo "PASS deletion-guard: missing sources → 0 deletions; machine config kept; bulk held; small deletion allowed"
|