// @ts-nocheck
// @ts-nocheck
import { debugLog } from '../common';
import { useModelStore } from '../../../stores/model';

export const SKILL_MARKDOWN_LINK_RE = /\[\$([^\]\n]+)\]\(([^)\n]*\/\.astrion\/skills\/[^)\n]+\/SKILL\.md)\)/g;

export function extractSkillRefsFromMessage(message = '') {
  const refs = [];
  const seen = new Set();
  const text = String(message || '');
  let match;
  SKILL_MARKDOWN_LINK_RE.lastIndex = 0;
  while ((match = SKILL_MARKDOWN_LINK_RE.exec(text))) {
    const name = String(match[1] || '').trim().replace(/^\$/, '');
    const path = String(match[2] || '').trim();
    if (!path || seen.has(path)) {
      continue;
    }
    seen.add(path);
    refs.push({ name, path });
  }
  return refs;
}

