version: '3'

# Triage v1 bootstrap fragment (#845 Story 6).
#
# Standalone fragment: this file is wired into the parent Taskfile.yml via the
# `includes:` block (see Taskfile.yml `## triage v1 fragment includes` comment).
# When included under namespace key `triage-bootstrap`, the inner task
# `bootstrap` is reachable as `task triage-bootstrap:bootstrap`. The parent
# Taskfile.yml additionally exposes the user-facing alias `task triage:bootstrap`
# which delegates here.
#
# Companion files in the four-fragment cluster (#845):
#   tasks/triage-cache.yml      (Story 1 -- cache populate + show)
#   tasks/triage-actions.yml    (Story 3 -- accept/reject/defer/...)
#   tasks/triage-bulk.yml       (Story 4 -- bulk ops + freshness)
#   tasks/triage-bootstrap.yml  (Story 6 -- this file)
#
# Handler: packages/cli/src/triage-bootstrap.ts via engine:invoke (packages/cli/dist).
# Help registry: packages/core/src/triage/help/registry-data.ts (edit in place).
#
# Per `conventions/task-caching.md` (#574): NO `sources:` / `generates:`
# declarations on this task because user-facing recovery flags
# (`--repo`, `--fetch-timeout-s`, `--json`, `--quiet`) are forwarded via
# {{.CLI_ARGS}} and go-task's incremental-build cache layer would silently
# swallow them. The Story 3 rebind dropped the v0.25.x `--skip-gitcrawl`
# install path entirely (#951): the script's argparse never accepted it.

vars:
  # Resolve the deft framework root from this fragment's directory. The
  # joinPath idiom mirrors the existing convention documented in the root
  # Taskfile.yml header (#566): `{{.TASKFILE_DIR}}/..` evaluated by go-task's
  # eager templating yields a native-separator absolute path that
  # `node .../bin.js` can open on Windows / macOS / Linux.
  DEFT_ROOT: '{{joinPath .TASKFILE_DIR ".."}}'

tasks:
  bootstrap:
    desc: "Idempotent triage v1 installer (#845): populate cache, backfill audit log, ensure gitignore for .deft-cache/ and vbrief/.eval/. Re-runnable; per-step progress on stderr; cache:fetch-all wall-clock cap (#952). -- task triage:bootstrap [-- --repo OWNER/NAME] [--limit N] [--state open|closed|all] [--fetch-timeout-s N] [--quiet] [--json]"
    internal: true
    deps: [":engine:_ts-build"]
    dir: '{{.USER_WORKING_DIR}}'
    cmds:
      - task: :engine:invoke
        vars:
          ENGINE_CMD: 'triage-bootstrap --project-root "{{.USER_WORKING_DIR}}" {{.CLI_ARGS}}'
