/**
 * engine/playbook-intents.js — W-mq1cczi90006b21f
 *
 * Maps Minions playbook names (work-item types) to the intent buckets each
 * playbook should surface from project-local skill discovery. The mapping is
 * the single source of truth for "which playbook gets which slice of the
 * skills block" — engine/playbook.js consults this at render time.
 *
 * Intent vocabulary (defined in engine/discover-project-skills.js):
 *   review | build | fix | test | plan | research | deploy | observability | meta
 *
 * Adding a new playbook? Add an entry here. Playbooks not in this map fall
 * through to NO skills block (the engine treats undefined as the empty set,
 * which is the safe default — agents see no header rather than a noisy one).
 *
 * Adding a new intent? Add the keyword regex to INTENT_KEYWORDS in
 * engine/discover-project-skills.js AND a row to this map (or update an
 * existing playbook to include it). Then document the verb in
 * docs/project-skills.md.
 */

// Canonical mapping. Lower-cased playbook names; intent values must be
// members of INTENT_VOCABULARY in engine/discover-project-skills.js.
const PLAYBOOK_INTENTS = Object.freeze({
  // Review-flavored playbooks — preserves PR-82 behavior verbatim.
  review:        ['review'],

  // Fix dispatches often need to re-run review tooling after the fix lands,
  // and may also touch tests; surface review+test alongside debug/triage.
  fix:           ['fix', 'test', 'review'],

  // Implementation surfaces build/scaffold/codemod skills plus the matching
  // test skills, and research for codebase investigation.
  implement:        ['build', 'test', 'research'],
  'implement-shared': ['build', 'test', 'research'],

  // Planning surfaces planning + research (codebase exploration is part of
  // good planning).
  plan:          ['plan', 'research'],
  'plan-to-prd': ['plan', 'research'],
  decompose:     ['plan', 'research'],

  // Doc / verify / build-and-test playbooks — keep tight intent sets so
  // we don't dump build-bumping skills into a docs prompt.
  docs:          ['research'],
  verify:        ['test', 'review'],
  'build-and-test': ['build', 'test'],
  test:          ['test'],

  // Exploration / asks: research-heavy.
  explore:       ['research'],

  // qa-validate: targeted at test/qa skills.
  'qa-validate': ['test'],

  // Followup-dispatch is a template (not a top-level playbook); the engine
  // inherits the parent dispatch's intent set when rendering follow-ups.
  // See engine/playbook.js → renderPlaybook for the inheritance plumb.
});

/**
 * Look up the intent set for a playbook name. Returns [] for unknown
 * playbooks (caller treats empty as "render no block").
 *
 * @param {string} playbookName
 * @returns {string[]}
 */
function intentsForPlaybook(playbookName) {
  if (!playbookName || typeof playbookName !== 'string') return [];
  return PLAYBOOK_INTENTS[playbookName.toLowerCase()] || [];
}

module.exports = {
  PLAYBOOK_INTENTS,
  intentsForPlaybook,
};
