version: '3'

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

# issue ingest task.
#
# IMPORTANT: runs from the consumer project root (``dir:
# '{{.USER_WORKING_DIR}}'``) so ``gh`` and ``git`` commands executed by
# ``scripts/issue_ingest.py`` resolve against the CONSUMER's remote, not
# deftai/directive (#538). The explicit ``--project-root`` flag makes the
# intent clear to the script and gives it a stable anchor even if Task's
# ``dir:`` semantics ever change. Script path dispatched via {{.DEFT_ROOT}}
# (defined locally in this file's `vars:` block via
# ``{{joinPath .TASKFILE_DIR ".."}}`` -- see ../Taskfile.yml for why
# root-level definition is avoided) to keep the path traversal-free and
# avoid the {{.TASKFILE_DIR}}/.. form that breaks on Windows under
# `uv --project "{{.DEFT_ROOT}}" run python` (#566).

tasks:

  ingest:
    desc: "Ingest GitHub issues as scope vBRIEFs (single <N> or --all [--label L] [--status S] [--dry-run])"
    dir: '{{.USER_WORKING_DIR}}'
    deps:
      - task: :engine:_ts-build
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'issue-ingest --project-root "{{.USER_WORKING_DIR}}" {{.CLI_ARGS}}'

  # issue emit task -- the write-direction counterpart to issue:ingest
  # (#1274 Change 2). Files GitHub issue(s) from scope vBRIEFs and records
  # the issue URL back into each vBRIEF's references[]. Runs from the
  # consumer project root (``dir: '{{.USER_WORKING_DIR}}'``) so ``gh`` /
  # ``git`` resolve against the CONSUMER's remote, not deftai/directive
  # (#538); --project-root anchors repo detection and glob expansion.
  # Honors --dry-run AND DEFT_NO_NETWORK=1 (plan only; no forge write).
  emit:
    desc: "File GitHub issue(s) from scope vBRIEF(s) (<path> | --umbrella <glob> | --per-vbrief <glob> [--dry-run])"
    dir: '{{.USER_WORKING_DIR}}'
    deps: [":engine:_ts-build"]
    env:
      PYTHONUTF8: "1"
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'issue-emit --project-root "{{.USER_WORKING_DIR}}" {{.CLI_ARGS}}'
