← back to dropdownlogistics__excelligence

Function bodies 4 total

All specs Real LLM only Function bodies
export_json function · python · L28-L113 (86 LOC)
api/excelligence_json_export.py
def export_json(registry_path, output_path):
    wb = load_workbook(registry_path)

    entries = []
    for row in wb["tbl_Entry"].iter_rows(min_row=2, values_only=True):
        if row[0]:
            entries.append({
                "id": row[0],
                "name": row[1],
                "type": row[2],
                "tier": row[3],
                "what_it_does": row[4] or "",
                "intent": row[5] or "",
                "example": row[6] or "",
                "failure_modes": row[7] or "",
                "performance_notes": row[8] or "",
                "governance_notes": row[9] or "",
                "created_at": str(row[10] or ""),
                "updated_at": str(row[11] or ""),
            })

    edges = []
    for row in wb["tbl_Edges"].iter_rows(min_row=2, values_only=True):
        if row[0]:
            edges.append({
                "source": row[0],
                "target": row[1],
                "type": row[2],
            })

    tags = []
 
loadANTEntries function · javascript · L14-L19 (6 LOC)
api/scan.js
async function loadANTEntries() {
  const res = await fetch(REGISTRY_URL);
  if (!res.ok) throw new Error('Registry fetch failed');
  const data = await res.json();
  return data.entries.filter(e => e.type === 'ANT');
}
buildSystemPrompt function · javascript · L22-L76 (55 LOC)
api/scan.js
function buildSystemPrompt(antEntries) {
  const entryBlock = antEntries.map(e => `
ENTRY: ${e.id}
Name: ${e.name}
What it does: ${e.what_it_does}
Intent: ${e.intent}
Failure modes: ${e.failure_modes}
Governance notes: ${e.governance_notes}
Severity: ${e.difficulty_score <= 1 ? 'High' : e.difficulty_score <= 2 ? 'Medium' : 'Low'}
`.trim()).join('\n\n---\n\n');

  return `You are the Excelligence Anti-Pattern Scanner — a governed diagnostic tool powered by the Excelligence Excel knowledge graph.

Your job: analyze the user's input (a formula, a workbook description, or a problem they're experiencing) and identify which governed anti-patterns from the registry apply.

REGISTRY CONTEXT — ${antEntries.length} ANT entries:

${entryBlock}

RULES:
1. Only cite anti-patterns from the registry above. Never invent anti-patterns.
2. For each finding, cite the exact entry ID (e.g. ANT-0009).
3. Be specific about WHERE in the user's input the anti-pattern appears.
4. Always provide the governed
handler function · javascript · L79-L163 (85 LOC)
api/scan.js
export default async function handler(req) {
  // CORS
  const headers = {
    'Content-Type': 'application/json',
    'Access-Control-Allow-Origin': 'https://excelligence.dev',
    'Access-Control-Allow-Methods': 'POST, OPTIONS',
    'Access-Control-Allow-Headers': 'Content-Type',
  };

  if (req.method === 'OPTIONS') {
    return new Response(null, { status: 204, headers });
  }

  if (req.method !== 'POST') {
    return new Response(JSON.stringify({ error: 'Method not allowed' }), { status: 405, headers });
  }

  try {
    const body = await req.json();
    const input = (body.input || '').trim();

    if (!input) {
      return new Response(JSON.stringify({ error: 'No input provided' }), { status: 400, headers });
    }

    if (input.length > 3000) {
      return new Response(JSON.stringify({ error: 'Input too long. Max 3000 characters.' }), { status: 400, headers });
    }

    // Load live registry
    const antEntries = await loadANTEntries();
    const systemPrompt = buildSys