@a-company/paradigm 6.3.4 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
10
  <link href="https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Inter:wght@300;400;500;600&display=swap" rel="stylesheet">
11
- <script type="module" crossorigin src="/assets/index-BlS8W3tC.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-vQHaGBMf.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="/assets/index-CMrxD7y5.css">
13
13
  </head>
14
14
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a-company/paradigm",
3
- "version": "6.3.4",
3
+ "version": "6.4.0",
4
4
  "description": "Unified CLI for Paradigm developer tools",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import'./chunk-5TAVYPOV.js';import x,{Router}from'express';import*as u from'path';import*as c from'fs';import {fileURLToPath}from'url';import m from'chalk';import*as w from'js-yaml';function C(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);if(!t)return null;try{return {fm:M(t[1]),body:t[2].trim()}}catch{return null}}function M(e){let t={},i=e.split(/\r?\n/);for(let s of i){if(!s.trim()||s.trim().startsWith("#"))continue;let r=s.match(/^([A-Za-z_][A-Za-z0-9_-]*)\s*:\s*(.*)$/);if(!r)continue;let n=r[1],a=r[2],o=r[2].trim();if(o.startsWith("[")&&o.endsWith("]")){let l=o.slice(1,-1).trim();a=l.length===0?[]:l.split(",").map(p=>p.trim().replace(/^['"]|['"]$/g,""));}else o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'")?a=o.slice(1,-1):/^\d+$/.test(o)?a=parseInt(o,10):o==="true"||o==="false"?a=o==="true":a=o;t[n]=a;}return t}function I(e){try{let t=c.readFileSync(e,"utf-8");return w.load(t)}catch{return null}}function E(e){let t=u.join(e,"paths");if(!c.existsSync(t))return [];let i=c.readdirSync(t).filter(r=>r.startsWith("LP-")&&r.endsWith(".yaml")),s=[];for(let r of i){let n=I(u.join(t,r));n?.id&&s.push(n);}return s}function J(e,t){let i=[e];if(!t)return i;let s=u.join(t,".paradigm","university");if(!c.existsSync(s))return i;c.existsSync(u.join(s,"paths"))&&i.push(s);try{for(let r of c.readdirSync(s,{withFileTypes:!0})){if(!r.isDirectory())continue;let n=u.join(s,r.name);c.existsSync(u.join(n,"paths"))&&i.push(n);}}catch{}return i}function T(e,t,i){let s=u.join(e,"notes"),r=u.join(e,"quizzes"),n=[],a=new Set,o=i.steps||[];for(let l of o){let p=l.content;if(!p.startsWith("N-")||a.has(p))continue;a.add(p);let d=p.slice(`N-${t}-`.length),f=u.join(s,`${p}.md`);if(!c.existsSync(f))continue;let y=c.readFileSync(f,"utf-8"),h=C(y);if(!h)continue;let j=h.fm,g={id:d,title:j.title||d,content:h.body,keyConcepts:Array.isArray(j.tags)?j.tags:[],quiz:[]},S=u.join(r,`Q-${t}-${d}.yaml`);if(c.existsSync(S)){let v=I(S);v?.questions&&(g.quiz=v.questions);}n.push(g);}return n}function O(e,t){let i=u.join(e,"paths",`LP-${t}.yaml`);if(!c.existsSync(i))return null;let s=I(i);if(!s?.id)return null;let r=T(e,t,s);return {id:t,title:s.title,description:s.description||"",lessons:r}}function R(e,t){let i=Router(),s=J(e,t);return i.get("/",(r,n)=>{let a=new Set,o=[];for(let l of s){let p=E(l);for(let d of p){let f=d.id.startsWith("LP-")?d.id.slice(3):d.id;if(a.has(f))continue;a.add(f);let y=T(l,f,d);o.push({id:f,title:d.title,description:d.description||"",lessonCount:y.length,lessons:y.map(h=>({id:h.id,title:h.title}))});}}return o.sort((l,p)=>l.id.localeCompare(p.id)),n.json({courses:o})}),i.get("/:id",(r,n)=>{for(let a of s){let o=O(a,r.params.id);if(o)return n.json(o)}return n.status(404).json({error:`Course '${r.params.id}' not found`})}),i.get("/:id/lessons/:lessonId",(r,n)=>{for(let a of s){let o=O(a,r.params.id);if(!o)continue;let l=o.lessons.find(p=>p.id===r.params.lessonId);if(l)return n.json(l)}return n.status(404).json({error:`Lesson '${r.params.lessonId}' not found`})}),i}function q(e){try{let t=c.readFileSync(e,"utf-8");return w.load(t)}catch{return null}}function V(e){for(let t=e.length-1;t>0;t--){let i=Math.floor(Math.random()*(t+1));[e[t],e[i]]=[e[i],e[t]];}return e}function Q(e){if(!e.variants||e.variants.length===0)return e;let t=[{id:e.id,scenario:e.scenario??"",question:e.question,choices:e.choices,correct:e.correct,explanation:e.explanation??""},...e.variants];return t[Math.floor(Math.random()*t.length)]}function U(e){return e.questions.length}function Z(e){let t={},i=[],s=new Map;for(let r of e.questions){let n=Q(r),a={id:n.id,course:r.section??"",scenario:n.scenario??r.scenario??"",question:n.question,choices:n.choices,correct:n.correct,explanation:n.explanation??r.explanation??"",...r.passageId?{passageId:r.passageId}:{}};r.passageId?(r.passage&&(t[r.passageId]=r.passage),s.has(r.passageId)||s.set(r.passageId,[]),s.get(r.passageId).push(a)):i.push([a]);}for(let r of s.values())i.push(r);return V(i),{questions:i.flat(),passages:t}}function _(e,t){let i=Router(),s=u.join(e,"quizzes");return i.get("/",(r,n)=>{if(!c.existsSync(s))return n.json({versions:[]});let a=c.readdirSync(s).filter(o=>o.startsWith("Q-plsat-v")&&o.endsWith(".yaml")).map(o=>{let l=q(u.join(s,o));if(!l)return null;let p=o.match(/^Q-plsat-v(\d+)\.yaml$/);return {version:p?`${p[1]}.0`:"0.0",frameworkVersion:"2.0",questionCount:U(l),timeLimit:l.timeLimit,passThreshold:l.passThreshold}}).filter(o=>o!==null);return a.sort((o,l)=>l.version.localeCompare(o.version)),n.json({versions:a})}),i.get("/:version",(r,n)=>{try{let a=r.params.version.split(".")[0],o=u.join(s,`Q-plsat-v${a}.yaml`);if(!c.existsSync(o))return n.status(404).json({error:`PLSAT version '${r.params.version}' not found`});let l=q(o);if(!l)return n.status(500).json({error:"Failed to parse PLSAT exam"});let{questions:p,passages:d}=Z(l);return n.json({version:r.params.version,frameworkVersion:"2.0",timeLimit:l.timeLimit,passThreshold:l.passThreshold,title:l.title,description:l.description??"",questions:p,...Object.keys(d).length>0?{passages:d}:{}})}catch(a){let o=a instanceof Error?a.message:"Internal error";return n.status(500).json({error:`Failed to load PLSAT exam: ${o}`})}}),i.post("/diploma",(r,n)=>{if(!t)return n.status(400).json({error:"No project directory configured"});let a=u.join(t,".paradigm","university","diplomas");if(!c.existsSync(a))return n.json({saved:false,reason:"university directory not found"});try{let{student:o,version:l,score:p,total:d,percentage:f,passed:y}=r.body;if(!o||!l||p==null||d==null)return n.status(400).json({error:"Missing required fields: student, version, score, total"});let h=new Date().toISOString().slice(0,10),j=String(o).toLowerCase().replace(/[^a-z0-9-]/g,"-").slice(0,20),g=`D-${h}-${j}-plsat-v${l}`,S={id:g,type:"plsat",student:j,earnedAt:new Date().toISOString(),source:`plsat:v${l}`,score:p,total:d,percentage:f??(d>0?Math.round(p/d*1e4)/100:0),passed:y??!1,details:{plsatVersion:l}},v=u.join(a,`${g}.yaml`),W=Object.entries(S).map(([b,D])=>{if(typeof D=="object"&&D!==null){let F=Object.entries(D).map(([z,N])=>` ${z}: ${JSON.stringify(N)}`).join(`
3
- `);return `${b}:
4
- ${F}`}return `${b}: ${JSON.stringify(D)}`});return c.writeFileSync(v,W.join(`
5
- `)+`
6
- `,"utf8"),n.json({saved:!0,diplomaId:g})}catch(o){let l=o instanceof Error?o.message:"Internal error";return n.status(500).json({error:`Failed to save diploma: ${l}`})}}),i}var G=fileURLToPath(import.meta.url),P=u.dirname(G);function H(e){let t=e;for(;t!==u.dirname(t);){if(c.existsSync(u.join(t,"package.json"))&&JSON.parse(c.readFileSync(u.join(t,"package.json"),"utf-8")).name==="@a-company/university")return t;t=u.dirname(t);}return e}var $={component(e){let t=m.magenta(`#${e}`);return {info:(i,s)=>{let r=s?m.gray(` ${Object.entries(s).map(([n,a])=>`${n}=${a}`).join(" ")}`):"";console.log(`${m.blue("\u2139")} ${t} ${i}${r}`);},success:(i,s)=>{let r=s?m.gray(` ${Object.entries(s).map(([n,a])=>`${n}=${a}`).join(" ")}`):"";console.log(`${m.green("\u2714")} ${t} ${i}${r}`);},warn:(i,s)=>{let r=s?m.gray(` ${Object.entries(s).map(([n,a])=>`${n}=${a}`).join(" ")}`):"";console.log(`${m.yellow("\u26A0")} ${t} ${i}${r}`);},error:(i,s)=>{let r=s?m.gray(` ${Object.entries(s).map(([n,a])=>`${n}=${a}`).join(" ")}`):"";console.error(`${m.red("\u2716")} ${t} ${i}${r}`);}}}};function B(e){if(e?.contentDir&&e?.uiDistPath)return {contentDir:e.contentDir,uiDistPath:e.uiDistPath};let t=u.join(P,"university-content"),i=u.join(P,"university-ui");if(c.existsSync(t)&&c.existsSync(i))return {contentDir:e?.contentDir||t,uiDistPath:e?.uiDistPath||i};let s=H(P);return {contentDir:e?.contentDir||u.join(s,"src","content"),uiDistPath:e?.uiDistPath||u.join(s,"ui","dist")}}function L(e){let t=x();t.use(x.json()),t.use((r,n,a)=>{n.header("Access-Control-Allow-Origin","*"),n.header("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS"),n.header("Access-Control-Allow-Headers","Content-Type"),a();});let{contentDir:i,uiDistPath:s}=B(e);return t.use("/api/courses",R(i,e?.projectDir)),t.use("/api/plsat",_(i,e?.projectDir)),t.get("/api/reference",(r,n)=>{let a=u.join(i,"reference.json");if(c.existsSync(a)){let o=JSON.parse(c.readFileSync(a,"utf-8"));n.json(o);}else n.status(404).json({error:"Reference data not found"});}),t.get("/api/health",(r,n)=>{n.json({status:"ok",timestamp:new Date().toISOString()});}),c.existsSync(s)&&(t.use(x.static(s)),t.get("{*path}",(r,n)=>{r.path.startsWith("/api")||n.sendFile(u.join(s,"index.html"));})),t}async function X(e){let t=L({contentDir:e.contentDir,uiDistPath:e.uiDistPath,projectDir:e.projectDir});return $.component("university-server").info("Starting server",{port:e.port}),new Promise((i,s)=>{t.listen(e.port,()=>{$.component("university-server").success("Server running",{url:`http://localhost:${e.port}`}),e.open&&import('open').then(r=>{r.default(`http://localhost:${e.port}`),$.component("university-server").info("Opened browser");}).catch(()=>{$.component("university-server").warn("Could not open browser automatically");}),i();}).on("error",r=>{r.code==="EADDRINUSE"?$.component("university-server").error("Port already in use",{port:e.port}):$.component("university-server").error("Server error",{error:r.message}),s(r);});})}
7
- export{L as createApp,X as startServer};