# shellcheck shell=bash

# 이 lib 은 단독으로 source 될 수 있다(계약 테스트가 그렇게 부른다). checks
# 경로 계산은 common.sh 한 곳에만 두고, 없으면 여기서 채운다.
# shellcheck source=common.sh
[ -n "${OKSTRA_VALIDATOR_CHECKS:-}" ] || . "$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"

# Verify that the npm build output under `runtime/` is fresh and matches the
# source files that `okstra install` (src/install.mjs) copies into the user's
# `~/.claude/skills/`, `~/.claude/agents/`, and `~/.okstra/` directories.
#
# Historically this validator checked a *project-local* `.claude/skills/` +
# `.claude/agents/` tree that `okstra.sh` seeded into the project root on
# every run. That seeding step was removed when install moved into
# `src/install.mjs`; install now writes only to the user's
# `$HOME/.claude` + `$HOME/.okstra`, never to the project root. The runtime/
# tree is the canonical staging area that `okstra install` rsyncs from, so we
# validate parity there instead.
validate_seeded_assets() {
  local validation_mode="$1"
  local runtime_root="$WORKSPACE_ROOT/runtime"

  if [[ ! -d "$runtime_root" ]]; then
    printf 'runtime/ build output is missing — run `npm run build` before validating.\n' >&2
    return 1
  fi

  python3 "$OKSTRA_VALIDATOR_CHECKS/validate-assets-01.py" "$SOURCE_ASSET_ROOT" "$WORKSPACE_ROOT/skills" "$runtime_root" "$validation_mode"
}
