// Marketplace seeds: idempotent installation of the Phase 1 skill + bundle catalog.
//
// Tool-kind items live in `tool_installations` (managed by lib/tools/registry.js).
// This module seeds the non-tool catalog (skills + bundles) into
// `marketplace_items` so the marketplace shell has real content on first load.
//
// All seeds are idempotent: re-running never duplicates an existing (kind, slug).
// Skill / bundle file installation into the user's workspace is Phase 2 work.
// In Phase 1, "installed" is purely a flag in `marketplace_installations`.

import { seedConnections } from './connection-seeds.js';

// Curated Open Design skills exposed in the marketplace. The full vendored
// catalog lives at workspace/skills/open-design/ — only the highest-value
// entries are surfaced here as standalone marketplace items.
const OPEN_DESIGN_CURATED_SKILLS = [
  { slug: 'web-prototype', title: 'Open Design — Web Prototype', description: 'Generate a complete production-quality web prototype from a brief.' },
  { slug: 'saas-landing', title: 'Open Design — SaaS Landing', description: 'Build a SaaS landing page with hero, features, social proof, pricing.' },
  { slug: 'dashboard', title: 'Open Design — Dashboard', description: 'Information-dense, hierarchy-driven dashboard scaffold.' },
  { slug: 'mobile-app', title: 'Open Design — Mobile App', description: 'Mobile-first product UI scaffold with touch targets and gestures.' },
  { slug: 'social-carousel', title: 'Open Design — Social Carousel', description: 'Editorial social carousel with platform-aware aspect ratios.' },
  { slug: 'magazine-poster', title: 'Open Design — Magazine Poster', description: 'Editorial magazine/poster typography with high contrast.' },
  { slug: 'deck-guizang-editorial', title: 'Open Design — Editorial Deck', description: 'Guizang editorial-style slide deck system.' },
  { slug: 'email-marketing', title: 'Open Design — Email Marketing', description: 'Transactional/marketing email scaffold with bulletproof HTML.' },
  { slug: 'design-brief', title: 'Open Design — Design Brief', description: 'Structured design brief used to seed the rest of the pipeline.' },
  { slug: 'design-review', title: 'Open Design — Design Review', description: 'Designer\'s eye plan review and visual QA pass.' },
  { slug: 'brand-guidelines', title: 'Open Design — Brand Guidelines', description: 'Distill or author a brand guidelines book.' },
  { slug: 'copywriting', title: 'Open Design — Copywriting', description: 'High-signal product copywriting craft notes and structure.' },
];

function buildOpenDesignSkillSeed(curated) {
  return {
    slug: `open-design-${curated.slug}`,
    title: curated.title,
    description: curated.description,
    category: 'design',
    author: 'nexu-io',
    source_kind: 'github',
    source_url: `https://github.com/nexu-io/open-design/tree/main/skills/${curated.slug}`,
    version: null,
    risk_summary: 'Read-only design corpus — no external writes.',
    tags: ['design', 'open-design', 'nexu-io'],
    manifest: {
      invocation: `/open-design/${curated.slug}`,
      file_paths: [`workspace/skills/open-design/skills/${curated.slug}/SKILL.md`],
      trigger_examples: [`apply ${curated.slug.replace(/-/g, ' ')}`, 'design using open-design'],
      upstream_slug: curated.slug,
    },
  };
}

const OPEN_DESIGN_BUNDLE = {
  slug: 'open-design',
  title: 'Open Design (nexu-io)',
  description:
    'Vendored design corpus from nexu-io/open-design: craft notes, 130+ skills, ~140 design systems, prompt + design templates. Apache-2.0.',
  category: 'design',
  author: 'nexu-io',
  source_kind: 'github',
  source_url: 'https://github.com/nexu-io/open-design',
  version: null,
  risk_summary: 'Read-only design content. No code executes; no external writes.',
  tags: ['design', 'craft', 'systems', 'templates', 'open-source', 'apache-2.0'],
  manifest: {
    item_refs: OPEN_DESIGN_CURATED_SKILLS.map(s => `skill:open-design-${s.slug}`),
    published_count: OPEN_DESIGN_CURATED_SKILLS.length,
    license: 'Apache-2.0',
    note:
      'Vendored under workspace/skills/open-design/. Re-vendor with `npm run vendor:open-design`. See NOTICE.md for attribution.',
  },
};

const SKILL_SEEDS = [
  {
    slug: 'design-shotgun',
    title: 'Design Shotgun',
    description:
      'Generate multiple AI design variants for any UI surface, open a comparison board, and iterate from approved options.',
    category: 'design',
    author: 'gstack',
    source_kind: 'builtin',
    source_url: null,
    version: null,
    risk_summary: 'Read-only ideation — no external writes.',
    tags: ['design', 'mockups', 'exploration'],
    manifest: {
      invocation: '/design-shotgun',
      file_paths: ['skills/design-shotgun/SKILL.md'],
      trigger_examples: [
        'explore designs',
        'show me design variants',
        'visual brainstorm',
      ],
    },
  },
  {
    slug: 'design-review',
    title: 'Design Review',
    description:
      'Visual QA pass on live pages: extracts the design system in use, audits hierarchy, typography, color, and spacing, and proposes fixes.',
    category: 'design',
    author: 'gstack',
    source_kind: 'builtin',
    source_url: null,
    version: null,
    risk_summary: 'Read-only audit — fixes are proposed, not applied.',
    tags: ['design', 'review', 'visual-qa'],
    manifest: {
      invocation: '/design-review',
      file_paths: ['skills/design-review/SKILL.md'],
      trigger_examples: [
        'review the design',
        'visual QA',
        'audit this page',
      ],
    },
  },
  {
    slug: 'qa-only',
    title: 'QA Only',
    description:
      'Systematically QA a web app and produce a structured report with health score, screenshots, and repro steps. Never modifies code.',
    category: 'review',
    author: 'gstack',
    source_kind: 'builtin',
    source_url: null,
    version: null,
    risk_summary: 'Report-only — no auto-fix.',
    tags: ['qa', 'testing', 'report'],
    manifest: {
      invocation: '/qa-only',
      file_paths: ['skills/qa-only/SKILL.md'],
      trigger_examples: [
        'just report bugs',
        'qa report only',
        'test but do not fix',
      ],
    },
  },
  {
    slug: 'cso-audit',
    title: 'CSO Audit',
    description:
      'Chief Security Officer mode: infrastructure-first security audit covering secrets archaeology, supply chain, OWASP Top 10, and threat modeling.',
    category: 'security',
    author: 'gstack',
    source_kind: 'builtin',
    source_url: null,
    version: null,
    risk_summary: 'Read-only audit; never executes destructive commands.',
    tags: ['security', 'audit', 'owasp', 'threat-model'],
    manifest: {
      invocation: '/cso',
      file_paths: ['skills/cso/SKILL.md'],
      trigger_examples: [
        'security audit',
        'threat model',
        'OWASP review',
      ],
    },
  },
];

// Business-default skill pack — the capabilities most teams reach for first, so
// a fresh agent can do real work out of the box (research, comms, documents,
// data, web). Each is a builtin skill catalog item backed by the default tools
// (web/email/calendar/files/supabase/browser). These are what the banner
// showcases; the design/QA skills above stay in the marketplace but are not the
// default highlight reel.
const BUSINESS_SKILL_SEEDS = [
  {
    slug: 'market-research', title: 'Market Research', category: 'research',
    description: 'Research any market, company, or topic across the web and deliver a cited, structured brief.',
    tools: ['web_search', 'web_fetch', 'file_write'], risk_summary: 'Read-only research; writes only the report file.',
    tags: ['research', 'web', 'brief'], invocation: '/research',
    trigger_examples: ['research this market', 'competitive landscape for X', 'brief me on company Y'],
  },
  {
    slug: 'competitor-watch', title: 'Competitor Watch', category: 'research',
    description: 'Track competitor pricing, features, and news on a schedule and alert you when something changes.',
    tools: ['web_fetch', 'web_extract', 'email_send'], risk_summary: 'Read-only monitoring; sends a summary email.',
    tags: ['research', 'monitoring', 'competitive'], invocation: '/watch',
    trigger_examples: ['watch competitor pricing', 'alert me when X changes', 'track this page weekly'],
  },
  {
    slug: 'inbox-triage', title: 'Inbox Triage', category: 'comms',
    description: 'Summarize, prioritize, and draft replies across your inbox so you act on what matters first.',
    tools: ['gmail_messages_list', 'gmail_thread_read', 'email_send'], risk_summary: 'Drafts replies; sending is approval-gated.',
    tags: ['email', 'inbox', 'comms'], invocation: '/inbox',
    trigger_examples: ['triage my inbox', 'summarize unread email', 'draft replies'],
  },
  {
    slug: 'meeting-scheduler', title: 'Meeting Scheduler', category: 'comms',
    description: 'Find times, schedule meetings, and send invites from your calendar and email.',
    tools: ['calendar_events_list', 'calendar_event_read', 'email_send'], risk_summary: 'Proposes times; invites are approval-gated.',
    tags: ['calendar', 'scheduling', 'comms'], invocation: '/schedule-meeting',
    trigger_examples: ['schedule a meeting', 'find a time with X', 'book a call next week'],
  },
  {
    slug: 'document-extract', title: 'Document Extraction', category: 'documents',
    description: 'Pull structured data and key facts from PDFs, documents, and audio into clean, usable output.',
    tools: ['file_read', 'transcribe_audio', 'file_write'], risk_summary: 'Read-only extraction; writes only the output file.',
    tags: ['documents', 'extraction', 'pdf'], invocation: '/extract',
    trigger_examples: ['extract data from this PDF', 'pull the numbers from these docs', 'transcribe this audio'],
  },
  {
    slug: 'report-builder', title: 'Report Builder', category: 'documents',
    description: 'Turn raw data and notes into a polished, formatted report or one-pager ready to share.',
    tools: ['file_read', 'file_write'], risk_summary: 'Generates a document; no external writes.',
    tags: ['documents', 'reporting', 'writing'], invocation: '/report',
    trigger_examples: ['build a report from this data', 'write a one-pager', 'summarize into a deck outline'],
  },
  {
    slug: 'database-query', title: 'Database Q&A', category: 'data',
    description: 'Ask questions of your database in plain English and get answers, tables, and charts.',
    tools: ['supabase_rest_select', 'supabase_sql'], risk_summary: 'Read-only queries by default; writes are approval-gated.',
    tags: ['data', 'sql', 'analytics'], invocation: '/ask-data',
    trigger_examples: ['how many orders last month', 'query the users table', 'top customers by revenue'],
  },
  {
    slug: 'spreadsheet-analysis', title: 'Spreadsheet Analysis', category: 'data',
    description: 'Clean, analyze, and summarize spreadsheets and CSVs — pivots, trends, and outliers.',
    tools: ['file_read', 'file_write'], risk_summary: 'Local file analysis; no external writes.',
    tags: ['data', 'spreadsheet', 'csv'], invocation: '/analyze-sheet',
    trigger_examples: ['analyze this spreadsheet', 'summarize this CSV', 'find trends in this data'],
  },
  {
    slug: 'web-automation', title: 'Web Automation', category: 'web',
    description: 'Fill forms, extract data, and run repetitive flows in a real browser, end to end.',
    tools: ['browser_open', 'browser_act', 'browser_extract'], risk_summary: 'Browser actions are bounded and audited.',
    tags: ['web', 'automation', 'browser'], invocation: '/automate-web',
    trigger_examples: ['automate this form', 'scrape this site', 'run this flow for each row'],
  },
];

// Business Agent Suite skill packs (P4). Department-grouped skills that lean on
// the planned/connected business tools. NOT default-on (no manifest.default) so
// they don't crowd the fresh-install showcase — they install with the module.
const BUSINESS_SUITE_SKILL_SEEDS = [
  { slug: 'paid-campaign-build', title: 'Paid Campaign Build', category: 'marketing',
    description: 'Structure a paid campaign — objective, audiences, ad sets, creative spec, and budget — ready for approval-gated launch.',
    tools: ['create_artifact', 'web_search'], risk_summary: 'Plans campaigns; every publish/budget set stays approval-gated.',
    tags: ['marketing', 'ads', 'campaign'], invocation: '/paid-campaign',
    trigger_examples: ['build a Meta campaign', 'plan a paid launch', 'structure ad sets'] },
  { slug: 'ads-reporting', title: 'Ads Reporting', category: 'marketing',
    description: 'Pull spend, CPA, ROAS, and reach from connected ad accounts into one weekly performance report.',
    tools: ['create_artifact', 'file_write'], risk_summary: 'Read-only reporting; no external writes.',
    tags: ['marketing', 'ads', 'reporting'], invocation: '/ads-report',
    trigger_examples: ['weekly ads report', 'how did campaigns perform', 'ROAS summary'] },
  { slug: 'content-calendar', title: 'Content Calendar', category: 'content',
    description: 'Plan a multi-channel content calendar with post drafts, captions, and a scheduled queue.',
    tools: ['create_artifact', 'file_write'], risk_summary: 'Drafts and schedules; every publish stays approval-gated.',
    tags: ['content', 'social', 'calendar'], invocation: '/content-calendar',
    trigger_examples: ['plan this month of content', 'build a content calendar', 'draft social posts'] },
  { slug: 'lead-research', title: 'Lead Research', category: 'sales',
    description: 'Build a qualified target list, enrich it, and prep a personalized outreach sequence.',
    tools: ['web_search', 'web_fetch', 'create_artifact'], risk_summary: 'Research + drafts; sequence enrollment and bulk sends are approval-gated.',
    tags: ['sales', 'outreach', 'leads'], invocation: '/lead-research',
    trigger_examples: ['build a target list', 'find leads for X', 'prep an outreach sequence'] },
  { slug: 'ticket-reply', title: 'Ticket Reply', category: 'support',
    description: 'Triage support tickets, draft replies in brand voice, and flag escalations.',
    tools: ['gmail_messages_list', 'file_write'], risk_summary: 'Drafts replies; outbound sends/status changes are approval-gated.',
    tags: ['support', 'helpdesk', 'tickets'], invocation: '/ticket-reply',
    trigger_examples: ['triage support tickets', 'draft ticket replies', 'escalate this ticket'] },
  { slug: 'runway-model', title: 'Runway Model', category: 'finance',
    description: 'Turn revenue/expense data into a runway model and P&L summary with scenario sensitivity.',
    tools: ['file_read', 'create_artifact'], risk_summary: 'Advisory analysis; any money movement is approval-gated.',
    tags: ['finance', 'runway', 'modeling'], invocation: '/runway',
    trigger_examples: ['model our runway', 'P&L summary', 'how many months of cash'] },
];

function buildSuiteSkillSeed(s) {
  return {
    slug: s.slug,
    title: s.title,
    description: s.description,
    category: s.category,
    author: 'madarx',
    source_kind: 'builtin',
    source_url: null,
    version: null,
    risk_summary: s.risk_summary,
    tags: s.tags,
    manifest: {
      invocation: s.invocation,
      uses_tools: s.tools,
      trigger_examples: s.trigger_examples,
    },
  };
}

function buildBusinessSkillSeed(s) {
  return {
    slug: s.slug,
    title: s.title,
    description: s.description,
    category: s.category,
    author: 'madarx',
    source_kind: 'builtin',
    source_url: null,
    version: null,
    risk_summary: s.risk_summary,
    tags: s.tags,
    manifest: {
      invocation: s.invocation,
      default: true,
      uses_tools: s.tools,
      trigger_examples: s.trigger_examples,
    },
  };
}

const BUNDLE_SEEDS = [
  {
    slug: 'gstack',
    title: 'gstack',
    description:
      '"Senior engineering team in your terminal." 8 power tools + a stack of specialist skills for design, QA, review, security, and shipping. MIT licensed.',
    category: 'engineering',
    author: 'garrytan',
    source_kind: 'builtin',
    source_url: 'https://github.com/garrytan/gstack',
    version: null,
    risk_summary:
      'Mixed-risk bundle: includes read-only review skills and write-capable workflows (e.g. /ship runs git push). Per-item risk surfaces in Phase 2 when install is wired up.',
    tags: ['engineering', 'skills-pack', 'mit'],
    manifest: {
      item_refs: [
        'skill:design-shotgun',
        'skill:design-review',
        'skill:qa-only',
        'skill:cso-audit',
      ],
      published_count: 4,
      license: 'MIT',
      note:
        'Agent personas in this bundle will surface in the Agent Marketplace when it ships.',
    },
  },
];

function upsertItem(db, kind, seed) {
  const existing = db
    .prepare('SELECT id FROM marketplace_items WHERE kind=? AND slug=?')
    .get(kind, seed.slug);
  const id = existing?.id || `${kind}:${seed.slug}`;
  const manifestJson = seed.manifest ? JSON.stringify(seed.manifest) : null;
  const tagsJson = seed.tags ? JSON.stringify(seed.tags) : null;

  if (existing) {
    db.prepare(`
      UPDATE marketplace_items
         SET title=?, description=?, category=?, author=?, source_kind=?,
             source_url=?, version=?, manifest_json=?, risk_summary=?, tags=?
       WHERE id=?
    `).run(
      seed.title,
      seed.description,
      seed.category,
      seed.author,
      seed.source_kind,
      seed.source_url,
      seed.version,
      manifestJson,
      seed.risk_summary,
      tagsJson,
      id,
    );
  } else {
    db.prepare(`
      INSERT INTO marketplace_items
        (id, kind, slug, title, description, category, author,
         source_kind, source_url, version, manifest_json, risk_summary, tags, created_at)
      VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    `).run(
      id,
      kind,
      seed.slug,
      seed.title,
      seed.description,
      seed.category,
      seed.author,
      seed.source_kind,
      seed.source_url,
      seed.version,
      manifestJson,
      seed.risk_summary,
      tagsJson,
      new Date().toISOString(),
    );

    // Default-on capabilities (manifest.default) seed as installed so the
    // marketplace reflects what the agent ships with out of the box.
    const installedDefault = seed?.manifest?.default ? 1 : 0;
    db.prepare(`
      INSERT OR IGNORE INTO marketplace_installations (item_id, installed, installed_at)
      VALUES (?, ?, ?)
    `).run(id, installedDefault, installedDefault ? new Date().toISOString() : null);
  }
}

// ── Module manifest contract ────────────────────────────────────────────────
// A `kind:'module'` marketplace item bundles a whole vertical. This is the shape
// a (future user-authored) module declares; install wires all of it up.
//
//   identity            slug, title, description, category, author,
//                       source_kind, source_url, version, risk_summary, tags
//   manifest.module_id  stable id for the module
//   manifest.agents[]   agent ids the module ships
//   manifest.tools[]    registry tool names the module enables
//   manifest.skill_packs[]        skill-pack slugs
//   manifest.workflow_templates[] workflow definition slugs
//   manifest.nav[]      sidebar surfaces this module adds when installed:
//                       { label, href, icon, group }
//                       `icon` is a string mapped to a Lucide icon in the
//                       sidebar's allowlist (lib/marketplace.js → UI). Unknown
//                       icon names fall back to a default. Modules that are not
//                       installed contribute no nav.
const MINES_MODULE_SEED = {
  slug: 'mines',
  title: 'Mines',
  description: 'Mining project analysis: portfolio screening, data interpretation, tiered valuation, market intelligence, and NI 43-101 report packaging.',
  category: 'industry',
  author: 'madarx',
  source_kind: 'builtin',
  source_url: null,
  version: '0.1.0',
  risk_summary: 'High-risk valuation and report tools are gated; external providers disabled by default.',
  tags: ['mining', 'metals', 'due-diligence', 'valuation'],
  manifest: {
    module_id: 'mines',
    manifest_path: 'config/madarx-module.json',
    agents: ['mines-analyst', 'mines-data-interpreter', 'mines-valuation-analyst', 'mines-market-researcher', 'mines-report-packager'],
    tools: ['mines_project_create', 'mines_project_read', 'mines_catalog_import', 'mines_data_import', 'mines_document_extract', 'mines_extract_facts', 'mines_spatial_index', 'mines_assumption_validate', 'mines_valuation_run', 'mines_sensitivity_run', 'mines_market_snapshot', 'mines_report_generate'],
    skill_packs: ['mines-taxonomy-classification', 'mines-ocr-spanish', 'mines-tiered-valuation', 'mines-ni43101-template', 'mines-provenance-rules'],
    workflow_templates: ['mine-project-intake', 'mine-valuation', 'mine-market-trend-monitor', 'mine-portfolio-screen'],
    nav: [{ label: 'Mines', href: '/mines', icon: 'Pickaxe', group: 'Industry' }],
  },
};

// ── Business Agent Suite module (P4) ─────────────────────────────────────────
// A "whole company in a box": one click provisions the cross-department agent
// roster, installs the department skill packs, enables the safe built-in tools,
// and points the operator at the connections to authenticate. External-write
// capabilities (ads, sends, CRM, deploys) stay disabled until the matching
// connection is set up and granted — nothing dangerous installs hot.
//
// manifest.agents are AGENT TEMPLATE SLUGS — installModule provisions each via
// installAgentTemplate (generic provisioning path in lib/marketplace-modules.js).
// manifest.connections lists the connection slugs the suite expects (seeded as
// kind:'connection' items the operator connects on demand).
const BUSINESS_SUITE_MODULE_SEED = {
  slug: 'business-suite',
  title: 'Business Agent Suite',
  description: 'A whole company in a box: a cross-department roster of business agents, department skill packs, and the connections they need. Marketing, ads, content, sales, support, ops, finance, legal, product, web, analyst, and a Chief of Staff to run the cadence.',
  category: 'business',
  author: 'madarx',
  source_kind: 'builtin',
  source_url: null,
  version: '0.1.0',
  risk_summary: 'Agents install with safe built-in tools only. Ad spend, sends, CRM writes, and deploys stay approval-gated and require connecting + granting the matching service first.',
  tags: ['business', 'company', 'marketing', 'sales', 'ops', 'starter'],
  manifest: {
    module_id: 'business-suite',
    agents: [
      'chief-of-staff', 'marketing-lead', 'ads-media-buyer', 'content-social',
      'sales-bd', 'customer-support', 'ops-manager', 'finance-ops',
      'legal-compliance', 'product-pm', 'web-ecommerce', 'competitor-scout',
    ],
    tools: [
      'web_search', 'web_fetch', 'file_read', 'file_write', 'create_artifact',
      'email_send', 'gmail_messages_list', 'calendar_events_list',
      'create_workflow_definition',
    ],
    skill_packs: [
      'market-research', 'report-builder', 'paid-campaign-build', 'ads-reporting',
      'content-calendar', 'lead-research', 'ticket-reply', 'runway-model',
    ],
    connections: ['resend', 'meta-ads', 'google-ads', 'ga4', 'hubspot-crm'],
    workflow_templates: [],
    nav: [],
  },
};

export function seedMarketplaceItems(db) {
  try {
    for (const s of BUSINESS_SKILL_SEEDS) upsertItem(db, 'skill', buildBusinessSkillSeed(s));
    for (const s of BUSINESS_SUITE_SKILL_SEEDS) upsertItem(db, 'skill', buildSuiteSkillSeed(s));
    for (const seed of SKILL_SEEDS) upsertItem(db, 'skill', seed);
    for (const seed of BUNDLE_SEEDS) upsertItem(db, 'bundle', seed);
    for (const curated of OPEN_DESIGN_CURATED_SKILLS) {
      upsertItem(db, 'skill', buildOpenDesignSkillSeed(curated));
    }
    upsertItem(db, 'bundle', OPEN_DESIGN_BUNDLE);
    seedConnections(db);
    // Mines module entry (kind:'module').
    upsertItem(db, 'module', MINES_MODULE_SEED);
    // Business Agent Suite module entry (kind:'module').
    upsertItem(db, 'module', BUSINESS_SUITE_MODULE_SEED);
  } catch (err) {
    console.warn('[marketplace-seeds] seed failed:', err?.message || err);
  }
}

// The default business skills, grouped by category for the CLI banner showcase.
export const DEFAULT_SKILL_SLUGS = BUSINESS_SKILL_SEEDS.map(s => s.slug);
const DEFAULT_SKILL_CATEGORY_ORDER = ['research', 'comms', 'documents', 'data', 'web'];
export function listDefaultSkillGroups() {
  const byCat = new Map();
  for (const s of BUSINESS_SKILL_SEEDS) {
    if (!byCat.has(s.category)) byCat.set(s.category, []);
    byCat.get(s.category).push(s.slug);
  }
  return DEFAULT_SKILL_CATEGORY_ORDER
    .filter(c => byCat.has(c))
    .map(category => ({ category, count: byCat.get(category).length, names: byCat.get(category) }));
}

/**
 * The default business skills rendered as a `skills.md` section — injected into
 * an agent's skills file so the runtime (which reads skills.md) actually surfaces
 * them. Grouped by category, with invocation, description, and the tools each
 * leans on.
 */
export function defaultSkillsMarkdown() {
  const titleCase = (s) => s.charAt(0).toUpperCase() + s.slice(1);
  const lines = [
    '## Default skills',
    '',
    'You ship with these ready-to-use business skills. Reach for them by intent;',
    'each is backed by your enabled tools and stays within the usual approval gates.',
    '',
  ];
  for (const g of listDefaultSkillGroups()) {
    lines.push(`### ${titleCase(g.category)}`);
    for (const slug of g.names) {
      const s = BUSINESS_SKILL_SEEDS.find((x) => x.slug === slug);
      if (!s) continue;
      lines.push(`- **${s.title}** (\`${s.invocation}\`) — ${s.description} _Tools: ${s.tools.join(', ')}._`);
    }
    lines.push('');
  }
  return lines.join('\n').trimEnd() + '\n';
}

export const BUSINESS_SUITE_SKILL_SLUGS = BUSINESS_SUITE_SKILL_SEEDS.map(s => s.slug);
export { BUSINESS_SUITE_MODULE_SEED };
export const PHASE1_SKILL_SLUGS = SKILL_SEEDS.map(s => s.slug);
export const PHASE1_BUNDLE_SLUGS = BUNDLE_SEEDS.map(s => s.slug);
export const OPEN_DESIGN_SKILL_SLUGS = OPEN_DESIGN_CURATED_SKILLS.map(s => `open-design-${s.slug}`);
export const OPEN_DESIGN_BUNDLE_SLUG = OPEN_DESIGN_BUNDLE.slug;
