version: '3'

vars:
  # Per ../Taskfile.yml header: joinPath is evaluated eagerly by go-task
  # templating and yields a native-separator absolute path so {{.DEFT_ROOT}}
  # resolves correctly under node on Windows (#566).
  DEFT_ROOT: '{{joinPath .TASKFILE_DIR ".."}}'

tasks:

  preflight:
    # Pre-v0.20 document-model probe (#793, #2068 cutoff). Detects legacy
    # SPECIFICATION.md / PROJECT.md or missing lifecycle folders and points
    # operators at the frozen-release migration path in UPGRADING.md. Does NOT
    # run the in-product migrator (retired from current npm deposits).
    desc: "Detect pre-v0.20 document model and report the frozen-release migration path (#2068). Three-state exit (#793)."
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: :engine:_ts-build
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'migrate-preflight --project-root "{{.USER_WORKING_DIR}}" --deft-root "{{.DEFT_ROOT}}" {{.CLI_ARGS}}'

  xbrief:
    # Hop 2 on current npm (#4092). Hop 1 (`migrate:vbrief`) is frozen on the
    # v0.59.0 tag only — current deposits must not ship that target.
    desc: "Migrate consumer vbrief/ layout to xbrief/ with semantic v0.6->v0.8 transforms (#2110 / #2034). Hop 2 of the frozen two-hop path (#4092)."
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: :engine:_ts-build
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'migrate-xbrief --project-root "{{.USER_WORKING_DIR}}" --framework-root "{{.DEFT_ROOT}}" {{.CLI_ARGS}}'

  category-b:
    desc: "Namespace Category B bare plan keys (policy / completedNote) under x-directive/ across the corpus (#1650 / #2034)."
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: :engine:_ts-build
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'migrate-category-b --project-root "{{.USER_WORKING_DIR}}" {{.CLI_ARGS}}'
