{"version":3,"file":"workflowCatalog.cjs","names":["DOOM_FULLSCREEN_UI_OPTIONS","visibleWidth","wrapTextWithAnsi","truncateToWidth","matchesQuery","DoomOverlay","matchesKey","isControlInput","Key","DOOM_OVERLAY_ACCENT","fit","pathTail","rightAligned"],"sources":["../../../../src/tui/workflow/workflowCatalog.ts"],"sourcesContent":["/**\n * The `SPC w l` board: every workflow this repository defines, with the cursor\n * workflow's parsed detail beside it and `r` to launch it.\n *\n * WHY NOT `workflowPicker.ts`:\n * That surface answers \"which one\", hands a value back, and closes - which is\n * what `SPC w c` recovery still needs. This one answers \"what is this workflow,\n * and do I want to run it\", so the detail has to be on screen next to the list\n * rather than behind a selection. The picker stays for the pick-and-return case\n * rather than growing a second mode.\n *\n * DESIGN PATTERNS:\n * - Detail is loaded through an injected loader, so parsing a workflow file\n *   stays out of the TUI and the surface is assertable as text. Loaded on\n *   demand for the cursor row and cached by row key: a repository with fifty\n *   workflows must not parse fifty files to draw one pane\n * - A row is two lines, name over path. One line made the name - the field a\n *   reader picks a row by - share a third of the overlay with a path that\n *   repeats its directory on every row\n * - `/` opens the filter rather than plain letters filtering as they are typed:\n *   the letter keys carry commands here (`r` launch, `t`/`i`/`s` tabs)\n */\n\nimport type { ExtensionContext, Theme } from '@earendil-works/pi-coding-agent';\nimport { Key, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi } from '@earendil-works/pi-tui';\n\nimport {\n  DOOM_FULLSCREEN_UI_OPTIONS,\n  DOOM_OVERLAY_ACCENT,\n  DoomOverlay,\n  type DoomOverlayChrome,\n  type DoomOverlayTui,\n} from './doomOverlay';\nimport {\n  CURSOR_BLOCK,\n  ELLIPSIS,\n  fit,\n  isControlInput,\n  matchesQuery,\n  pathTail,\n  rightAligned,\n  SELECTION_MARKER,\n} from './overlayText';\n\nexport const WORKFLOW_CATALOG_OVERLAY_OPTIONS = DOOM_FULLSCREEN_UI_OPTIONS.overlayOptions;\n\n/** One workflow file, as the catalog tool reports it. */\nexport interface WorkflowCatalogRow {\n  /** Stable identity and the loader's cache key: the absolute path. */\n  key: string;\n  name: string;\n  relativePath: string;\n  description: string;\n  tags: readonly string[];\n}\n\nexport interface WorkflowInputSummary {\n  name: string;\n  description?: string;\n  required?: boolean;\n  default?: string;\n  options?: readonly string[];\n}\n\nexport interface WorkflowJobSummary {\n  name: string;\n  steps: readonly string[];\n}\n\n/**\n * What the detail pane shows for one workflow. `runners` is undefined when the\n * workflow names no runner map at all, which is not the same as naming an empty\n * one - see `compatibleRunners`.\n */\nexport interface WorkflowCatalogDetail {\n  triggers: readonly string[];\n  inputs: readonly WorkflowInputSummary[];\n  jobs: readonly WorkflowJobSummary[];\n  runners?: readonly string[];\n  /** Set when the file could not be parsed; the pane shows this instead of guessing. */\n  error?: string;\n}\n\nexport type WorkflowDetailLoader = (row: WorkflowCatalogRow) => WorkflowCatalogDetail;\n\n/** Starts one workflow and returns immediately; the overlay closes on launch. */\nexport type WorkflowLaunchDispatcher = (row: WorkflowCatalogRow) => void;\n\nexport interface WorkflowCatalogOptions {\n  loadDetail: WorkflowDetailLoader;\n  /** Absent until a composition root wires the launch key to a real launcher. */\n  launchWorkflow?: WorkflowLaunchDispatcher;\n}\n\nexport type WorkflowDetailTab = 'triggers' | 'inputs' | 'steps';\n\ntype ThemeColor = Parameters<Theme['fg']>[0];\n\nconst TITLE = 'WORKFLOWS';\nconst BREADCRUMB = 'SPC › w / workflows › l / list';\nconst DIVIDER = '│';\nconst DEFAULT_PAGE_SIZE = 1;\nconst ROWS_PER_ENTRY = 2;\n/** Indent under `${SELECTION_MARKER} `, so the path line hangs under the name. */\nconst META_INDENT = '  ';\nconst EMPTY_NAME = '(unnamed)';\nconst LAUNCH_KEY = 'r';\nconst FILTER_KEY = '/';\nconst KEY_CLEAR = '\\x15';\nconst FILTER_LABEL = 'FILTER';\nconst EMPTY_MESSAGE = 'No workflow definitions were found in this repository.';\nconst TAB_ORDER: readonly WorkflowDetailTab[] = ['triggers', 'inputs', 'steps'];\nconst TAB_KEYS: Record<string, WorkflowDetailTab> = { t: 'triggers', i: 'inputs', s: 'steps' };\nconst FOOTER = '↑↓ cursor · JK scroll · tab detail · / filter · r launch · esc close';\nconst FOOTER_HINTS: readonly (readonly [string, string])[] = [\n  ['↑↓', 'move'],\n  ['JK', 'scroll'],\n  ['tab', 'cycle'],\n  ['/', 'filter'],\n  ['r', 'launch'],\n];\nconst FILTER_FOOTER = 'enter keep · esc clear · ctrl+u wipe';\nconst FILTER_FOOTER_HINTS: readonly (readonly [string, string])[] = [\n  ['enter', 'keep'],\n  ['esc', 'clear'],\n  ['ctrl+u', 'wipe'],\n];\n\ninterface SplitLayout {\n  leftContentWidth: number;\n  rightContentWidth: number;\n  gutterWidth: number;\n}\n\nfunction splitLayout(width: number): SplitLayout {\n  const paneBudget = Math.max(2, width - visibleWidth(DIVIDER));\n  const leftPaneWidth = Math.max(1, Math.floor(paneBudget / 3));\n  const rightPaneWidth = Math.max(1, paneBudget - leftPaneWidth);\n  const gutterWidth = leftPaneWidth >= 3 && rightPaneWidth >= 3 ? 1 : 0;\n  return {\n    leftContentWidth: Math.max(1, leftPaneWidth - gutterWidth),\n    rightContentWidth: Math.max(1, rightPaneWidth - gutterWidth),\n    gutterWidth,\n  };\n}\n\nfunction appendWrapped(lines: string[], text: string, width: number, colour: ThemeColor, theme: Theme): void {\n  for (const line of wrapTextWithAnsi(text, Math.max(1, width))) lines.push(theme.fg(colour, line));\n}\n\nfunction appendSection(lines: string[], heading: string, items: readonly string[], width: number, theme: Theme): void {\n  lines.push(theme.bold(theme.fg('accent', heading)));\n  if (items.length === 0) lines.push(theme.fg('dim', '  none'));\n  else for (const item of items) appendWrapped(lines, `  • ${item}`, width, 'text', theme);\n  lines.push('');\n}\n\nfunction inputLabel(input: WorkflowInputSummary): string {\n  const qualifiers = [\n    input.required ? 'required' : 'optional',\n    input.default === undefined ? undefined : `default ${input.default}`,\n    input.options && input.options.length > 0 ? `one of ${input.options.join(', ')}` : undefined,\n  ].filter((part): part is string => Boolean(part));\n  const description = input.description ? `${input.description} · ` : '';\n  return `${input.name} — ${description}${qualifiers.join(' · ')}`;\n}\n\nexport function workflowDetailLines(\n  detail: WorkflowCatalogDetail,\n  tab: WorkflowDetailTab,\n  width: number,\n  theme: Theme,\n): string[] {\n  const lines: string[] = [];\n  if (detail.error) {\n    lines.push(theme.bold(theme.fg('error', 'WORKFLOW ERROR')));\n    appendWrapped(lines, detail.error, width, 'error', theme);\n    lines.push('');\n    return lines;\n  }\n  if (tab === 'triggers') {\n    appendSection(lines, 'TRIGGERS', detail.triggers, width, theme);\n    // No runner map means every runner qualifies, which a bare \"none\" would\n    // report as the opposite.\n    appendSection(lines, 'RUNNERS', detail.runners ?? ['any available runner'], width, theme);\n    return lines;\n  }\n  if (tab === 'inputs') {\n    appendSection(lines, 'DISPATCH INPUTS', detail.inputs.map(inputLabel), width, theme);\n    return lines;\n  }\n  for (const job of detail.jobs) {\n    lines.push(theme.bold(theme.fg('accent', job.name)));\n    if (job.steps.length === 0) lines.push(theme.fg('dim', '  no steps'));\n    else for (const step of job.steps) appendWrapped(lines, `  • ${step}`, width, 'text', theme);\n    lines.push('');\n  }\n  if (detail.jobs.length === 0) appendSection(lines, 'JOBS', [], width, theme);\n  return lines;\n}\n\nfunction tabStrip(tab: WorkflowDetailTab, width: number, theme: Theme): string {\n  const labels = TAB_ORDER.map((candidate) => {\n    const label = candidate.toUpperCase();\n    return candidate === tab ? theme.inverse(theme.bold(` ${label} `)) : theme.fg('dim', ` ${label} `);\n  }).join(' ');\n  return truncateToWidth(labels, Math.max(0, width), ELLIPSIS);\n}\n\nexport function filterWorkflowRows(rows: readonly WorkflowCatalogRow[], query: string): readonly WorkflowCatalogRow[] {\n  if (!query.trim()) return rows;\n  return rows.filter((row) =>\n    matchesQuery([row.name, row.relativePath, row.description, row.tags.join(' ')].join(' '), query),\n  );\n}\n\nexport class WorkflowCatalogComponent extends DoomOverlay {\n  private readonly rows: readonly WorkflowCatalogRow[];\n  private readonly detailCache = new Map<string, WorkflowCatalogDetail>();\n  private cursorIndex = 0;\n  private tab: WorkflowDetailTab = 'triggers';\n  private query = '';\n  private filtering = false;\n  private notice: string | undefined;\n  private listPageSize = DEFAULT_PAGE_SIZE;\n  private detailPageSize = DEFAULT_PAGE_SIZE;\n  private detailOffset = 0;\n  private detailTotal = 0;\n\n  constructor(\n    tui: DoomOverlayTui,\n    theme: Theme,\n    rows: readonly WorkflowCatalogRow[],\n    private readonly done: (result: undefined) => void,\n    private readonly options: WorkflowCatalogOptions,\n  ) {\n    super(tui, theme);\n    this.rows = [...rows].sort((left, right) => left.name.localeCompare(right.name));\n  }\n\n  private matches(): readonly WorkflowCatalogRow[] {\n    return filterWorkflowRows(this.rows, this.query);\n  }\n\n  private cursorRow(): WorkflowCatalogRow | undefined {\n    const matches = this.matches();\n    return matches[Math.min(this.cursorIndex, Math.max(0, matches.length - 1))];\n  }\n\n  /** Parsed once per workflow, then reused for every repaint of that row. */\n  private detailFor(row: WorkflowCatalogRow): WorkflowCatalogDetail {\n    const cached = this.detailCache.get(row.key);\n    if (cached) return cached;\n    const detail = this.options.loadDetail(row);\n    this.detailCache.set(row.key, detail);\n    return detail;\n  }\n\n  private moveCursor(delta: number): void {\n    const count = this.matches().length;\n    if (count === 0) return;\n    const next = Math.max(0, Math.min(count - 1, this.cursorIndex + delta));\n    if (next === this.cursorIndex) return;\n    this.cursorIndex = next;\n    // The detail pane follows the cursor, so its scroll belonged to the row\n    // that was showing, not the one replacing it.\n    this.detailOffset = 0;\n    this.invalidate();\n  }\n\n  private switchTab(tab: WorkflowDetailTab): void {\n    if (this.tab === tab) return;\n    this.tab = tab;\n    this.detailOffset = 0;\n    this.invalidate();\n  }\n\n  private cycleTab(): void {\n    const current = TAB_ORDER.indexOf(this.tab);\n    this.switchTab(TAB_ORDER[(current + 1) % TAB_ORDER.length] ?? 'triggers');\n  }\n\n  private scrollDetail(delta: number): void {\n    if (!this.cursorRow()) return;\n    const maximum = Math.max(0, this.detailTotal - this.detailPageSize);\n    const next = Math.max(0, Math.min(maximum, this.detailOffset + delta));\n    if (next === this.detailOffset) return;\n    this.detailOffset = next;\n    this.invalidate();\n  }\n\n  private setNotice(notice: string): void {\n    this.notice = notice;\n    this.invalidate();\n  }\n\n  private setQuery(query: string): void {\n    if (query === this.query) return;\n    this.query = query;\n    // The previous index named a row this filter may no longer list.\n    this.cursorIndex = 0;\n    this.detailOffset = 0;\n    this.invalidate();\n  }\n\n  private launchCursor(): void {\n    const row = this.cursorRow();\n    if (!row) {\n      this.setNotice('launch unavailable · no workflow is selected');\n      return;\n    }\n    const launchWorkflow = this.options.launchWorkflow;\n    if (!launchWorkflow) {\n      this.setNotice('launch unavailable · no workflow launcher is attached');\n      return;\n    }\n    const detail = this.detailFor(row);\n    if (detail.error) {\n      this.setNotice(`launch unavailable · ${detail.error}`);\n      return;\n    }\n    // Closing first is what makes the launcher's own prompts reachable: they\n    // are host dialogs, and a fullscreen overlay sits over them.\n    this.done(undefined);\n    launchWorkflow(row);\n  }\n\n  private handleFilterInput(data: string): void {\n    if (matchesKey(data, 'escape') || matchesKey(data, 'ctrl+c')) {\n      this.filtering = false;\n      this.setQuery('');\n      this.invalidate();\n      return;\n    }\n    if (matchesKey(data, 'enter')) {\n      this.filtering = false;\n      this.invalidate();\n      return;\n    }\n    if (matchesKey(data, 'backspace')) {\n      this.setQuery(this.query.slice(0, -1));\n      return;\n    }\n    if (data === KEY_CLEAR) {\n      this.setQuery('');\n      return;\n    }\n    if (!isControlInput(data)) this.setQuery(this.query + data);\n  }\n\n  handleInput(data: string): void {\n    if (this.filtering) {\n      this.handleFilterInput(data);\n      return;\n    }\n    if (matchesKey(data, 'escape') || matchesKey(data, 'ctrl+c')) {\n      this.done(undefined);\n      return;\n    }\n    if (matchesKey(data, Key.shift('k'))) return this.scrollDetail(-1);\n    if (matchesKey(data, Key.shift('j'))) return this.scrollDetail(1);\n    if (matchesKey(data, 'up') || data === 'k') return this.moveCursor(-1);\n    if (matchesKey(data, 'down') || data === 'j') return this.moveCursor(1);\n    if (matchesKey(data, 'pageUp')) return this.moveCursor(-this.listPageSize);\n    if (matchesKey(data, 'pageDown')) return this.moveCursor(this.listPageSize);\n    if (matchesKey(data, 'tab')) return this.cycleTab();\n    if (data === FILTER_KEY) {\n      this.filtering = true;\n      this.notice = undefined;\n      this.invalidate();\n      return;\n    }\n    if (data === LAUNCH_KEY) return this.launchCursor();\n    const tab = TAB_KEYS[data];\n    if (tab) this.switchTab(tab);\n  }\n\n  protected getChrome(): DoomOverlayChrome {\n    const matches = this.matches();\n    const scope = this.query ? `${matches.length} of ${this.rows.length}` : `${this.rows.length}`;\n    return {\n      title: TITLE,\n      accent: DOOM_OVERLAY_ACCENT,\n      breadcrumb: BREADCRUMB,\n      headerRight: `${scope} workflows · ${this.tab}`,\n      footer: this.filtering ? FILTER_FOOTER : FOOTER,\n      footerHints: this.filtering ? FILTER_FOOTER_HINTS : FOOTER_HINTS,\n      footerRight: matches.length\n        ? `${Math.min(this.cursorIndex, matches.length - 1) + 1}/${matches.length}`\n        : 'no match',\n    };\n  }\n\n  protected renderBody(width: number, height: number): string[] {\n    const filterRows = this.filtering || this.query ? 1 : 0;\n    const transientRows = filterRows + (this.notice === undefined ? 0 : 1);\n    const mainHeight = Math.max(0, height - transientRows);\n    const layout = splitLayout(width);\n    const left = this.renderList(layout.leftContentWidth, mainHeight);\n    const right = this.renderDetail(layout.rightContentWidth, mainHeight);\n    const gutter = ' '.repeat(layout.gutterWidth);\n    const divider = this.theme.fg('borderMuted', DIVIDER);\n    const lines: string[] = [];\n    for (let index = 0; index < mainHeight; index++) {\n      lines.push(\n        `${fit(left[index] ?? '', layout.leftContentWidth)}${gutter}${divider}${gutter}${fit(\n          right[index] ?? '',\n          layout.rightContentWidth,\n        )}`,\n      );\n    }\n    if (filterRows) {\n      const value = this.filtering ? `${this.query}${CURSOR_BLOCK}` : this.query;\n      lines.push(` ${this.theme.bold(this.theme.fg('accent', FILTER_LABEL))} ${value}`);\n    }\n    if (this.notice !== undefined) lines.push(` ${this.theme.fg('muted', this.notice)}`);\n    return lines.slice(0, height).map((line) => fit(line, width));\n  }\n\n  private renderList(width: number, height: number): string[] {\n    const matches = this.matches();\n    const lines = [this.theme.bold(this.theme.fg('accent', `WORKFLOWS ${matches.length}`))];\n    if (matches.length === 0) {\n      appendWrapped(\n        lines,\n        this.rows.length === 0 ? EMPTY_MESSAGE : 'No workflow matches this filter.',\n        width,\n        'dim',\n        this.theme,\n      );\n      this.listPageSize = DEFAULT_PAGE_SIZE;\n      return lines.slice(0, height);\n    }\n\n    this.listPageSize = Math.max(DEFAULT_PAGE_SIZE, Math.floor((height - 1) / ROWS_PER_ENTRY));\n    const active = Math.min(this.cursorIndex, matches.length - 1);\n    const start = Math.max(\n      0,\n      Math.min(active - this.listPageSize + 1, Math.max(0, matches.length - this.listPageSize)),\n    );\n    for (const [offset, row] of matches.slice(start, start + this.listPageSize).entries()) {\n      const current = start + offset === active;\n      const marker = current ? this.theme.fg('accent', SELECTION_MARKER) : ' ';\n      const label = row.name || EMPTY_NAME;\n      const name = current ? this.theme.bold(this.theme.fg('accent', label)) : this.theme.fg('text', label);\n      const meta = this.theme.fg('dim', pathTail(row.relativePath, Math.max(0, width - META_INDENT.length)));\n      lines.push(fit(`${marker} ${name}`, width));\n      lines.push(fit(`${META_INDENT}${meta}`, width));\n    }\n    return lines.slice(0, height);\n  }\n\n  private renderDetail(width: number, height: number): string[] {\n    const row = this.cursorRow();\n    if (!row) {\n      this.detailTotal = 0;\n      this.detailPageSize = Math.max(DEFAULT_PAGE_SIZE, height);\n      this.detailOffset = 0;\n      const lines = [this.theme.bold(this.theme.fg('accent', 'WORKFLOW DETAIL')), ''];\n      appendWrapped(\n        lines,\n        this.rows.length === 0 ? EMPTY_MESSAGE : 'No workflow matches this filter.',\n        width,\n        'text',\n        this.theme,\n      );\n      return lines.slice(0, height);\n    }\n\n    const header = [\n      rightAligned(\n        this.theme.bold(this.theme.fg('accent', `INSPECTING ${row.name || EMPTY_NAME}`)),\n        this.theme.fg('dim', pathTail(row.relativePath, Math.max(0, Math.floor(width / 2)))),\n        width,\n      ),\n    ];\n    if (row.description) appendWrapped(header, row.description, width, 'text', this.theme);\n    if (row.tags.length > 0) appendWrapped(header, row.tags.join(' · '), width, 'dim', this.theme);\n    header.push(tabStrip(this.tab, width, this.theme), '');\n\n    const body = workflowDetailLines(this.detailFor(row), this.tab, width, this.theme);\n    this.detailPageSize = Math.max(0, height - header.length);\n    this.detailTotal = body.length;\n    this.detailOffset = Math.min(this.detailOffset, Math.max(0, body.length - this.detailPageSize));\n    return [...header, ...body.slice(this.detailOffset, this.detailOffset + this.detailPageSize)].slice(0, height);\n  }\n}\n\nexport async function openWorkflowCatalogOverlay(\n  ctx: ExtensionContext,\n  rows: readonly WorkflowCatalogRow[],\n  options: WorkflowCatalogOptions,\n): Promise<void> {\n  await ctx.ui.custom<undefined>(\n    (tui, theme, _keybindings, done) => new WorkflowCatalogComponent(tui, theme, rows, done, options),\n    DOOM_FULLSCREEN_UI_OPTIONS,\n  );\n}\n"],"mappings":";;;AA4CgDA,oBAAAA,2BAA2B;AAsD3E,MAAM,QAAQ;AACd,MAAM,aAAa;AACnB,MAAM,UAAU;AAChB,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;;AAEvB,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,YAA0C;CAAC;CAAY;CAAU;AAAO;AAC9E,MAAM,WAA8C;CAAE,GAAG;CAAY,GAAG;CAAU,GAAG;AAAQ;AAC7F,MAAM,SAAS;AACf,MAAM,eAAuD;CAC3D,CAAC,MAAM,MAAM;CACb,CAAC,MAAM,QAAQ;CACf,CAAC,OAAO,OAAO;CACf,CAAC,KAAK,QAAQ;CACd,CAAC,KAAK,QAAQ;AAChB;AACA,MAAM,gBAAgB;AACtB,MAAM,sBAA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