/** * Legacy Claude Code source detection. * * After #37/#38 the DSH runtime prefers `~/.dsh` for skills and roles. The * `~/.claude` locations stay as a migration fallback: a machine that has not * rerun `dsh/install.sh --skills --roles` keeps working, but the agent should * say so once instead of serving legacy paths silently. */ import { homedir } from 'node:os' import { join, sep } from 'node:path' const warned = new Set() /** Whether `path` lives under `/.claude` (the legacy source root). */ export function isLegacyClaudePath(path, home = homedir()) { if (typeof path !== 'string' || path === '') return false return path.startsWith(join(home, '.claude') + sep) } /** * Warn once per process and per kind+path: `agent/pre-step` runs on every * step, so an unconditional warning would flood the log. */ export function warnLegacyOnce(logger, kind, path, flag = kind) { const key = `${kind}|${path}` if (warned.has(key)) return warned.add(key) logger?.warn?.( '[dsh-harness] legacy Claude Code source in use for %s: %s; run dsh/install.sh --%s', kind, path, flag, ) }