Compare commits
No commits in common. "4054e13806c30107d8e338745346487a49d8601c" and "12f19b1de5b5814b4462ac46cf65153b250851d5" have entirely different histories.
4054e13806
...
12f19b1de5
@ -28,7 +28,6 @@ DO_SKILLS=0
|
|||||||
DO_ROLES=0
|
DO_ROLES=0
|
||||||
DO_OPENSPEC=0
|
DO_OPENSPEC=0
|
||||||
SUPERPOWERS_FROM=""
|
SUPERPOWERS_FROM=""
|
||||||
SUPERPOWERS_FROM_SET=0
|
|
||||||
CLONE_HINT="git clone --depth 1 https://github.com/obra/superpowers $DSH_HOME/superpowers"
|
CLONE_HINT="git clone --depth 1 https://github.com/obra/superpowers $DSH_HOME/superpowers"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
@ -74,26 +73,15 @@ while [ "$#" -gt 0 ]; do
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
SUPERPOWERS_FROM="$2"
|
SUPERPOWERS_FROM="$2"
|
||||||
SUPERPOWERS_FROM_SET=1
|
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--superpowers-from=*)
|
--superpowers-from=*) SUPERPOWERS_FROM="${1#*=}" ;;
|
||||||
SUPERPOWERS_FROM="${1#*=}"
|
|
||||||
SUPERPOWERS_FROM_SET=1
|
|
||||||
;;
|
|
||||||
-h|--help) usage; exit 0 ;;
|
-h|--help) usage; exit 0 ;;
|
||||||
*) echo "unknown option: $1" >&2; usage >&2; exit 2 ;;
|
*) echo "unknown option: $1" >&2; usage >&2; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
# An explicit flag with an empty value is a typo, not "use the default source":
|
|
||||||
# falling through to legacy would mask exactly the misconfiguration D-2 forbids.
|
|
||||||
if [ "$SUPERPOWERS_FROM_SET" = 1 ] && [ -z "$SUPERPOWERS_FROM" ]; then
|
|
||||||
echo "option --superpowers-from needs a non-empty directory" >&2
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Normalize a superpowers source: accept the repo root (with skills/) or the
|
# Normalize a superpowers source: accept the repo root (with skills/) or the
|
||||||
# skills directory itself. Prints the skills directory, returns 1 otherwise.
|
# skills directory itself. Prints the skills directory, returns 1 otherwise.
|
||||||
normalize_superpowers_dir() {
|
normalize_superpowers_dir() {
|
||||||
@ -129,11 +117,8 @@ superpowers_source() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
legacy="$(ls -d "$HOME"/.claude/plugins/cache/claude-plugins-official/superpowers/*/skills 2>/dev/null | sort -V | tail -1 || true)"
|
legacy="$(ls -d "$HOME"/.claude/plugins/cache/claude-plugins-official/superpowers/*/skills 2>/dev/null | sort -V | tail -1 || true)"
|
||||||
# A cache directory without using-superpowers is a broken cache, not a source:
|
if [ -n "$legacy" ] && [ -d "$legacy" ]; then
|
||||||
# accepting it would copy 0 skills and report success (the silent empty
|
printf '%s\tlegacy\n' "$legacy"
|
||||||
# bootstrap this change removes).
|
|
||||||
if [ -n "$legacy" ] && dir="$(normalize_superpowers_dir "$legacy")"; then
|
|
||||||
printf '%s\tlegacy\n' "$dir"
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if dir="$(normalize_superpowers_dir "$HOME/.claude/skills")"; then
|
if dir="$(normalize_superpowers_dir "$HOME/.claude/skills")"; then
|
||||||
@ -153,7 +138,7 @@ explicit_source_name() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
report_invalid_explicit_source() {
|
report_invalid_explicit_source() {
|
||||||
echo "FAIL: explicit superpowers source is invalid: $(explicit_source_name) has no using-superpowers/SKILL.md (expected <dir>/skills/... or <dir>/...)" >&2
|
echo "FAIL: explicit superpowers source $(explicit_source_name) has no using-superpowers/SKILL.md (expected <dir>/skills/... or <dir>/...)" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
check() {
|
check() {
|
||||||
|
|||||||
@ -231,7 +231,7 @@ test('an invalid explicit source fails without touching the legacy cache', () =>
|
|||||||
const run = runInstaller(home, ['--skills', '--superpowers-from', empty])
|
const run = runInstaller(home, ['--skills', '--superpowers-from', empty])
|
||||||
const out = run.stdout + run.stderr
|
const out = run.stdout + run.stderr
|
||||||
assert.equal(run.status, 1, out)
|
assert.equal(run.status, 1, out)
|
||||||
assert.match(out, /FAIL: explicit superpowers source is invalid: .* has no using-superpowers\/SKILL\.md/)
|
assert.match(out, /FAIL: explicit superpowers source .* has no using-superpowers\/SKILL\.md/)
|
||||||
assert.equal(existsSync(join(home, '.dsh', 'skills', 'brainstorming')), false)
|
assert.equal(existsSync(join(home, '.dsh', 'skills', 'brainstorming')), false)
|
||||||
} finally {
|
} finally {
|
||||||
cleanup(home)
|
cleanup(home)
|
||||||
@ -303,44 +303,3 @@ test('--global installs DSH role paths and explains the instruction format', ()
|
|||||||
cleanup(home)
|
cleanup(home)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
test('a legacy cache without using-superpowers is not a source', () => {
|
|
||||||
const home = tempDir()
|
|
||||||
try {
|
|
||||||
const cache = join(
|
|
||||||
home,
|
|
||||||
'.claude',
|
|
||||||
'plugins',
|
|
||||||
'cache',
|
|
||||||
'claude-plugins-official',
|
|
||||||
'superpowers',
|
|
||||||
'7.0.0',
|
|
||||||
'skills',
|
|
||||||
)
|
|
||||||
write(join(cache, 'brainstorming', 'SKILL.md'), '---\nname: brainstorming\n---\nbody\n')
|
|
||||||
const run = runInstaller(home, ['--skills'])
|
|
||||||
const out = run.stdout + run.stderr
|
|
||||||
assert.equal(run.status, 1, out)
|
|
||||||
assert.match(out, /FAIL: no superpowers source/)
|
|
||||||
assert.doesNotMatch(out, /copied 0 superpowers/)
|
|
||||||
assert.equal(existsSync(join(home, '.dsh', 'skills', 'brainstorming')), false)
|
|
||||||
} finally {
|
|
||||||
cleanup(home)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
test('an empty --superpowers-from is rejected, not ignored', () => {
|
|
||||||
const home = tempDir()
|
|
||||||
try {
|
|
||||||
makeLegacyCache(home)
|
|
||||||
for (const args of [['--skills', '--superpowers-from='], ['--skills', '--superpowers-from', '']]) {
|
|
||||||
const run = runInstaller(home, args)
|
|
||||||
const out = run.stdout + run.stderr
|
|
||||||
assert.equal(run.status, 2, out)
|
|
||||||
assert.match(out, /needs a non-empty directory/)
|
|
||||||
assert.equal(existsSync(join(home, '.dsh', 'skills', 'using-superpowers')), false)
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
cleanup(home)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user