version: '3'

# Pack-slicing surface (#1283 design, #1294 lessons pilot, #1295 skills pack,
# #1296 rules + strategies packs, ADR-001 Layer B).
#
# `packs:slice` is the agent-facing named-slice API (pack-agnostic, driven by
# each pack's schema x-sliceRegistry + x-display); `packs:render` regenerates
# every pack's projection (meta/lessons.md for lessons, the proof SKILL.md for
# skills, the proof coding/testing.md for rules, the proof strategies/yolo.md
# for strategies) from its canonical pack source; `packs:verify-drift` is the
# drift gate that fails when ANY committed projection diverges from a freshly
# rendered buffer. The pack-agnostic renderer/resolver is the #1294 machinery
# generalized to four packs through a shared data-driven registry, not
# copy-pasted per pack.
#
# DEFT_ROOT is defined locally via `{{joinPath .TASKFILE_DIR ".."}}` (same
# idiom as tasks/issue.yml) so the scripts dispatch traversal-free on every
# platform (#566). The slice / render scripts resolve their own pack source /
# output paths relative to the framework root, so they are CWD-independent;
# `dir: '{{.USER_WORKING_DIR}}'` keeps parity with the other Taskfile-
# dispatched scripts. Per `conventions/task-caching.md` (#574) none of these
# declare `sources:` / `generates:` because they forward user-facing flags via
# `{{.CLI_ARGS}}` (slice filters, --check) that go-task's incremental-build
# cache would otherwise silently swallow.

vars:
  DEFT_ROOT: '{{joinPath .TASKFILE_DIR ".."}}'

tasks:
  slice:
    desc: "Named, structured slice access to a content pack (#1283, #1295). -- task packs:slice <pack> <name> [-- --since YYYY-MM | --tag T | --trigger KW] [--list] [--list-packs] [--json]"
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: ":engine:_ts-build"
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'packs-slice {{.CLI_ARGS}}'

  render:
    desc: "Regenerate every content-pack projection from its canonical source (ADR-001): meta/lessons.md (lessons), the proof SKILL.md (skills), coding/testing.md (rules), strategies/yolo.md (strategies). -- task packs:render [-- --pack rules] [--check]"
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: ":engine:_ts-build"
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'pack-render {{.CLI_ARGS}}'

  render-skills:
    desc: "One-shot migration: rebuild packs/skills/skills-pack-0.1.json from skills/*/SKILL.md + the AGENTS.md Skill Routing table (#1295)."
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: ":engine:_ts-build"
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'pack-migrate-skills {{.CLI_ARGS}}'

  render-rules:
    desc: "One-shot migration: rebuild packs/rules/rules-pack-0.1.json from the RFC2119 directives in coding/*.md (#1296)."
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: ":engine:_ts-build"
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'pack-migrate-rules {{.CLI_ARGS}}'

  render-strategies:
    desc: "One-shot migration: rebuild packs/strategies/strategies-pack-0.1.json from strategies/*.md (#1296)."
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: ":engine:_ts-build"
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'pack-migrate-strategies {{.CLI_ARGS}}'

  render-patterns:
    desc: "One-shot migration: rebuild packs/patterns/patterns-pack-0.1.json from patterns/*.md (#1637)."
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: ":engine:_ts-build"
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'pack-migrate-patterns {{.CLI_ARGS}}'

  render-swarm-spec:
    desc: "One-shot migration: rebuild packs/swarm-spec/swarm-spec-pack-0.1.json from swarm/*.md (#1637)."
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: ":engine:_ts-build"
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'pack-migrate-swarm-spec {{.CLI_ARGS}}'

  verify-drift:
    desc: "Drift gate: fail (exit 1) when ANY pack projection (meta/lessons.md, the skills proof SKILL.md, coding/testing.md, strategies/yolo.md) diverges from a freshly rendered buffer. Wired into `task check` and surfaced as `task verify:pack-drift`."
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: ":engine:_ts-build"
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'pack-render --check {{.CLI_ARGS}}'
