@a-company/paradigm 5.22.0 → 5.24.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.
Files changed (39) hide show
  1. package/dist/{ambient-WEPHBAJD.js → ambient-HYZR42NX.js} +1 -1
  2. package/dist/chunk-4DVT5IEY.js +2 -0
  3. package/dist/chunk-73R63P7K.js +2 -0
  4. package/dist/{chunk-QIGE36CB.js → chunk-FSOI3CCD.js} +79 -21
  5. package/dist/{compliance-TSXLXADI.js → compliance-NLG7KB73.js} +2 -2
  6. package/dist/{docs-RXPN6CK7.js → docs-UIYXJ3O3.js} +1 -1
  7. package/dist/{habits-LX5IWCZM.js → habits-GICVMTJL.js} +1 -1
  8. package/dist/{hooks-EFM2IK6E.js → hooks-E7HQQ57M.js} +1 -1
  9. package/dist/index.js +3 -3
  10. package/dist/mcp.js +64 -41
  11. package/dist/{migrate-OMR5G5AF.js → migrate-WT56YYAM.js} +1 -1
  12. package/dist/platform-server-FXYBBH6E.js +25 -0
  13. package/dist/{project-type-SURTOIG7.js → project-type-4Y6CESWP.js} +1 -1
  14. package/dist/{roster-FLRZ5J42.js → roster-K2QILE7K.js} +1 -1
  15. package/dist/{serve-JE6UF5P2.js → serve-5W6KOA4R.js} +1 -1
  16. package/dist/{shift-ASDLMMK5.js → shift-TDOYQKR4.js} +2 -2
  17. package/dist/university-FJ7OCOA3.js +2 -0
  18. package/package.json +1 -1
  19. package/platform-ui/dist/assets/AmbientSection-BYjt75R1.js +1 -0
  20. package/platform-ui/dist/assets/{CanvasSection-DLW0s-Bu.js → CanvasSection-rKvA_vZj.js} +2 -2
  21. package/platform-ui/dist/assets/{DocsSection-BQ9Hi51g.js → DocsSection-CI9K73M-.js} +1 -1
  22. package/platform-ui/dist/assets/GitSection-DSGj_c6S.js +4 -0
  23. package/platform-ui/dist/assets/{GraphSection-0c9C-w7K.js → GraphSection-CawN7pC5.js} +2 -2
  24. package/platform-ui/dist/assets/LoreSection-oO5dCe6O.js +1 -0
  25. package/platform-ui/dist/assets/{SentinelSection-C4OoME9U.js → SentinelSection-DNgoYMH0.js} +1 -1
  26. package/platform-ui/dist/assets/SymphonySection-C0zfcqv3.js +1 -0
  27. package/platform-ui/dist/assets/TeamSection-Bzd3Dt9Q.js +1 -0
  28. package/platform-ui/dist/assets/UniversitySection-B3ltVfpt.css +1 -0
  29. package/platform-ui/dist/assets/UniversitySection-tBr62R0S.js +1 -0
  30. package/platform-ui/dist/assets/{index-DPpOdAtC.js → index-BaOmyn11.js} +12 -12
  31. package/platform-ui/dist/index.html +1 -1
  32. package/dist/chunk-AGVAHVUA.js +0 -2
  33. package/dist/chunk-RMOALQJN.js +0 -2
  34. package/dist/platform-server-2KXHGHFV.js +0 -25
  35. package/platform-ui/dist/assets/AmbientSection-DqQ2mfCO.js +0 -1
  36. package/platform-ui/dist/assets/GitSection-QQeUX6o3.js +0 -4
  37. package/platform-ui/dist/assets/LoreSection--t56kCj2.js +0 -1
  38. package/platform-ui/dist/assets/SymphonySection-B-rvsLxq.js +0 -1
  39. package/platform-ui/dist/assets/TeamSection-CBFmNEEo.js +0 -1
@@ -48,7 +48,7 @@ component_types:
48
48
  `),{status:"applied",message:"Added component_types glossary to config.yaml",filesModified:[".paradigm/config.yaml"]}):{status:"error",message:"Cannot read config.yaml"}}},ue={id:"add-discipline-config",introducedIn:"3.4.0",description:"Add discipline field to config.yaml",category:"config",auto:true,async check(e){let t=A(e);return t?D(t,"discipline")?{needed:false,reason:"discipline already set"}:{needed:true,reason:"Missing discipline field"}:{needed:false,reason:"No config.yaml found"}},async apply(e,t){if(t.dryRun)return {status:"skipped",message:"Would add discipline to config.yaml"};let n=I(e);if(!n)return {status:"error",message:"Cannot read config.yaml"};let i=n.replace(/^(project:\s*.+)$/m,`$1
49
49
  discipline: auto`);return i===n?x(e,n.trimEnd()+`
50
50
  discipline: auto
51
- `):x(e,i),{status:"applied",message:"Added discipline: auto to config.yaml",filesModified:[".paradigm/config.yaml"]}}},fe={id:"sync-templates",introducedIn:"evergreen",description:"Update specs/ and docs/ from installed CLI templates",category:"template",auto:true,async check(e){let t=$();if(!t)return {needed:false,reason:"Templates directory not found"};let n=[],i=["specs","docs","prompts"];for(let r of i){let a=p.join(t,r),d=p.join(e,".paradigm",r);if(o.existsSync(a))try{let g=o.readdirSync(a).filter(m=>o.statSync(p.join(a,m)).isFile());for(let m of g)o.existsSync(p.join(d,m))||n.push(`${r}/${m}`);}catch{}}return n.length===0?{needed:false,reason:"All templates are up to date"}:{needed:true,reason:`${n.length} new template file(s) available`,details:n.map(r=>`New: ${r}`)}},async apply(e,t){let n=$();if(!n)return {status:"error",message:"Templates directory not found"};let i=p.basename(e),r=[],a=["specs","docs","prompts"];for(let d of a){let g=p.join(n,d),m=p.join(e,".paradigm",d);if(o.existsSync(g)){t.dryRun||o.mkdirSync(m,{recursive:true});try{let S=o.readdirSync(g,{withFileTypes:!0});for(let k of S){if(k.isDirectory())continue;let M=p.join(m,k.name);if(!o.existsSync(M)){if(t.dryRun){r.push(`${d}/${k.name}`);continue}let c=o.readFileSync(p.join(g,k.name),"utf8");c=c.replace(/\{\{PROJECT_NAME\}\}/g,i),o.writeFileSync(M,c,"utf8"),r.push(`${d}/${k.name}`);}}}catch{}}}return t.dryRun?{status:"skipped",message:`Would copy ${r.length} template file(s)`}:r.length===0?{status:"skipped",message:"No new templates to sync"}:{status:"applied",message:`Synced ${r.length} template file(s)`,filesCreated:r.map(d=>`.paradigm/${d}`)}}},me={id:"refresh-hooks",introducedIn:"evergreen",description:"Reinstall hook scripts from plugin",category:"hook",auto:true,async check(e){let t=[p.join(e,".claude","hooks"),p.join(e,".cursor","hooks")];for(let i of t)if(o.existsSync(i))try{if(o.readdirSync(i).some(a=>a.includes("paradigm")))return {needed:!1,reason:"Hooks are installed"}}catch{}let n=p.join(e,".claude","settings.local.json");if(o.existsSync(n))try{if(JSON.parse(o.readFileSync(n,"utf8")).hooks)return {needed:!1,reason:"Plugin-managed hooks are configured"}}catch{}return {needed:true,reason:"No paradigm hooks found"}},async apply(e,t){if(t.dryRun)return {status:"skipped",message:"Would reinstall hooks"};try{let{hooksInstallCommand:n}=await import('./hooks-EFM2IK6E.js');return await n({force:!0}),{status:"applied",message:"Hooks reinstalled"}}catch(n){return {status:"error",message:`Hook install failed: ${n.message}`}}}},b=[Q,X,Z,ee,te,ne,se,ue,de,le,re,oe,ie,ae,ce,pe,ge,fe,me];var he=createRequire(import.meta.url),{version:W}=he("../package.json");function C(e){let t=p.join(e,".paradigm","migrate.yaml");if(!o.existsSync(t))return null;try{let n=o.readFileSync(t,"utf8");return F.load(n)}catch{return null}}async function V(e){let t=p.join(e,".paradigm"),n=C(e),i=n?.applied.map(l=>l.id)??[],r="unknown",a=p.join(t,"config.yaml");if(o.existsSync(a))try{let l=F.load(o.readFileSync(a,"utf8"));r=String(l.version??"unknown");}catch{}let g=["specs","docs","prompts","lore","tasks","protocols","personas"].filter(l=>!o.existsSync(p.join(t,l))),m=["discipline","tag-bank","purpose-required","component_types"],S=[];if(o.existsSync(a))try{let l=F.load(o.readFileSync(a,"utf8"));S=m.filter(h=>{let j=h.replace(/-/g,"_");return !(h in l)&&!(j in l)&&!(h.replace(/_/g,"-")in l)});}catch{}let k=[],M=$();if(M){let l=["specs","docs"];for(let h of l){let j=p.join(M,h),L=p.join(t,h);if(o.existsSync(j)&&o.existsSync(L)){let J=o.readdirSync(j).filter(R=>!o.statSync(p.join(j,R)).isDirectory());for(let R of J){let Y=p.join(L,R);o.existsSync(Y)||k.push(`${h}/${R}`);}}}}let c=!o.existsSync(p.join(e,".claude","hooks")),u=[];for(let l of b){let h=l.introducedIn==="evergreen";if(i.includes(l.id)&&!h)continue;(await l.check(e)).needed&&u.push(l);}return {configVersion:r,cliVersion:W,pendingMigrations:u,appliedIds:i,health:{missingDirectories:g,missingConfigFields:S,staleTemplates:k,hooksOutdated:c}}}async function U(e){let t=[],n=new Date().toISOString();for(let i of b){if(i.introducedIn==="evergreen")continue;(await i.check(e)).needed||t.push({id:i.id,appliedAt:n,cliVersion:W});}return t}function $(){let e=new URL(import.meta.url).pathname,t=p.dirname(e),n=[p.join(t,"..","..","..","templates","paradigm"),p.join(t,"..","..","templates","paradigm"),p.join(t,"..","templates","paradigm")];for(let i of n)if(o.existsSync(i))return i;return null}var ke=createRequire(import.meta.url),{version:N}=ke("../package.json");async function B(e){let t=C(e);if(t)return t;let n=await U(e);return {version:"1.0",cliVersion:N,lastMigrated:new Date().toISOString(),applied:n}}function _(e,t){let n=p.join(e,".paradigm","migrate.yaml");o.mkdirSync(p.dirname(n),{recursive:true}),t.cliVersion=N,t.lastMigrated=new Date().toISOString(),o.writeFileSync(n,F.dump(t,{indent:2,lineWidth:120,noRefs:true,sortKeys:false,quotingType:'"'}),"utf8");}async function E(e,t,n,i){let r={applied:0,skipped:0,errors:0,manual:0,results:[]},a=new Date().toISOString();for(let d of t){if(!d.auto){r.manual++,r.results.push({id:d.id,result:{status:"skipped",message:"Manual review recommended"}});continue}try{let g=await d.apply(e,n);r.results.push({id:d.id,result:g}),g.status==="applied"?(r.applied++,i.applied.push({id:d.id,appliedAt:a,cliVersion:N})):g.status==="skipped"?r.skipped++:r.errors++;}catch(g){r.errors++,r.results.push({id:d.id,result:{status:"error",message:g.message}});}}return r}async function _e(e={}){let t=process.cwd(),n=p.join(t,".paradigm");if((!o.existsSync(n)||!o.statSync(n).isDirectory())&&!(o.existsSync(n)&&o.statSync(n).isFile())){e.quiet||console.log(s.yellow("\n No .paradigm/ directory found. Run `paradigm init` or `paradigm shift` first.\n"));return}let i=we();e.quiet||i.start("Detecting project state...");let r=await V(t);e.quiet||i.stop();let a=await B(t),d=r.pendingMigrations;if(e.only&&e.only.length>0&&(d=d.filter(c=>e.only.includes(c.id))),e.category&&(d=d.filter(c=>c.category===e.category)),e.force){let c=e.only?b.filter(u=>e.only.includes(u.id)):e.category?b.filter(u=>u.category===e.category):b;d=[];for(let u of c)((await u.check(t)).needed||e.force)&&d.push(u);}let g=d.filter(c=>c.auto),m=d.filter(c=>!c.auto);if(e.list){Me(a,r,e);return}if(e.quiet){if(g.length===0)return;let c=await E(t,g,e,a);return _(t,a),c}let S=C(t);if(console.log(s.blue(`
51
+ `):x(e,i),{status:"applied",message:"Added discipline: auto to config.yaml",filesModified:[".paradigm/config.yaml"]}}},fe={id:"sync-templates",introducedIn:"evergreen",description:"Update specs/ and docs/ from installed CLI templates",category:"template",auto:true,async check(e){let t=$();if(!t)return {needed:false,reason:"Templates directory not found"};let n=[],i=["specs","docs","prompts"];for(let r of i){let a=p.join(t,r),d=p.join(e,".paradigm",r);if(o.existsSync(a))try{let g=o.readdirSync(a).filter(m=>o.statSync(p.join(a,m)).isFile());for(let m of g)o.existsSync(p.join(d,m))||n.push(`${r}/${m}`);}catch{}}return n.length===0?{needed:false,reason:"All templates are up to date"}:{needed:true,reason:`${n.length} new template file(s) available`,details:n.map(r=>`New: ${r}`)}},async apply(e,t){let n=$();if(!n)return {status:"error",message:"Templates directory not found"};let i=p.basename(e),r=[],a=["specs","docs","prompts"];for(let d of a){let g=p.join(n,d),m=p.join(e,".paradigm",d);if(o.existsSync(g)){t.dryRun||o.mkdirSync(m,{recursive:true});try{let S=o.readdirSync(g,{withFileTypes:!0});for(let k of S){if(k.isDirectory())continue;let M=p.join(m,k.name);if(!o.existsSync(M)){if(t.dryRun){r.push(`${d}/${k.name}`);continue}let c=o.readFileSync(p.join(g,k.name),"utf8");c=c.replace(/\{\{PROJECT_NAME\}\}/g,i),o.writeFileSync(M,c,"utf8"),r.push(`${d}/${k.name}`);}}}catch{}}}return t.dryRun?{status:"skipped",message:`Would copy ${r.length} template file(s)`}:r.length===0?{status:"skipped",message:"No new templates to sync"}:{status:"applied",message:`Synced ${r.length} template file(s)`,filesCreated:r.map(d=>`.paradigm/${d}`)}}},me={id:"refresh-hooks",introducedIn:"evergreen",description:"Reinstall hook scripts from plugin",category:"hook",auto:true,async check(e){let t=[p.join(e,".claude","hooks"),p.join(e,".cursor","hooks")];for(let i of t)if(o.existsSync(i))try{if(o.readdirSync(i).some(a=>a.includes("paradigm")))return {needed:!1,reason:"Hooks are installed"}}catch{}let n=p.join(e,".claude","settings.local.json");if(o.existsSync(n))try{if(JSON.parse(o.readFileSync(n,"utf8")).hooks)return {needed:!1,reason:"Plugin-managed hooks are configured"}}catch{}return {needed:true,reason:"No paradigm hooks found"}},async apply(e,t){if(t.dryRun)return {status:"skipped",message:"Would reinstall hooks"};try{let{hooksInstallCommand:n}=await import('./hooks-E7HQQ57M.js');return await n({force:!0}),{status:"applied",message:"Hooks reinstalled"}}catch(n){return {status:"error",message:`Hook install failed: ${n.message}`}}}},b=[Q,X,Z,ee,te,ne,se,ue,de,le,re,oe,ie,ae,ce,pe,ge,fe,me];var he=createRequire(import.meta.url),{version:W}=he("../package.json");function C(e){let t=p.join(e,".paradigm","migrate.yaml");if(!o.existsSync(t))return null;try{let n=o.readFileSync(t,"utf8");return F.load(n)}catch{return null}}async function V(e){let t=p.join(e,".paradigm"),n=C(e),i=n?.applied.map(l=>l.id)??[],r="unknown",a=p.join(t,"config.yaml");if(o.existsSync(a))try{let l=F.load(o.readFileSync(a,"utf8"));r=String(l.version??"unknown");}catch{}let g=["specs","docs","prompts","lore","tasks","protocols","personas"].filter(l=>!o.existsSync(p.join(t,l))),m=["discipline","tag-bank","purpose-required","component_types"],S=[];if(o.existsSync(a))try{let l=F.load(o.readFileSync(a,"utf8"));S=m.filter(h=>{let j=h.replace(/-/g,"_");return !(h in l)&&!(j in l)&&!(h.replace(/_/g,"-")in l)});}catch{}let k=[],M=$();if(M){let l=["specs","docs"];for(let h of l){let j=p.join(M,h),L=p.join(t,h);if(o.existsSync(j)&&o.existsSync(L)){let J=o.readdirSync(j).filter(R=>!o.statSync(p.join(j,R)).isDirectory());for(let R of J){let Y=p.join(L,R);o.existsSync(Y)||k.push(`${h}/${R}`);}}}}let c=!o.existsSync(p.join(e,".claude","hooks")),u=[];for(let l of b){let h=l.introducedIn==="evergreen";if(i.includes(l.id)&&!h)continue;(await l.check(e)).needed&&u.push(l);}return {configVersion:r,cliVersion:W,pendingMigrations:u,appliedIds:i,health:{missingDirectories:g,missingConfigFields:S,staleTemplates:k,hooksOutdated:c}}}async function U(e){let t=[],n=new Date().toISOString();for(let i of b){if(i.introducedIn==="evergreen")continue;(await i.check(e)).needed||t.push({id:i.id,appliedAt:n,cliVersion:W});}return t}function $(){let e=new URL(import.meta.url).pathname,t=p.dirname(e),n=[p.join(t,"..","..","..","templates","paradigm"),p.join(t,"..","..","templates","paradigm"),p.join(t,"..","templates","paradigm")];for(let i of n)if(o.existsSync(i))return i;return null}var ke=createRequire(import.meta.url),{version:N}=ke("../package.json");async function B(e){let t=C(e);if(t)return t;let n=await U(e);return {version:"1.0",cliVersion:N,lastMigrated:new Date().toISOString(),applied:n}}function _(e,t){let n=p.join(e,".paradigm","migrate.yaml");o.mkdirSync(p.dirname(n),{recursive:true}),t.cliVersion=N,t.lastMigrated=new Date().toISOString(),o.writeFileSync(n,F.dump(t,{indent:2,lineWidth:120,noRefs:true,sortKeys:false,quotingType:'"'}),"utf8");}async function E(e,t,n,i){let r={applied:0,skipped:0,errors:0,manual:0,results:[]},a=new Date().toISOString();for(let d of t){if(!d.auto){r.manual++,r.results.push({id:d.id,result:{status:"skipped",message:"Manual review recommended"}});continue}try{let g=await d.apply(e,n);r.results.push({id:d.id,result:g}),g.status==="applied"?(r.applied++,i.applied.push({id:d.id,appliedAt:a,cliVersion:N})):g.status==="skipped"?r.skipped++:r.errors++;}catch(g){r.errors++,r.results.push({id:d.id,result:{status:"error",message:g.message}});}}return r}async function _e(e={}){let t=process.cwd(),n=p.join(t,".paradigm");if((!o.existsSync(n)||!o.statSync(n).isDirectory())&&!(o.existsSync(n)&&o.statSync(n).isFile())){e.quiet||console.log(s.yellow("\n No .paradigm/ directory found. Run `paradigm init` or `paradigm shift` first.\n"));return}let i=we();e.quiet||i.start("Detecting project state...");let r=await V(t);e.quiet||i.stop();let a=await B(t),d=r.pendingMigrations;if(e.only&&e.only.length>0&&(d=d.filter(c=>e.only.includes(c.id))),e.category&&(d=d.filter(c=>c.category===e.category)),e.force){let c=e.only?b.filter(u=>e.only.includes(u.id)):e.category?b.filter(u=>u.category===e.category):b;d=[];for(let u of c)((await u.check(t)).needed||e.force)&&d.push(u);}let g=d.filter(c=>c.auto),m=d.filter(c=>!c.auto);if(e.list){Me(a,r,e);return}if(e.quiet){if(g.length===0)return;let c=await E(t,g,e,a);return _(t,a),c}let S=C(t);if(console.log(s.blue(`
52
52
  \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510`)),console.log(s.blue("\u2502")+s.white.bold(" paradigm migrate ")+s.blue("\u2502")),console.log(s.blue("\u2502")+s.gray(" Bring your project up to date ")+s.blue("\u2502")),console.log(s.blue(`\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
53
53
  `)),console.log(s.white(` Project: ${s.cyan(p.basename(t))}`)),console.log(s.white(` Config version: ${s.cyan(r.configVersion)}`)),console.log(s.white(` CLI version: ${s.cyan(r.cliVersion)}`)),console.log(s.white(` Last migrated: ${s.cyan(S?.lastMigrated??"never")}`)),console.log(""),d.length===0){console.log(s.green(` All migrations are up to date.
54
54
  `)),S||(_(t,a),e.verbose&&console.log(s.gray(` Created .paradigm/migrate.yaml with bootstrap state.
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import {a,b as b$1,c}from'./chunk-XMAV5AG6.js';import {a as a$1,b as b$2}from'./chunk-Y6KXTQBG.js';import'./chunk-5TAVYPOV.js';import U,{Router}from'express';import*as ut from'http';import*as v from'path';import*as S from'fs';import {fileURLToPath}from'url';import A from'chalk';import {WebSocketServer,WebSocket}from'ws';import X from'simple-git';import*as W from'js-yaml';import*as H from'os';function dt(r){let n=["#58a6ff","#3fb950","#f85149","#d29922","#bc8cff","#f778ba","#79c0ff","#56d364"],o=0;for(let s=0;s<r.length;s++)o=(o<<5)-o+r.charCodeAt(s)|0;return n[Math.abs(o)%n.length]}var gt=0,E=class{agents=new Map;staleTimeout=120*1e3;join(n){let o=new Date().toISOString(),s={agentId:n,color:dt(n),connectedAt:o,lastActivity:o};return this.agents.set(n,s),s}touch(n){let o=this.agents.get(n);o&&(o.lastActivity=new Date().toISOString());}leave(n){this.agents.delete(n);}getAll(){return Array.from(this.agents.values())}pruneStale(){let n=Date.now(),o=[];for(let[s,t]of this.agents)n-new Date(t.lastActivity).getTime()>this.staleTimeout&&(this.agents.delete(s),o.push(s));return o}},M=class{state={section:"overview",selectedSymbol:null,theme:"dark",lastInteraction:Date.now()};highlights=[];annotations=[];muted=false;updateSection(n){this.state.section=n,this.state.lastInteraction=Date.now();}updateSelectedSymbol(n){this.state.selectedSymbol=n,this.state.lastInteraction=Date.now();}updateTheme(n){this.state.theme=n;}setMuted(n){this.muted=n;}isMuted(){return this.muted}isUserActive(n=5e3){return Date.now()-this.state.lastInteraction<n}getState(){return {...this.state,muted:this.muted}}addHighlight(n){this.highlights.push(n),n.duration>0&&setTimeout(()=>{this.highlights=this.highlights.filter(o=>o!==n);},n.duration);}addAnnotation(n){let o={...n,id:`ann-${++gt}`,createdAt:Date.now()};return this.annotations.push(o),o.duration>0&&setTimeout(()=>{this.annotations=this.annotations.filter(s=>s!==o);},o.duration),o}clearHighlights(){this.highlights=[];}clearAnnotations(){this.annotations=[];}clearAll(){this.highlights=[],this.annotations=[];}getHighlights(){return [...this.highlights]}getAnnotations(){return [...this.annotations]}};function Q(r){let n=new Set,o=new E,s=new M;function t(a){let c=JSON.stringify(a);for(let l of n)l.readyState===WebSocket.OPEN&&l.send(c);}return new WebSocketServer({server:r,path:"/ws"}).on("connection",a=>{n.add(a),a.on("message",c=>{try{let l=JSON.parse(c.toString());l.type==="user:navigate"?s.updateSection(l.section):l.type==="user:select"?s.updateSelectedSymbol(l.symbol??null):l.type==="user:theme"?s.updateTheme(l.theme):l.type==="user:mute"?(s.setMuted(l.muted),t({type:"agent:mute_changed",muted:l.muted})):l.type==="ping"&&a.send(JSON.stringify({type:"pong",timestamp:new Date().toISOString()}));}catch{}}),a.on("close",()=>{n.delete(a);}),a.on("error",()=>{n.delete(a);});}),setInterval(()=>{let a=o.pruneStale();for(let c of a)t({type:"agent:leave",agentId:c});},3e4),{broadcast:t,agentPresence:o,userState:s,clientCount:()=>n.size}}function V(r){let n=Router();return n.post("/",(o,s)=>{let{command:t,agentId:e,payload:a}=o.body;if(!t||!e){s.status(400).json({error:"Missing command or agentId"});return}switch(r.agentPresence.getAll().find(l=>l.agentId===e)||(r.agentPresence.join(e),r.broadcast({type:"agent:join",agent:r.agentPresence.getAll().find(l=>l.agentId===e)})),r.agentPresence.touch(e),t){case "navigate":{let{section:l,symbol:i,loreId:u}=a,m=r.userState.isUserActive();if(r.userState.isMuted()){s.json({navigated:false,reason:"Agent actions are muted by user"});return}r.broadcast({type:"agent:navigate",agentId:e,section:l,symbol:i,loreId:u,userActive:m}),l&&r.userState.updateSection(l),i&&r.userState.updateSelectedSymbol(i),s.json({navigated:true,section:l,symbol:i,userActive:m});return}case "highlight":{let{symbols:l,color:i,duration:u,pulse:m,label:d}=a;if(r.userState.isMuted()){s.json({highlighted:false,reason:"Agent actions are muted by user"});return}let f=l||[];r.userState.addHighlight({symbols:f,color:i||r.agentPresence.getAll().find(P=>P.agentId===e)?.color||"#58a6ff",duration:u||5e3,pulse:m??true,label:d,createdAt:Date.now()}),r.broadcast({type:"agent:highlight",agentId:e,symbols:f,color:i||"#58a6ff",duration:u||5e3,pulse:m??true,label:d}),s.json({highlighted:true,count:f.length});return}case "annotate":{let{type:l,message:i,symbol:u,severity:m,duration:d}=a;if(r.userState.isMuted()){s.json({annotated:false,reason:"Agent actions are muted by user"});return}let f=r.userState.addAnnotation({type:l||"toast",message:i||"",symbol:u,severity:m||"info",duration:d||6e3});r.broadcast({type:"agent:annotate",agentId:e,annotation:f}),s.json({annotated:true,id:f.id});return}case "observe":{let l=r.userState.getState(),i=r.agentPresence.getAll(),u=r.clientCount()>0;s.json({connected:u,users:r.clientCount(),agents:i,state:{section:l.section,selectedSymbol:l.selectedSymbol,theme:l.theme,muted:l.muted},highlights:r.userState.getHighlights(),annotations:r.userState.getAnnotations()});return}case "clear":{let{target:l}=a,i=l||"all";(i==="highlights"||i==="all")&&r.userState.clearHighlights(),(i==="annotations"||i==="all")&&r.userState.clearAnnotations(),r.broadcast({type:"agent:clear",agentId:e,target:i}),s.json({cleared:true,target:i});return}default:s.status(400).json({error:`Unknown command: ${t}`});return}}),n}function yt(r){try{return JSON.parse(S.readFileSync(r,"utf-8"))}catch{return null}}function O(r){try{return W.load(S.readFileSync(r,"utf-8"))}catch{return null}}function bt(r){let n=v.join(r,".paradigm","scan-index.json"),o=yt(n);if(!o?.symbols)return {total:0,byType:{}};let s={};for(let t of o.symbols){let e=t.category||"unknown";s[e]=(s[e]||0)+1;}return {total:o.symbols.length,byType:s}}function St(r){let n=v.join(r,".paradigm","lore","entries");if(!S.existsSync(n))return {total:0,thisWeek:0,lastEntry:null,calibrationScore:null,assessed:0};let o=S.readdirSync(n).filter(d=>d.endsWith(".yaml")||d.endsWith(".yml")),t=Date.now()-10080*60*1e3,e=null,a=0,c=0,l=0,i=0,u=0;for(let d of o)try{let p=O(v.join(n,d));if(!p)continue;let f=p.timestamp;if(f){let P=new Date(f).getTime();(!e||P>new Date(e).getTime())&&(e=f),P>=t&&a++;}p.assessment&&(c++,typeof p.confidence=="number"&&typeof p.assessment_delta=="number"&&(l+=p.confidence,i+=Math.abs(p.assessment_delta),u++));}catch{}let m=u>0?Math.max(0,1-i/u):null;return {total:o.length,thisWeek:a,lastEntry:e,calibrationScore:m,assessed:c}}function vt(r){let n=v.join(r,".paradigm","tasks");if(!S.existsSync(n))return {total:0,inProgress:0,completed:0};let o=S.readdirSync(n).filter(e=>e.endsWith(".yaml")||e.endsWith(".yml")),s=0,t=0;for(let e of o)try{let a=O(v.join(n,e));if(!a)continue;let c=a.status;c==="in-progress"||c==="in_progress"?s++:(c==="completed"||c==="done")&&t++;}catch{}return {total:o.length,inProgress:s,completed:t}}function Rt(r){let n=["src","lib","packages"],o=0,s=0;for(let t of n){let e=v.join(r,t);S.existsSync(e)&&tt(e,{},a=>{o+=a.withPurpose,s+=a.total;});}return S.existsSync(v.join(r,".purpose"))&&(o++,s++),s===0?1:o/s}function tt(r,n,o){let s={withPurpose:0,total:0};try{let t=S.readdirSync(r,{withFileTypes:!0});t.some(a=>a.isFile()&&/\.(ts|tsx|js|jsx|rs|py|go|swift)$/.test(a.name))&&(s.total++,t.some(a=>a.isFile()&&a.name===".purpose")&&s.withPurpose++);for(let a of t)a.isDirectory()&&!a.name.startsWith(".")&&a.name!=="node_modules"&&a.name!=="dist"&&tt(v.join(r,a.name),s,c=>{s.withPurpose+=c.withPurpose,s.total+=c.total;});}catch{}o(s);}function jt(r){let n=v.join(r,"portal.yaml");if(!S.existsSync(n))return 1;let o=O(n);return o?.routes?Object.keys(o.routes).length>0?1:.5:1}function wt(r){let n=v.join(r,".paradigm","aspect-graph.db");return S.existsSync(n),1}function At(r){let n=v.join(r,".paradigm","config.yaml"),o=O(n);return {name:o?.project||v.basename(r),discipline:o?.discipline||"general"}}async function Pt(r,n){try{return (await X(r).log({maxCount:n})).all.map(t=>({timestamp:t.date,type:"commit",summary:t.message.split(`
3
+ `)[0],symbol:kt(t.message),link:t.hash.substring(0,7)}))}catch{return []}}function kt(r){let n=r.match(/[#$^!~][\w-]+/);return n?n[0]:void 0}function xt(r,n){let o=v.join(r,".paradigm","lore","entries");if(!S.existsSync(o))return [];let s=S.readdirSync(o).filter(e=>e.endsWith(".yaml")||e.endsWith(".yml")),t=[];for(let e of s)try{let a=O(v.join(o,e));if(!a)continue;t.push({timestamp:a.timestamp||"",type:"lore",summary:a.title||e,symbol:Array.isArray(a.symbols_touched)?a.symbols_touched[0]:void 0,link:a.id});}catch{}return t.sort((e,a)=>new Date(a.timestamp).getTime()-new Date(e.timestamp).getTime()).slice(0,n)}function et(r){return async(n,o)=>{try{let s=At(r),t=bt(r),e=St(r),a=vt(r),c=Rt(r),l=jt(r),i=wt(r),u="unknown";try{u=(await X(r).branch()).current;}catch{}let[m,d]=await Promise.all([Pt(r,20),Promise.resolve(xt(r,20))]),p=[...m,...d].sort((x,g)=>new Date(g.timestamp).getTime()-new Date(x.timestamp).getTime()).slice(0,20),f=e.lastEntry?Math.floor((Date.now()-new Date(e.lastEntry).getTime())/(1e3*60*60*24)):0,P={project:{name:s.name,branch:u,discipline:s.discipline},symbols:t,lore:{total:e.total,thisWeek:e.thisWeek,lastEntry:e.lastEntry},calibration:{score:e.calibrationScore,assessed:e.assessed},tasks:a,health:{purposeCoverage:c,aspectAnchors:i,gateCompliance:l,calibration:e.calibrationScore??1,loreFreshnessDays:f},recentActivity:p};o.json(P);}catch(s){o.status(500).json({error:"Failed to aggregate overview",detail:String(s)});}}}var qt=/[#$^!~][\w-]+/g;function It(r){let n=r.match(qt);return n?[...new Set(n)]:[]}function nt(r){let n=Router(),o=X(r);return n.get("/status",async(s,t)=>{try{let[e,a]=await Promise.all([o.status(),o.branch()]);t.json({branch:a.current,ahead:e.ahead,behind:e.behind,staged:e.staged,unstaged:e.modified.filter(c=>!e.staged.includes(c)),untracked:e.not_added});}catch(e){t.status(500).json({error:"Failed to get git status",detail:String(e)});}}),n.get("/branches",async(s,t)=>{try{let e=await o.branch(),a=Object.values(e.branches).map(c=>({name:c.name,current:c.current,commit:c.commit,label:c.label}));t.json({current:e.current,branches:a});}catch(e){t.status(500).json({error:"Failed to get branches",detail:String(e)});}}),n.get("/log",async(s,t)=>{try{let e=Math.min(parseInt(s.query.limit)||20,100),a=parseInt(s.query.offset)||0,c=await o.log({maxCount:e,"--skip":a}),l=c.all.map(i=>({hash:i.hash,shortHash:i.hash.substring(0,7),message:i.message,author:i.author_name,date:i.date,symbols:It(i.message)}));t.json({commits:l,total:c.total});}catch(e){t.status(500).json({error:"Failed to get git log",detail:String(e)});}}),n.get("/diff",async(s,t)=>{try{let e=s.query.path,a=s.query.staged==="true",c=[];a&&c.push("--cached"),e&&c.push("--",e);let l=await o.diff(c);t.json({diff:l});}catch(e){t.status(500).json({error:"Failed to get diff",detail:String(e)});}}),n.post("/stage",async(s,t)=>{try{let{paths:e}=s.body;if(!e?.length){t.status(400).json({error:"paths is required"});return}await o.add(e),t.json({staged:e});}catch(e){t.status(500).json({error:"Failed to stage files",detail:String(e)});}}),n.post("/unstage",async(s,t)=>{try{let{paths:e}=s.body;if(!e?.length){t.status(400).json({error:"paths is required"});return}await o.reset(["HEAD","--",...e]),t.json({unstaged:e});}catch(e){t.status(500).json({error:"Failed to unstage files",detail:String(e)});}}),n.post("/commit",async(s,t)=>{try{let{message:e}=s.body;if(!e?.trim()){t.status(400).json({error:"message is required"});return}let a=await o.commit(e);t.json({hash:a.commit,summary:a.summary});}catch(e){t.status(500).json({error:"Failed to commit",detail:String(e)});}}),n.post("/push",async(s,t)=>{try{let e=await o.push();t.json({pushed:!0,branch:e.branch,remoteMessages:e.remoteMessages});}catch(e){t.status(500).json({error:"Failed to push",detail:String(e)});}}),n}function N(r){if(!S.existsSync(r))return [];try{let o=S.readFileSync(r,"utf-8").split(`
4
+ `).filter(t=>t.trim()),s=[];for(let t of o)try{s.push(JSON.parse(t));}catch{}return s}catch{return []}}function $t(r,n){let o=v.dirname(r);S.existsSync(o)||S.mkdirSync(o,{recursive:true});let s=n.map(t=>JSON.stringify(t)).join(`
5
+ `)+`
6
+ `;S.writeFileSync(r,s,"utf-8");}function Ot(r){let n=r.match(/^(\d+)(m|h|d)$/);if(!n)return null;let o=parseInt(n[1],10),s=n[2],t=Date.now();switch(s){case "m":return new Date(t-o*60*1e3);case "h":return new Date(t-o*60*60*1e3);case "d":return new Date(t-o*24*60*60*1e3);default:return null}}function rt(r,n){let o=Router(),s=v.join(r,".paradigm","events","stream.jsonl"),t=v.join(r,".paradigm","events","nominations.jsonl"),e=v.join(r,".paradigm","events","debates.jsonl"),a=v.join(r,".paradigm","data-policy.yaml");return o.get("/events",(c,l)=>{try{let{type:i,source:u,symbol:m,agent:d,since:p,limit:f}=c.query,P=f?parseInt(f,10):50,x=p?Ot(p):null,g=N(s);i&&(g=g.filter(w=>w.type===i)),u&&(g=g.filter(w=>w.source===u)),m&&(g=g.filter(w=>w.symbol===m)),d&&(g=g.filter(w=>w.agent===d)),x&&(g=g.filter(w=>w.timestamp?new Date(w.timestamp).getTime()>=x.getTime():!1));let T=g.slice(-P);n.broadcast({type:"ambient:event",action:"query",count:T.length}),l.json(T);}catch(i){l.status(500).json({error:"Failed to query events",detail:String(i)});}}),o.get("/nominations",(c,l)=>{try{let{agent:i,urgency:u,pending_only:m,include_debates:d,limit:p}=c.query,f=p?parseInt(p,10):20,P=m!=="false",x=d==="true",g=N(t);i&&(g=g.filter(k=>k.agent===i)),u&&(g=g.filter(k=>k.urgency===u)),P&&(g=g.filter(k=>!k.engaged)),g=g.slice(-f);let T;if(x){let k=N(e);T=new Map;for(let I of k)if(I.nominationId){let z=T.get(I.nominationId)||[];z.push(I),T.set(I.nominationId,z);}}let w=g.map(k=>{let I={...k};return x&&T&&k.id&&(I.debates=T.get(k.id)||[]),I});l.json(w);}catch(i){l.status(500).json({error:"Failed to query nominations",detail:String(i)});}}),o.post("/nominations/:id/engage",(c,l)=>{try{let{id:i}=c.params,{response:u}=c.body;if(!u||!["accepted","dismissed","deferred"].includes(u)){l.status(400).json({error:"response must be one of: accepted, dismissed, deferred"});return}let m=N(t),d=m.findIndex(p=>p.id===i);if(d===-1){l.status(404).json({error:`Nomination not found: ${i}`});return}m[d]={...m[d],engaged:!0,response:u},$t(t,m),n.broadcast({type:"ambient:nomination",action:"engaged",nominationId:i,response:u}),l.json(m[d]);}catch(i){l.status(500).json({error:"Failed to engage nomination",detail:String(i)});}}),o.get("/stream",(c,l)=>{l.setHeader("Content-Type","text/event-stream"),l.setHeader("Cache-Control","no-cache"),l.setHeader("Connection","keep-alive"),l.flushHeaders();let i=0;try{i=S.statSync(s).size;}catch{}let m=setInterval(()=>{try{if(!S.existsSync(s))return;let d=S.statSync(s);if(d.size<=i)if(d.size<i)i=0;else return;let p=S.openSync(s,"r"),f=Buffer.alloc(d.size-i);S.readSync(p,f,0,f.length,i),S.closeSync(p),i=d.size;let x=f.toString("utf-8").split(`
7
+ `).filter(g=>g.trim());for(let g of x)try{let T=JSON.parse(g);l.write(`data: ${JSON.stringify(T)}
8
+
9
+ `);}catch{}}catch{}},1e3);l.write(`: connected
10
+
11
+ `),c.on("close",()=>{clearInterval(m);});}),o.get("/policy",(c,l)=>{try{if(S.existsSync(a)){let i=S.readFileSync(a,"utf-8"),u=W.load(i);l.json(u);}else l.json({version:"1.0",retention:{events:"30d",nominations:"90d",debates:"90d"},collection:{telemetry:!1,usage:!1},sharing:{external:!1}});}catch(i){l.status(500).json({error:"Failed to read data policy",detail:String(i)});}}),o}function Ct(r){if(!S.existsSync(r))return [];try{return S.readFileSync(r,"utf-8").trim().split(`
12
+ `).filter(n=>n.trim()).map(n=>{try{return JSON.parse(n)}catch{return null}}).filter(n=>n!==null)}catch{return []}}function _t(){let r=v.join(H.homedir(),".paradigm","agents"),n=[];if(!S.existsSync(r))return n;for(let o of S.readdirSync(r).filter(s=>s.endsWith(".agent")))try{let s=S.readFileSync(v.join(r,o),"utf-8"),t=W.load(s);if(!t?.id)continue;let e=t.expertise||[];e.sort((a,c)=>c.confidence-a.confidence),n.push({id:t.id,role:t.role||t.id,nickname:t.nickname,benched:t.benched||!1,expertiseCount:e.length,topExpertise:e.slice(0,3).map(a=>({symbol:a.symbol,confidence:parseFloat(a.confidence.toFixed(2))})),threshold:t.attention?.threshold});}catch{}return n}function Et(){let r=v.join(H.homedir(),".paradigm","mail","agents");if(!S.existsSync(r))return [];let n=[];try{for(let t of S.readdirSync(r,{withFileTypes:!0})){if(!t.isDirectory())continue;let e=v.join(r,t.name);for(let a of ["inbox.jsonl","outbox.jsonl"]){let c=v.join(e,a),l=Ct(c);for(let i of l)i.threadRoot?.startsWith("thr-orch-")&&(n.some(u=>u.id===i.id)||n.push({id:i.id,threadRoot:i.threadRoot,timestamp:i.timestamp,sender:{name:i.sender?.name||"unknown",role:i.sender?.role,project:i.sender?.project},intent:i.intent||"context",text:i.content?.text||"",symbols:i.symbols||[],diff:i.content?.diff,decision:i.content?.decision}));}}}catch{}let o=new Map;for(let t of n){let e=t.threadRoot;o.has(e)||o.set(e,[]),o.get(e).push(t);}let s=[];for(let[t,e]of o){e.sort((i,u)=>i.timestamp.localeCompare(u.timestamp));let c=t.replace("thr-orch-","").split("-"),l=c[0]?`Team ${c[0]}`:t;s.push({id:t,displayName:l,messages:e,lastActivity:e[e.length-1]?.timestamp||""});}return s.sort((t,e)=>e.lastActivity.localeCompare(t.lastActivity)),s}function ot(r){let n=Router();return n.get("/roster",(o,s)=>{try{let t=_t(),e=t.filter(c=>!c.benched),a=t.filter(c=>c.benched);s.json({active:e,benched:a,total:t.length});}catch(t){s.status(500).json({error:"Failed to load roster",detail:String(t)});}}),n.get("/threads",(o,s)=>{try{let t=Et();s.json({threads:t,count:t.length});}catch(t){s.status(500).json({error:"Failed to load threads",detail:String(t)});}}),n.patch("/agents/:id/bench",(o,s)=>{try{let{id:t}=o.params,{benched:e}=o.body,a=v.join(H.homedir(),".paradigm","agents"),c=v.join(a,`${t}.agent`);if(!S.existsSync(c)){s.status(404).json({error:`Agent "${t}" not found`});return}let l=S.readFileSync(c,"utf-8"),i=W.load(l);i.benched=e,i.updated=new Date().toISOString(),S.writeFileSync(c,W.dump(i,{lineWidth:120,noRefs:!0,sortKeys:!1}),"utf-8"),s.json({id:t,benched:e,updated:i.updated});}catch(t){s.status(500).json({error:"Failed to update agent",detail:String(t)});}}),n}var Nt=new Set(["node_modules",".git","dist",".next","build",".paradigm",".turbo",".cache","coverage",".output"]);function it(r,n){let o=[],s;try{s=S.readdirSync(r,{withFileTypes:!0});}catch{return o}for(let t of s)t.isDirectory()?!Nt.has(t.name)&&!t.name.startsWith(".")&&o.push(...it(v.join(r,t.name),n)):t.isFile()&&t.name.endsWith(".canvas")&&o.push(v.relative(n,v.join(r,t.name)));return o}var $=null,at=0,Ht=5e3;function Jt(r){let n=Date.now();if($&&n-at<Ht)return $;let o=S.readdirSync(r).filter(t=>t.endsWith(".canvas")).map(t=>t),s=it(r,r).filter(t=>!o.includes(t));return $=[...o,...s],at=n,$}function J(r,n){let o=v.resolve(r,n);return !o.startsWith(r+v.sep)&&o!==r||!o.endsWith(".canvas")?null:o}function ct(r){let n=Router();return n.get("/files",(o,s)=>{try{let e=Jt(r).map(a=>{let c=v.join(r,a);try{let l=S.statSync(c),i=v.basename(a,".canvas"),u="";try{let m=W.load(S.readFileSync(c,"utf8"));m&&typeof m.name=="string"&&(i=m.name),m&&typeof m.description=="string"&&(u=m.description);}catch{}return {path:a,name:i,description:u,modified:l.mtime.toISOString(),size:l.size}}catch{return null}}).filter(Boolean);e.sort((a,c)=>c.modified.localeCompare(a.modified)),s.json({files:e});}catch(t){s.status(500).json({error:"Failed to list canvas files",details:t.message});}}),n.get("/files/*",(o,s)=>{let t=o.params[0]||o.params.path||"";if(!t){s.status(400).json({error:"File path required"});return}let e=J(r,t);if(!e){s.status(400).json({error:"Invalid path"});return}if(!S.existsSync(e)){s.status(404).json({error:`Canvas file not found: ${t}`});return}try{let a=S.readFileSync(e,"utf8"),c=W.load(a);s.json(c);}catch(a){s.status(500).json({error:"Failed to read canvas file",details:a.message});}}),n.put("/files/*",(o,s)=>{let t=o.params[0]||o.params.path||"";if(!t){s.status(400).json({error:"File path required"});return}let e=J(r,t);if(!e){s.status(400).json({error:"Invalid path"});return}try{let a=o.body;if(!a||typeof a!="object"){s.status(400).json({error:"Request body must be a JSON object"});return}let c=new Date().toISOString();a.created||(a.created=c),a.updated=c;let l=v.dirname(e);S.existsSync(l)||S.mkdirSync(l,{recursive:!0});let i=W.dump(a,{lineWidth:-1,noRefs:!0,quotingType:'"',forceQuotes:!1});S.writeFileSync(e,i,"utf8"),$=null,s.json({saved:!0,path:t});}catch(a){s.status(500).json({error:"Failed to save canvas file",details:a.message});}}),n.delete("/files/*",(o,s)=>{let t=o.params[0]||o.params.path||"";if(!t){s.status(400).json({error:"File path required"});return}let e=J(r,t);if(!e){s.status(400).json({error:"Invalid path"});return}if(!S.existsSync(e)){s.status(404).json({error:`Canvas file not found: ${t}`});return}try{S.unlinkSync(e),$=null,s.json({deleted:!0,path:t});}catch(a){s.status(500).json({error:"Failed to delete canvas file",details:a.message});}}),n}var zt=fileURLToPath(import.meta.url),lt=v.dirname(zt),b={component(r){let n=A.magenta(`#${r}`);return {info:(o,s)=>{let t=s?A.gray(` ${Object.entries(s).map(([e,a])=>`${e}=${a}`).join(" ")}`):"";console.log(`${A.blue("i")} ${n} ${o}${t}`);},success:(o,s)=>{let t=s?A.gray(` ${Object.entries(s).map(([e,a])=>`${e}=${a}`).join(" ")}`):"";console.log(`${A.green("+")} ${n} ${o}${t}`);},warn:(o,s)=>{let t=s?A.gray(` ${Object.entries(s).map(([e,a])=>`${e}=${a}`).join(" ")}`):"";console.log(`${A.yellow("!")} ${n} ${o}${t}`);},error:(o,s)=>{let t=s?A.gray(` ${Object.entries(s).map(([e,a])=>`${e}=${a}`).join(" ")}`):"";console.error(`${A.red("x")} ${n} ${o}${t}`);}}}};function mt(r){let n=["overview","lore","graph","canvas","git","ambient","team"],o=r.sections??[...n,"sentinel","university","symphony","docs"],s=new Set;for(let t of o){if(n.includes(t)){s.add(t);continue}if(t==="sentinel"){let e=v.join(r.projectDir,".paradigm");S.existsSync(e)&&s.add(t);}else if(t==="university")s.add(t);else if(t==="symphony"){let e=v.join(process.env.HOME||"~",".paradigm","score");S.existsSync(e)&&s.add(t);}else s.add(t);}return s}function Gt(r){let n=U(),o=mt(r);n.use(U.json()),n.use((t,e,a)=>{if(e.header("Access-Control-Allow-Origin","*"),e.header("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS"),e.header("Access-Control-Allow-Headers","Content-Type"),t.method==="OPTIONS"){e.sendStatus(204);return}a();}),n.use("/api/lore",a(r.projectDir)),n.use("/api/info",b$1(r.projectDir)),n.use("/api/sessions",c(r.projectDir)),n.use("/api/symbols",a$1(r.projectDir)),n.use("/api/graphs",b$2(r.projectDir)),n.get("/api/platform/overview",et(r.projectDir)),n.use("/api/canvas",ct(r.projectDir)),n.use("/api/git",nt(r.projectDir)),n.get("/api/platform/health",(t,e)=>{e.json({status:"ok",timestamp:new Date().toISOString(),sections:Array.from(o)});}),n.get("/api/platform/sections",(t,e)=>{e.json({sections:Array.from(o)});}),n.get("/api/health",(t,e)=>{e.json({status:"ok",timestamp:new Date().toISOString()});}),n.set("agentRouterSlot",true);let s=v.join(lt,"..","platform-ui","dist");return S.existsSync(s)||(s=v.join(lt,"..","..","platform-ui","dist")),S.existsSync(s)?(n.use(U.static(s)),n.get("{*path}",(t,e,a)=>{t.path.startsWith("/api")?a():e.sendFile(v.join(s,"index.html"));})):n.get("/",(t,e)=>{e.send(`
13
+ <html>
14
+ <head><title>Paradigm Platform</title></head>
15
+ <body style="background:#0d1117;color:#e6edf3;font-family:system-ui;display:flex;align-items:center;justify-content:center;height:100vh;margin:0">
16
+ <div style="text-align:center">
17
+ <h1 style="font-size:2rem;margin-bottom:8px">Paradigm Platform</h1>
18
+ <p style="color:#8b949e">UI not built yet. Run <code style="background:#21262d;padding:4px 8px;border-radius:4px">cd platform-ui && npx vite build</code></p>
19
+ <p style="color:#8b949e;margin-top:16px">APIs available:</p>
20
+ <p><a href="/api/lore" style="color:#58a6ff">/api/lore</a> &middot; <a href="/api/symbols" style="color:#58a6ff">/api/symbols</a> &middot; <a href="/api/platform/health" style="color:#58a6ff">/api/platform/health</a></p>
21
+ </div>
22
+ </body>
23
+ </html>
24
+ `);}),n}async function Pe(r){let n=Gt(r),o=mt(r);b.component("platform-server").info("Starting Paradigm Platform",{port:r.port}),b.component("platform-server").info("Project directory",{path:r.projectDir}),b.component("platform-server").info("Sections",{enabled:Array.from(o).join(", ")});let s=ut.createServer(n),t=Q(s);if(n.use("/api/platform/agent-command",V(t)),n.use("/api/ambient",rt(r.projectDir,t)),n.use("/api/team",ot(r.projectDir)),o.has("sentinel"))try{let{createSentinelBridge:e}=await import('./sentinel-bridge-VR357PKL.js'),a=await e(r.projectDir,t.broadcast);a&&(n.use("/api/sentinel",a),b.component("platform-server").success("Sentinel routes mounted"));}catch{b.component("platform-server").warn("Sentinel not available");}if(o.has("symphony"))try{let{createSymphonyRouter:e}=await import('./symphony-3QMBGCZY.js');n.use("/api/symphony",e(r.projectDir,t.broadcast)),b.component("platform-server").success("Symphony routes mounted");}catch{b.component("platform-server").warn("Symphony routes failed to mount");}if(o.has("docs"))try{let{createDocsRouter:e}=await import('./docs-EDQ2STFK.js');n.use("/api/docs",e(r.projectDir)),b.component("platform-server").success("Docs routes mounted");}catch{b.component("platform-server").warn("Docs routes failed to mount");}if(o.has("university"))try{let{createUniversityRouter:e}=await import('./university-FJ7OCOA3.js');n.use("/api/university",e(r.projectDir)),b.component("platform-server").success("University routes mounted");}catch{b.component("platform-server").warn("University routes failed to mount");}return new Promise((e,a)=>{s.listen(r.port,()=>{b.component("platform-server").success("Platform running",{url:`http://localhost:${r.port}`}),b.component("platform-ws").success("WebSocket ready",{url:`ws://localhost:${r.port}/ws`}),console.log(""),console.log(A.gray(" Sections:"));for(let c of o)console.log(A.gray(` ${A.cyan("\u25CF")} ${c}`));console.log(""),r.open&&import('open').then(c=>{c.default(`http://localhost:${r.port}`),b.component("platform-server").info("Opened browser");}).catch(()=>{b.component("platform-server").warn("Could not open browser automatically");}),e();}),s.on("error",c=>{c.code==="EADDRINUSE"?b.component("platform-server").error("Port already in use",{port:r.port}):b.component("platform-server").error("Server error",{error:c.message}),a(c);});})}
25
+ export{Gt as createPlatformApp,Pe as startPlatformServer};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export{b as ROSTER_SUGGESTIONS,a as detectProjectType}from'./chunk-AGVAHVUA.js';import'./chunk-5TAVYPOV.js';
2
+ export{b as ROSTER_SUGGESTIONS,a as detectProjectType}from'./chunk-4DVT5IEY.js';import'./chunk-5TAVYPOV.js';
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import {a as a$1,f,c,e,g as g$1,b as b$1,d}from'./chunk-WR6D3SC6.js';import {a}from'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';import*as g from'fs';import*as m from'path';import*as b from'os';import r from'chalk';import*as $ from'js-yaml';var x=m.join(b.homedir(),".paradigm","agents"),O=".agent";function C(){return m.join(process.cwd(),".paradigm","roster.yaml")}function k(){let n=C();if(!g.existsSync(n))return null;try{return $.load(g.readFileSync(n,"utf-8"))}catch{return null}}function F(n){let s=C(),c=m.dirname(s);g.existsSync(c)||g.mkdirSync(c,{recursive:true}),g.writeFileSync(s,$.dump(n,{lineWidth:-1,noRefs:true,sortKeys:false}),"utf-8");}function E(){if(!g.existsSync(x))return [];try{return g.readdirSync(x).filter(n=>n.endsWith(O)).map(n=>n.replace(O,"")).sort()}catch{return []}}function P(n){let s=m.join(x,`${n}${O}`);if(!g.existsSync(s))return null;try{let c=$.load(g.readFileSync(s,"utf-8"));return {id:c.id||n,nickname:c.nickname,role:c.role||"Unknown"}}catch{return null}}async function U(n={}){let s=process.cwd(),c$1=a.command("agent-roster-show").start("Showing project roster",{cwd:s}),o=E().length,i=k();if(!i){n.json?a$1(JSON.stringify({roster:null,message:"No roster configured",totalAgents:o})):(f("Agent Roster"),a$1(""),c(`No roster configured \u2014 all ${o} agents are active.`),e(` Run ${r.cyan("paradigm agent roster init")} to create one.`),a$1("")),c$1.success("No roster found");return}let t=i.active||[];if(n.json){let h=t.map(y=>P(y)||{id:y,role:"Unknown"});a$1(JSON.stringify({count:t.length,total:o,project:i.project,type:i.type,agents:h},null,2)),c$1.success(`${t.length} of ${o} agents active`);return}f("Agent Roster"),a$1("");let a$2="ID".padEnd(16),l="Nickname".padEnd(12);a$1(` ${r.dim(a$2)} ${r.dim(l)} ${r.dim("Role")}`),a$1(` ${r.dim("-".repeat(16))} ${r.dim("-".repeat(12))} ${r.dim("-".repeat(30))}`);for(let h of t.sort()){let y=P(h),f=y?.nickname||r.dim("\u2014"),S=y?.role||r.dim("Unknown");a$1(` ${r.white.bold(h.padEnd(16))} ${f.toString().padEnd(12)} ${r.gray(S)}`);}a$1(""),a$1(` ${r.cyan(String(t.length))} of ${r.cyan(String(o))} agents active on this project`),i.type&&g$1("Project type",i.type),a$1(""),c$1.success(`${t.length} of ${o} agents active`);}async function G(n={}){let s=process.cwd(),c$1=a.command("agent-roster-init").start("Initializing project roster",{cwd:s}),u=C();if(g.existsSync(u)&&!n.force){let S=k()?.active?.length??0;n.json?a$1(JSON.stringify({error:"Roster already exists",count:S})):(c(`Roster already exists with ${S} agents.`),e(` Use ${r.cyan("--force")} to reinitialize, or ${r.cyan("paradigm agent roster add/remove")} to modify.`)),c$1.error("Roster already exists");return}let{detectProjectType:o,ROSTER_SUGGESTIONS:i}=await import('./project-type-SURTOIG7.js'),t=o(s),a$2=i[t]||i.generic,l=m.basename(s),d=m.join(s,".paradigm","config.yaml");if(g.existsSync(d))try{let f=$.load(g.readFileSync(d,"utf-8"));f?.project&&typeof f.project=="string"&&(l=f.project);}catch{}let h={version:"1.0",project:l,type:t,active:a$2.sort()};F(h);let y=E();n.json?a$1(JSON.stringify({created:true,project:l,type:t,active:a$2.sort(),count:a$2.length,total:y.length},null,2)):(f("Agent Roster Initialized"),a$1(""),g$1("Project",l),g$1("Detected type",t),g$1("Active agents",`${a$2.length} of ${y.length}`),a$1(""),a$1(` ${r.cyan(a$2.sort().join(", "))}`),a$1(""),b$1(`Roster written to ${r.dim(".paradigm/roster.yaml")}`),e(` Modify with ${r.cyan("paradigm agent roster add/remove <agent-id>")}`),a$1("")),c$1.success(`Created roster: ${a$2.length} agents for ${t}`);}async function _(n,s={}){let c=process.cwd(),u=a.command("agent-roster-add").start(`Adding agents: ${n.join(", ")}`,{cwd:c}),o=k();if(!o){s.json?a$1(JSON.stringify({error:"No roster found. Run `paradigm agent roster init` first."})):(d("No roster found."),e(` Run ${r.cyan("paradigm agent roster init")} first.`)),u.error("No roster found");return}let i=E(),t=[],a$2=[],l=[];for(let d of n){if(!i.includes(d)){t.push(d);continue}if(o.active.includes(d)){a$2.push(d);continue}o.active.push(d),l.push(d);}l.length>0&&(o.active.sort(),F(o)),s.json?a$1(JSON.stringify({added:l,alreadyActive:a$2,invalid:t,total:o.active.length},null,2)):(l.length>0&&b$1(`Added: ${r.cyan(l.join(", "))}`),a$2.length>0&&e(` Already active: ${a$2.join(", ")}`),t.length>0&&(d(`Unknown agent(s): ${t.join(", ")}`),e(` Available: ${i.join(", ")}`)),l.length>0&&a$1(` Roster now has ${r.cyan(String(o.active.length))} active agents.`)),u.success(`Added ${l.length}, skipped ${a$2.length}, invalid ${t.length}`);}async function z(n,s={}){let c$1=process.cwd(),u=a.command("agent-roster-remove").start(`Removing agents: ${n.join(", ")}`,{cwd:c$1}),o=k();if(!o){s.json?a$1(JSON.stringify({error:"No roster found. Run `paradigm agent roster init` first."})):(d("No roster found."),e(` Run ${r.cyan("paradigm agent roster init")} first.`)),u.error("No roster found");return}let i=[],t=[];for(let a of n){let l=o.active.indexOf(a);if(l<0){i.push(a);continue}o.active.splice(l,1),t.push(a);}t.length>0&&F(o),s.json?a$1(JSON.stringify({removed:t,notFound:i,total:o.active.length},null,2)):(t.length>0&&b$1(`Removed: ${r.cyan(t.join(", "))}`),i.length>0&&c(`Not in roster: ${i.join(", ")}`),t.length>0&&a$1(` Roster now has ${r.cyan(String(o.active.length))} active agents.`)),u.success(`Removed ${t.length}, not found ${i.length}`);}export{_ as rosterAddCommand,G as rosterInitCommand,z as rosterRemoveCommand,U as rosterShowCommand};
2
+ import {a as a$1,f,c,e,g as g$1,b as b$1,d}from'./chunk-WR6D3SC6.js';import {a}from'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';import*as g from'fs';import*as m from'path';import*as b from'os';import r from'chalk';import*as $ from'js-yaml';var x=m.join(b.homedir(),".paradigm","agents"),O=".agent";function C(){return m.join(process.cwd(),".paradigm","roster.yaml")}function k(){let n=C();if(!g.existsSync(n))return null;try{return $.load(g.readFileSync(n,"utf-8"))}catch{return null}}function F(n){let s=C(),c=m.dirname(s);g.existsSync(c)||g.mkdirSync(c,{recursive:true}),g.writeFileSync(s,$.dump(n,{lineWidth:-1,noRefs:true,sortKeys:false}),"utf-8");}function E(){if(!g.existsSync(x))return [];try{return g.readdirSync(x).filter(n=>n.endsWith(O)).map(n=>n.replace(O,"")).sort()}catch{return []}}function P(n){let s=m.join(x,`${n}${O}`);if(!g.existsSync(s))return null;try{let c=$.load(g.readFileSync(s,"utf-8"));return {id:c.id||n,nickname:c.nickname,role:c.role||"Unknown"}}catch{return null}}async function U(n={}){let s=process.cwd(),c$1=a.command("agent-roster-show").start("Showing project roster",{cwd:s}),o=E().length,i=k();if(!i){n.json?a$1(JSON.stringify({roster:null,message:"No roster configured",totalAgents:o})):(f("Agent Roster"),a$1(""),c(`No roster configured \u2014 all ${o} agents are active.`),e(` Run ${r.cyan("paradigm agent roster init")} to create one.`),a$1("")),c$1.success("No roster found");return}let t=i.active||[];if(n.json){let h=t.map(y=>P(y)||{id:y,role:"Unknown"});a$1(JSON.stringify({count:t.length,total:o,project:i.project,type:i.type,agents:h},null,2)),c$1.success(`${t.length} of ${o} agents active`);return}f("Agent Roster"),a$1("");let a$2="ID".padEnd(16),l="Nickname".padEnd(12);a$1(` ${r.dim(a$2)} ${r.dim(l)} ${r.dim("Role")}`),a$1(` ${r.dim("-".repeat(16))} ${r.dim("-".repeat(12))} ${r.dim("-".repeat(30))}`);for(let h of t.sort()){let y=P(h),f=y?.nickname||r.dim("\u2014"),S=y?.role||r.dim("Unknown");a$1(` ${r.white.bold(h.padEnd(16))} ${f.toString().padEnd(12)} ${r.gray(S)}`);}a$1(""),a$1(` ${r.cyan(String(t.length))} of ${r.cyan(String(o))} agents active on this project`),i.type&&g$1("Project type",i.type),a$1(""),c$1.success(`${t.length} of ${o} agents active`);}async function G(n={}){let s=process.cwd(),c$1=a.command("agent-roster-init").start("Initializing project roster",{cwd:s}),u=C();if(g.existsSync(u)&&!n.force){let S=k()?.active?.length??0;n.json?a$1(JSON.stringify({error:"Roster already exists",count:S})):(c(`Roster already exists with ${S} agents.`),e(` Use ${r.cyan("--force")} to reinitialize, or ${r.cyan("paradigm agent roster add/remove")} to modify.`)),c$1.error("Roster already exists");return}let{detectProjectType:o,ROSTER_SUGGESTIONS:i}=await import('./project-type-4Y6CESWP.js'),t=o(s),a$2=i[t]||i.generic,l=m.basename(s),d=m.join(s,".paradigm","config.yaml");if(g.existsSync(d))try{let f=$.load(g.readFileSync(d,"utf-8"));f?.project&&typeof f.project=="string"&&(l=f.project);}catch{}let h={version:"1.0",project:l,type:t,active:a$2.sort()};F(h);let y=E();n.json?a$1(JSON.stringify({created:true,project:l,type:t,active:a$2.sort(),count:a$2.length,total:y.length},null,2)):(f("Agent Roster Initialized"),a$1(""),g$1("Project",l),g$1("Detected type",t),g$1("Active agents",`${a$2.length} of ${y.length}`),a$1(""),a$1(` ${r.cyan(a$2.sort().join(", "))}`),a$1(""),b$1(`Roster written to ${r.dim(".paradigm/roster.yaml")}`),e(` Modify with ${r.cyan("paradigm agent roster add/remove <agent-id>")}`),a$1("")),c$1.success(`Created roster: ${a$2.length} agents for ${t}`);}async function _(n,s={}){let c=process.cwd(),u=a.command("agent-roster-add").start(`Adding agents: ${n.join(", ")}`,{cwd:c}),o=k();if(!o){s.json?a$1(JSON.stringify({error:"No roster found. Run `paradigm agent roster init` first."})):(d("No roster found."),e(` Run ${r.cyan("paradigm agent roster init")} first.`)),u.error("No roster found");return}let i=E(),t=[],a$2=[],l=[];for(let d of n){if(!i.includes(d)){t.push(d);continue}if(o.active.includes(d)){a$2.push(d);continue}o.active.push(d),l.push(d);}l.length>0&&(o.active.sort(),F(o)),s.json?a$1(JSON.stringify({added:l,alreadyActive:a$2,invalid:t,total:o.active.length},null,2)):(l.length>0&&b$1(`Added: ${r.cyan(l.join(", "))}`),a$2.length>0&&e(` Already active: ${a$2.join(", ")}`),t.length>0&&(d(`Unknown agent(s): ${t.join(", ")}`),e(` Available: ${i.join(", ")}`)),l.length>0&&a$1(` Roster now has ${r.cyan(String(o.active.length))} active agents.`)),u.success(`Added ${l.length}, skipped ${a$2.length}, invalid ${t.length}`);}async function z(n,s={}){let c$1=process.cwd(),u=a.command("agent-roster-remove").start(`Removing agents: ${n.join(", ")}`,{cwd:c$1}),o=k();if(!o){s.json?a$1(JSON.stringify({error:"No roster found. Run `paradigm agent roster init` first."})):(d("No roster found."),e(` Run ${r.cyan("paradigm agent roster init")} first.`)),u.error("No roster found");return}let i=[],t=[];for(let a of n){let l=o.active.indexOf(a);if(l<0){i.push(a);continue}o.active.splice(l,1),t.push(a);}t.length>0&&F(o),s.json?a$1(JSON.stringify({removed:t,notFound:i,total:o.active.length},null,2)):(t.length>0&&b$1(`Removed: ${r.cyan(t.join(", "))}`),i.length>0&&c(`Not in roster: ${i.join(", ")}`),t.length>0&&a$1(` Roster now has ${r.cyan(String(o.active.length))} active agents.`)),u.success(`Removed ${t.length}, not found ${i.length}`);}export{_ as rosterAddCommand,G as rosterInitCommand,z as rosterRemoveCommand,U as rosterShowCommand};
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import'./chunk-5TAVYPOV.js';import o from'chalk';async function i(e){let n=process.cwd(),t=parseInt(e.port||"3850",10),s=e.open!==false,a=e.sections?e.sections.split(",").map(r=>r.trim()):void 0;console.log(o.cyan(`
3
3
  Starting Paradigm Platform...
4
- `));try{let{startPlatformServer:r}=await import('./platform-server-2KXHGHFV.js');await r({port:t,projectDir:n,open:s,sections:a}),console.log(o.green(` Platform running at ${o.bold(`http://localhost:${t}`)}`)),console.log(o.gray(` Press Ctrl+C to stop
4
+ `));try{let{startPlatformServer:r}=await import('./platform-server-FXYBBH6E.js');await r({port:t,projectDir:n,open:s,sections:a}),console.log(o.green(` Platform running at ${o.bold(`http://localhost:${t}`)}`)),console.log(o.gray(` Press Ctrl+C to stop
5
5
  `)),await new Promise(()=>{});}catch(r){r.code==="EADDRINUSE"?(console.error(o.red(`
6
6
  Error: Port ${t} is already in use.`)),console.log(o.gray(` Try: paradigm serve --port ${t+1}
7
7
  `))):console.error(o.red(`
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import {b}from'./chunk-VPMJWJ5R.js';import'./chunk-DG236EXP.js';import'./chunk-TYWB5IQJ.js';import'./chunk-WESTEMIM.js';import'./chunk-FYDRENK7.js';import'./chunk-IZSBGW6E.js';import {d as d$1}from'./chunk-AO7ZSRME.js';import'./chunk-Y4XFVDZC.js';import {a as a$5}from'./chunk-QIGE36CB.js';import {d}from'./chunk-W5IWDW4Y.js';import {a as a$3,b as b$1}from'./chunk-AGVAHVUA.js';import'./chunk-SHD27BQX.js';import {a as a$6}from'./chunk-CSXVL2U7.js';import'./chunk-EKZDFEJW.js';import {a as a$1}from'./chunk-33LKBMVK.js';import {b as b$2}from'./chunk-JBDMCRPP.js';import'./chunk-4TXOVRWD.js';import'./chunk-T6IDXUUA.js';import'./chunk-JIXHEBGK.js';import'./chunk-QT2LKB3P.js';import'./chunk-VCKKJDLP.js';import'./chunk-WR6D3SC6.js';import {a as a$2}from'./chunk-UIKLE3WD.js';import {a as a$4}from'./chunk-QNZEG7IT.js';import'./chunk-HMQ5BHP2.js';import'./chunk-JQKKVAAN.js';import {a}from'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';import*as r from'fs';import*as n from'path';import e from'chalk';import U from'ora';import*as g from'js-yaml';async function te(l={}){let s=process.cwd(),h=n.basename(s),u=n.join(s,".paradigm"),k=r.existsSync(u)&&r.statSync(u).isDirectory();console.log(e.blue(`
2
+ import {b}from'./chunk-VPMJWJ5R.js';import'./chunk-DG236EXP.js';import'./chunk-TYWB5IQJ.js';import'./chunk-WESTEMIM.js';import'./chunk-FYDRENK7.js';import'./chunk-IZSBGW6E.js';import {d as d$1}from'./chunk-AO7ZSRME.js';import'./chunk-Y4XFVDZC.js';import {a as a$5}from'./chunk-FSOI3CCD.js';import {d}from'./chunk-W5IWDW4Y.js';import {a as a$3,b as b$1}from'./chunk-4DVT5IEY.js';import'./chunk-SHD27BQX.js';import {a as a$6}from'./chunk-CSXVL2U7.js';import'./chunk-EKZDFEJW.js';import {a as a$1}from'./chunk-33LKBMVK.js';import {b as b$2}from'./chunk-JBDMCRPP.js';import'./chunk-4TXOVRWD.js';import'./chunk-T6IDXUUA.js';import'./chunk-JIXHEBGK.js';import'./chunk-QT2LKB3P.js';import'./chunk-VCKKJDLP.js';import'./chunk-WR6D3SC6.js';import {a as a$2}from'./chunk-UIKLE3WD.js';import {a as a$4}from'./chunk-QNZEG7IT.js';import'./chunk-HMQ5BHP2.js';import'./chunk-JQKKVAAN.js';import {a}from'./chunk-LKAT7IAK.js';import'./chunk-5TAVYPOV.js';import*as r from'fs';import*as n from'path';import e from'chalk';import U from'ora';import*as g from'js-yaml';async function te(l={}){let s=process.cwd(),h=n.basename(s),u=n.join(s,".paradigm"),k=r.existsSync(u)&&r.statSync(u).isDirectory();console.log(e.blue(`
3
3
  \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510`)),console.log(e.blue("\u2502")+e.white.bold(" paradigm shift ")+e.blue("\u2502")),console.log(e.blue("\u2502")+e.gray(" Full project setup in one command ")+e.blue("\u2502")),console.log(e.blue(`\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
4
4
  `)),console.log(e.white(` \u{1F4C1} Project: ${e.cyan(h)}`)),console.log(e.white(` \u{1F4CD} Status: ${k?e.green("Paradigm detected"):e.yellow("New project")}`)),console.log("");let j=a.command("shift").start("Running paradigm shift",{project:h}),i=U();if(!k||l.force){i.start("Step 1/6: Initializing Paradigm...");try{await a$1({force:l.force,quick:!0,name:h,stack:l.stack}),i.succeed(e.green("Paradigm initialized"));}catch(t){i.fail(e.red(`Init failed: ${t.message}`)),j.error("Shift failed at init",{error:t.message});return}}else {i.succeed(e.gray("Step 1/6: Already initialized (use --force to reinit)"));let t=n.join(u,"config.yaml");if(r.existsSync(t))try{let o=r.readFileSync(t,"utf8"),a=g.load(o);if(!a.discipline||a.discipline==="auto"){let c=a$2(s);if(c!=="backend"){let f=o.replace(/^discipline:\s*auto\b.*$/m,`discipline: ${c}`);f!==o&&(r.writeFileSync(t,f,"utf8"),console.log(e.green(` \u2713 Detected discipline: ${e.cyan(c)} (updated config.yaml)`)));}else if(!a.discipline){let f=o.replace(/^(project:\s*.+)$/m,`$1
5
- discipline: ${c}`);f!==o&&(r.writeFileSync(t,f,"utf8"),console.log(e.green(` \u2713 Added discipline: ${e.cyan(c)} to config.yaml`)));}}}catch(o){a.operation("shift").debug("Discipline detection failed",{error:o.message});}}if(k){i.start("Step 1b/6: Checking for migrations...");try{let{migrateCommand:t}=await import('./migrate-OMR5G5AF.js');await t({apply:!0,quiet:!0,noSync:!0}),i.succeed(e.green("Migrations applied"));}catch(t){i.warn(e.yellow(`Migration warning: ${t.message}`));}}{let t=n.join(u,"config.yaml");if(l.workspace&&r.existsSync(t)){let o=l.workspacePath?n.resolve(s,l.workspacePath):n.join(n.dirname(s),".paradigm-workspace");if(r.existsSync(o))try{let a=g.load(r.readFileSync(o,"utf8")),c=n.basename(s),f=n.dirname(o),d$1="./"+n.relative(f,s);if(a.members.some(y=>n.resolve(f,y.path)===s))console.log(e.green(` \u2713 Already a member of workspace: ${e.cyan(a.name)}`));else {let y=d(c,s);a.members.push({name:c,path:d$1,...y&&{role:y}}),r.writeFileSync(o,g.dump(a,{indent:2,lineWidth:120,noRefs:!0,sortKeys:!1,quotingType:'"'}),"utf8"),console.log(e.green(` \u2713 Joined workspace: ${e.cyan(a.name)} (added as member)`));}}catch(a){console.log(e.yellow(` \u26A0 Failed to join workspace: ${a.message}`));}else try{let a=n.basename(s),c=n.dirname(o),f="./"+n.relative(c,s),d$1=d(a,s),p={version:"1.0",name:l.workspace,members:[{name:a,path:f,...d$1&&{role:d$1}}]};r.mkdirSync(n.dirname(o),{recursive:!0}),r.writeFileSync(o,g.dump(p,{indent:2,lineWidth:120,noRefs:!0,sortKeys:!1,quotingType:'"'}),"utf8"),console.log(e.green(` \u2713 Created workspace: ${e.cyan(l.workspace)} at ${e.gray(n.relative(s,o))}`));}catch(a){console.log(e.yellow(` \u26A0 Failed to create workspace: ${a.message}`));}try{let a=r.readFileSync(t,"utf8"),c=g.load(a),f=n.relative(s,o);if(c.workspace!==f){if(c.workspace){let d=a.replace(/^workspace:\s*.*$/m,`workspace: "${f}"`);r.writeFileSync(t,d,"utf8");}else {let d=a.trimEnd()+`
5
+ discipline: ${c}`);f!==o&&(r.writeFileSync(t,f,"utf8"),console.log(e.green(` \u2713 Added discipline: ${e.cyan(c)} to config.yaml`)));}}}catch(o){a.operation("shift").debug("Discipline detection failed",{error:o.message});}}if(k){i.start("Step 1b/6: Checking for migrations...");try{let{migrateCommand:t}=await import('./migrate-WT56YYAM.js');await t({apply:!0,quiet:!0,noSync:!0}),i.succeed(e.green("Migrations applied"));}catch(t){i.warn(e.yellow(`Migration warning: ${t.message}`));}}{let t=n.join(u,"config.yaml");if(l.workspace&&r.existsSync(t)){let o=l.workspacePath?n.resolve(s,l.workspacePath):n.join(n.dirname(s),".paradigm-workspace");if(r.existsSync(o))try{let a=g.load(r.readFileSync(o,"utf8")),c=n.basename(s),f=n.dirname(o),d$1="./"+n.relative(f,s);if(a.members.some(y=>n.resolve(f,y.path)===s))console.log(e.green(` \u2713 Already a member of workspace: ${e.cyan(a.name)}`));else {let y=d(c,s);a.members.push({name:c,path:d$1,...y&&{role:y}}),r.writeFileSync(o,g.dump(a,{indent:2,lineWidth:120,noRefs:!0,sortKeys:!1,quotingType:'"'}),"utf8"),console.log(e.green(` \u2713 Joined workspace: ${e.cyan(a.name)} (added as member)`));}}catch(a){console.log(e.yellow(` \u26A0 Failed to join workspace: ${a.message}`));}else try{let a=n.basename(s),c=n.dirname(o),f="./"+n.relative(c,s),d$1=d(a,s),p={version:"1.0",name:l.workspace,members:[{name:a,path:f,...d$1&&{role:d$1}}]};r.mkdirSync(n.dirname(o),{recursive:!0}),r.writeFileSync(o,g.dump(p,{indent:2,lineWidth:120,noRefs:!0,sortKeys:!1,quotingType:'"'}),"utf8"),console.log(e.green(` \u2713 Created workspace: ${e.cyan(l.workspace)} at ${e.gray(n.relative(s,o))}`));}catch(a){console.log(e.yellow(` \u26A0 Failed to create workspace: ${a.message}`));}try{let a=r.readFileSync(t,"utf8"),c=g.load(a),f=n.relative(s,o);if(c.workspace!==f){if(c.workspace){let d=a.replace(/^workspace:\s*.*$/m,`workspace: "${f}"`);r.writeFileSync(t,d,"utf8");}else {let d=a.trimEnd()+`
6
6
  workspace: "${f}"
7
7
  `;r.writeFileSync(t,d,"utf8");}console.log(e.green(" \u2713 Linked workspace in config.yaml"));}}catch(a$1){a.operation("shift").debug("Workspace config link failed",{error:a$1.message});}}else if(r.existsSync(t))try{let o=r.readFileSync(t,"utf8");if(!g.load(o).workspace){let c=n.dirname(s);for(let f=0;f<3;f++){let d=n.join(c,".paradigm-workspace");if(r.existsSync(d)){let y=n.relative(s,d),N=o.trimEnd()+`
8
8
  workspace: "${y}"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import'./chunk-5TAVYPOV.js';import {Router}from'express';import*as n from'fs';import*as o from'path';function m(p){let i=Router(),u=o.join(__dirname,"..","..","university-content");return i.get("/courses",(a,e)=>{try{let s=o.join(u,"courses");if(!n.existsSync(s))return e.json({courses:[]});let l=n.readdirSync(s).filter(r=>r.endsWith(".json")).map(r=>{let t=JSON.parse(n.readFileSync(o.join(s,r),"utf-8"));return {id:t.id,title:t.title,description:t.description,lessonCount:t.lessons?.length||0,quizCount:t.quizzes?.length||0,lessons:(t.lessons||[]).map(d=>({id:d.id,title:d.title}))}});return l.sort((r,t)=>r.id.localeCompare(t.id)),e.json({courses:l})}catch(s){e.status(500).json({error:"Failed to list courses",detail:String(s)});}}),i.get("/courses/:id",(a,e)=>{try{let s=o.join(u,"courses",`${a.params.id}.json`);if(!n.existsSync(s))return e.status(404).json({error:`Course '${a.params.id}' not found`});let c=JSON.parse(n.readFileSync(s,"utf-8"));return e.json(c)}catch(s){e.status(500).json({error:"Failed to load course",detail:String(s)});}}),i.get("/plsat",(a,e)=>{try{let s=o.join(u,"plsat");if(!n.existsSync(s))return e.json({versions:[]});let l=n.readdirSync(s).filter(r=>r.endsWith(".json")).map(r=>{let t=JSON.parse(n.readFileSync(o.join(s,r),"utf-8"));return {version:t.version||r.replace(".json",""),frameworkVersion:t.frameworkVersion,questionCount:t.questions?.length||0,timeLimit:t.timeLimit,passThreshold:t.passThreshold}});return e.json({versions:l})}catch(s){e.status(500).json({error:"Failed to list PLSAT versions",detail:String(s)});}}),i.get("/diplomas",(a,e)=>{try{let s=o.join(p,".paradigm","university","diplomas");if(!n.existsSync(s))return e.json({diplomas:[]});let l=n.readdirSync(s).filter(r=>r.endsWith(".json")||r.endsWith(".yaml")).map(r=>{let t=n.readFileSync(o.join(s,r),"utf-8");return r.endsWith(".json")?JSON.parse(t):t}).filter(Boolean);return e.json({diplomas:l})}catch(s){e.status(500).json({error:"Failed to load diplomas",detail:String(s)});}}),i.get("/reference",(a,e)=>{try{let s=o.join(u,"reference.json");if(!n.existsSync(s))return e.json({});let c=JSON.parse(n.readFileSync(s,"utf-8"));return e.json(c)}catch(s){e.status(500).json({error:"Failed to load reference",detail:String(s)});}}),i}export{m as createUniversityRouter};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a-company/paradigm",
3
- "version": "5.22.0",
3
+ "version": "5.24.0",
4
4
  "description": "Unified CLI for Paradigm developer tools",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1 @@
1
+ import{c as j,r as u,e as N,j as n,S as b}from"./index-BaOmyn11.js";let l=null,m=null;const y=j((e,s)=>({events:[],nominations:[],debates:[],loading:!1,eventFilter:{},fetchEvents:async t=>{l==null||l.abort(),l=new AbortController;const{signal:a}=l;e({loading:!0});try{const c=t||s().eventFilter,o=new URLSearchParams;c.type&&o.set("type",c.type),c.since&&o.set("since",c.since);const r=await fetch(`/api/ambient/events?${o}`,{signal:a});if(!r.ok)throw new Error(`HTTP ${r.status}`);const d=await r.json();e({events:d.events||[],loading:!1})}catch(c){if(c instanceof Error&&c.name==="AbortError")return;e({loading:!1})}},fetchNominations:async()=>{m==null||m.abort(),m=new AbortController;const{signal:t}=m;try{const a=await fetch("/api/ambient/nominations?pending_only=true&include_debates=true",{signal:t});if(!a.ok)throw new Error(`HTTP ${a.status}`);const c=await a.json();e({nominations:c.nominations||[],debates:c.debates||[]})}catch(a){if(a instanceof Error&&a.name==="AbortError")return}},engageNomination:async(t,a)=>{try{const c=await fetch(`/api/ambient/nominations/${encodeURIComponent(t)}/engage`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({response:a})});if(!c.ok)throw new Error(`HTTP ${c.status}`);e(o=>({nominations:o.nominations.map(r=>r.id===t?{...r,engaged:!0,response:a}:r)}))}catch{s().fetchNominations()}},setEventFilter:t=>{e({eventFilter:t}),s().fetchEvents(t)},connectSSE:()=>{const t=new EventSource("/api/ambient/stream");return t.onmessage=a=>{try{const c=JSON.parse(a.data);e(o=>({events:[c,...o.events].slice(0,200)}))}catch{}},t.onerror=()=>{},()=>t.close()}})),p={critical:0,high:1,medium:2,low:3};function w(e){try{const s=new Date(e),a=Date.now()-s.getTime();return a<6e4?"just now":a<36e5?`${Math.floor(a/6e4)}m ago`:a<864e5?`${Math.floor(a/36e5)}h ago`:a<6048e5?`${Math.floor(a/864e5)}d ago`:s.toLocaleDateString()}catch{return""}}function E(e){return["file_change","tool_call","sentinel","agent"].includes(e)?`ambient__type-badge--${e}`:"ambient__type-badge--default"}function S(e){return["critical","high","medium","low"].includes(e)?`ambient__urgency-badge--${e}`:"ambient__urgency-badge--low"}function A(e){const s=Date.now()-36e5;return e.filter(t=>{try{return new Date(t.timestamp).getTime()>s}catch{return!1}}).length}function T(e){const s=new Set(e.map(t=>t.type));return Array.from(s).sort()}function D({event:e}){return n.jsxs("div",{className:"ambient__event-item",children:[n.jsx("span",{className:`ambient__type-badge ${E(e.type)}`,children:e.type.replace(/_/g," ")}),n.jsxs("div",{className:"ambient__event-body",children:[n.jsxs("div",{className:"ambient__event-top-row",children:[e.context&&n.jsx("span",{className:"ambient__event-context",children:e.context}),!e.context&&e.source&&n.jsx("span",{className:"ambient__event-context",children:e.source})]}),e.path&&n.jsx("span",{className:"ambient__event-path",children:e.path}),e.symbols&&e.symbols.length>0&&n.jsx("div",{className:"ambient__event-symbols",children:e.symbols.map(s=>n.jsx("span",{className:"ambient__event-symbol",children:s},s))})]}),n.jsx("span",{className:"ambient__event-time",children:w(e.timestamp)})]})}function $({nomination:e,onEngage:s}){const t=e.engaged;return n.jsxs("div",{className:"ambient__nom-item",children:[n.jsxs("div",{className:"ambient__nom-header",children:[n.jsx("span",{className:`ambient__urgency-badge ${S(e.urgency)}`,children:e.urgency}),n.jsx("span",{className:"ambient__nom-agent",children:e.agent}),n.jsx("span",{className:"ambient__nom-type",children:e.type})]}),n.jsx("div",{className:"ambient__nom-brief",children:e.brief}),!t&&n.jsxs("div",{className:"ambient__nom-actions",children:[n.jsx("button",{className:"ambient__nom-btn ambient__nom-btn--accept",onClick:()=>s(e.id,"accepted"),children:"Accept"}),n.jsx("button",{className:"ambient__nom-btn ambient__nom-btn--dismiss",onClick:()=>s(e.id,"dismissed"),children:"Dismiss"})]}),t&&n.jsx("div",{style:{fontSize:11,color:"var(--p-text-muted)",fontStyle:"italic"},children:e.response==="accepted"?"Accepted":e.response==="dismissed"?"Dismissed":"Deferred"})]})}function k({debate:e}){return n.jsxs("div",{className:"ambient__debate-item",children:[n.jsx("div",{className:"ambient__debate-topic",children:e.topic}),n.jsxs("div",{className:"ambient__debate-meta",children:[e.type," · ",e.nominations.length," nomination",e.nominations.length!==1?"s":""]})]})}function R(){const{events:e,nominations:s,debates:t,loading:a,eventFilter:c,fetchEvents:o,fetchNominations:r,engageNomination:d,setEventFilter:g,connectSSE:v}=y(),h=u.useRef(null);u.useEffect(()=>{o(),r();const i=v();return h.current=setInterval(()=>{N.getState().activeSection==="ambient"&&r()},1e4),()=>{i(),h.current&&clearInterval(h.current)}},[]);const _=s.filter(i=>!i.engaged).sort((i,x)=>(p[i.urgency]??99)-(p[x.urgency]??99)),f=T(e);return a&&e.length===0?n.jsxs("div",{className:"ambient",children:[n.jsx("h1",{className:"ambient__title",children:"Ambient"}),n.jsx("p",{style:{color:"var(--p-text-muted)"},children:"Loading..."})]}):n.jsxs("div",{className:"ambient",children:[n.jsx("h1",{className:"ambient__title",children:"Ambient"}),n.jsxs("div",{className:"ambient__cards",children:[n.jsx(b,{value:A(e),label:"Events (last hour)",accent:"var(--p-accent-blue)"}),n.jsx(b,{value:_.length,label:"Pending Nominations",accent:"var(--p-accent-orange)"}),n.jsx(b,{value:t.length,label:"Active Debates",accent:"var(--p-accent-purple)"})]}),n.jsxs("div",{className:"ambient__grid",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"ambient__section-header",children:[n.jsx("span",{className:"ambient__section-header-title",children:"Event Stream"}),n.jsxs("select",{className:"ambient__filter-select",value:c.type||"",onChange:i=>g({...c,type:i.target.value||void 0}),children:[n.jsx("option",{value:"",children:"All types"}),f.map(i=>n.jsx("option",{value:i,children:i.replace(/_/g," ")},i))]})]}),n.jsxs("div",{className:"ambient__events",children:[e.length===0&&n.jsx("div",{className:"ambient__events-empty",children:"No events recorded yet"}),e.map(i=>n.jsx(D,{event:i},i.id))]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"ambient__section-title",children:"Nominations"}),n.jsxs("div",{className:"ambient__nominations",children:[_.length===0&&n.jsx("div",{className:"ambient__nominations-empty",children:"No pending nominations"}),_.map(i=>n.jsx($,{nomination:i,onEngage:d},i.id))]}),t.length>0&&n.jsxs("div",{className:"ambient__debates",children:[n.jsx("div",{className:"ambient__section-title",children:"Debates"}),t.map(i=>n.jsx(k,{debate:i},i.id))]})]})]})]})}export{R as default};