@a-company/paradigm 7.1.0 → 7.3.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 (167) hide show
  1. package/dist/{accept-orchestration-WMGFGYDK.js → accept-orchestration-JA3A3TSU.js} +1 -1
  2. package/dist/add-CBDU23S2.js +12 -0
  3. package/dist/{aggregate-KZICPVT3.js → aggregate-H7SB2UYT.js} +1 -1
  4. package/dist/{ambient-HAXPDIWK.js → ambient-TFLZFV5Y.js} +1 -1
  5. package/dist/ambient-VCTUHHIG.js +2 -0
  6. package/dist/arch-loader-YVOS3QRY.js +2 -0
  7. package/dist/{beacon-52EWNZPK.js → beacon-WVN264OT.js} +1 -1
  8. package/dist/calibrate-SH6PRZFD.js +2 -0
  9. package/dist/calibration-aggregate-5IVXSBDP.js +2 -0
  10. package/dist/calibration-aggregate-DUEE3LL2.js +4 -0
  11. package/dist/captain-ILBN2IKJ.js +2 -0
  12. package/dist/captain-J4FZ5PRU.js +2 -0
  13. package/dist/{chunk-QDP4G53M.js → chunk-27EK3OQZ.js} +4 -4
  14. package/dist/{chunk-KP5VOYAH.js → chunk-3F4QP2Z5.js} +1 -1
  15. package/dist/{chunk-VPNJL4LS.js → chunk-5VR7FKS5.js} +1 -1
  16. package/dist/{chunk-S3UVQ5RV.js → chunk-6VZSOQ7Y.js} +1 -1
  17. package/dist/chunk-7BZPDOOQ.js +25 -0
  18. package/dist/{chunk-YQK3XU63.js → chunk-7HUPVOAY.js} +12 -12
  19. package/dist/chunk-A5EEY6NO.js +3 -0
  20. package/dist/{chunk-4GC35IFF.js → chunk-D6BSCELB.js} +1 -1
  21. package/dist/{chunk-G6DK3ND3.js → chunk-DH7QVZDI.js} +9 -0
  22. package/dist/chunk-FG3M6VVO.js +30 -0
  23. package/dist/chunk-FNYYQNJY.js +2 -0
  24. package/dist/{chunk-RDWWSQGH.js → chunk-IBKCMLOW.js} +14 -14
  25. package/dist/chunk-K6TLYNRQ.js +7 -0
  26. package/dist/{chunk-W4BW7GXA.js → chunk-KA6QEI3C.js} +1 -1
  27. package/dist/chunk-L3AOKDMU.js +93 -0
  28. package/dist/chunk-M7JHVVDW.js +6 -0
  29. package/dist/chunk-MBKTVQS2.js +2 -0
  30. package/dist/chunk-NFN5UUJB.js +2 -0
  31. package/dist/chunk-O4ADSTSY.js +504 -0
  32. package/dist/chunk-RPGSQQTS.js +2 -0
  33. package/dist/chunk-RQHZUPLO.js +4 -0
  34. package/dist/chunk-SD3KVW5Q.js +2 -0
  35. package/dist/chunk-VKVVIN6J.js +25 -0
  36. package/dist/chunk-VOPJ47QY.js +2 -0
  37. package/dist/chunk-VR2LLUYE.js +17 -0
  38. package/dist/chunk-WMTES556.js +2 -0
  39. package/dist/chunk-XBK244QR.js +6 -0
  40. package/dist/{chunk-MBSY57RN.js → chunk-Y76OIMDO.js} +1 -1
  41. package/dist/{chunk-EG22HDXI.js → chunk-YNFF7XHV.js} +12 -12
  42. package/dist/chunk-YYRP7FLC.js +2 -0
  43. package/dist/{compliance-4P3EE5OA.js → compliance-3M6COUCO.js} +3 -3
  44. package/dist/{constellation-RHZAEFV7.js → constellation-TIKNCZWR.js} +1 -1
  45. package/dist/{cost-24UZSS2P.js → cost-VTHZQKO4.js} +2 -2
  46. package/dist/{diff-VBVIUNL5.js → diff-NZSJW3V3.js} +1 -1
  47. package/dist/dist-6TDAY6TQ-HMSTBL57.js +39 -0
  48. package/dist/{dist-TNE4GFT7.js → dist-PW5YPGFF.js} +1 -1
  49. package/dist/{docs-NTP6UENF.js → docs-DWU3T2BV.js} +1 -1
  50. package/dist/github-GI3HX3N5.js +4 -0
  51. package/dist/{habits-BX2IRSUI.js → habits-UA7YT3CG.js} +3 -3
  52. package/dist/{hooks-AXBWYJ5V.js → hooks-XXJ7CSGJ.js} +1 -1
  53. package/dist/index.js +9 -9
  54. package/dist/{init-F4MSKZIW.js → init-QPMLEQWQ.js} +1 -1
  55. package/dist/{integrity-7TKX3DZ4.js → integrity-FRGF5BFS.js} +1 -1
  56. package/dist/lint-Y4P3MHBV.js +26 -0
  57. package/dist/list-5XRLWD7K.js +12 -0
  58. package/dist/mcp.js +1 -1
  59. package/dist/{migrate-5M4KUQ2L.js → migrate-LIVXILOO.js} +1 -1
  60. package/dist/nomination-engine-EFXDEPZN.js +2 -0
  61. package/dist/{orchestrate-MLUGQOEJ.js → orchestrate-C7SI4J7C.js} +1 -1
  62. package/dist/orchestration-4MJKBSGM.js +2 -0
  63. package/dist/orchestration-S2ESNKSA.js +2 -0
  64. package/dist/platform-server-IOWHNS7Q.js +25 -0
  65. package/dist/{probe-27ARJKRO.js → probe-G3TKOJYW.js} +1 -1
  66. package/dist/quiz-QKIKAVL7.js +10 -0
  67. package/dist/registry-NEW4OJ44.js +2 -0
  68. package/dist/{reindex-ZLDQBFUR.js → reindex-G2JLIGOQ.js} +1 -1
  69. package/dist/reindex-JR3PXYQE.js +2 -0
  70. package/dist/remember-KZYAY77S.js +14 -0
  71. package/dist/{review-BRO2UP4M.js → review-WHRNLW2W.js} +1 -1
  72. package/dist/{ripple-KCVDS3WE.js → ripple-B6U7263T.js} +1 -1
  73. package/dist/{sentinel-EFPEX246.js → sentinel-RIEQWALQ.js} +1 -1
  74. package/dist/{sentinel-bridge-UR2MKARY.js → sentinel-bridge-D4LFDFCH.js} +1 -1
  75. package/dist/{serve-2PKJP65E.js → serve-6RNZYK2I.js} +2 -2
  76. package/dist/serve-PWAFVYYC.js +9 -0
  77. package/dist/{server-4D77LCST.js → server-K7G3IHR3.js} +1 -1
  78. package/dist/{setup-5V2AGLQ6.js → setup-L5OP24US.js} +3 -3
  79. package/dist/{shift-PM4GI736.js → shift-HGXZ5THV.js} +3 -3
  80. package/dist/{show-N5LGB5B2.js → show-VXNGIJE4.js} +3 -3
  81. package/dist/{snapshot-YMX5QRBM.js → snapshot-MT5L6XE4.js} +1 -1
  82. package/dist/status-45KIG32R.js +6 -0
  83. package/dist/{status-3GJXI4IK.js → status-4QGKLOP6.js} +4 -4
  84. package/dist/{summary-RPU2BS3Q.js → summary-6QNVQZJV.js} +1 -1
  85. package/dist/symphony-KQJ6HIXB.js +53 -0
  86. package/dist/symphony-VDNDFK7H.js +2 -0
  87. package/dist/symphony-relay-ASMKPDEE.js +3 -0
  88. package/dist/sync-layer-C2PF273N.js +2 -0
  89. package/dist/task-PRLQ4VPK.js +3 -0
  90. package/dist/task-loader-EIXPKHA3.js +2 -0
  91. package/dist/task-loader-LFEE6OU7.js +2 -0
  92. package/dist/task-settlement-A2T6EACG.js +3 -0
  93. package/dist/task-settlement-ZXOY4YGX.js +3 -0
  94. package/dist/team-KP4HMUB5.js +2 -0
  95. package/dist/thread-2A7QKU72.js +41 -0
  96. package/dist/tools-NOMEIBS7.js +2 -0
  97. package/dist/tools-YW3Q27UI.js +142 -0
  98. package/dist/validate-OZTX3FYX.js +13 -0
  99. package/dist/validate-RIMSY3RP.js +9 -0
  100. package/dist/{workspace-6POCBPDY.js → workspace-4D4TQ637.js} +1 -1
  101. package/package.json +2 -6
  102. package/platform-ui/dist/assets/{AmbientSection-CwatqcBD.js → AmbientSection-xoxr3DQg.js} +1 -1
  103. package/platform-ui/dist/assets/{DocsSection-BZ2SFJBZ.js → DocsSection-Us2qksna.js} +1 -1
  104. package/platform-ui/dist/assets/{GitSection-MNNYU1tO.js → GitSection-DIHZyadf.js} +1 -1
  105. package/platform-ui/dist/assets/{GraphSection-COYjb4Pt.js → GraphSection-9TO0L1IO.js} +1 -1
  106. package/platform-ui/dist/assets/{LoreSection-B0hUbfsJ.js → LoreSection-DVDit8Aw.js} +1 -1
  107. package/platform-ui/dist/assets/{SentinelSection-BCxW1DCp.js → SentinelSection-a5_VNYcx.js} +1 -1
  108. package/platform-ui/dist/assets/{SymphonySection-BsucZRqy.js → SymphonySection-cRHEoJ9t.js} +1 -1
  109. package/platform-ui/dist/assets/TasksSection-44_gDO3L.css +1 -0
  110. package/platform-ui/dist/assets/TasksSection-h8x3qRIj.js +1 -0
  111. package/platform-ui/dist/assets/{TeamSection-C0QNTudW.js → TeamSection-mFoDyNic.js} +1 -1
  112. package/platform-ui/dist/assets/{UniversitySection-DN1-g9pw.js → UniversitySection-D99YRjmC.js} +1 -1
  113. package/platform-ui/dist/assets/{index-DwUT8pju.js → index-D_wB2S_2.js} +11 -11
  114. package/platform-ui/dist/index.html +1 -1
  115. package/dist/add-V6XR7DU5.js +0 -12
  116. package/dist/agent-loader-Z753DQWH.js +0 -2
  117. package/dist/ambient-QB7V4TBR.js +0 -6
  118. package/dist/calibrate-PHVP7RPH.js +0 -4
  119. package/dist/captain-3COP6YTD.js +0 -2
  120. package/dist/chunk-4CGPLLWQ.js +0 -30
  121. package/dist/chunk-7SWEOPWF.js +0 -2
  122. package/dist/chunk-CHSU6LTR.js +0 -2
  123. package/dist/chunk-EKNLG73M.js +0 -6
  124. package/dist/chunk-H55W26AR.js +0 -3
  125. package/dist/chunk-HE2NA5QF.js +0 -8
  126. package/dist/chunk-JIXHEBGK.js +0 -7
  127. package/dist/chunk-MBPLJKE5.js +0 -3
  128. package/dist/chunk-OIYJUU6T.js +0 -25
  129. package/dist/chunk-QO7YPQXC.js +0 -2
  130. package/dist/chunk-XMAV5AG6.js +0 -2
  131. package/dist/chunk-XPPFILCM.js +0 -2
  132. package/dist/chunk-YCDOA5IQ.js +0 -18
  133. package/dist/dist-GQ42YS5N-4HIJZVBB.js +0 -39
  134. package/dist/lint-IGKE6UPS.js +0 -26
  135. package/dist/list-NC3QGT75.js +0 -12
  136. package/dist/lore-loader-HAZ5FRLP.js +0 -2
  137. package/dist/lore-server-FC2GMDLT.js +0 -14
  138. package/dist/nomination-engine-ORHH4L2W.js +0 -2
  139. package/dist/orchestration-O2OVPTIZ.js +0 -2
  140. package/dist/platform-server-Y6TLEXR2.js +0 -25
  141. package/dist/quiz-TNV6APBM.js +0 -10
  142. package/dist/remember-MJRNTXYS.js +0 -14
  143. package/dist/serve-L52ZUTU6.js +0 -10
  144. package/dist/serve-XZ6GBUS3.js +0 -8
  145. package/dist/session-work-log-FF7CKMWP.js +0 -2
  146. package/dist/status-ENAI35NL.js +0 -6
  147. package/dist/symphony-CFAYJGLF.js +0 -2
  148. package/dist/symphony-L56O5ZG3.js +0 -53
  149. package/dist/symphony-relay-Y2UR3YNR.js +0 -3
  150. package/dist/task-loader-H7HQAYGL.js +0 -2
  151. package/dist/task-loader-YZME4RKE.js +0 -2
  152. package/dist/task-settlement-HINBVZBE.js +0 -3
  153. package/dist/task-settlement-XC6E6JNT.js +0 -3
  154. package/dist/team-25LK6CWM.js +0 -2
  155. package/dist/thread-HFXK65D4.js +0 -41
  156. package/dist/tools-GAU5WOEI.js +0 -2
  157. package/dist/validate-IQG7DBFC.js +0 -9
  158. package/dist/validate-LSCDOLBO.js +0 -13
  159. package/dist/work-log-loader-CRVTOMVB.js +0 -2
  160. package/graph-ui/dist/assets/index-BlgXTl53.css +0 -1
  161. package/graph-ui/dist/assets/index-Bq5nXK8p.js +0 -63
  162. package/graph-ui/dist/index.html +0 -13
  163. package/lore-ui/dist/assets/index-C3EixkjW.css +0 -1
  164. package/lore-ui/dist/assets/index-DKhNxgtW.js +0 -56
  165. package/lore-ui/dist/index.html +0 -13
  166. package/platform-ui/dist/assets/CanvasSection-dFAthehN.js +0 -9
  167. package/platform-ui/dist/assets/CanvasSection-flMXU19z.css +0 -1
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import*as A from'fs';import*as $ from'js-yaml';import {z as z$1}from'zod';import*as d from'path';import {glob}from'glob';var j=z$1.object({description:z$1.string(),type:z$1.string().optional(),parent:z$1.string().optional(),anchors:z$1.array(z$1.string()).optional(),tags:z$1.array(z$1.string()).optional(),endpoints:z$1.array(z$1.string()).optional(),tests:z$1.array(z$1.string()).optional(),rules:z$1.record(z$1.unknown()).optional(),aspects:z$1.array(z$1.string()).optional(),flows:z$1.array(z$1.string()).optional(),gates:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional(),states:z$1.array(z$1.string()).optional(),components:z$1.array(z$1.string()).optional(),location:z$1.string().optional(),locations:z$1.array(z$1.string()).optional(),uses:z$1.array(z$1.string()).optional(),"used-by":z$1.array(z$1.string()).optional(),"used-for":z$1.array(z$1.string()).optional(),exports:z$1.array(z$1.string()).optional(),status:z$1.string().optional(),properties:z$1.record(z$1.unknown()).optional(),handles:z$1.array(z$1.string()).optional()}).passthrough(),v=j.extend({id:z$1.string()}),P=z$1.object({description:z$1.string().optional(),category:z$1.string().optional(),severity:z$1.enum(["info","warn","error"]).optional(),emitters:z$1.array(z$1.string()).optional(),related:z$1.array(z$1.string()).optional(),data:z$1.record(z$1.unknown()).optional()}),E=z$1.union([P,z$1.string().transform(n=>({description:n}))]),O=z$1.object({from:z$1.string(),to:z$1.string(),type:z$1.string(),description:z$1.string().optional()}),C=z$1.union([O,z$1.string()]),F=z$1.object({component:z$1.string(),action:z$1.string(),description:z$1.string().optional()}),k=z$1.union([F,z$1.string()]),I=z$1.object({name:z$1.string(),description:z$1.string().optional(),steps:z$1.array(k)}),R=z$1.object({description:z$1.string().optional(),gates:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional(),components:z$1.array(z$1.string()).optional(),steps:z$1.array(k).optional()}),D=z$1.object({description:z$1.string().optional(),requires:z$1.array(z$1.string()).optional(),keys:z$1.array(z$1.string()).optional(),signals:z$1.array(z$1.string()).optional()}),M=z$1.object({description:z$1.string().optional(),default:z$1.unknown().optional(),type:z$1.string().optional()}),Y=z$1.object({description:z$1.string().optional(),tags:z$1.array(z$1.string()).optional(),anchors:z$1.array(z$1.string()).optional(),"applies-to":z$1.array(z$1.string()).optional(),enforcement:z$1.string().optional()}),V=z$1.object({target:z$1.string(),type:z$1.string(),path:z$1.string()}),W=z$1.object({version:z$1.string().optional(),description:z$1.string().optional(),apiSpec:z$1.string().optional(),context:z$1.array(z$1.string()).optional(),rules:z$1.record(z$1.unknown()).optional(),features:z$1.union([z$1.array(v),z$1.record(j)]).optional(),components:z$1.union([z$1.array(v),z$1.record(j)]).optional(),gates:z$1.record(D).optional(),states:z$1.record(M).optional(),signals:z$1.record(E).optional(),aspects:z$1.record(Y).optional(),relationships:z$1.array(C).optional(),flows:z$1.union([z$1.array(I),z$1.record(R)]).optional(),references:z$1.array(V).optional()});function T(n){let e=z(n);return {data:e.data,errors:e.errors}}function z(n){let e=[],r=[],s;try{s=A.readFileSync(n,"utf8");}catch(i){let p=`Cannot read file: ${i.message}`;return e.push(p),r.push({message:p,type:"file"}),{data:null,errors:e,detailedErrors:r,rawContent:void 0,isYamlValid:false}}let c=s.replace(/^([#~!$^][\w-]+):/gm,'"$1":').replace(/^(\s*-\s+)([!#][\w-]+)$/gm,'$1"$2"'),a=null;try{a=$.load(c);}catch(i){let p=i,f=p.mark?.line?p.mark.line+1:void 0,l=`YAML syntax error: ${p.reason||i.message}`;return e.push(`${l}${f?` (line ${f})`:""}`),r.push({message:l,line:f,type:"yaml"}),{data:null,errors:e,detailedErrors:r,rawContent:s,isYamlValid:false}}if(a==null)return {data:{},errors:[],detailedErrors:[],rawContent:s,isYamlValid:true};if(typeof a=="object"&&a!==null){let i=a,p={"#":"components",$:"flows","^":"gates","!":"signals","~":"aspects"};for(let f of Object.keys(i)){let l=f[0],u=p[l];if(!u||f.length<2)continue;let g=f.slice(1),y=i[f];if(typeof y!="object"||y===null)continue;let w=i[u]||{};u in i||(i[u]=w),g in w||(w[g]=y),delete i[f];}}let o=W.safeParse(a);if(!o.success){for(let i of o.error.issues){let p=i.path.join("."),f=i.message;e.push(`Schema error at ${p||"/"}: ${f}`),r.push({message:f,path:p||"/",type:"schema"});}return {data:a,errors:e,detailedErrors:r,rawContent:s,isYamlValid:true}}return {data:o.data,errors:[],detailedErrors:[],rawContent:s,isYamlValid:true}}function L(n){return $.dump(n,{indent:2,lineWidth:-1,noRefs:true,sortKeys:false})}function H(){return L({version:"1.0.0",description:"Project purpose and context",context:["Add contextual notes for AI agents here"],features:{},components:{}})}function m(n){return n?Array.isArray(n)?n.map(e=>[e.id,e]):Object.entries(n):[]}function N(n){let e={description:"",context:[],rules:{},features:{},components:{},referencedItems:{},ruleConflicts:[]};if(!n||n.length===0)return e;n.forEach(({data:s})=>{let c=new Set(e.context);for(let i of s.context||[])c.has(i)||(e.context.push(i),c.add(i));if(s.rules)for(let[i,p]of Object.entries(s.rules))e.rules[i]!==void 0&&e.rules[i]!==p&&e.ruleConflicts.push(`Conflict on rule "${i}": existing value "${e.rules[i]}" overwritten with "${p}"`),e.rules[i]=p;let a=m(s.features);for(let[i,p]of a)e.features[i]=p;let o=m(s.components);for(let[i,p]of o)e.components[i]=p;});let r=n[n.length-1];return e.description=r.data.description||e.description,e.apiSpec=r.data.apiSpec||e.apiSpec,e}async function Z(n){let e=d.resolve(n);return (await glob("**/.purpose",{cwd:e,absolute:true,ignore:["**/node_modules/**","**/dist/**","**/.git/**"]})).sort((s,c)=>{let a=s.split(d.sep).length,o=c.split(d.sep).length;return a-o})}async function U(n){let e=await Z(n),r=[];for(let s of e){let{data:c,errors:a}=T(s);c&&(r.push({filePath:s,data:c}),a.length>0&&console.warn(`Warnings parsing ${s}:`,a));}return r}function J(n){let e=new Map;for(let{filePath:r,data:s}of n){let c=m(s.features);for(let[a,o]of c)e.set(a,{item:o,filePath:r});}return e}function Q(n){let e=new Map;for(let{filePath:r,data:s}of n){let c=m(s.components);for(let[a,o]of c)e.set(a,{item:o,filePath:r});}return e}function X(n){let e=new Map;for(let{filePath:r,data:s}of n)if(s.gates)for(let[c,a]of Object.entries(s.gates))e.set(c,{item:a,filePath:r});return e}function tt(n){let e=new Map;for(let{filePath:r,data:s}of n)if(s.states)for(let[c,a]of Object.entries(s.states))e.set(c,{item:a,filePath:r});return e}function et(n){let e=new Map;for(let{filePath:r,data:s}of n)if(s.flows)if(Array.isArray(s.flows))for(let c of s.flows)e.set(c.name,{item:{id:c.name,description:c.description,steps:c.steps},filePath:r});else for(let[c,a]of Object.entries(s.flows))e.set(c,{item:{id:c,description:a.description,gates:a.gates,signals:a.signals,components:a.components,steps:a.steps},filePath:r});return e}function ot(n){let e=new Map;for(let{filePath:r,data:s}of n)if(s.signals)for(let[c,a]of Object.entries(s.signals))e.set(c,{item:a,filePath:r});return e}function st(n){let e=new Map;for(let{filePath:r,data:s}of n)if(s.aspects)for(let[c,a]of Object.entries(s.aspects))e.set(c,{item:a,filePath:r});return e}function nt(n){let e=[],r=new Set;for(let{filePath:s,data:c}of n){let a=m(c.features);for(let[i,p]of a)S(`#${i}`,p,s,e,r);let o=m(c.components);for(let[i,p]of o)S(`#${i}`,p,s,e,r);}return e}function S(n,e,r,s,c){if(e.flows)for(let a of e.flows){let o=a.startsWith("$")?a:`$${a}`;c.has(o)||(c.add(o),s.push({symbol:o,type:"flow",sourceSymbol:n,filePath:r}));}if(e.gates)for(let a of e.gates){let o=a.startsWith("^")?a:`^${a}`;c.has(o)||(c.add(o),s.push({symbol:o,type:"gate",sourceSymbol:n,filePath:r}));}if(e.signals)for(let a of e.signals){let o=a.startsWith("!")?a:`!${a}`;c.has(o)||(c.add(o),s.push({symbol:o,type:"signal",sourceSymbol:n,filePath:r}));}if(e.states)for(let a of e.states){let o=a.startsWith("#")?a:a.startsWith("%")?`#${a.slice(1)}`:`#${a}`;c.has(o)||(c.add(o),s.push({symbol:o,type:"component",sourceSymbol:n,filePath:r}));}if(e.components)for(let a of e.components){let o=a.startsWith("#")?a:`#${a}`;c.has(o)||(c.add(o),s.push({symbol:o,type:"component",sourceSymbol:n,filePath:r}));}if(e.aspects)for(let a of e.aspects){let o=a.startsWith("~")?a:`~${a}`;c.has(o)||(c.add(o),s.push({symbol:o,type:"aspect",sourceSymbol:n,filePath:r}));}if(e.description){let a=_(e.description);for(let{symbol:o,type:i}of a)c.has(o)||(c.add(o),s.push({symbol:o,type:i,sourceSymbol:n,filePath:r}));}}var B=new Set(["$lib","$env","$app","$service-worker","$virtual","$schema","$ref","$id","$type"]);function _(n){let e=[],r=/([$^!#~%])([a-zA-Z][a-zA-Z0-9._-]*)/g,s;for(;(s=r.exec(n))!==null;){let c=s[1],a=s[2],o,i;switch(c){case "#":i="component",o=`#${a}`;break;case "$":i="flow",o=`$${a}`;break;case "^":i="gate",o=`^${a}`;break;case "!":i="signal",o=`!${a}`;break;case "~":i="aspect",o=`~${a}`;break;case "%":i="component",o=`#${a}`;break;default:continue}B.has(o)||e.push({symbol:o,type:i});}return e}function h(n){return n?Array.isArray(n)?n.map(e=>[e.id,e]):Object.entries(n):[]}function b(n){return n?Array.isArray(n)?n.map(e=>e.id):Object.keys(n):[]}function rt(n,e){let r=[],s=e?`${e}: `:"",c=h(n.features);for(let[o,i]of c)x(o,i,"feature",s,r);let a=h(n.components);for(let[o,i]of a)x(o,i,"component",s,r);if(n.relationships){let o=new Set([...b(n.features),...b(n.components)]);for(let i of n.relationships){if(typeof i=="string"||!i||!i.from||!i.to)continue;let p=i.from.replace(/^[@#$%~^!?]/,"");!o.has(p)&&!i.from.includes(".")&&r.push({type:"warning",message:`${s}Relationship references unknown source: "${i.from}"`,path:"relationships"});let f=i.to.replace(/^[@#$%~^!?]/,"");!o.has(f)&&!i.to.includes(".")&&r.push({type:"warning",message:`${s}Relationship references unknown target: "${i.to}"`,path:"relationships"});}}if(n.flows){let o=new Set(b(n.components));if(Array.isArray(n.flows)){for(let i of n.flows)if(!(!i||typeof i!="object")&&(i.name||r.push({type:"error",message:`${s}Flow missing required "name" field`,path:"flows"}),i.steps&&Array.isArray(i.steps)))for(let p of i.steps){if(typeof p=="string"||!p||!p.component)continue;let f=p.component.replace(/^#/,"");o.has(f)||r.push({type:"warning",message:`${s}Flow "${i.name}" references unknown component: "${p.component}"`,path:`flows.${i.name}`});}}else for(let[i,p]of Object.entries(n.flows))if(!(!p||typeof p!="object")&&p.steps&&Array.isArray(p.steps))for(let f of p.steps){if(typeof f=="string"||!f||!f.component)continue;let l=f.component.replace(/^#/,"");o.has(l)||r.push({type:"warning",message:`${s}Flow "${i}" references unknown component: "${f.component}"`,path:`flows.${i}`});}}return {valid:r.filter(o=>o.type==="error").length===0,issues:r}}function x(n,e,r,s,c){let a=`${r}s.${n}`;if(/^[a-zA-Z][a-zA-Z0-9-]*$/.test(n)||c.push({type:"warning",message:`${s}${r} ID "${n}" should use alphanumeric characters and hyphens`,path:a}),(!e.description||e.description.trim()==="")&&c.push({type:"warning",message:`${s}${r} "${n}" has no description`,path:a}),e.endpoints)for(let o of e.endpoints)/^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\s+\//.test(o)||c.push({type:"warning",message:`${s}Endpoint "${o}" in ${r} "${n}" may not be in standard format (e.g., "GET /api/users")`,path:`${a}.endpoints`});}function at(n){let e=[],r=new Set;for(let{data:s}of n){let c=h(s.components);for(let[o]of c)r.add(`#${o}`),r.add(o);let a=h(s.features);for(let[o]of a)r.add(`#${o}`),r.add(o);if(s.gates)for(let o of Object.keys(s.gates))r.add(`^${o}`),r.add(o);if(s.signals)for(let o of Object.keys(s.signals))r.add(`!${o}`),r.add(o);if(s.flows)if(Array.isArray(s.flows))for(let o of s.flows)o?.name&&(r.add(`$${o.name}`),r.add(o.name));else for(let o of Object.keys(s.flows))r.add(`$${o}`),r.add(o);if(s.aspects)for(let o of Object.keys(s.aspects))r.add(`~${o}`),r.add(o);if(s.states)for(let o of Object.keys(s.states))r.add(`#${o}`),r.add(o);}for(let{filePath:s,data:c}of n){let a=s?`${s}: `:"",o=[...h(c.components),...h(c.features)];for(let[i,p]of o){if(p.parent){let l=p.parent.replace(/^["']|["']$/g,""),u=l.replace(/^[#$^!~@%?&]/,"");!r.has(l)&&!r.has(u)&&e.push({type:"warning",message:`${a}Component "${i}" references parent "${l}" which is not defined in any .purpose file`,path:`components.${i}.parent`});}let f=[{field:"gates",refs:p.gates},{field:"signals",refs:p.signals},{field:"flows",refs:p.flows},{field:"components",refs:p.components},{field:"aspects",refs:p.aspects}];for(let{field:l,refs:u}of f)if(u)for(let g of u){let y=g.replace(/^[#$^!~@%?&]/,"");!r.has(g)&&!r.has(y)&&e.push({type:"warning",message:`${a}Symbol "${i}" references ${l} "${g}" which is not defined`,path:`components.${i}.${l}`});}}if(c.flows){if(Array.isArray(c.flows)){for(let i of c.flows)if(i?.steps)for(let p of i.steps){if(typeof p=="string"||!p?.component)continue;let f=p.component.replace(/^#/,"");!r.has(p.component)&&!r.has(f)&&e.push({type:"warning",message:`${a}Flow "${i.name}" step references "${p.component}" which is not defined`,path:`flows.${i.name}.steps`});}}else for(let[i,p]of Object.entries(c.flows))if(p?.steps)for(let f of p.steps){if(typeof f=="string"||!f?.component)continue;let l=f.component.replace(/^#/,"");!r.has(f.component)&&!r.has(l)&&e.push({type:"warning",message:`${a}Flow "${i}" step references "${f.component}" which is not defined`,path:`flows.${i}.steps`});}}}return {valid:e.filter(s=>s.type==="error").length===0,issues:e}}function it(n){if(n.valid&&n.issues.length===0)return "\u2705 Purpose file is valid";let e=[],r=n.issues.filter(c=>c.type==="error"),s=n.issues.filter(c=>c.type==="warning");if(r.length>0){e.push(`
3
+ \u274C ${r.length} error(s):`);for(let c of r)e.push(` \u2022 ${c.message}${c.path?` (${c.path})`:""}`);}if(s.length>0){e.push(`
4
+ \u26A0\uFE0F ${s.length} warning(s):`);for(let c of s)e.push(` \u2022 ${c.message}${c.path?` (${c.path})`:""}`);}return n.valid?e.push(`
5
+ \u2705 Purpose file is valid (with warnings)`):e.push(`
6
+ \u274C Purpose file is invalid`),e.join(`
7
+ `)}export{T as a,z as b,L as c,H as d,N as e,Z as f,U as g,J as h,Q as i,X as j,tt as k,et as l,ot as m,st as n,nt as o,rt as p,at as q,it as r};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import {b}from'./chunk-EG22HDXI.js';import {e,f,c,d,l,h,g,k,i,m as m$1,o,n,j,b as b$1,a as a$1}from'./chunk-YXLGVOZO.js';import {a}from'./chunk-Y4XFVDZC.js';import*as $ from'fs';import*as m from'path';import e$1 from'chalk';import E from'prompts';function F(){return process.env.CLAUDE_CODE==="1"||process.env.TERM_PROGRAM==="claude"?false:!!(process.env.TERM_PROGRAM==="cursor"||process.env.CURSOR_SESSION||process.env.CURSOR_TRACE_ID||process.env.VSCODE_CWD&&process.env.VSCODE_CWD.toLowerCase().includes("cursor")||process.env.VSCODE_NLS_CONFIG&&process.env.VSCODE_NLS_CONFIG.toLowerCase().includes("cursor")||process.env.TERM_PROGRAM==="vscode"&&process.env.VSCODE_GIT_ASKPASS_NODE?.toLowerCase().includes("cursor")||process.stdin.isTTY)}async function T(g){let n=new a(g),c=await n.discover();console.log(e$1.cyan(`
2
+ import {b}from'./chunk-YNFF7XHV.js';import {e,f,c,d,l,h,g,k,i,m as m$1,o,n,j,b as b$1,a as a$1}from'./chunk-YXLGVOZO.js';import {a}from'./chunk-Y4XFVDZC.js';import*as $ from'fs';import*as m from'path';import e$1 from'chalk';import E from'prompts';function F(){return process.env.CLAUDE_CODE==="1"||process.env.TERM_PROGRAM==="claude"?false:!!(process.env.TERM_PROGRAM==="cursor"||process.env.CURSOR_SESSION||process.env.CURSOR_TRACE_ID||process.env.VSCODE_CWD&&process.env.VSCODE_CWD.toLowerCase().includes("cursor")||process.env.VSCODE_NLS_CONFIG&&process.env.VSCODE_NLS_CONFIG.toLowerCase().includes("cursor")||process.env.TERM_PROGRAM==="vscode"&&process.env.VSCODE_GIT_ASKPASS_NODE?.toLowerCase().includes("cursor")||process.stdin.isTTY)}async function T(g){let n=new a(g),c=await n.discover();console.log(e$1.cyan(`
3
3
  Configure Agent Models
4
4
  `)),console.log(e$1.gray(` Environment: ${c.source}`)),console.log(e$1.gray(` Available: ${c.models.length} models
5
5
  `));let i={},o=n.groupByTier(c.models),a$2=t=>{let r=a$1[t],s=r.tier==="high"?o.high:r.tier==="medium"?o.medium:o.low,l=[];for(let f of s){let P=l.length===0;l.push({title:P?`${f.name} (recommended)`:f.name,value:f.id,description:`${f.provider} - ${r.tier} tier`});}let u=o.high.filter(f=>!s.includes(f)),y=o.medium.filter(f=>!s.includes(f)),v=o.low.filter(f=>!s.includes(f));for(let f of u)l.push({title:f.name,value:f.id,description:`${f.provider} - high tier`});for(let f of y)l.push({title:f.name,value:f.id,description:`${f.provider} - medium tier`});for(let f of v)l.push({title:f.name,value:f.id,description:`${f.provider} - low tier`});return l};for(let t of ["architect","builder","tester","reviewer","security"]){let r=a$1[t],s=t.charAt(0).toUpperCase()+t.slice(1),l=a$2(t),u=await E({type:"select",name:"model",message:`${s} (${r.description})`,choices:l,initial:0},{onCancel:()=>{console.log(e$1.yellow(`
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ import {f,a,o,z}from'./chunk-VR2LLUYE.js';import {t}from'./chunk-M7JHVVDW.js';import {a as a$2,b as b$4,c as c$1}from'./chunk-M4UMM6DC.js';import {j,b as b$2,a as a$5}from'./chunk-GRZQIKST.js';import {b as b$1,a as a$4}from'./chunk-EK4ZRIFJ.js';import {a as a$1,b as b$3}from'./chunk-4TXOVRWD.js';import {H,m}from'./chunk-D6BSCELB.js';import {a as a$3,q as q$1}from'./chunk-K6TLYNRQ.js';import {c,b,d}from'./chunk-5TAVYPOV.js';import*as S from'fs';import*as T from'path';import*as D from'crypto';import {execSync}from'child_process';import*as C from'js-yaml';import*as B from'os';import te from'sql.js';var At={};c(At,{contentSearch:()=>Zt,detectFileRename:()=>xt,generateFingerprint:()=>Rt,levenshteinDistance:()=>bt,levenshteinSimilarity:()=>Z,searchSiblingFiles:()=>Lt,slidingWindowSearch:()=>Y});function Rt(e){let t=e.split(`
3
+ `).filter(n=>n.trim()!=="");return {firstLine:G(t[0]||""),lastLine:G(t[t.length-1]||""),lineCount:t.length,structuralHash:_t(t)}}function _t(e){let t=e.map(n=>n.trim()).filter(n=>St.test(n)).map(n=>{let r=n.match(St);return r?r[1].trim():""}).join("|");return D.createHash("sha256").update(t).digest("hex").slice(0,16)}function G(e){return e.trim().replace(/\s+/g," ").toLowerCase()}function bt(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;e.length>t.length&&([e,t]=[t,e]);let n=e.length,r=t.length;if(n>5e3||r>5e3)return Math.abs(n-r);let s=new Array(n+1),i=new Array(n+1);for(let a=0;a<=n;a++)s[a]=a;for(let a=1;a<=r;a++){i[0]=a;for(let c=1;c<=n;c++){let o=e[c-1]===t[a-1]?0:1;i[c]=Math.min(s[c]+1,i[c-1]+1,s[c-1]+o);}[s,i]=[i,s];}return s[n]}function Z(e,t){if(e.length===0&&t.length===0)return 1;let n=Math.max(e.length,t.length);return 1-bt(e,t)/n}function Y(e,t,n,r=3){let{lineCount:s}=t,i=Math.max(1,Math.floor(s*.8)),a=Math.ceil(s*1.2),c=[],o=Q(n);for(let l of [s,i,a])if(!(l>e.length))for(let u=0;u<=e.length-l;u++){let f=e.slice(u,u+l),y=Qt(f,t,o);if(y>=.5){let h=f.join(`
4
+ `);c.push({windowStart:u+1,windowEnd:u+l,similarity:Z(Q(h),o),score:y});}}let d=new Map;for(let l of c){let u=d.get(l.windowStart);(!u||l.score>u.score)&&d.set(l.windowStart,l);}return Array.from(d.values()).sort((l,u)=>u.score-l.score).slice(0,r)}function Qt(e,t,n){let r=e.filter(f=>f.trim()!=="");if(r.length===0)return 0;let s=0,i=G(r[0]),a=G(r[r.length-1]),c=0;i===t.firstLine&&(c+=.5),a===t.lastLine&&(c+=.5),s+=c*qt,_t(r)===t.structuralHash&&(s+=Kt);let d=r.join(`
5
+ `),l=Z(Q(d),n);l>=.8&&(s+=(l-.8)/.2*Vt);let u=r.length/t.lineCount;if(u>=.8&&u<=1.2){let f=1-Math.abs(1-u)/.2;s+=f*Jt;}return s}function Q(e){return e.split(`
6
+ `).map(t=>t.trim()).filter(t=>t!=="").join(`
7
+ `)}function xt(e,t){try{let n=execSync(`git log --follow --diff-filter=R --name-status --format="" -- "${t}"`,{cwd:e,encoding:"utf8",timeout:5e3}).trim();if(!n)return null;let r=n.split(`
8
+ `);for(let s of r){let i=s.split(" ");if(i.length>=3&&i[0].startsWith("R"))return i[2]}return null}catch{return null}}function Lt(e,t,n,r,s=10){let i=T.isAbsolute(t)?t:T.join(e,t);if(!S.existsSync(i))return [];let a=[];try{let c=S.readdirSync(i).filter(o=>!o.startsWith(".")&&S.statSync(T.join(i,o)).isFile()).slice(0,s);for(let o of c)try{let l=S.readFileSync(T.join(i,o),"utf8").split(`
9
+ `),u=Y(l,n,r,1);if(u.length>0&&u[0].score>=.7){let f=T.relative(e,T.join(i,o));a.push({file:f,score:u[0].score,start:u[0].windowStart,end:u[0].windowEnd});}}catch{}}catch{return []}return a.sort((c,o)=>o.score-c.score)}function Zt(e,t,n,r=true){let s=Rt(n),i=T.isAbsolute(t)?t:T.join(e,t);if(S.existsSync(i)){let l=S.readFileSync(i,"utf8").split(`
10
+ `),u=Y(l,s,n);if(u.length>0){let f=u[0];return {found:f.score>=.7,score:f.score,suggestedStart:f.windowStart,suggestedEnd:f.windowEnd,similarity:f.similarity}}}let a=xt(e,t);if(a){let d=T.join(e,a);if(S.existsSync(d)){let u=S.readFileSync(d,"utf8").split(`
11
+ `),f=Y(u,s,n);if(f.length>0&&f[0].score>=.7)return {found:true,score:f[0].score,suggestedStart:f[0].windowStart,suggestedEnd:f[0].windowEnd,suggestedPath:a,similarity:f[0].similarity}}}let c=T.dirname(t),o=Lt(e,c,s,n);if(o.length>0&&o[0].score>=.7){let d=o[0];return {found:true,score:d.score,suggestedStart:d.start,suggestedEnd:d.end,suggestedPath:d.file!==t?d.file:void 0,similarity:d.score}}return {found:false,score:0}}var St,qt,Kt,Vt,Jt,It=b(()=>{St=/^\s*(function |class |if |else |for |while |switch |case |return |export |import |const |let |var |async |await |try |catch |throw |struct |enum |protocol |guard |def |fn )/;qt=.4,Kt=.3,Vt=.2,Jt=.1;});var $t=300*1e3,W=null;function Tt(){W=null;}function O(e,t){return S.existsSync(T.join(e,t))}function M(e,t){return S.existsSync(T.join(e,t))}function Bt(e,t,n){let r=e;try{if(!S.existsSync(r))return !1;let s=S.readdirSync(r,{withFileTypes:!0});for(let i of s){if(i.isFile()&&i.name.endsWith(t))return !0;if(i.isDirectory())try{if(S.readdirSync(T.join(r,i.name)).some(c=>c.endsWith(t)))return !0}catch{}}}catch{}return false}var Gt={wisdom:e=>O(e,".paradigm/wisdom"),history:e=>O(e,".paradigm/history"),lore:e=>O(e,".paradigm/lore"),habits:e=>M(e,".paradigm/habits.yaml"),sentinel:e=>{try{let t=T.join(e,".paradigm","config.yaml");return S.existsSync(t)?S.readFileSync(t,"utf-8").includes("sentinel"):!1}catch{return false}},flows:e=>M(e,".paradigm/flow-index.json")||M(e,".paradigm/flows.yaml"),fixtures:e=>M(e,".paradigm/fixtures.yaml"),orchestration:e=>M(e,".paradigm/agents.yaml"),tasks:e=>O(e,".paradigm/tasks"),assessment:e=>O(e,".paradigm/lore"),personas:e=>Bt(e,".persona"),protocols:e=>O(e,".paradigm/protocols"),symphony:()=>{let e=T.join(B.homedir(),".paradigm","score");return S.existsSync(e)},university:e=>O(e,".paradigm/university"),agents:e=>{let t=T.join(B.homedir(),".paradigm","agents");return O(e,".paradigm/agents")||S.existsSync(t)},"aspect-graph":e=>M(e,".paradigm/aspect-graph.db"),pan:e=>M(e,".pan")||M(e,"nevr.yaml"),notebooks:e=>{let t=T.join(B.homedir(),".paradigm","notebooks");return O(e,".paradigm/notebooks")||S.existsSync(t)}},Et=class{modules=new Map;activatedAdvanced=new Set;rootDir;constructor(t){this.rootDir=t;}register(t){this.modules.set(t.key,t);}registerAll(t){for(let n of t)this.register(n);}detectActiveFeatures(){if(W&&Date.now()-W.timestamp<$t)return W.features;let t=new Set;for(let[n,r]of this.modules){if(r.tier==="core"){t.add(n);continue}if(r.tier==="advanced"){this.activatedAdvanced.has(n)&&t.add(n);continue}let s=r.detect||Gt[n];if(s)try{s(this.rootDir)&&t.add(n);}catch{}else t.add(n);}return W={features:t,timestamp:Date.now()},t}getActiveTools(){let t=this.detectActiveFeatures(),n=[];for(let[r,s]of this.modules)t.has(r)&&n.push(...s.getToolsList());return n}activateAdvanced(t){let n=this.modules.get(t);return !n||n.tier!=="advanced"?null:(this.activatedAdvanced.add(t),n.getToolsList())}getAvailableAdvanced(){let t=[];for(let[n,r]of this.modules)r.tier==="advanced"&&!this.activatedAdvanced.has(n)&&t.push({key:n,toolCount:r.getToolsList().length});return t}async dispatch(t,n,r,s){let i=this.detectActiveFeatures();for(let[a,c]of this.modules)if(i.has(a))try{let o=await c.handleTool(t,n,r,s);if(o.handled)return o}catch(o){return {handled:true,text:JSON.stringify({error:`Tool handler error in module "${a}"`,message:o.message},null,2)}}return null}get size(){return this.modules.size}getRegistryInfo(){let t=this.detectActiveFeatures(),n={core:0,feature:0,advanced:0};for(let r of this.modules.values())n[r.tier]++;return {total:this.modules.size,byTier:n,activeFeatures:[...t],availableAdvanced:[...this.modules.entries()].filter(([r,s])=>s.tier==="advanced"&&!this.activatedAdvanced.has(r)).map(([r])=>r)}}};var tt=null;async function ee(){return tt||(tt=await te()),tt}var ne=[`CREATE TABLE IF NOT EXISTS aspects (
12
+ id TEXT PRIMARY KEY,
13
+ description TEXT NOT NULL,
14
+ category TEXT DEFAULT 'rule',
15
+ severity TEXT DEFAULT 'medium',
16
+ value TEXT,
17
+ enforcement TEXT,
18
+ defined_in TEXT NOT NULL,
19
+ tags TEXT,
20
+ created_at TEXT NOT NULL,
21
+ updated_at TEXT NOT NULL
22
+ )`,`CREATE TABLE IF NOT EXISTS anchors (
23
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
24
+ aspect_id TEXT NOT NULL REFERENCES aspects(id) ON DELETE CASCADE,
25
+ file_path TEXT NOT NULL,
26
+ start_line INTEGER NOT NULL,
27
+ end_line INTEGER NOT NULL,
28
+ content_hash TEXT,
29
+ normalized_hash TEXT,
30
+ materialized_at_commit TEXT,
31
+ last_verified TEXT,
32
+ drifted INTEGER DEFAULT 0
33
+ )`,"CREATE INDEX IF NOT EXISTS idx_anchors_file ON anchors(file_path)","CREATE INDEX IF NOT EXISTS idx_anchors_aspect ON anchors(aspect_id)",`CREATE TABLE IF NOT EXISTS edges (
34
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
35
+ source TEXT NOT NULL,
36
+ target TEXT NOT NULL,
37
+ relation TEXT NOT NULL,
38
+ weight REAL DEFAULT 1.0,
39
+ origin TEXT DEFAULT 'explicit',
40
+ created_at TEXT NOT NULL
41
+ )`,"CREATE INDEX IF NOT EXISTS idx_edges_source ON edges(source)","CREATE INDEX IF NOT EXISTS idx_edges_target ON edges(target)",`CREATE TABLE IF NOT EXISTS lore_links (
42
+ aspect_id TEXT NOT NULL,
43
+ lore_id TEXT NOT NULL,
44
+ PRIMARY KEY (aspect_id, lore_id)
45
+ )`,`CREATE TABLE IF NOT EXISTS search_log (
46
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
47
+ query TEXT NOT NULL,
48
+ results_returned TEXT NOT NULL,
49
+ selected_result TEXT,
50
+ timestamp TEXT NOT NULL
51
+ )`,"CREATE INDEX IF NOT EXISTS idx_search_query ON search_log(query)",`CREATE TABLE IF NOT EXISTS search_weights (
52
+ query_normalized TEXT NOT NULL,
53
+ aspect_id TEXT NOT NULL,
54
+ weight REAL DEFAULT 1.0,
55
+ hit_count INTEGER DEFAULT 1,
56
+ last_hit TEXT NOT NULL,
57
+ PRIMARY KEY (query_normalized, aspect_id)
58
+ )`,`CREATE TABLE IF NOT EXISTS heatmap (
59
+ aspect_id TEXT NOT NULL,
60
+ access_type TEXT NOT NULL,
61
+ count INTEGER DEFAULT 0,
62
+ last_accessed TEXT NOT NULL,
63
+ PRIMARY KEY (aspect_id, access_type)
64
+ )`],se=["ALTER TABLE anchors ADD COLUMN original_content TEXT",`CREATE TABLE IF NOT EXISTS anchor_history (
65
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
66
+ anchor_id INTEGER NOT NULL,
67
+ action TEXT NOT NULL,
68
+ old_start INTEGER,
69
+ old_end INTEGER,
70
+ new_start INTEGER,
71
+ new_end INTEGER,
72
+ old_path TEXT,
73
+ new_path TEXT,
74
+ confidence REAL,
75
+ commit_hash TEXT,
76
+ healed_at TEXT NOT NULL
77
+ )`],re="CREATE VIRTUAL TABLE IF NOT EXISTS aspects_fts USING fts5(id, description, enforcement, tags)";function I(e,t,n){let r=e.prepare(t);n&&n.length>0&&r.bind(n);let s=[];for(;r.step();)s.push(r.getAsObject());return r.free(),s}function oe(e,t,n){let r=e.prepare(t);n&&n.length>0&&r.bind(n);let s=null;return r.step()&&(s=r.getAsObject()),r.free(),s}async function Nt(e){let t=await ee(),n=T.join(e,".paradigm"),r=T.join(n,"aspect-graph.db"),s;if(S.existsSync(r)){let i=S.readFileSync(r);s=new t.Database(i);}else S.existsSync(n)||S.mkdirSync(n,{recursive:true}),s=new t.Database;for(let i of ne)s.run(i);try{s.run(re);}catch{}for(let i of se)try{s.run(i);}catch{}return s}function Ot(e,t){if(t){let n=T.join(t,".paradigm");S.existsSync(n)||S.mkdirSync(n,{recursive:true});let r=T.join(n,"aspect-graph.db"),s=e.export();S.writeFileSync(r,Buffer.from(s));}e.close();}function vt(e,t,n){let r=t.filter(a=>a.type==="aspect"),s=new Date().toISOString(),i=null;try{i=execSync("git rev-parse HEAD",{cwd:n,encoding:"utf8"}).trim();}catch{}e.run("DELETE FROM anchors"),e.run("DELETE FROM edges"),e.run("DELETE FROM aspects");try{e.run("DELETE FROM aspects_fts");}catch{}for(let a of r){let c=a.data??{},o=le(c,a),d=de(c,a),l=c.value!=null?String(c.value):null,u=a.enforcement??(c.enforcement!=null?String(c.enforcement):null),f=a.tags?JSON.stringify(a.tags):null;if(e.run(`INSERT INTO aspects (id, description, category, severity, value, enforcement, defined_in, tags, created_at, updated_at)
78
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,[a.symbol,a.description??"",o,d,l,u,a.filePath,f,a.created??s,a.modified??s]),a.anchors)for(let h of a.anchors){let{startLine:_,endLine:N}=Ft(h),L=ce();e.run(`INSERT INTO anchors (aspect_id, file_path, start_line, end_line, content_hash, normalized_hash, materialized_at_commit, last_verified, original_content)
79
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,[a.symbol,h.path,_,N,L.exact,L.normalized,i,s,L.normalizedContent]);}let y=c.edges;if(Array.isArray(y))for(let h of y)e.run(`INSERT INTO edges (source, target, relation, weight, origin, created_at)
80
+ VALUES (?, ?, ?, ?, ?, ?)`,[h.source??a.symbol,h.target??"",h.relation??"related-to",h.weight??1,h.origin??"explicit",s]);if(a.appliesTo)for(let h of a.appliesTo)e.run(`INSERT INTO edges (source, target, relation, weight, origin, created_at)
81
+ VALUES (?, ?, ?, ?, ?, ?)`,[a.symbol,h,"related-to",.5,"inferred",s]);try{e.run(`INSERT INTO aspects_fts (id, description, enforcement, tags)
82
+ VALUES (?, ?, ?, ?)`,[a.symbol,a.description??"",u??"",f??""]);}catch{}}}function He(e,t){return oe(e,"SELECT * FROM aspects WHERE id = ?",[t])}function Ue(e,t){return I(e,"SELECT * FROM anchors WHERE aspect_id = ?",[t])}function Xe(e,t){return I(e,"SELECT * FROM edges WHERE source = ?",[t])}function We(e,t){return I(e,"SELECT * FROM edges WHERE target = ?",[t])}function ze(e,t){return I(e,"SELECT * FROM edges WHERE source = ? OR target = ?",[t,t])}function $e(e,t,n){let r=new Date().toISOString();e.run(`INSERT INTO heatmap (aspect_id, access_type, count, last_accessed)
83
+ VALUES (?, ?, 1, ?)
84
+ ON CONFLICT(aspect_id, access_type)
85
+ DO UPDATE SET count = count + 1, last_accessed = ?`,[t,n,r,r]);}function Be(e,t=20,n){return n?I(e,"SELECT * FROM heatmap WHERE access_type = ? ORDER BY count DESC LIMIT ?",[n,t]):I(e,"SELECT * FROM heatmap ORDER BY count DESC LIMIT ?",[t])}function Ge(e,t,n,r=true,s=.7,i=.85){let a=n?I(e,"SELECT * FROM anchors WHERE aspect_id = ?",[n]):I(e,"SELECT * FROM anchors"),c=[];for(let o of a){let l=I(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id])[0]?.defined_in,u=l?T.dirname(T.isAbsolute(l)?l:T.resolve(t,l)):t,f=H(o.file_path,u,t),y=f.resolvedPath;if(!f.exists){c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"missing",resolvedBy:"none",exists:false,drifted:true});continue}try{let _=S.readFileSync(y,"utf8").split(`
86
+ `),N=Math.max(0,o.start_line-1),L=Math.min(_.length,o.end_line),P=_.slice(N,L).join(`
87
+ `),j=D.createHash("sha256").update(P).digest("hex");if(o.content_hash!=null&&j===o.content_hash){c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"clean",resolvedBy:"exact-hash",exists:!0,drifted:!1}),o.drifted===1&&e.run("UPDATE anchors SET drifted = 0 WHERE id = ?",[o.id]);continue}let U=D.createHash("sha256").update(nt(P)).digest("hex");if(o.normalized_hash!=null&&U===o.normalized_hash){e.run("UPDATE anchors SET content_hash = ?, drifted = 0 WHERE id = ?",[j,o.id]),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"cosmetic",resolvedBy:"normalized-hash",exists:!0,drifted:!1});continue}if(o.content_hash==null&&o.normalized_hash==null){e.run("UPDATE anchors SET content_hash = ?, normalized_hash = ?, drifted = 0 WHERE id = ?",[j,U,o.id]),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"clean",resolvedBy:"exact-hash",exists:!0,drifted:!1});continue}let H=!1;if(o.materialized_at_commit){let m=ae(t,o.file_path,o.materialized_at_commit,o.start_line,o.end_line);if(m){let g=Math.max(0,m.currentStart-1),p=Math.min(_.length,m.currentEnd),E=_.slice(g,p).join(`
88
+ `),F=D.createHash("sha256").update(E).digest("hex");if(o.content_hash!=null&&F===o.content_hash){let k=r;if(k){e.run("UPDATE anchors SET start_line = ?, end_line = ?, drifted = 0 WHERE id = ?",[m.currentStart,m.currentEnd,o.id]);let X=I(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id]);X.length>0&&et(t,X[0].defined_in,o.file_path,o.start_line,o.end_line,m.currentStart,m.currentEnd);}c.push({aspectId:o.aspect_id,path:o.file_path,startLine:k?m.currentStart:o.start_line,endLine:k?m.currentEnd:o.end_line,status:"shifted",resolvedBy:"git-line-mapping",exists:!0,drifted:!1,suggestedStart:m.currentStart,suggestedEnd:m.currentEnd,autoHealed:k}),H=!0;}else {let k=D.createHash("sha256").update(nt(E)).digest("hex");if(o.normalized_hash!=null&&k===o.normalized_hash){if(r){let X=D.createHash("sha256").update(E).digest("hex");e.run("UPDATE anchors SET start_line = ?, end_line = ?, content_hash = ?, drifted = 0 WHERE id = ?",[m.currentStart,m.currentEnd,X,o.id]);let z=I(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id]);z.length>0&&et(t,z[0].defined_in,o.file_path,o.start_line,o.end_line,m.currentStart,m.currentEnd);}c.push({aspectId:o.aspect_id,path:o.file_path,startLine:r?m.currentStart:o.start_line,endLine:r?m.currentEnd:o.end_line,status:"shifted",resolvedBy:"git-line-mapping",exists:!0,drifted:!1,suggestedStart:m.currentStart,suggestedEnd:m.currentEnd,autoHealed:r}),H=!0;}}}}if(H)continue;if(o.original_content){let{contentSearch:m}=(It(),d(At)),g=m(t,o.file_path,o.original_content,r);if(g.found&&g.score>=s){if(r&&g.score>=i&&!g.suggestedPath&&g.suggestedStart&&g.suggestedEnd){e.run("UPDATE anchors SET start_line = ?, end_line = ?, drifted = 0 WHERE id = ?",[g.suggestedStart,g.suggestedEnd,o.id]);try{e.run(`INSERT INTO anchor_history (anchor_id, action, old_start, old_end, new_start, new_end, confidence, healed_at)
89
+ VALUES (?, 'relocated', ?, ?, ?, ?, ?, ?)`,[o.id,o.start_line,o.end_line,g.suggestedStart,g.suggestedEnd,g.score,new Date().toISOString()]);}catch{}let E=I(e,"SELECT defined_in FROM aspects WHERE id = ?",[o.aspect_id]);E.length>0&&et(t,E[0].defined_in,o.file_path,o.start_line,o.end_line,g.suggestedStart,g.suggestedEnd),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:g.suggestedStart,endLine:g.suggestedEnd,status:"relocated",resolvedBy:"content-search",exists:!0,similarity:g.similarity,suggestedStart:g.suggestedStart,suggestedEnd:g.suggestedEnd,autoHealed:!0,drifted:!1});continue}c.push({aspectId:o.aspect_id,path:g.suggestedPath||o.file_path,startLine:o.start_line,endLine:o.end_line,status:"relocated",resolvedBy:"content-search",exists:!0,similarity:g.similarity,suggestedStart:g.suggestedStart,suggestedEnd:g.suggestedEnd,autoHealed:!1,drifted:!0});continue}}e.run("UPDATE anchors SET drifted = 1 WHERE id = ?",[o.id]),c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"modified",resolvedBy:"none",exists:!0,currentContent:P,drifted:!0});}catch{c.push({aspectId:o.aspect_id,path:o.file_path,startLine:o.start_line,endLine:o.end_line,status:"modified",resolvedBy:"none",exists:true,drifted:true});}}return c}function Ft(e){let{lines:t}=e;return typeof t=="number"?{startLine:t,endLine:t}:Array.isArray(t)?t.length===2?{startLine:t[0],endLine:t[1]}:{startLine:Math.min(...t),endLine:Math.max(...t)}:{startLine:1,endLine:1}}function ie(e){let t=[],n=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/gm,r;for(;(r=n.exec(e))!==null;)t.push({oldStart:parseInt(r[1],10),oldCount:r[2]!==void 0?parseInt(r[2],10):1,newStart:parseInt(r[3],10),newCount:r[4]!==void 0?parseInt(r[4],10):1});return t}function ae(e,t,n,r,s){let i;try{i=execSync(`git diff ${n}..HEAD --unified=0 -- "${t}"`,{cwd:e,encoding:"utf8",timeout:5e3});}catch{return null}if(!i.trim())return {originalStart:r,originalEnd:s,currentStart:r,currentEnd:s};let a=ie(i),c=0;for(let o of a){if(o.oldStart+o.oldCount<=r){c+=o.newCount-o.oldCount;continue}if(o.oldStart<s)return null;break}return c===0?null:{originalStart:r,originalEnd:s,currentStart:r+c,currentEnd:s+c}}function et(e,t,n,r,s,i,a){let c=T.isAbsolute(t)?t:T.join(e,t);if(!S.existsSync(c))return false;try{let o=S.readFileSync(c,"utf8"),d=r===s?`${n}:${r}`:`${n}:${r}-${s}`,l=i===a?`${n}:${i}`:`${n}:${i}-${a}`;if(!o.includes(d))return !1;let u=o.replace(d,l);return S.writeFileSync(c,u,"utf8"),!0}catch{return false}}function nt(e){return e.split(`
90
+ `).map(t=>t.trimEnd()).filter(t=>t.trim()!=="").map(t=>t.replace(/\s+/g," ")).join(`
91
+ `)}function ce(e,t,n){return {exact:null,normalized:null,normalizedContent:null};}function le(e,t){if(typeof e.category=="string")return e.category;let n=(t.description??"").toLowerCase();return /\b(must|require|always)\b/.test(n)?"rule":/\b(decided|chose)\b/.test(n)?"decision":/\b(limit|cannot)\b/.test(n)?"constraint":/\b(set to|configured|value)\b/.test(n)?"configuration":"rule"}function de(e,t){if(typeof e.severity=="string")return e.severity;let n=t.tags??[];return n.includes("critical")?"critical":n.includes("security")||n.includes("compliance")?"high":"medium"}j();var ue=/L-\d{4}-\d{2}-\d{2}-\d{3}/g;async function kt(e,t){e.run("DELETE FROM lore_links");let n=await a$5(t);if(n.length===0)return 0;let r=fe(n),s=new Map;for(let d of n)s.set(d.id,d);let i=new Set,a=e.exec("SELECT id, enforcement FROM aspects");if(a.length>0){let{columns:d,values:l}=a[0],u=d.indexOf("id"),f=d.indexOf("enforcement");for(let y of l){let h=String(y[u]),_=y[f];if(_&&typeof _=="string"){let N=_.match(ue);if(N)for(let L of N)s.has(L)&&i.add(`${h}\0${L}`);}}}let c=e.exec("SELECT source, target FROM edges");if(c.length>0&&a.length>0){let d=pe(e,c);for(let[l,u]of d)for(let f of u){let y=r.get(f);if(y)for(let h of y)i.add(`${l}\0${h}`);}}if(i.size===0)return 0;let o=e.prepare("INSERT OR IGNORE INTO lore_links (aspect_id, lore_id) VALUES (?, ?)");try{for(let d of i){let[l,u]=d.split("\0");o.bind([l,u]),o.step(),o.reset();}}finally{o.free();}return i.size}async function Ke(e,t,n){let r=e.exec("SELECT lore_id FROM lore_links WHERE aspect_id = ?",[n]);if(r.length===0||r[0].values.length===0)return [];let s=r[0].values.map(i=>String(i[0]));return ge(t,s)}async function Mt(e,t){let n=await a$5(t);if(n.length===0)return 0;let r=e.exec("SELECT id FROM aspects"),s=new Set;if(r.length>0)for(let o of r[0].values)s.add(String(o[0]));if(s.size<2)return 0;let i=new Date().toISOString(),a=0,c=e.prepare(`INSERT OR IGNORE INTO edges (source, target, relation, weight, origin, created_at)
92
+ VALUES (?, ?, 'related-to', 0.3, 'learned', ?)`);try{for(let o of n){if(!o.symbols_touched||o.symbols_touched.length<2)continue;let d=[];for(let l of o.symbols_touched){let u=l.startsWith("~")?l.slice(1):l;s.has(u)&&d.push(u);}for(let l=0;l<d.length;l++)for(let u=l+1;u<d.length;u++){let[f,y]=d[l]<d[u]?[d[l],d[u]]:[d[u],d[l]];c.bind([f,y,i]),c.step(),c.reset(),a++;}}}finally{c.free();}return a}function fe(e){let t=new Map;for(let n of e)if(n.symbols_touched)for(let r of n.symbols_touched){let s=t.get(r);s||(s=new Set,t.set(r,s)),s.add(n.id);}return t}function pe(e,t){let n=e.exec("SELECT id FROM aspects"),r=new Set;if(n.length>0)for(let d of n[0].values)r.add(String(d[0]));let s=new Map;if(t.length===0)return s;let{columns:i,values:a}=t[0],c=i.indexOf("source"),o=i.indexOf("target");for(let d of a){let l=String(d[c]),u=String(d[o]);if(r.has(l)){let f=s.get(l);f||(f=new Set,s.set(l,f)),f.add(u),f.add(`~${l}`);}if(r.has(u)){let f=s.get(u);f||(f=new Set,s.set(u,f)),f.add(l),f.add(`~${u}`);}}return s}async function ge(e,t){let n=new Set,r=[];for(let s of t){if(n.has(s))continue;n.add(s);let i=await b$2(e,s);i&&r.push(me(i));}return r}function me(e){return {id:e.id,title:e.title,summary:e.summary,timestamp:e.timestamp,symbolsTouched:e.symbols_touched}}var he="PARADIGM_STRICT";function q(){let e=process.env[he];if(e===void 0||e==="")return false;let t=e.toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}var Dt=new Set(["duplicate-key-detected"]);function ye(e){let t=e.trim();if(t.includes("/")||t.includes("\\")){let n=t.split(/[/\\]/);t=n[n.length-1]||"unknown";}return t.length>40&&(t=t.slice(0,40)),t||"unknown"}var K=class{transforms=new Map;record(t,n,r=1){let s=ye(n),i=`${t}::${s}`,a=this.transforms.get(i);a?a.count+=r:this.transforms.set(i,{kind:t,surface:s,count:r});}report(){let t=Array.from(this.transforms.values()).sort((r,s)=>r.kind!==s.kind?r.kind.localeCompare(s.kind):r.surface.localeCompare(s.surface)),n=t.filter(r=>Dt.has(r.kind)).reduce((r,s)=>r+s.count,0);return {reindex_ts:new Date().toISOString(),transformations:t,lossy_count:n,strict_mode:q()}}hasLossy(){for(let t of this.transforms.values())if(Dt.has(t.kind))return true;return false}totalCount(){let t=0;for(let n of this.transforms.values())t+=n.count;return t}};b$1();var Ee={"@":{category:"features",prefix:"@"},"#":{category:"components",prefix:"#"},"^":{category:"gates",prefix:"^"},$:{category:"flows",prefix:"$"},"&":{category:"integrations",prefix:"&"},"!":{category:"signals",prefix:"!"},"%":{category:"state",prefix:"%"}},Te={features:["src/features/","features/","app/","src/app/","src/modules/","modules/"],components:["src/components/","components/","src/lib/","lib/","src/ui/","ui/"],gates:["middleware/","src/middleware/","auth/","src/auth/","guards/","src/guards/"],flows:["flows/","src/flows/","workflows/","src/workflows/","sagas/","src/sagas/"],integrations:["integrations/","src/integrations/","external/","src/external/","vendors/"],signals:["events/","src/events/","handlers/","src/handlers/"],state:["stores/","src/stores/","state/","src/state/","reducers/","src/reducers/"]},Se={config:[".paradigm/config.yaml","package.json","tsconfig.json",".env.example"],entry:["src/index.ts","src/index.tsx","src/main.ts","src/main.tsx","index.ts","main.ts","src/app.ts","src/app.tsx"],types:["src/types/","types/","src/types.ts","types.ts"]},st={always:["node_modules/","dist/","build/",".git/",".next/",".nuxt/",".cache/","*.lock","*.log"],unless_testing:["**/*.test.ts","**/*.test.tsx","**/*.spec.ts","**/*.spec.tsx","__tests__/","test/","tests/"],unless_docs:["docs/","*.md","README*","CHANGELOG*"]};function hn(){return [{name:"paradigm_reindex",description:"Rebuild scan-index.json, navigator.yaml, and flow-index.json from .purpose files. Call after modifying paradigm files or at the end of a work session to ensure static index files are fresh. Returns counts of indexed symbols, files processed, and any errors. ~150 tokens.",inputSchema:{type:"object",properties:{}},annotations:{readOnlyHint:false,destructiveHint:true},aliases:["rebuild","refresh","rescan","regenerate index","update index"]}]}async function yn(e,t,n,r){if(e!=="paradigm_reindex")return {handled:false,text:""};try{let s=await we(n.rootDir,n);await r(),f.clear(),Tt();let i=(s.integrityReport?.brokenReferences?.length||0)+(s.integrityReport?.duplicateSymbols?.length||0)+(s.componentAnchorIssues||0)+(s.crossFileIssues||0),a$1={success:!0,symbolCount:s.symbolCount,breakdown:s.breakdown,flowCount:s.flowCount,filesWritten:s.filesWritten.length,...s.aspectGraphStats?{aspects:s.aspectGraphStats.aspects,loreLinks:s.aspectGraphStats.loreLinks}:{},...s.protocolHealth?{protocols:s.protocolHealth.total,staleProtocols:s.protocolHealth.stale}:{},...i>0?{issues:i}:{}};s.consistency&&(a$1.consistency=s.consistency);let c=JSON.stringify(a$1,null,2);return a(c.length,e),{handled:!0,text:c}}catch(s){let i=JSON.stringify({error:s.message},null,2);return a(i.length,e),{handled:true,text:i}}}async function we(e,t$1){let n=[],r=new K,s;t$1?s=t$1.aggregation:s=await m(e);let i=t$1?.projectName||T.basename(e),a=T.join(e,".paradigm");S.existsSync(a)||S.mkdirSync(a,{recursive:true}),Re(e,r),_e(s.purposeFiles,r);let c=a$1({symbols:s.symbols,purposeFiles:s.purposeFiles,portalFiles:s.portalFiles},{projectName:i}),o$1=T.join(a,"scan-index.json");S.writeFileSync(o$1,b$3(c),"utf8"),n.push(".paradigm/scan-index.json");let d=be(e,s),l=T.join(a,"navigator.yaml");S.writeFileSync(l,C.dump(d,{indent:2,lineWidth:120,noRefs:true,sortKeys:false}),"utf8"),n.push(".paradigm/navigator.yaml");let u=Ne(e,s.purposeFiles),f=0;if(u&&Object.keys(u.flows).length>0){let p=T.join(a,"flow-index.json");S.writeFileSync(p,JSON.stringify(u,null,2),"utf8"),n.push(".paradigm/flow-index.json"),f=Object.keys(u.flows).length;}let y;try{let p=await Nt(e);vt(p,s.symbols,e);let E=await kt(p,e),F=await Mt(p,e),k=p.exec("SELECT COUNT(*) FROM aspects")[0]?.values[0]?.[0]??0,X=p.exec("SELECT COUNT(*) FROM anchors")[0]?.values[0]?.[0]??0,z=p.exec("SELECT COUNT(*) FROM edges")[0]?.values[0]?.[0]??0;Ot(p,e),n.push(".paradigm/aspect-graph.db"),y={aspects:k,anchors:X,edges:z,loreLinks:E};}catch{}let h=0;try{let p=await o(e);h=Object.keys(p.personas).length,h>0&&n.push(".paradigm/personas/index.yaml");}catch{}let _;try{let p=await z(e);p.health.total>0&&(_=p.health,n.push(".paradigm/protocols/index.yaml"));}catch{}let N;try{let p=T.join(e,".paradigm","university");if(S.existsSync(p)){let E=t(e);(E.totalContent>0||E.diplomaCount>0)&&(N={totalContent:E.totalContent,diplomaCount:E.diplomaCount},n.push(".paradigm/university/index.yaml"));}}catch{}let L;try{L=a$2(s,e);}catch{}let P;try{let p=b$4(s.symbols,e),E=p.missing+p.outOfBounds;E>0&&(P=E);}catch{}let j;try{j=c$1(s.purposeFiles,e);}catch{}let U;try{let p=[];for(let E of s.purposeFiles){let F=a$3(E);F.data&&p.push({filePath:E,data:F.data});}if(p.length>0){let F=q$1(p).issues.length;F>0&&(U=F);}}catch{}let H={};for(let p of s.symbols)H[p.type]=(H[p.type]||0)+1;let m$1={};for(let p of s.symbols)p.type==="component"&&p.componentType&&(m$1[p.componentType]=(m$1[p.componentType]||0)+1);let g=r.report();try{let p=T.join(a,"manifest.consistency.json");S.writeFileSync(p,JSON.stringify(g,null,2),"utf-8"),n.push(".paradigm/manifest.consistency.json");}catch{a$4.component("#reindex").warn("failed to write consistency manifest",{stage:"manifest-write"});}if(q()&&r.hasLossy())throw new Error(`reindex aborted: ${g.lossy_count} lossy transformation(s) detected under PARADIGM_STRICT=1. See .paradigm/manifest.consistency.json.`);return {action:"reindex",filesWritten:n,symbolCount:s.symbols.length,breakdown:H,flowCount:f,aspectGraphStats:y,personaCount:h,protocolHealth:_,consistency:g,...Object.keys(m$1).length>0?{componentTypeBreakdown:m$1}:{},...N?{universityStats:N}:{},...L?{integrityReport:L}:{},...P!==void 0?{componentAnchorIssues:P}:{},...j?{purposeHealth:j}:{},...U!==void 0?{crossFileIssues:U}:{}}}function Re(e,t){let n=T.join(e,"portal.yaml");if(!S.existsSync(n))return;let r;try{r=S.readFileSync(n,"utf-8");}catch{return}try{C.load(r);}catch(o){(o?.reason?.toLowerCase()||"").includes("duplicate")&&t.record("duplicate-key-detected","portal.yaml");return}let s;try{s=C.load(r,{schema:C.FAILSAFE_SCHEMA});}catch{return}if(!s||typeof s!="object")return;let i=s,a=i.gates;if(a&&typeof a=="object"&&!Array.isArray(a)){let o=0;for(let d of Object.keys(a))d.startsWith("^")&&o++;o>0&&t.record("prefix-stripped","portal.yaml",o);}else Array.isArray(a)&&a.length>0&&t.record("array-coerced","portal.yaml");let c=i.routes;Array.isArray(c)&&c.length>0&&t.record("array-coerced","portal.yaml"),i.version||t.record("default-applied","portal.yaml");}function _e(e,t){for(let n of e){let r;try{r=S.readFileSync(n,"utf-8");}catch{continue}try{C.load(r);}catch(l){(l?.reason?.toLowerCase()||"").includes("duplicate")&&t.record("duplicate-key-detected","purpose.yaml");continue}let s;try{s=C.load(r,{schema:C.FAILSAFE_SCHEMA});}catch{continue}if(!s||typeof s!="object")continue;let i=s,a=["components","features","gates","signals","aspects","states"],c=0;for(let l of a)Array.isArray(i[l])&&c++;c>0&&t.record("array-coerced","purpose.yaml",c);let o=(l,u)=>{if(!l||typeof l!="object"||Array.isArray(l))return 0;let f=0;for(let y of Object.keys(l))y.startsWith(u)&&f++;return f},d=o(i.gates,"^")+o(i.signals,"!")+o(i.aspects,"~")+o(i.components,"#")+o(i.features,"#");d>0&&t.record("prefix-stripped","purpose.yaml",d);}}function be(e,t){let n={};for(let r of t.symbols)if(r.type==="component"&&r.componentType){let s=r.componentType;n[s]||(n[s]=[]),n[s].push(r.symbol);}return {version:"1.0",generated:new Date().toISOString(),structure:xe(e),key_files:Le(e),skip_patterns:Ae(e),symbols:Ce(t.symbols,t.purposeFiles),...Object.keys(n).length>0?{symbolsByComponentType:n}:{}}}function xe(e){let t={};for(let[n,r]of Object.entries(Te)){let s=r.filter(i=>S.existsSync(T.join(e,i)));if(s.length>0){let i=Object.values(Ee).find(a=>a.category===n);t[n]={paths:s,symbol:i?.prefix||"@"};}}return t}function Le(e){let t={};for(let[n,r]of Object.entries(Se)){let s=r.filter(i=>S.existsSync(T.join(e,i)));s.length>0&&(t[n]=s);}return t.config||(t.config=[]),t.entry||(t.entry=[]),t.types||(t.types=[]),t}function Ae(e){let t={always:[...st.always],unless_testing:[...st.unless_testing],unless_docs:[...st.unless_docs]},n=T.join(e,".gitignore");if(S.existsSync(n))try{let s=S.readFileSync(n,"utf8").split(`
93
+ `).map(i=>i.trim()).filter(i=>i&&!i.startsWith("#")).filter(i=>i.endsWith("/")||i.includes("*")||["node_modules","dist","build",".cache"].some(a=>i.includes(a))).slice(0,20);for(let i of s)t.always.includes(i)||t.always.push(i);}catch{}return t}function Ie(e){switch(e){case "feature":return "@";case "component":return "#";case "gate":return "^";case "flow":return "$";case "integration":return "&";case "signal":return "!";case "state":return "%";case "idea":return "?";case "deprecated":return "~";case "aspect":return "~";default:return "@"}}function Ce(e,t,n){let r={};for(let s of e){let a=`${Ie(s.type)}${s.id}`;if(s.filePath)r[a]=s.filePath;else {let c=t.find(o=>T.dirname(o).toLowerCase().includes(s.id.toLowerCase()));c&&(r[a]=T.dirname(c)+"/");}}return r}function Ne(e,t){let n={},r={};for(let s of t)try{let i=S.readFileSync(s,"utf8"),a=C.load(i);if(!a?.flows)continue;if(Array.isArray(a.flows))for(let c of a.flows){let o=c;if(!o.name)continue;let d=`$${o.name}`,l=Pt(o.steps);l.length>0&&(n[d]={id:d,description:o.description||"",steps:l,definedIn:T.relative(e,s)},jt(d,l,r));}else for(let[c,o]of Object.entries(a.flows)){let d=c.startsWith("$")?c:`$${c}`,l=Pt(o.steps);l.length>0&&(n[d]={id:d,description:o.description||"",trigger:o.trigger,steps:l,validation:o.validation,definedIn:T.relative(e,s)},jt(d,l,r));}}catch{}return Object.keys(n).length===0?null:{version:"1.0",generatedAt:new Date().toISOString(),flows:n,symbolToFlows:r}}function Pt(e){if(!e||!Array.isArray(e))return [];let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r=="object"&&r!==null){let s=r,i=s.action||s.description||s.component||"";i&&t.push({id:s.id||`step-${n+1}`,action:i,symbol:s.symbol||s.component,expect:s.expect});}}return t}function jt(e,t,n){for(let r of t)r.symbol&&(n[r.symbol]||(n[r.symbol]=[]),n[r.symbol].includes(e)||n[r.symbol].push(e));}export{Et as a,q as b,Nt as c,Ot as d,He as e,Ue as f,Xe as g,We as h,ze as i,$e as j,Be as k,Ge as l,Ke as m,hn as n,yn as o,we as p};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import {z}from'zod';import*as l from'fs';import*as u from'path';import*as p from'js-yaml';var bt={warn(){}},kt=bt;function A(){return kt}var k="pack.yaml";var Pt="paradigm.universityPack";var V=/^[a-z0-9][a-z0-9-]{0,63}$/,B=["track","index","chronological","featured"],H=64,It=z.object({id:z.string().regex(V,"invalid section id"),name:z.string().min(1).max(120),order:z.number().int().min(0).max(9999),style:z.enum(B,{errorMap:()=>({message:`section.style must be one of ${B.join("|")}`})}),description:z.string().max(1e3).optional(),default:z.boolean({invalid_type_error:"section.default must be a boolean"}).optional()}).strict(),X=z.array(It).max(H,`sections must contain \u2264${H} entries`);z.object({sections:X.optional()}).passthrough();z.object({section:z.string().regex(V).optional(),order:z.number().int().min(0).max(9999).optional()}).passthrough();var Z="@a-company/university",tt=".paradigm/university",et=".paradigm/cache/packs.json",S=class extends Error{constructor(t,e){super(`pack-load failed (${t}: ${e})`),this.errorClass=t,this.detail=e,this.name="PackLoadError";}},Ct=["id","name","version","schema_version","tenant_kind"],wt=new Set(["first-party","project","external"]),J={id:"main",name:"Curriculum",order:1,style:"track",default:true};function nt(t){if(t==null)return [{...J}];if(Array.isArray(t)&&t.length===0)return [{...J}];let e=X.safeParse(t);if(!e.success){let i=e.error.issues[0],a=i?`${i.path.join(".")||"sections"}: ${i.message}`:"sections failed schema validation";throw new S("manifest-invalid",a)}let n=e.data.map(i=>({...i})),r=new Set;for(let i of n){if(r.has(i.id))throw new S("manifest-invalid",`duplicate section id "${i.id}"`);r.add(i.id);}n.length===1&&!n[0].default&&(n[0]={...n[0],default:true});let s=n.filter(i=>i.default===true);if(s.length>1)throw new S("manifest-invalid",`at most one section may set default: true (found ${s.length})`);return n.sort((i,a)=>i.order-a.order||i.id.localeCompare(a.id)),n}function xt(t){if(t&&typeof t=="object"&&"name"in t&&typeof t.name=="string"){let e=t.name;return e==="YAMLException"?"yaml syntax error":e}return "parse error"}function E(t){let e=u.join(t,k);if(!l.existsSync(e))throw new S("missing-manifest",`no ${k} at pack root`);let n;try{n=l.readFileSync(e,"utf-8");}catch{throw new S("manifest-unparseable","file read error")}let r;try{r=p.load(n);}catch(i){throw new S("manifest-unparseable",xt(i))}let s=r;if(!s||typeof s!="object")throw new S("manifest-invalid","manifest is not an object");for(let i of Ct){let a=s[i];if(a==null||a==="")throw new S("missing-required-field",`required field ${String(i)} is missing or empty`)}if(!wt.has(String(s.tenant_kind)))throw new S("missing-required-field","tenant_kind must be one of first-party|project|external");return s.sections=nt(s.sections),s}function Vt(t){let e=u.join(t,k);if(!l.existsSync(e))return null;try{let n=p.load(l.readFileSync(e,"utf8"));return n&&typeof n.id=="string"&&n.id.length>0?n.id:null}catch{return null}}function _t(t){let e=Et(t);if(e)return e;let n=[],r=u.join(t,"node_modules",Z);if(l.existsSync(u.join(r,k)))try{let i=E(r);n.push({manifest:i,rootDir:r,source:"first-party"});}catch(i){A().warn("first-party pack manifest invalid",{errorClass:i instanceof S?i.errorClass:"other"});}for(let i of jt(t))try{let a=E(i);n.push({manifest:a,rootDir:i,source:"npm"});}catch(a){A().warn("npm pack manifest invalid",{errorClass:a instanceof S?a.errorClass:"other"});}let s=u.join(t,tt);if(l.existsSync(s)&&l.statSync(s).isDirectory()){let i=u.join(s,k),a;if(l.existsSync(i))try{a=E(s),n.push({manifest:a,rootDir:s,source:"local"});}catch(d){A().warn("local pack manifest invalid",{errorClass:d instanceof S?d.errorClass:"other"});}let o=a?.id??"project";for(let d of At(s))try{let f=E(d);n.push({manifest:f,rootDir:d,source:"local",parentPackId:o});}catch(f){A().warn("discipline sub-pack manifest invalid",{errorClass:f instanceof S?f.errorClass:"other"});}}return Tt(t,n),n}function jt(t){let e=u.join(t,"package.json");if(!l.existsSync(e))return [];let n;try{n=JSON.parse(l.readFileSync(e,"utf8"));}catch{return []}let r=new Set([...Object.keys(n.dependencies||{}),...Object.keys(n.devDependencies||{}),...Object.keys(n.peerDependencies||{})]);if(r.size===0)return [];let s=u.join(t,"node_modules");if(!l.existsSync(s))return [];let i=[];for(let a of r){if(a===Z)continue;let o=u.join(s,a,"package.json");if(!l.existsSync(o))continue;let d;try{d=JSON.parse(l.readFileSync(o,"utf8"));}catch{continue}let f=d.paradigm?.universityPack;if(typeof f!="string"||f.length===0)continue;let c=u.resolve(u.dirname(o),f);l.existsSync(u.join(c,k))&&i.push(c);}return i}function At(t){let e=[],n;try{n=l.readdirSync(t,{withFileTypes:!0});}catch{return e}for(let r of n){if(!r.isDirectory()||r.name.startsWith("."))continue;let s=u.join(t,r.name);l.existsSync(u.join(s,k))&&e.push(s);}return e}function st(t){try{return l.statSync(u.join(t,"node_modules")).mtime.getTime()}catch{return}}function rt(t){try{return l.statSync(u.join(t,tt)).mtime.getTime()}catch{return}}function Et(t){let e=u.join(t,et);if(!l.existsSync(e))return null;let n;try{n=JSON.parse(l.readFileSync(e,"utf8"));}catch{return null}if(n.version!==1||!Array.isArray(n.packs))return null;let r=st(t),s=rt(t);return n.node_modules_mtime_ms!==r||n.local_university_mtime_ms!==s?null:n.packs.map(i=>({manifest:i.manifest,rootDir:i.rootDir,source:i.source,...i.parentPackId?{parentPackId:i.parentPackId}:{}}))}function Tt(t,e){let n=u.join(t,et);try{l.mkdirSync(u.dirname(n),{recursive:!0});let r={version:1,node_modules_mtime_ms:st(t),local_university_mtime_ms:rt(t),packs:e.map(s=>({manifest:s.manifest,rootDir:s.rootDir,source:s.source,...s.parentPackId?{parentPackId:s.parentPackId}:{}}))};l.writeFileSync(n,JSON.stringify(r,null,2),"utf8");}catch{}}var P=".paradigm/university",w="content",L="notes",T="policies",F="quizzes",N="paths",W="diplomas",U="index.yaml",it="config.yaml";function ot(t){return typeof t=="string"?{packRoot:t,stampPackId:true,resolveDefaultPack:true}:{packRoot:t?.packRoot,stampPackId:t?.stampPackId??true,resolveDefaultPack:t?.resolveDefaultPack??true}}function at(t,e,n){return e||(n?ct(t):u.join(t,P))}function ct(t){let e=u.join(t,P);if(l.existsSync(e))return e;try{let r=_t(t).find(s=>s.manifest.tenant_kind==="first-party");if(r)return r.rootDir}catch{}return e}function $(t){if(!l.existsSync(t))return null;let e=u.join(t,k);if(l.existsSync(e))try{return E(t)}catch(r){A().warn("pack manifest invalid, using implicit manifest",{errorClass:r instanceof S?r.errorClass:"other"});}let n=u.basename(t)||"project";return {id:n,name:n,version:"0.0.0",schema_version:"1",tenant_kind:"project",description:"Implicit project pack (pack.yaml not present \u2014 v5 layout)",origin_hint:"authored",sections:nt(void 0)}}function Ft(t,e,n){return e?{...t,...t.pack_id?{}:{pack_id:e.id},...t.discipline||!n?{}:{discipline:n}}:t}var R={name:"Project University",tagline:"Learn the codebase",institution:"Paradigm"},G={primary:"#6366f1",secondary:"#8b5cf6",accent:"#f59e0b",background:"#0f172a",surface:"#1e293b",text:"#f8fafc",textMuted:"#94a3b8",success:"#22c55e",error:"#ef4444",font:"Inter, system-ui, sans-serif"},q={branding:R,theme:G,content:{categories:[],defaultDifficulty:"beginner",requireApproval:false},diplomas:{includeGlobalPLSAT:true,customCertStyle:null}};function Y(t){let e=u.join(t,P,it);if(!l.existsSync(e))return {...q};try{let n=l.readFileSync(e,"utf8"),r=p.load(n);return r?{branding:{...R,...r.branding||{}},theme:{...G,...r.theme||{}},content:{categories:r.content?.categories||[],defaultDifficulty:r.content?.defaultDifficulty||"beginner",requireApproval:r.content?.requireApproval??!1,defaultCategory:r.content?.defaultCategory},diplomas:{includeGlobalPLSAT:r.diplomas?.includeGlobalPLSAT??!0,customCertStyle:r.diplomas?.customCertStyle??null}}:{...q}}catch{return {...q}}}function Nt(t){let e=u.join(t,it);if(!l.existsSync(e))return null;try{let n=l.readFileSync(e,"utf8"),r=p.load(n);return r?{branding:{...R,...r.branding||{}},theme:{...G,...r.theme||{}},content:{categories:r.content?.categories||[],defaultDifficulty:r.content?.defaultDifficulty||"beginner",requireApproval:r.content?.requireApproval??!1,defaultCategory:r.content?.defaultCategory},diplomas:{includeGlobalPLSAT:r.diplomas?.includeGlobalPLSAT??!0,customCertStyle:r.diplomas?.customCertStyle??null}}:null}catch{return null}}function $t(t){let e=u.join(t,k);if(!l.existsSync(e))return false;try{let n=l.readFileSync(e,"utf8"),r=p.load(n);return !r||!Array.isArray(r.sections)?!1:r.sections.some(s=>s&&typeof s.id=="string"&&s.id.length>0)}catch{return false}}function M(t){let e=u.join(t,P,U);if(!l.existsSync(e))return null;try{let n=l.readFileSync(e,"utf8");return p.load(n)}catch{return null}}function ft(t){let e=t.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!e)return null;try{return {frontmatter:p.load(e[1]),body:e[2].trim()}}catch{return null}}function Dt(t,e){return `---
3
+ ${p.dump(t,{lineWidth:-1,noRefs:true,sortKeys:false})}---
4
+
5
+ ${e}
6
+ `}function Xt(t,e,n){let r=Q(t,e,".md",n);if(!r)return null;try{let s=l.readFileSync(r,"utf8"),i=ft(s);if(!i)return null;let a=i.frontmatter;return {frontmatter:Gt(a),body:i.body}}catch{return null}}function Zt(t,e,n,r){let{packRoot:s,stampPackId:i,resolveDefaultPack:a}=ot(r),o=e.type==="policy"?T:L,d=at(t,s,a),f=u.join(d,w,o);l.mkdirSync(f,{recursive:true});let c=i?$(d):null,b=Ft(e,c),_=u.join(f,`${b.id}.md`),x=Dt(b,n);return l.writeFileSync(_,x,"utf8"),_}function Ot(t,e,n){let r=Q(t,e,".yaml",n);if(!r)return null;try{let s=l.readFileSync(r,"utf8"),i=p.load(s);return !i||!i.id?null:Yt(i)}catch{return null}}function te(t,e,n){let{packRoot:r,stampPackId:s,resolveDefaultPack:i}=ot(n),a=at(t,r,i),o=u.join(a,w,F);l.mkdirSync(o,{recursive:true});let d=s?$(a):null,f={...e,...e.pack_id||!d?{}:{pack_id:d.id}},c=u.join(o,`${f.id}.yaml`);return l.writeFileSync(c,p.dump(f,{lineWidth:-1,noRefs:true}),"utf8"),c}function lt(t,e,n){let r=Q(t,e,".yaml",n);if(!r)return null;try{let s=l.readFileSync(r,"utf8"),i=p.load(s);return !i||!i.id?null:i}catch{return null}}function ee(t,e,n){let r=n??ct(t),s=u.join(r,w,N);l.mkdirSync(s,{recursive:true});let i=u.join(s,`${e.id}.yaml`);return l.writeFileSync(i,p.dump(e,{lineWidth:-1,noRefs:true}),"utf8"),i}function dt(t,e,n){let r=n??u.join(t,P),s=u.join(r,W);if(!l.existsSync(s))return [];let i=[];try{let a=l.readdirSync(s).filter(o=>o.endsWith(".yaml"));for(let o of a)try{let d=l.readFileSync(u.join(s,o),"utf8"),f=p.load(d);if(!f||!f.id||e?.student&&f.student!==e.student||e?.type&&f.type!==e.type)continue;i.push(f);}catch{}}catch{}return i.sort((a,o)=>o.earnedAt.localeCompare(a.earnedAt))}function ne(t,e,n){let r=n??u.join(t,P),s=u.join(r,W);l.mkdirSync(s,{recursive:true});let i=$(r),a={...e,...e.pack_id||!i?{}:{pack_id:i.id}},o=u.join(s,`${a.id}.yaml`);return l.writeFileSync(o,p.dump(a,{lineWidth:-1,noRefs:true}),"utf8"),o}function se(t,e,n){return Lt(t,e,n).entries}function Lt(t,e,n){let r=n?K(n):M(t);if(!r)return {entries:[],total:0,returned:0};let s=[...r.entries];if(e.type&&(s=s.filter(d=>d.type===e.type)),e.tag&&(s=s.filter(d=>d.tags.some(f=>f.startsWith(e.tag)))),e.difficulty&&(s=s.filter(d=>d.difficulty===e.difficulty)),e.symbol&&(s=s.filter(d=>d.symbols.some(f=>f===e.symbol))),e.author&&(s=s.filter(d=>d.author===e.author)),e.query){let d=e.query.toLowerCase();s=s.filter(f=>f.title.toLowerCase().includes(d)||f.id.toLowerCase().includes(d)||f.tags.some(c=>c.toLowerCase().includes(d)));}if(e.category&&(s=s.filter(d=>d.category===e.category)),e.section&&(s=s.filter(d=>d.section===e.section)),e.track){let d=Y(t),f=new Map;for(let c of d.content.categories)f.set(c.id,c.track||"core");s=s.filter(c=>(c.category&&f.get(c.category)||"core")===e.track);}let i=s.length,a=e.limit||20,o=s.slice(0,a);return {entries:o,total:i,returned:o.length}}var ut=[w,"src/content"],yt=[L,T,F,N];function Mt(t){if(!l.existsSync(t))return false;for(let e of yt){let n=u.join(t,e);if(l.existsSync(n))try{if(l.readdirSync(n).some(r=>r.endsWith(".md")||r.endsWith(".yaml")))return !0}catch{}}return false}function qt(t){let e=ht(t);return e?u.join(t,e):null}function ht(t){let e=null;for(let n of ut){let r=u.join(t,n);if(l.existsSync(r)&&(e===null&&(e=n),Mt(r)))return n}return e}function re(t){for(let e of ut){let n=u.join(t,e);if(!l.existsSync(n))continue;let r=0;for(let s of yt){let i=u.join(n,s);if(l.existsSync(i))try{r+=l.readdirSync(i).filter(a=>a.endsWith(".md")||a.endsWith(".yaml")).length;}catch{}}if(r>0)return r}return 0}function mt(t,e){let n=[];for(let i of [L,T]){let a=u.join(t,i);if(l.existsSync(a))try{for(let o of l.readdirSync(a).filter(d=>d.endsWith(".md")))try{let d=l.readFileSync(u.join(a,o),"utf8"),f=ft(d);if(!f)continue;let c=f.frontmatter;n.push({id:c.id||o.replace(".md",""),title:c.title||o,type:c.type||(i===T?"policy":"note"),author:c.author||"unknown",created:c.created||"",updated:c.updated||"",tags:Array.isArray(c.tags)?c.tags:[],symbols:Array.isArray(c.symbols)?c.symbols:[],difficulty:c.difficulty||"beginner",file:`${e}/${i}/${o}`,...c.category?{category:c.category}:{},...typeof c.section=="string"&&c.section?{section:c.section}:{},...typeof c.order=="number"&&Number.isFinite(c.order)?{order:c.order}:{}});}catch{}}catch{}}let r=u.join(t,F);if(l.existsSync(r))try{for(let i of l.readdirSync(r).filter(a=>a.endsWith(".yaml")))try{let a=l.readFileSync(u.join(r,i),"utf8"),o=p.load(a);if(!o||!o.id)continue;n.push({id:o.id,title:o.title||i,type:"quiz",author:o.author||"unknown",created:o.created||"",updated:o.updated||"",tags:o.tags||[],symbols:o.symbols||[],difficulty:o.difficulty||"beginner",file:`${e}/${F}/${i}`,...o.category?{category:o.category}:{},...typeof o.section=="string"&&o.section?{section:o.section}:{},...typeof o.order=="number"&&Number.isFinite(o.order)?{order:o.order}:{}});}catch{}}catch{}let s=u.join(t,N);if(l.existsSync(s))try{for(let i of l.readdirSync(s).filter(a=>a.endsWith(".yaml")))try{let a=l.readFileSync(u.join(s,i),"utf8"),o=p.load(a);if(!o||!o.id)continue;n.push({id:o.id,title:o.title||i,type:"path",author:o.author||"unknown",created:o.created||"",updated:o.updated||"",tags:o.tags||[],symbols:[],file:`${e}/${N}/${i}`,...o.category?{category:o.category}:{},...typeof o.section=="string"&&o.section?{section:o.section}:{},...typeof o.order=="number"&&Number.isFinite(o.order)?{order:o.order}:{}});}catch{}}catch{}return n}function zt(t){let e=u.join(t,P),n=u.join(e,w),r=mt(n,w),s=0,i=u.join(e,W);if(l.existsSync(i))try{s=l.readdirSync(i).filter(d=>d.endsWith(".yaml")).length;}catch{}let a={version:"1.0",generatedAt:new Date().toISOString(),totalContent:r.length,entries:r,diplomaCount:s};l.mkdirSync(e,{recursive:true});let o=u.join(e,U);return l.writeFileSync(o,p.dump(a,{lineWidth:-1,noRefs:true}),"utf8"),a}function K(t,e){let n=u.join(t,U);if(l.existsSync(n))try{let a=l.readFileSync(n,"utf8"),o=p.load(a);if(o)return o}catch{}let r=ht(t);if(!r)return {version:"1.0",generatedAt:new Date().toISOString(),totalContent:0,entries:[],diplomaCount:0};let s=u.join(t,r),i=mt(s,r);return {version:"1.0",generatedAt:new Date().toISOString(),totalContent:i.length,entries:i,diplomaCount:0}}function ie(t,e,n){let r=n?K(n):M(t)||zt(t),s=[],i=r.entries;e?.id&&(i=i.filter(c=>c.id===e.id));let a=null;e?.deep&&(a=pt(t));let o=new Set(r.entries.map(c=>c.id));for(let c of i){if(c.title||s.push({contentId:c.id,severity:"error",check:"missing-title",message:"Content is missing a title",fix:"Add a title field to the content frontmatter"}),c.type==="quiz"&&Wt(t,c.id,s,n),c.type==="path"&&Ut(t,c.id,o,s,n),a&&c.symbols.length>0){Y(t).content.categories.find(h=>h.id===c.category)?.validationStrictness==="relaxed";for(let h of c.symbols)a.has(h)||s.push({contentId:c.id,severity:"warning",check:"broken-symbol-ref",message:`Symbol "${h}" not found in scan-index`,fix:`Remove or update the symbol reference in ${c.id}`});}e?.deep&&c.symbols.length>0&&c.updated&&Qt(t,c,s);}Rt(t,r,s,n);let d=dt(t);for(let c of d)if(c.total>0&&c.percentage!==Math.round(c.score/c.total*1e4)/100){let b=Math.round(c.score/c.total*1e4)/100;Math.abs(c.percentage-b)>.1&&s.push({contentId:c.id,severity:"warning",check:"diploma-score-mismatch",message:`Diploma percentage ${c.percentage} doesn't match score ${c.score}/${c.total} (expected ${b})`});}let f=Kt(t,r);return {status:s.some(c=>c.severity==="error")?"errors":s.length>0?"warnings":"healthy",totalContent:r.totalContent,checked:i.length,issues:s,symbolCoverage:f}}function Wt(t,e,n,r){let s=Ot(t,e,r);if(!s){n.push({contentId:e,severity:"error",check:"unreadable-quiz",message:"Quiz file could not be parsed"});return}(!s.passThreshold||s.passThreshold<0||s.passThreshold>1)&&n.push({contentId:e,severity:"warning",check:"invalid-pass-threshold",message:`passThreshold should be between 0 and 1, got ${s.passThreshold}`,fix:"Set passThreshold to a value between 0.0 and 1.0"});for(let i of s.questions){if(!i.choices||typeof i.choices!="object"){n.push({contentId:e,severity:"error",check:"invalid-quiz-choices",message:`Question ${i.id} has no choices defined`});continue}(!i.correct||!(i.correct in i.choices))&&n.push({contentId:e,severity:"error",check:"invalid-quiz-answer",message:`Question ${i.id}: correct answer "${i.correct}" not found in choices [${Object.keys(i.choices).join(", ")}]`,fix:`Set correct to one of: ${Object.keys(i.choices).join(", ")}`});}}function Ut(t,e,n,r,s){let i=lt(t,e,s);if(!i){r.push({contentId:e,severity:"error",check:"unreadable-path",message:"Learning path file could not be parsed"});return}for(let a of i.steps)a.content.startsWith("plsat:")||n.has(a.content)||r.push({contentId:e,severity:"error",check:"broken-path-step",message:`Learning path step references "${a.content}" which doesn't exist`,fix:`Create content with id "${a.content}" or remove this step`});}function Rt(t,e,n,r){let s=r??u.join(t,P),i=$(s);if(!i||!i.sections||i.sections.length===0)return;let a=new Set(i.sections.map(f=>f.id)),o=i.sections.find(f=>f.default===true);for(let f of e.entries)f.section&&!a.has(f.section)&&n.push({contentId:f.id,severity:"warning",check:"dangling-section-ref",message:`Entry references section "${f.section}" which is not declared in pack.yaml`,fix:`Add a section with id "${f.section}" to pack.yaml, or remove the section field`});let d=new Map;for(let f of i.sections)d.set(f.id,0);for(let f of e.entries)f.section&&a.has(f.section)?d.set(f.section,(d.get(f.section)||0)+1):!f.section&&o&&d.set(o.id,(d.get(o.id)||0)+1);for(let f of i.sections)(d.get(f.id)||0)===0&&n.push({contentId:f.id,severity:"warning",check:"empty-section",message:`Section "${f.id}" has zero entries`,fix:`Add at least one entry with section: "${f.id}", or remove the section from pack.yaml`});}function oe(t,e){let n=M(t);if(!n)return [];let r=[];for(let s of n.entries)if(s.symbols.includes(e)){let i=gt(t,s,e);r.push({id:s.id,title:s.title,type:s.type,stale:i});}return r}function ae(t,e,n){let r=n?K(n):M(t);if(!r)return {paths:[],suggestedContent:[],extracurricular:[],diplomaCount:0,totalContent:0};let s=n&&Nt(n)||Y(t),i=new Set;for(let h of s.content.categories)h.excludeFromOnboarding&&i.add(h.id);let a=r.entries.filter(h=>!h.category||!i.has(h.category)),o=r.entries.filter(h=>h.category&&i.has(h.category)),d=a.filter(h=>h.type==="path"),f=e?dt(t,{student:e},n):[],c=new Set(f.map(h=>h.source)),b=d.map(h=>{let I=lt(t,h.id,n);return {id:h.id,title:h.title,steps:I?.steps.length||0,completed:c.has(h.id)}}),_=a.filter(h=>h.type!=="path"&&(h.difficulty==="beginner"||h.tags.includes("onboarding"))).slice(0,10),x={paths:b,suggestedContent:_,extracurricular:o,diplomaCount:f.length,totalContent:r.totalContent};if(n&&$t(n)){let I=($(n)?.sections??[]).slice().sort((D,C)=>D.order-C.order||D.id.localeCompare(C.id));if(I.length>0){let D=I.find(g=>g.default===true)??I[0],C=new Map;for(let g of I)C.set(g.id,[]);for(let g of r.entries){let j=g.section&&C.has(g.section)?g.section:D.id,O=C.get(j);O&&O.push(g);}let St=(g,j)=>{let O=typeof g.order=="number"?g.order:Number.POSITIVE_INFINITY,vt=typeof j.order=="number"?j.order:Number.POSITIVE_INFINITY;return O-vt||g.id.localeCompare(j.id)};x.sections=I.map(g=>({id:g.id,name:g.name,entries:(C.get(g.id)??[]).sort(St)}));}}return x}function Q(t,e,n,r){let s=r??u.join(t,P),i=qt(s)??u.join(s,w);for(let a of [L,T,F,N]){let o=u.join(i,a,`${e}${n}`);if(l.existsSync(o))return o}return null}function Gt(t){return {id:t.id||"",title:t.title||"",type:t.type||"note",author:t.author||"unknown",created:t.created||"",updated:t.updated||"",tags:Array.isArray(t.tags)?t.tags:[],symbols:Array.isArray(t.symbols)?t.symbols:[],difficulty:t.difficulty||"beginner",estimatedMinutes:t.estimatedMinutes,prerequisites:Array.isArray(t.prerequisites)?t.prerequisites:[],...t.category?{category:t.category}:{},...t.origin?{origin:t.origin}:{},...t.source?{source:t.source}:{},...t.pack_id?{pack_id:t.pack_id}:{},...t.discipline?{discipline:t.discipline}:{},...t.section?{section:t.section}:{},...typeof t.order=="number"?{order:t.order}:{}}}function Yt(t){return {...t,tags:t.tags||[],symbols:t.symbols||[],difficulty:t.difficulty||"beginner",passThreshold:t.passThreshold??.7,questions:t.questions||[]}}function pt(t){let e=new Set,n=u.join(t,".paradigm","scan-index.json");if(!l.existsSync(n))return e;try{let r=l.readFileSync(n,"utf8"),s=JSON.parse(r);if(s.symbols&&Array.isArray(s.symbols))for(let i of s.symbols)i.symbol&&e.add(i.symbol);}catch{}return e}function Kt(t,e){let n=pt(t),r=new Set;for(let i of e.entries)for(let a of i.symbols)n.has(a)&&r.add(a);let s=n.size;return {totalSymbols:s,coveredByContent:r.size,percentage:s>0?Math.round(r.size/s*100):0}}function gt(t,e,n){if(!e.updated)return false;let r=new Date(e.updated).getTime();if(isNaN(r))return false;let s=u.join(t,".paradigm","scan-index.json");if(!l.existsSync(s))return false;try{let i=l.readFileSync(s,"utf8"),a=JSON.parse(i);if(a.symbols&&Array.isArray(a.symbols)){for(let o of a.symbols)if(o.symbol===n&&o.filePath){let d=u.join(t,o.filePath);if(l.existsSync(d)&&l.statSync(d).mtime.getTime()>r)return !0}}}catch{}return false}function Qt(t,e,n){for(let r of e.symbols)if(gt(t,e,r)){n.push({contentId:e.id,severity:"warning",check:"stale-content",message:`Content may be stale: symbol "${r}" was updated after content was last modified`,fix:`Review and update ${e.id} to reflect changes to ${r}`});break}}export{k as a,Pt as b,Vt as c,ct as d,$ as e,Y as f,M as g,Xt as h,Zt as i,Ot as j,te as k,lt as l,ee as m,dt as n,ne as o,se as p,Lt as q,qt as r,re as s,zt as t,K as u,ie as v,oe as w,ae as x};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import {b as b$1,a}from'./chunk-EK4ZRIFJ.js';import*as d from'fs';import*as g from'path';import*as h from'js-yaml';b$1();var T=".paradigm/tasks",y="entries",C="index.yaml";function I(e){if(e&&e.session_link&&!e.external_ref){let n=e.session_link,i=n.toLowerCase(),r;i.includes("github")?r="github":i.includes("session")?r="session":r="url",e.external_ref={provider:r,ref:n},delete e.session_link;}let t=e?.external_ref;return t&&t.kind!==void 0&&t.provider===void 0&&(t.provider=t.kind,delete t.kind),e}function D(e,t){let n=g.join(e,T,y,t);if(!d.existsSync(n))return `T-${t}-001`;let i=d.readdirSync(n).filter(o=>o.startsWith("T-")&&o.endsWith(".yaml")).map(o=>{let c=o.match(/T-\d{4}-\d{2}-\d{2}-(\d+)\.yaml/);return c?parseInt(c[1],10):0}),r=i.length>0?Math.max(...i)+1:1;return `T-${t}-${String(r).padStart(3,"0")}`}function A(e,t){return e===t?true:({open:["in-progress","done","shelved"],"in-progress":["done","open","shelved"],shelved:["open"],done:["open"]}[e]??[]).includes(t)}var O={high:0,medium:1,low:2},N=["open","in-progress"];function $(e,t){return t==="all"?true:t==="active"?N.includes(e.status):e.status===t}function R(e){let t=e.created?new Date(e.created).getTime():NaN;if(!Number.isNaN(t))return t;let n=e.id?.match(/^T-(\d{4}-\d{2}-\d{2})-/);if(n){let i=new Date(n[1]).getTime();if(!Number.isNaN(i))return i}return 0}function W(e,t){let n=e;if(t.status&&t.status!=="all"&&(n=n.filter(i=>$(i,t.status))),t.priority&&(n=n.filter(i=>i.priority===t.priority)),t.tag&&(n=n.filter(i=>i.tags.includes(t.tag))),t.claimant){let{kind:i,ref:r}=t.claimant;n=n.filter(o=>o.claimant!=null&&o.claimant.ref===r&&(i===void 0||o.claimant.kind===i));}return n.sort((i,r)=>{let o=(O[i.priority]??1)-(O[r.priority]??1);return o!==0?o:R(r)-R(i)}),t.limit&&(n=n.slice(0,t.limit)),n}async function b(e,t){let n=g.join(e,T,y);if(!d.existsSync(n))return [];let i={status:"open",limit:20,...t},r=[],o=d.readdirSync(n).filter(c=>/^\d{4}-\d{2}-\d{2}$/.test(c)).sort().reverse();for(let c of o){let k=g.join(n,c),u=d.readdirSync(k).filter(s=>s.endsWith(".yaml")).sort();for(let s of u)try{let a=d.readFileSync(g.join(k,s),"utf8"),f=I(h.load(a));r.push(f);}catch{}}return W(r,i)}async function V(e,t,n){return b(e,{claimant:t,status:n?.status??"active",limit:n?.limit??200})}async function K(e,t){let n=t.match(/^T-(\d{4}-\d{2}-\d{2})-/);if(n){let r=g.join(e,T,y,n[1],`${t}.yaml`);if(d.existsSync(r))try{return I(h.load(d.readFileSync(r,"utf8")))}catch{return null}}return (await b(e,{status:"all",limit:9999})).find(r=>r.id===t)||null}function L(e){let t=[],n=new Map;for(let s of e)s.id&&n.set(s.id,s);for(let s of e)if(s.id){s.parentTaskId===s.id?t.push({kind:"self-parent",taskId:s.id,detail:s.id}):s.parentTaskId&&!n.has(s.parentTaskId)&&t.push({kind:"dangling-parent",taskId:s.id,detail:s.parentTaskId});for(let a of s.dependsOn??[])a===s.id?t.push({kind:"self-parent",taskId:s.id,detail:`dependsOn:${a}`}):n.has(a)||t.push({kind:"dangling-dependency",taskId:s.id,detail:a});}let i=0,r=1,o=2,c=new Map;for(let s of n.keys())c.set(s,i);let k=s=>{let a=[];s.parentTaskId&&s.parentTaskId!==s.id&&n.has(s.parentTaskId)&&a.push(s.parentTaskId);for(let f of s.dependsOn??[])f!==s.id&&n.has(f)&&a.push(f);return a},u=new Set;for(let s of n.keys()){if(c.get(s)!==i)continue;let a=[{id:s,path:[s]}],f=new Set;for(;a.length;){let l=a[a.length-1];c.get(l.id)===i&&(c.set(l.id,r),f.add(l.id));let S=false;for(let p of k(n.get(l.id)))if(c.get(p)===r){let m=l.path.indexOf(p),w=m>=0?l.path.slice(m).concat(p):[l.id,p],P=[...w].sort().join("|");u.has(P)||(u.add(P),t.push({kind:"cycle",taskId:p,detail:w.join(" \u2192 ")}));}else if(c.get(p)===i){a.push({id:p,path:[...l.path,p]}),S=true;break}S||(c.set(l.id,o),f.delete(l.id),a.pop());}}return t}async function B(e,t){let n=new Date,i=n.toISOString().slice(0,10),r=g.join(e,T,y,i);d.mkdirSync(r,{recursive:true});let o=D(e,i),c={id:o,blurb:t.blurb,priority:t.priority||"medium",status:"open",tags:t.tags||[],created:n.toISOString(),related_lore:t.related_lore,claimant:t.claimant,parentTaskId:t.parentTaskId,dependsOn:t.dependsOn,stage:t.stage,external_ref:t.external_ref,session_link:t.session_link};return I(c),d.writeFileSync(g.join(r,`${o}.yaml`),h.dump(j(c),{lineWidth:-1,noRefs:true})),await F(e),o}async function v(e,t,n){let i=await K(e,t);if(!i)return false;let r=i.created.slice(0,10),o=g.join(e,T,y,r,`${t}.yaml`);if(!d.existsSync(o))return false;let{id:c,created:k,...u}=n;if(u.status!==void 0&&u.status!==i.status){if(!A(i.status,u.status))return a.component("#task-loader").warn("Illegal task status transition rejected",{taskId:t,from:i.status,to:u.status}),false;u.status==="in-progress"&&!i.started_at&&u.started_at===void 0&&(u.started_at=new Date().toISOString()),i.status==="done"&&u.status==="open"&&(u.completed=void 0,u.settledAt=void 0,u.crashed_at=void 0,u.crash_reason=void 0);}let s={...i,...u};if(d.writeFileSync(o,h.dump(j(s),{lineWidth:-1,noRefs:true})),await F(e),_(s.status)&&s.parentTaskId)try{let{settleParentIfComplete:a}=await import('./task-settlement-ZXOY4YGX.js');await a(e,s.parentTaskId,s.id);}catch(a$1){a.component("#task-loader").warn("Settlement after updateTask failed (non-fatal)",{taskId:t,parentTaskId:s.parentTaskId,error:a$1 instanceof Error?a$1.message:String(a$1)});}if(_(s.status))try{let a$1=await b(e,{status:"all",limit:9999}),f=new Map(a$1.map(l=>[l.id,l]));for(let l of a$1){if(!l.blocked_on||!l.dependsOn?.includes(s.id))continue;(l.dependsOn??[]).every(p=>{let m=f.get(p);return m!=null&&_(m.status)})&&(await v(e,l.id,{blocked_on:void 0}),a.component("#task-loader").info("Auto-cleared blocked_on (all deps terminal)",{taskId:l.id,resolvedBy:s.id}));}}catch(a$1){a.component("#task-loader").warn("blocked_on auto-clear failed (non-fatal)",{taskId:t,error:a$1 instanceof Error?a$1.message:String(a$1)});}return true}function _(e){return e==="done"||e==="shelved"}async function U(e,t){return v(e,t,{status:"done",completed:new Date().toISOString()})}async function Y(e,t){return v(e,t,{status:"shelved",shelved:new Date().toISOString()})}async function F(e){let t=g.join(e,T,y),n=g.join(e,T),i=0,r=0,o=0,c=0,k=0,u=[];if(d.existsSync(t)){let a=d.readdirSync(t).filter(f=>/^\d{4}-\d{2}-\d{2}$/.test(f));for(let f of a){let l=g.join(t,f),S=d.readdirSync(l).filter(p=>p.endsWith(".yaml"));for(let p of S)try{let m=I(h.load(d.readFileSync(g.join(l,p),"utf8")));i++,m.status==="open"?r++:m.status==="in-progress"?o++:m.status==="done"?c++:m.status==="shelved"&&k++,!m.parentTaskId&&m.id&&u.push(m.id);}catch{}}}let s={version:"1.1",total:i,open:r,in_progress:o,done:c,shelved:k,roots:u,last_updated:new Date().toISOString()};return d.mkdirSync(n,{recursive:true}),d.writeFileSync(g.join(n,C),h.dump(s,{lineWidth:-1,noRefs:true})),s}function j(e){let t={};for(let[n,i]of Object.entries(e))i!==void 0&&(t[n]=i);return t}export{I as a,D as b,A as c,b as d,V as e,K as f,L as g,B as h,v as i,U as j,Y as k,F as l};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import {b,a}from'./chunk-EK4ZRIFJ.js';b();var n=new Map,t=new Map;function y(r,e){n.set(r,e),t.delete(r),a.component("#sync-provider").info("Provider registered",{id:r});}function v(r){let e=t.get(r);if(e)return e;let o=n.get(r);if(!o)return;let i=o();return t.set(r,i),i}function p(){n.clear(),t.clear();}export{y as a,v as b,p as c};